diff --git a/Public/api.js b/Public/api.js
index 457a647..16432c4 100644
--- a/Public/api.js
+++ b/Public/api.js
@@ -4,6 +4,8 @@
const apiPath = "/schafkopf"
+var useEnglishTexts = false
+
function webSocketPath() {
const prefix = (window.location.protocol === "https:") ? "wss://" : "ws://"
return prefix + window.location.host + apiPath + "/session/start"
@@ -109,6 +111,53 @@ function convertJsonResponse(text) {
if (text == "") {
return null;
}
- console.log(text)
return JSON.parse(text);
}
+
+// The state identifiers for all player states
+const stateCanDouble = "canDouble"
+const stateDidDouble = "doubled"
+const stateIsDisconnected = "offline"
+const stateMustBid = "bidder"
+const stateDidFold = "fold"
+const stateDidBid = "bid"
+const stateIsGameSelector = "selects"
+const stateIsWeddingOfferer = "wedding"
+const stateIsCalled = "called"
+const stateDidRaise = "raised"
+const stateLeadsGame = "leads"
+const stateIsWinner = "winner"
+const stateIsLooser = "looser"
+
+function convertStateToString(state) {
+ switch (state) {
+ case stateCanDouble:
+ return useEnglishTexts ? "Can double" : "Kann legen"
+ case stateDidDouble:
+ return useEnglishTexts ? "Doubled" : "Leger"
+ case stateIsDisconnected:
+ return useEnglishTexts ? "Disconnected" : "Abwesend"
+ case stateMustBid:
+ return useEnglishTexts ? "Must bid": "Muss ansagen"
+ case stateDidFold:
+ return useEnglishTexts ? "Fold" : "Weg"
+ case stateDidBid:
+ return useEnglishTexts ? "Wants to play" : "Spielt"
+ case stateIsGameSelector:
+ return useEnglishTexts ? "Selects game" : "Wählt Spiel"
+ case stateIsWeddingOfferer:
+ return useEnglishTexts ? "Offers wedding" : "Hochzeit"
+ case stateIsCalled:
+ return useEnglishTexts ? "Called" : "Gerufen"
+ case stateDidRaise:
+ return useEnglishTexts ? "Raised" : "Schuss"
+ case stateLeadsGame:
+ return useEnglishTexts ? "Player" : "Spieler"
+ case stateIsWinner:
+ return useEnglishTexts ? "Winner" : "Hat gewonnen"
+ case stateIsLooser:
+ return useEnglishTexts ? "Looser" : "Hat verloren"
+ default:
+ return state
+ }
+}
\ No newline at end of file
diff --git a/Public/elements.js b/Public/elements.js
index 420214b..8c0dbe6 100644
--- a/Public/elements.js
+++ b/Public/elements.js
@@ -290,25 +290,25 @@ function setInfoForPlayer(player, position, game) {
if (player.hasOwnProperty("card")) {
card = player.card
}
- const leadsGame = player.leads
const layer = player.position
setTableCard(position, card, layer)
setTablePlayerName(position, player.name, player.active)
- if (!player.connected) {
- showPlayerDisconnected(position)
- return
- }
- var state = []
- if (game != null && leadsGame) {
- state.push(game)
+ // if (!player.connected) {
+ // showPlayerDisconnected(position)
+ // return
+ // }
+ var state = player.state
+ if (game != null && state.indexOf("selects") > -1) {
+ const i = state.indexOf("selects")
+ state[i] = game
}
- const double = doubleText(player.doubles)
- if (double) {
- state.push(double)
- }
+ // const double = doubleText(player.doubles)
+ // if (double) {
+ // state.push(double)
+ // }
- const text = state.join(", ")
+ const text = state.map(x => convertStateToString(x)).join("
")
showPlayerState(position, text)
}
diff --git a/Public/game.js b/Public/game.js
index 721362a..ddace46 100644
--- a/Public/game.js
+++ b/Public/game.js
@@ -4,6 +4,13 @@ var socket = null;
var tableId = null;
var activePlayer = null;
+const createTableRow = '