src/util.js
function getPlayerPlays(player, game) {
  // Shuffle so that equal-weighted players aren't
  // always prioritized by their turn order
  return Util.shuffle(game.players)
    .reduce((plays, target) => {
      if (player === target) {
        return plays
      }
      return plays.concat(
        player.hand
          .map((card) => {
            return card.validPlays ? card.validPlays(player, target, game) : []
          })
          .reduce((acc, array) => {
            return acc.concat(array)
          }, [])
      )
    }, [])
    .sort((playA, playB) => playB.weight - playA.weight)
}
function getPlayerPlays(player, game) {
  // Shuffle so that equal-weighted players aren't
  // always prioritized by their turn order
  return Util.shuffle(game.players)
    .reduce((plays, target) => {
      if (player === target) {
        return plays
      }
      return plays.concat(
        player.hand
          .map((card) => {
            return card.validPlays ? card.validPlays(player, target, game) : []
          })
          .reduce((acc, array) => {
            return acc.concat(array)
          }, [])
      )
    }, [])
    .sort((playA, playB) => playB.weight - playA.weight)
}
function getPlayerPlays ( player , game ) { // Shuffle so that equal-weighted players aren't // always prioritized by their turn order return Util . shuffle ( game . players ) . reduce ( ( plays , target ) => { if ( player === target ) { return plays } return plays . concat ( player . hand . map ( ( card ) => { return card . validPlays ? card . validPlays ( player , target , game ) : [ ] } ) . reduce ( ( acc , array ) => { return acc . concat ( array ) } , [ ] ) ) } , [ ] ) . sort ( ( playA , playB ) => playB . weight - playA . weight ) }
Get a list of possible moves a player can play, sorted by best option
Get a list of possible moves a player can play sorted by best option