rename RevealCard -> CutCard for knock-out whist
authorGeoffrey Allott <geoffrey@allott.email>
Tue, 16 Mar 2021 21:21:19 +0000 (21:21 +0000)
committerGeoffrey Allott <geoffrey@allott.email>
Tue, 16 Mar 2021 21:21:19 +0000 (21:21 +0000)
site/modules/poker.js
site/modules/whist.js
src/game/action.rs
src/game/whist.rs

index 560b93e5604864d96334ea696177532a74d11e0d..7c3931554273116cb5550fe3ab1b66bdebbbbd89 100644 (file)
@@ -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),
index 4c0ba0723f3cb74f002fd3b4adb79aaa94c6dbd0..2a1e8e9d248e3be7e55e32f8793e6d9b4141dfb2 100644 (file)
@@ -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),
index 85fac7bc58fa04a39ace17d77fc171138cf72f59..c6222067543be94fdfc40b495a696f63ebdad8b2 100644 (file)
@@ -44,6 +44,7 @@ pub enum Action {
     ReceiveCard { card: Option<Card> },
     EndDeal,
     RevealCard { card: Card },
+    CutCard { card: Card },
     PlayCard { card: Card },
     ChooseTrumps { suit: Suit },
     Fold,
index 86c7032306f8b6bfca1ef7c77774ec9aa33063ab..0f38968bc30bbcd62dc816ff6ba06cda5a08d15d 100644 (file)
@@ -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::<usize>() == 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"}}},