this.user_icons = new Map();
this.small_blind = this.summary.settings.small_blind;
this.big_blind = this.small_blind * 2;
+ this.error_text_timeout = null;
this.mouse_clicked = false;
document.addEventListener("mousedown", () => this.mouse_clicked = true);
background.setAttribute("fill", "#404040");
this.svg.append(background);
+ this.error = document.createElementNS(svgns, "text");
+ this.error.setAttribute("x", "20");
+ this.error.setAttribute("y", "480");
+ this.error.classList.add("game-error");
+ this.error_text = document.createTextNode("");
+ this.error.append(this.error_text);
+ this.svg.append(this.error);
+
const table = document.createElementNS(svgns, "ellipse");
table.setAttribute("cx", "250");
table.setAttribute("cy", "253");
}
}
+ set_error_text(text) {
+ this.error_text.textContent = text;
+ if (this.error_text_timeout !== null) clearTimeout(this.error_text_timeout);
+ this.error_text_timeout = setTimeout(() => {
+ this.error_text.textContent = "";
+ this.error_text_timeout = null;
+ }, 5000);
+ }
+
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);
break;
default:
console.error("Unhandled action for texas hold'em", user_action);
+ this.set_error_text("Unhandled action for texas hold'em: " + user_action.action.action);
break;
}
}
this.send({type: "TakeAction", action: {action: "Join", seat: message.action.action.seat + 1, chips: message.action.action.chips}});
} else {
console.error("Taking action failed: " + message.reason, message.action);
+ this.game.set_error_text(message.reason);
}
break;
case "TakeActionSuccess":
console.error("Websocket closed unexpectedly - attempting reconnect in " + reconnect_timeout + "ms");
this.state = "Disconnected";
setTimeout(() => window.location.reload(), reconnect_timeout);
+ this.game.set_error_text("Websocket closed unexpectedly - attempting reconnect in " + reconnect_timeout + "ms");
}
}
this.community = [];
this.trick = [];
this.user_icons = new Map();
+ this.error_text_timeout = null;
this.svg = document.createElementNS(svgns, "svg");
this.svg.classList.add("knock-out-whist");
background.setAttribute("fill", "#404040");
this.svg.append(background);
+ this.error = document.createElementNS(svgns, "text");
+ this.error.setAttribute("x", "20");
+ this.error.setAttribute("y", "480");
+ this.error.classList.add("game-error");
+ this.error_text = document.createTextNode("");
+ this.error.append(this.error_text);
+ this.svg.append(this.error);
+
const table = document.createElementNS(svgns, "ellipse");
table.setAttribute("cx", "250");
table.setAttribute("cy", "253");
}
}
+ set_error_text(text) {
+ this.error_text.textContent = text;
+ if (this.error_text_timeout !== null) clearTimeout(this.error_text_timeout);
+ this.error_text_timeout = setTimeout(() => {
+ this.error_text.textContent = "";
+ this.error_text_timeout = null;
+ }, 5000);
+ }
+
redraw_players() {
const active_player = this.call || this.active;
for (const [username, [icon, active]] of this.user_icons) {
x -= 20;
}
}
+ let x = 257.5;
for (const {card, image} of this.trick) {
- const x = 227.5;
const y = 210;
image.classList.remove("my-card");
image.setAttribute("x", x);
image.setAttribute("y", y);
+ x -= 20;
}
+ x = 120.0;
for (const {card, image} of this.community) {
- const x = 120.0;
const y = 210;
image.setAttribute("x", x);
image.setAttribute("y", y);
+ x -= 20;
}
}
}
} else if (card.card.suit === user_action.action.card.suit && card.card.rank === user_action.action.card.rank) {
this.trick.push(card);
+ this.svg.append(card.image);
return false;
} else {
return true;
break;
default:
console.error("Unhandled action for knock-out whist", user_action);
+ this.set_error_text("Unhandled action for knock-out whist: " + user_action.action.action);
break;
}
}
height: 100%;
}
+.game-error {
+ fill: red;
+}
+
.my-card {
transform: none;
transition: transform 0.5s;