From: Geoffrey Allott Date: Tue, 16 Mar 2021 21:21:19 +0000 (+0000) Subject: rename RevealCard -> CutCard for knock-out whist X-Git-Url: https://git.pointlesshacks.com/?a=commitdiff_plain;h=e9f90593598f9f7fea4fc6c1c4430703e7d61a0c;p=pokerwave.git rename RevealCard -> CutCard for knock-out whist --- diff --git a/site/modules/poker.js b/site/modules/poker.js index 560b93e..7c39315 100644 --- a/site/modules/poker.js +++ b/site/modules/poker.js @@ -26,7 +26,7 @@ export class TexasHoldEm { document.addEventListener("mouseup", () => this.mouse_clicked = false); this.svg = document.createElementNS(svgns, "svg"); - this.svg.classList.add("knock-out-whist"); + this.svg.classList.add("texas-hold-em"); this.svg.setAttribute("viewBox", "0 0 500 500"); const background = document.createElementNS(svgns, "rect"); @@ -434,7 +434,6 @@ export class TexasHoldEm { this.redraw_players(); break; case "ReceiveCard": - case "RevealCard": const card = { card: user_action.action.card, image: this.card_image(user_action.username, user_action.action.card), diff --git a/site/modules/whist.js b/site/modules/whist.js index 4c0ba07..2a1e8e9 100644 --- a/site/modules/whist.js +++ b/site/modules/whist.js @@ -229,7 +229,7 @@ export class KnockOutWhist { this.redraw_players(); break; case "ReceiveCard": - case "RevealCard": + case "CutCard": const card = { card: user_action.action.card, image: this.card_image(user_action.username, user_action.action.card), diff --git a/src/game/action.rs b/src/game/action.rs index 85fac7b..c622206 100644 --- a/src/game/action.rs +++ b/src/game/action.rs @@ -44,6 +44,7 @@ pub enum Action { ReceiveCard { card: Option }, EndDeal, RevealCard { card: Card }, + CutCard { card: Card }, PlayCard { card: Card }, ChooseTrumps { suit: Suit }, Fold, diff --git a/src/game/whist.rs b/src/game/whist.rs index 86c7032..0f38968 100644 --- a/src/game/whist.rs +++ b/src/game/whist.rs @@ -263,7 +263,7 @@ impl Game for KnockOutWhist { self.state = State::Completed; Ok(()) } - (State::CutForCall, Action::RevealCard { card }) => { + (State::CutForCall, Action::CutCard { card }) => { self.deck.remove(&card); self.hands.entry(username).or_default().insert(card); if self.hands.values().map(HashSet::len).sum::() == self.winners.len() { @@ -357,7 +357,7 @@ impl Game for KnockOutWhist { State::CutForCall => { if let Some(username) = self.receiver { if let Some(card) = rng.choose_from(&self.deck).cloned() { - DealerAction::TakeAction(ValidatedUserAction(UserAction { timestamp, username, action: Action::RevealCard { card } })) + DealerAction::TakeAction(ValidatedUserAction(UserAction { timestamp, username, action: Action::CutCard { card } })) } else { error!("Expected to cut for call but there were no cards left in the deck"); DealerAction::Leave @@ -538,8 +538,8 @@ mod tests { {"timestamp":0,"username":"kat","action":{"action":"PlayCard","card":{"rank":"Queen","suit":"Clubs"}}}, {"timestamp":0,"username":"geoff","action":{"action":"PlayCard","card":{"rank":"Five","suit":"Clubs"}}}, {"timestamp":0,"username":"kat","action":{"action":"WinTrick"}}, - {"timestamp":0,"username":"geoff","action":{"action":"RevealCard","card":{"rank":"Three","suit":"Diamonds"}}}, - {"timestamp":0,"username":"kat","action":{"action":"RevealCard","card":{"rank":"Ten","suit":"Clubs"}}}, + {"timestamp":0,"username":"geoff","action":{"action":"CutCard","card":{"rank":"Three","suit":"Diamonds"}}}, + {"timestamp":0,"username":"kat","action":{"action":"CutCard","card":{"rank":"Ten","suit":"Clubs"}}}, {"timestamp":0,"username":"kat","action":{"action":"WinCall"}}, {"timestamp":0,"username":"geoff","action":{"action":"NextToDeal"}}, {"timestamp":0,"username":"kat","action":{"action":"ReceiveCard","card":{"rank":"King","suit":"Spades"}}}, @@ -703,8 +703,8 @@ mod tests { {"timestamp":1615925234913,"username":"geoff","action":{"action":"PlayCard","card":{"rank":"Nine","suit":"Diamonds"}}}, {"timestamp":1615925235946,"username":"kat","action":{"action":"PlayCard","card":{"rank":"Jack","suit":"Spades"}}}, {"timestamp":1615925235949,"username":"geoff","action":{"action":"WinTrick"}}, - {"timestamp":1615925235951,"username":"geoff","action":{"action":"RevealCard","card":{"rank":"Jack","suit":"Diamonds"}}}, - {"timestamp":1615925235953,"username":"kat","action":{"action":"RevealCard","card":{"rank":"Six","suit":"Diamonds"}}}, + {"timestamp":1615925235951,"username":"geoff","action":{"action":"CutCard","card":{"rank":"Jack","suit":"Diamonds"}}}, + {"timestamp":1615925235953,"username":"kat","action":{"action":"CutCard","card":{"rank":"Six","suit":"Diamonds"}}}, {"timestamp":1615925235955,"username":"geoff","action":{"action":"WinCall"}}, {"timestamp":1615925235956,"username":"geoff","action":{"action":"NextToDeal"}}, {"timestamp":1615925235958,"username":"kat","action":{"action":"ReceiveCard","card":{"rank":"Jack","suit":"Diamonds"}}}, @@ -738,8 +738,8 @@ mod tests { {"timestamp":1615925273054,"username":"geoff","action":{"action":"PlayCard","card":{"rank":"King","suit":"Diamonds"}}}, {"timestamp":1615925273976,"username":"kat","action":{"action":"PlayCard","card":{"rank":"Nine","suit":"Clubs"}}}, {"timestamp":1615925273979,"username":"kat","action":{"action":"WinTrick"}}, - {"timestamp":1615925273980,"username":"geoff","action":{"action":"RevealCard","card":{"rank":"Queen","suit":"Spades"}}}, - {"timestamp":1615925273983,"username":"kat","action":{"action":"RevealCard","card":{"rank":"Eight","suit":"Hearts"}}}, + {"timestamp":1615925273980,"username":"geoff","action":{"action":"CutCard","card":{"rank":"Queen","suit":"Spades"}}}, + {"timestamp":1615925273983,"username":"kat","action":{"action":"CutCard","card":{"rank":"Eight","suit":"Hearts"}}}, {"timestamp":1615925273984,"username":"geoff","action":{"action":"WinCall"}}, {"timestamp":1615925273986,"username":"geoff","action":{"action":"NextToDeal"}}, {"timestamp":1615925273987,"username":"kat","action":{"action":"ReceiveCard","card":{"rank":"Six","suit":"Spades"}}},