Created
September 17, 2016 01:45
-
-
Save knubie/710342fab801f9cbd9ab1a5f7852fd93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// makePly :: (Game, Ply) -> Game | |
var makePly = function(game, ply) { | |
check(arguments, [Game]); | |
if (ply.type === 'MovePly') { | |
return movePly( | |
Piece.of(R.evolve({position: Position.of}, ply.piece)), | |
Position.of(ply.position), | |
game); | |
} else if (ply.type === 'DrawPly') { | |
return drawCardPly(game.turn, game); | |
} else if (ply.type === 'AbilityPly') { | |
return abilityPly( | |
Piece.of(R.evolve({position: Position.of}, ply.piece)), | |
game); | |
} else if (ply.type === 'UseCardPly') { | |
return useCardPly(game.turn, ply.card, { | |
positions: R.map(Position.of, ply.params.positions || []) | |
}, game); | |
} else if (ply.type === 'MulliganPly') { | |
return mulliganPly(ply.cards, ply.player, game); | |
} else { // draft | |
return Game.of(R.evolve({ | |
// TODO: change to integer. | |
//turn: (turn) => { return turn === 'white' ? 'black' : 'white'; }, | |
plys: R.append('draft'), | |
}, game)); | |
//return game; | |
} | |
} | |
// getGameFromPlys :: (Game, [Ply]) -> Game | |
var getGameFromPlys = R.reduce(makePly); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment