}
set_error_text(text) {
- // TODO
+ this.chat.append(this.chat_element("chatroom-error", "«error»", message));
}
take_action(user_action, initialising) {
{ 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"] },
];
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");
}
}
- 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);
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;
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);
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;
case "WinCall":
case "WinHand":
return 1000;
+ case "NewBlinds":
+ return 5000;
case "PostBlind":
case "Fold":
case "TimeoutFold":
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();
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");
}
}
- 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 {
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);
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);
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]);
}
}
}
}
}
this.hands.clear();
+ this.tricks_won.clear();
this.trumps = null;
this.active = this.player_after(user_action.username);
this.redraw_trumps();
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":
@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");
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;
}
border-radius: 3vw;
}
+.chatroom-error > .chatroom-username {
+ background-color: red;
+}
+
.chatroom-info > .chatroom-username {
background-color: skyblue;
color: black;
}
.chatroom-leave > .chatroom-username {
- background-color: red;
+ background-color: darkgreen;
}
.chatroom-win-game > .chatroom-username {
.game-title {
font-weight: bold;
}
-
-.game-close {
- display: block;
- position: absolute;
- right: 0;
- top: 0;
- font-size: 5vw;
-}
--- /dev/null
+.game-error {
+ fill: red;
+}
+
+.game-info {
+ fill: white;
+}
+
+.game-close {
+ display: block;
+ position: absolute;
+ right: 0;
+ top: 0;
+ font-size: 5vw;
+}
height: 100%;
}
-.game-error {
- fill: red;
-}
-
.my-card {
transform: none;
transition: transform 0.5s;