-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrapState.js
More file actions
47 lines (44 loc) · 1.29 KB
/
bootstrapState.js
File metadata and controls
47 lines (44 loc) · 1.29 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const CardPrettiefier = require('./cardPrettifier')
const BOOTSTRAP_STATE = 'bootstrap-state'
function BootstrapState(
startedBy,
roomId,
dealerName,
smallBlindName,
bigBlindName,
poolPrize,
hands,
nextState
) {
return {
startedBy,
roomId,
dealerName,
smallBlindName,
bigBlindName,
poolPrize,
hands,
nextState,
print(chat) {
chat.game(this.roomId, `Game in room ${this.roomId} has started by ${this.startedBy}`)
chat.game(this.roomId, `The dealer is ${this.dealerName}`)
chat.game(this.roomId, `The small blind is ${this.smallBlindName}`)
chat.game(this.roomId, `The big blind is ${this.bigBlindName}`)
chat.game(this.roomId, `Current pool prize is: ${this.poolPrize}`)
chat.game(this.roomId, 'Dealing cards...')
for (let i = 0; i < this.hands.length; i += 1) {
const hand = this.hands[i]
const cards = CardPrettiefier().prettify(hand.cards)
chat.toSelf(hand.id, `Your hand is ${cards}`)
chat.toSelfInTopic(
hand.id,
{ cards, poolPrize: this.poolPrize, moneyLeft: hand.moneyLeft },
BOOTSTRAP_STATE
)
}
this.nextState.print(chat)
chat.toRoomInTopic(this.roomId, '', 'update-common-cards')
},
}
}
module.exports = BootstrapState