Skip to content

Instantly share code, notes, and snippets.

@knubie
Created September 17, 2016 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knubie/710342fab801f9cbd9ab1a5f7852fd93 to your computer and use it in GitHub Desktop.
Save knubie/710342fab801f9cbd9ab1a5f7852fd93 to your computer and use it in GitHub Desktop.
...
// 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