1
0

Kick, loading, and changing now works better

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-01-29 16:23:37 -08:00
parent 395fb5558d
commit 5088d63729
2 changed files with 29 additions and 19 deletions

View File

@ -1276,15 +1276,16 @@ class Board extends React.Component {
}
updateMessage() {
const player = (this.game && this.game.color) ? this.game.players[this.game.color] : undefined;
const player = (this.game && this.game.color) ? this.game.players[this.game.color] : undefined,
name = this.game ? this.game.name : "";
let message = [];
if (this.state.pickName) {
if (this.state.pickName || !name) {
message.push((<>Enter the name you would like to be known by, then press&nbsp;<b>ENTER</b>&nbsp;or select &nbsp;<b>SET</b>.</>));
} else {
switch (this.game && this.game.state) {
case 'lobby':
message.push((<>You are in the lobby as&nbsp;<b>{this.game.name}</b>.</>));
message.push((<>You are in the lobby as&nbsp;<b>{name}</b>.</>));
if (!this.game.color) {
message.push((<>You need to pick your color.</>));
} else {
@ -1299,12 +1300,8 @@ class Board extends React.Component {
break;
case 'game-order':
if (!player) {
message.push((<>This game is already active.</>));
if (!this.game.name) {
message.push((<>Enter the name you would like to be known by, then press&nbsp;<b>ENTER</b>&nbsp;or select &nbsp;<b>SET</b>.</>));
} else {
message.push((<>You can chat with other players below as&nbsp;<b>{this.game.name}</b>, but cannot play unless players go back to the Lobby.</>));
}
message.push((<>This game as an observer as &nbsp;<b>{name}</b>.</>));
message.push((<>You can chat with other players below as&nbsp;<b>{this.game.name}</b>, but cannot play unless players go back to the Lobby.</>));
} else {
if (!player.order) {
message.push((<>You need to roll for game order. Click&nbsp;<b>Roll Dice</b>&nbsp;below.</>));

View File

@ -207,6 +207,12 @@ const loadGame = async (id) => {
return game;
};
const clearPlayer = (player) => {
player.status = 'Not active';
player.lastActive = 0;
player.order = 0;
}
const adminActions = (game, action, value) => {
switch (action) {
case "kick":
@ -228,12 +234,16 @@ const adminActions = (game, action, value) => {
continue;
}
console.log(`Kicking ${value} from ${game.id}.`);
const name = session.name ? `${session.name} (${color})` : color;
const preamble = session.name ? `${session.name}, playing as ${color},` : color;
game.chat.push({
date: Date.now(),
message: `${name} has been kicked from game.`
message: `${preamble} was kicked from game by the Admin.`
});
session.player = undefined;
if (player) {
session.player = undefined;
clearPlayer(player);
}
session.color = undefined;
return;
}
return `Unable to find active session for ${color} (${value})`;
@ -256,15 +266,19 @@ const setPlayerName = (game, session, name) => {
}
}
const old = session.name ? session.name : "Unknown";
const old = session.name;
let message;
session.name = name;
if (name) {
message = `${old} is now known as ${name}.`;
if (!old) {
message = `A new player has entered the lobby as ${name}.`;
} else {
message = `${name} has chosen to play as ${old}.`;
}
} else {
message = `${old} no longer has a name.`;
message = `Nobody is playing ${old} any more.`;
}
game.chat.push({
@ -287,11 +301,10 @@ const setPlayerColor = (game, session, color) => {
if (player) {
/* Deselect currently active player for this session */
player.status = 'Not active';
player.lastActive = 0;
clearPlayer(player);
game.chat.push({
date: Date.now(),
message: `${session.color} is no longer claimed.`
message: `${name} is no longer ${session.color}.`
});
session.player = undefined;
session.color = undefined;
@ -328,7 +341,7 @@ const setPlayerColor = (game, session, color) => {
session.color = color;
game.chat.push({
date: Date.now(),
message: `${color} is now '${session.name}'.`
message: `${session.name} has chosen to play as ${color}.`
});
};