From: Geoffrey Allott Date: Sat, 20 Mar 2021 17:59:57 +0000 (+0000) Subject: update site to specify blind structure X-Git-Url: https://git.pointlesshacks.com/?a=commitdiff_plain;h=b880670ea91fe873475805a8fa643040b1f3d196;p=pokerwave.git update site to specify blind structure --- diff --git a/site/modules/chatroom.js b/site/modules/chatroom.js index 0137fd6..242ac19 100644 --- a/site/modules/chatroom.js +++ b/site/modules/chatroom.js @@ -32,7 +32,7 @@ export class Chatroom { } set_error_text(text) { - // TODO + this.chat.append(this.chat_element("chatroom-error", "«error»", message)); } take_action(user_action, initialising) { diff --git a/site/modules/gamelist.js b/site/modules/gamelist.js index ca0ca99..9237549 100644 --- a/site/modules/gamelist.js +++ b/site/modules/gamelist.js @@ -188,6 +188,8 @@ export class GameList { { name: "max_players", display: "Max Players", value: 2, formats: ["TexasHoldEm", "KnockOutWhist"] }, { name: "small_blind", display: "Small Blind", value: 25, formats: ["TexasHoldEm"] }, { name: "starting_stack", display: "Starting Stack", value: 1000, formats: ["TexasHoldEm"] }, + { name: "round_length", display: "Round Length", value: 60000, formats: ["TexasHoldEm"] }, + { name: "tournament_length", display: "Tournament Length", value: 600000, formats: ["TexasHoldEm"] }, { name: "action_timeout", display: "Action Timeout", value: 30000, formats: ["TexasHoldEm"] }, ]; diff --git a/site/modules/poker.js b/site/modules/poker.js index 05fd2df..72c6b54 100644 --- a/site/modules/poker.js +++ b/site/modules/poker.js @@ -38,10 +38,21 @@ export class TexasHoldEm { this.error = document.createElementNS(svgns, "text"); this.error.setAttribute("x", "20"); - this.error.setAttribute("y", "480"); + this.error.setAttribute("y", "450"); this.error.classList.add("game-error"); - this.error_text = document.createTextNode(""); - this.error.append(this.error_text); + this.error_lines = []; + this.error_text = []; + const num_error_lines = 2; + for (let i = 0; i < num_error_lines; i++) { + const line = document.createElementNS(svgns, "tspan"); + const text = document.createTextNode(""); + line.setAttribute("x", "20"); + line.setAttribute("dy", "20"); + line.append(text); + this.error.append(line); + this.error_lines.push(line); + this.error_text.push(text); + } this.svg.append(this.error); const table = document.createElementNS(svgns, "ellipse"); @@ -214,15 +225,32 @@ export class TexasHoldEm { } } - set_error_text(text) { - this.error_text.textContent = text; + set_text(style, text) { + this.error.setAttribute("class", style); + const lines = text.split("\n", this.error_text.length); + for (const text of this.error_text) { + text.textContent = ""; + } + for (let i = 0; i < lines.length; i++) { + this.error_text[i + this.error_text.length - lines.length].textContent = lines[i]; + } if (this.error_text_timeout !== null) clearTimeout(this.error_text_timeout); this.error_text_timeout = setTimeout(() => { - this.error_text.textContent = ""; + for (const text of this.error_text) { + text.textContent = ""; + } this.error_text_timeout = null; }, 5000); } + set_info_text(text) { + this.set_text("game-info", text); + } + + set_error_text(text) { + this.set_text("game-error", text); + } + redraw_players() { this.fold_control.classList.toggle("active", this.active === this.username && this.chips_to_call() > 0); this.call_control.classList.toggle("active", this.active === this.username); @@ -427,6 +455,13 @@ export class TexasHoldEm { this.redraw_cards(); this.redraw_players(); break; + case "NewBlinds": + this.small_blind = user_action.action.small_blind; + this.big_blind = user_action.action.big_blind; + this.set_info_text("Blinds Up: " + + "Level " + user_action.action.level + + ": " + user_action.action.small_blind + "/" + user_action.action.big_blind) + break; case "NextToDeal": this.remove_ghosts(); this.dealer = user_action.username; @@ -494,6 +529,9 @@ export class TexasHoldEm { this.bets.clear(); this.pot -= user_action.action.chips; this.stacks.set(user_action.username, this.stacks.get(user_action.username) + user_action.action.chips); + this.set_info_text(user_action.username + + " wins " + user_action.action.chips + " chips" + + (user_action.action.hand === null ? "" : " with\n" + user_action.action.hand)); this.redraw_players(); case "EndDeal": this.active = this.player_after(user_action.username, username => true); @@ -502,6 +540,16 @@ export class TexasHoldEm { case "WinGame": this.active = null; this.remove_ghosts(); + for (const card of this.community) { + this.svg.removeChild(card.image); + } + this.community = []; + for (const [username, hand] of this.hands) { + for (const card of hand) { + this.svg.removeChild(card.image); + } + } + this.hands.clear(); this.redraw_players(); new CongratulateWinner(this.svg, user_action.username); break; diff --git a/site/modules/socket.js b/site/modules/socket.js index c63ebd4..dff9571 100644 --- a/site/modules/socket.js +++ b/site/modules/socket.js @@ -147,6 +147,8 @@ export class Socket { case "WinCall": case "WinHand": return 1000; + case "NewBlinds": + return 5000; case "PostBlind": case "Fold": case "TimeoutFold": diff --git a/site/modules/whist.js b/site/modules/whist.js index 98a2e37..abe0f92 100644 --- a/site/modules/whist.js +++ b/site/modules/whist.js @@ -11,6 +11,7 @@ export class KnockOutWhist { this.send = send; this.seats = new Map(); this.hands = new Map(); + this.tricks_won = new Map(); this.community = []; this.trick = []; this.user_icons = new Map(); @@ -28,10 +29,21 @@ export class KnockOutWhist { this.error = document.createElementNS(svgns, "text"); this.error.setAttribute("x", "20"); - this.error.setAttribute("y", "480"); + this.error.setAttribute("y", "450"); this.error.classList.add("game-error"); - this.error_text = document.createTextNode(""); - this.error.append(this.error_text); + this.error_lines = []; + this.error_text = []; + const num_error_lines = 2; + for (let i = 0; i < num_error_lines; i++) { + const line = document.createElementNS(svgns, "tspan"); + const text = document.createTextNode(""); + line.setAttribute("x", "20"); + line.setAttribute("dy", "20"); + line.append(text); + this.error.append(line); + this.error_lines.push(line); + this.error_text.push(text); + } this.svg.append(this.error); const table = document.createElementNS(svgns, "ellipse"); @@ -91,20 +103,38 @@ export class KnockOutWhist { } } - set_error_text(text) { - this.error_text.textContent = text; + set_text(style, text) { + this.error.setAttribute("class", style); + const lines = text.split("\n", this.error_text.length); + for (const text of this.error_text) { + text.textContent = ""; + } + for (let i = 0; i < lines.length; i++) { + this.error_text[i + this.error_text.length - lines.length].textContent = lines[i]; + } if (this.error_text_timeout !== null) clearTimeout(this.error_text_timeout); this.error_text_timeout = setTimeout(() => { - this.error_text.textContent = ""; + for (const text of this.error_text) { + text.textContent = ""; + } this.error_text_timeout = null; }, 5000); } + set_info_text(text) { + this.set_text("game-info", text); + } + + set_error_text(text) { + this.set_text("game-error", text); + } + redraw_players() { const active_player = this.call || this.active; - for (const [username, [icon, active]] of this.user_icons) { + for (const [username, [icon, tricks, active]] of this.user_icons) { if (!this.seats.has(username)) { this.svg.removeChild(icon); + this.svg.removeChild(tricks); this.svg.removeChild(active); this.user_icons.delete(username); } else { @@ -114,6 +144,9 @@ export class KnockOutWhist { const y = 250 + 120 * Math.cos(angle) + 50 * Math.sign(Math.cos(angle)); icon.setAttribute("x", x); icon.setAttribute("y", y); + tricks.childNodes[0].nodeValue = this.tricks_won.get(username); + tricks.setAttribute("x", 240 - 120 * Math.sin(angle)); + tricks.setAttribute("y", 250 + 70 * Math.cos(angle)); active.classList.toggle("active", active_player === username); active.setAttribute("cx", x - 10); active.setAttribute("cy", y - 5); @@ -130,6 +163,14 @@ export class KnockOutWhist { icon.setAttribute("x", x); icon.setAttribute("y", y); this.svg.append(icon); + + const tricks = document.createElementNS(svgns, "text"); + const tricks_text = document.createTextNode(this.tricks_won.get(username) || ""); + tricks.append(tricks_text); + tricks.setAttribute("x", 240 - 120 * Math.sin(angle)); + tricks.setAttribute("y", 250 + 70 * Math.cos(angle)); + this.svg.append(tricks); + const active = document.createElementNS(svgns, "circle"); active.setAttribute("cx", x - 10); active.setAttribute("cy", y - 5); @@ -137,7 +178,7 @@ export class KnockOutWhist { active.classList.add("active-indicator"); active.classList.toggle("active", active_player === username); this.svg.append(active); - this.user_icons.set(username, [icon, active]); + this.user_icons.set(username, [icon, tricks, active]); } } } @@ -242,6 +283,7 @@ export class KnockOutWhist { } } this.hands.clear(); + this.tricks_won.clear(); this.trumps = null; this.active = this.player_after(user_action.username); this.redraw_trumps(); @@ -305,11 +347,14 @@ export class KnockOutWhist { this.svg.removeChild(card.image); } this.trick = []; + const tricks_won = this.tricks_won.get(user_action.username) || 0; + this.tricks_won.set(user_action.username, tricks_won + 1) this.active = user_action.username; this.redraw_players(); break; case "WinCall": this.call = user_action.username; + this.set_info_text(user_action.username + " wins the call"); this.redraw_players(); break; case "EndDeal": diff --git a/site/style.css b/site/style.css index 80656cf..d925c5b 100644 --- a/site/style.css +++ b/site/style.css @@ -1,6 +1,7 @@ @import url("style/login.css"); @import url("style/mainmenu.css"); @import url("style/game-list.css"); +@import url("style/game.css"); @import url("style/chatroom.css"); @import url("style/poker.css"); @import url("style/whist.css"); diff --git a/site/style/chatroom.css b/site/style/chatroom.css index 4ff23a5..fddab8d 100644 --- a/site/style/chatroom.css +++ b/site/style/chatroom.css @@ -21,7 +21,7 @@ align-self: end; } -.chatroom-join, .chatroom-message, .chatroom-info, .chatroom-leave, .chatroom-win-game { +.chatroom-join, .chatroom-message, .chatroom-info, .chatroom-error, .chatroom-leave, .chatroom-win-game { display: flex; } @@ -36,6 +36,10 @@ border-radius: 3vw; } +.chatroom-error > .chatroom-username { + background-color: red; +} + .chatroom-info > .chatroom-username { background-color: skyblue; color: black; @@ -51,7 +55,7 @@ } .chatroom-leave > .chatroom-username { - background-color: red; + background-color: darkgreen; } .chatroom-win-game > .chatroom-username { diff --git a/site/style/game-list.css b/site/style/game-list.css index 4096aeb..8e52758 100644 --- a/site/style/game-list.css +++ b/site/style/game-list.css @@ -146,11 +146,3 @@ .game-title { font-weight: bold; } - -.game-close { - display: block; - position: absolute; - right: 0; - top: 0; - font-size: 5vw; -} diff --git a/site/style/game.css b/site/style/game.css new file mode 100644 index 0000000..6c0cc4c --- /dev/null +++ b/site/style/game.css @@ -0,0 +1,15 @@ +.game-error { + fill: red; +} + +.game-info { + fill: white; +} + +.game-close { + display: block; + position: absolute; + right: 0; + top: 0; + font-size: 5vw; +} diff --git a/site/style/whist.css b/site/style/whist.css index faba26e..43b41cd 100644 --- a/site/style/whist.css +++ b/site/style/whist.css @@ -3,10 +3,6 @@ svg { height: 100%; } -.game-error { - fill: red; -} - .my-card { transform: none; transition: transform 0.5s;