-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwinningMultiState.js
More file actions
30 lines (26 loc) · 878 Bytes
/
winningMultiState.js
File metadata and controls
30 lines (26 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const CardPrettiefier = require('./cardPrettifier')
const SHOW_PLAYING_PLAYERS = 'show-playing-players'
function WinningMultiState(winnerPlayers, room, poolPrize, tableStatus) {
return {
winnerPlayers,
room,
poolPrize,
tableStatus,
print(chat) {
if (tableStatus) {
const cp = CardPrettiefier()
const prettyHands = tableStatus.hands.map((h) => ({
cards: cp.prettify(h.cards),
name: h.name,
}))
chat.toRoomInTopic(this.room, { hands: prettyHands }, SHOW_PLAYING_PLAYERS)
}
for (let i = 0; i < winnerPlayers.length; i += 1) {
const p = this.winnerPlayers[i]
chat.game(this.room, `Player ${p.user.name} wins ${poolPrize}!`)
chat.toSelfInTopic(p.user.id, { money: p.money.toString() }, 'update-money-left')
}
},
}
}
module.exports = WinningMultiState