vitogit / vue-chessboard

Chessboard vue component to load positions, create positions and see threats
http://vitomd.com/vue-chessboard-examples/
GNU General Public License v3.0
165 stars 49 forks source link

Missed move in history in case of a checkmate #9

Closed PureLines closed 4 years ago

PureLines commented 4 years ago

You can see this behaviour at http://vitomd.com/vue-chessboard-examples/.

When a move results in a checkmate, the last move doesn't appear in history.

Also an error appears in console in this case:

vue-chessboard.common.js:1:73024
TypeError: e is null
    afterMove vue-chessboard.common.js:1
    afterMove self-hosted:844
    changeTurn vue-chessboard.common.js:1
    r vue-chessboard.common.js:1
vitogit commented 4 years ago

Thanks for the report, I will take a look

PureLines commented 4 years ago

Seems, you didn't publish latest version to npm. This code is from npm 0.6.5:

    afterMove () {
      if (this.showThreats) {
        this.paintThreats()
      }
      let threats = this.countThreats(this.toColor())  // this line
      threats['history'] = this.game.history()
      threats['fen'] = this.game.fen()
      this.$emit('onMove', threats)
    },

And this is in master branch: https://github.com/vitogit/vue-chessboard/blob/fe6a5e2d08198db6acfed2256a54ff28e440c2c2/src/components/chessboard/index.vue#L125-L133

And compiled code in master branch is also wrong: https://github.com/vitogit/vue-chessboard/blob/fe6a5e2d08198db6acfed2256a54ff28e440c2c2/dist/vue-chessboard.common.js#L235

Update it please.

vitogit commented 4 years ago

@PureLines Yes you are right, I never pushed the changes to npm. It should be working now, also I updated http://vitomd.com/vue-chessboard-examples/ with the latest version (0.6.6). Let me know if you have any issues

PureLines commented 4 years ago

Great! Now it works well. Thank you!

vitogit commented 4 years ago

Thank you for reporting the issue.