lib/summary.js
function summary(hand) {
  const res = {}
  if (hand.players == null || hand.players.length === 0) return res

  const bb = hand.info.bb

  res.header = getHeader(hand)
  const seatsInfo = getSeats(hand)
  res.seats = seatsInfo.seats
  res.chipStackRatio = seatsInfo.hero != null
    ? getChipStackRatio(res.header.gametype, res.header.bb, seatsInfo.hero)
    : null
  res.preflopSummary = seatsInfo.preflopSummary
  res.preflopActions = getPlayerActions(hand, hand.actions.preflop)

  if (hand.actions.flop != null && hand.actions.flop.length > 0) {
    res.flopSummary = getFlopSummary(hand, bb)
    res.flopActions = getPlayerActions(hand, hand.actions.flop)
  }

  if (hand.actions.turn != null && hand.actions.turn.length > 0) {
    res.turnSummary = getTurnSummary(hand, bb)
    res.turnActions = getPlayerActions(hand, hand.actions.turn)
  }

  if (hand.actions.river != null && hand.actions.river.length > 0) {
    res.riverSummary = getRiverSummary(hand, bb)
    res.riverActions = getPlayerActions(hand, hand.actions.river)
  }

  res.totalPot = getTotalPot(hand)
  res.spoilers = getSpoilers(hand.players)

  return res
}
function summary(hand) {
  const res = {}
  if (hand.players == null || hand.players.length === 0) return res

  const bb = hand.info.bb

  res.header = getHeader(hand)
  const seatsInfo = getSeats(hand)
  res.seats = seatsInfo.seats
  res.chipStackRatio = seatsInfo.hero != null
    ? getChipStackRatio(res.header.gametype, res.header.bb, seatsInfo.hero)
    : null
  res.preflopSummary = seatsInfo.preflopSummary
  res.preflopActions = getPlayerActions(hand, hand.actions.preflop)

  if (hand.actions.flop != null && hand.actions.flop.length > 0) {
    res.flopSummary = getFlopSummary(hand, bb)
    res.flopActions = getPlayerActions(hand, hand.actions.flop)
  }

  if (hand.actions.turn != null && hand.actions.turn.length > 0) {
    res.turnSummary = getTurnSummary(hand, bb)
    res.turnActions = getPlayerActions(hand, hand.actions.turn)
  }

  if (hand.actions.river != null && hand.actions.river.length > 0) {
    res.riverSummary = getRiverSummary(hand, bb)
    res.riverActions = getPlayerActions(hand, hand.actions.river)
  }

  res.totalPot = getTotalPot(hand)
  res.spoilers = getSpoilers(hand.players)

  return res
}
function summary ( hand ) { const res = { } if ( hand . players == null || hand . players . length === 0 ) return res const bb = hand . info . bb res . header = getHeader ( hand ) const seatsInfo = getSeats ( hand ) res . seats = seatsInfo . seats res . chipStackRatio = seatsInfo . hero != null ? getChipStackRatio ( res . header . gametype , res . header . bb , seatsInfo . hero ) : null res . preflopSummary = seatsInfo . preflopSummary res . preflopActions = getPlayerActions ( hand , hand . actions . preflop ) if ( hand . actions . flop != null && hand . actions . flop . length > 0 ) { res . flopSummary = getFlopSummary ( hand , bb ) res . flopActions = getPlayerActions ( hand , hand . actions . flop ) } if ( hand . actions . turn != null && hand . actions . turn . length > 0 ) { res . turnSummary = getTurnSummary ( hand , bb ) res . turnActions = getPlayerActions ( hand , hand . actions . turn ) } if ( hand . actions . river != null && hand . actions . river . length > 0 ) { res . riverSummary = getRiverSummary ( hand , bb ) res . riverActions = getPlayerActions ( hand , hand . actions . river ) } res . totalPot = getTotalPot ( hand ) res . spoilers = getSpoilers ( hand . players ) return res }
Converts a hand that was analyzed and then scripted to a summary representation.

The summary has the following properties:

- header: contains game info, like room, pokertype, blinds, etc.
- seats: lists the seats of the players including pos, chips and hero indicators
- chipsStackRatio: hero's M for tournaments, his BBs for cash games
- preflopSummary: hero's cards and position
- preflopActions: action types + amounts of each player by position
- flopSummary: pot at flop, board and playersInvolved
- flopActions: same as preflopActions
- turnSummary: pot at turn, turn card and playersInvolved
- turnActions: same as preflopActions
- riverSummary: pot at river, river card and playersInvolved
- riverActions: same as preflopActions
- totalPot: total money in the pot
- spoilers: players whos cards are known by position

@name hha.summary

@function
@param {Object} script
@returns {Object} the hand summarized
Converts a hand that was analyzed and then scripted to a summary representation .