Skip to content

Commit

Permalink
Fix a bug that capturing piece (#31)
Browse files Browse the repository at this point in the history
* Fix a bug that capturing piece

How replicate an issue - Capturing each pieces by sequential

* Remove unused function
  • Loading branch information
jsveron23 committed Mar 4, 2019
1 parent a08226a commit ec0a402
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/actions/ingame.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compose, ifElse, reject, flip, identity, map } from 'ramda'
import { compose, ifElse, reject, flip, identity } from 'ramda'
import * as types from '~/actions'
import { OPPONENT } from '~/chess/constants'
import {
Expand Down Expand Up @@ -60,25 +60,25 @@ export function setSnapshot (snapshot) {

export function setNext (snapshot) {
return (dispatch, getState) => {
return Promise.all([setSnapshot(snapshot), setMovableAxis(), toggleTurn()])
.then(map(dispatch))
.then(() => {
const { ingame } = getState()
const { present, past } = ingame
const { turn } = present

const checkBy = findCheckCode(() => {
const { side, piece, file, rank } = compose(
diffSnapshot(snapshot),
getPrevSnapshot
)(past)

return { turn, snapshot, side, piece, file, rank }
})

return Promise.all([setCheckBy(checkBy), setSelected()])
})
.then(map(dispatch))
dispatch(setSnapshot(snapshot))
dispatch(setMovableAxis())
dispatch(toggleTurn())
dispatch(setSelected())

const { ingame } = getState()
const { present, past } = ingame
const { turn } = present

const checkBy = findCheckCode(() => {
const { side, piece, file, rank } = compose(
diffSnapshot(snapshot),
getPrevSnapshot
)(past)

return { turn, snapshot, side, piece, file, rank }
})

dispatch(setCheckBy(checkBy))
}
}

Expand Down

0 comments on commit ec0a402

Please sign in to comment.