populate chat with actions and error messages
authorGeoffrey Allott <geoffrey@allott.email>
Sun, 21 Mar 2021 14:22:06 +0000 (14:22 +0000)
committerGeoffrey Allott <geoffrey@allott.email>
Sun, 21 Mar 2021 14:22:06 +0000 (14:22 +0000)
site/modules/chatroom.js
site/modules/poker.js

index 242ac19f9a6827352e681fda16a2c59d7bdf68f9..4046da22f646601e586326bc9b4681bb9892fdd9 100644 (file)
@@ -32,7 +32,7 @@ export class Chatroom {
     }
 
     set_error_text(text) {
-        this.chat.append(this.chat_element("chatroom-error", "«error»", message));
+        this.chat.append(this.chat_element("chatroom-error", "«error»", text));
     }
 
     take_action(user_action, initialising) {
index 6ea0fd5331e4bb0a096136a947becdc4a4225cc1..a6c88b583aaf6b48d444fe49992b63584535ef31 100644 (file)
@@ -227,13 +227,14 @@ export class TexasHoldEm {
         this.svg.append(this.chat_control);
 
         this.container.append(this.svg);
-        for (const user_action of this.actions) {
-            this.take_action(user_action);
-        }
 
         this.chatroom_container = document.createElement("div");
         this.chatroom_container.classList.add("embedded-chatroom");
-        this.chatroom = new Chatroom(this.chatroom_container, summary, actions, username, send);
+        this.chatroom = new Chatroom(this.chatroom_container, summary, [], username, send);
+
+        for (const user_action of this.actions) {
+            this.take_action(user_action);
+        }
 
         this.container.append(this.chatroom_container);
 
@@ -265,6 +266,7 @@ export class TexasHoldEm {
     }
 
     set_error_text(text) {
+        this.chatroom.set_error_text(text);
         this.set_text("game-error", text);
     }
 
@@ -429,6 +431,7 @@ export class TexasHoldEm {
     }
 
     take_action(user_action) {
+        this.chatroom.take_action(user_action);
         switch (user_action.action.action) {
             case "Join":
                 this.seats.set(user_action.username, user_action.action.seat);