Kick, loading, and changing now works better
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
395fb5558d
commit
5088d63729
@ -1276,15 +1276,16 @@ class Board extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateMessage() {
|
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 = [];
|
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 <b>ENTER</b> or select <b>SET</b>.</>));
|
message.push((<>Enter the name you would like to be known by, then press <b>ENTER</b> or select <b>SET</b>.</>));
|
||||||
} else {
|
} else {
|
||||||
switch (this.game && this.game.state) {
|
switch (this.game && this.game.state) {
|
||||||
case 'lobby':
|
case 'lobby':
|
||||||
message.push((<>You are in the lobby as <b>{this.game.name}</b>.</>));
|
message.push((<>You are in the lobby as <b>{name}</b>.</>));
|
||||||
if (!this.game.color) {
|
if (!this.game.color) {
|
||||||
message.push((<>You need to pick your color.</>));
|
message.push((<>You need to pick your color.</>));
|
||||||
} else {
|
} else {
|
||||||
@ -1299,12 +1300,8 @@ class Board extends React.Component {
|
|||||||
break;
|
break;
|
||||||
case 'game-order':
|
case 'game-order':
|
||||||
if (!player) {
|
if (!player) {
|
||||||
message.push((<>This game is already active.</>));
|
message.push((<>This game as an observer as <b>{name}</b>.</>));
|
||||||
if (!this.game.name) {
|
message.push((<>You can chat with other players below as <b>{this.game.name}</b>, but cannot play unless players go back to the Lobby.</>));
|
||||||
message.push((<>Enter the name you would like to be known by, then press <b>ENTER</b> or select <b>SET</b>.</>));
|
|
||||||
} else {
|
|
||||||
message.push((<>You can chat with other players below as <b>{this.game.name}</b>, but cannot play unless players go back to the Lobby.</>));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!player.order) {
|
if (!player.order) {
|
||||||
message.push((<>You need to roll for game order. Click <b>Roll Dice</b> below.</>));
|
message.push((<>You need to roll for game order. Click <b>Roll Dice</b> below.</>));
|
||||||
|
@ -207,6 +207,12 @@ const loadGame = async (id) => {
|
|||||||
return game;
|
return game;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearPlayer = (player) => {
|
||||||
|
player.status = 'Not active';
|
||||||
|
player.lastActive = 0;
|
||||||
|
player.order = 0;
|
||||||
|
}
|
||||||
|
|
||||||
const adminActions = (game, action, value) => {
|
const adminActions = (game, action, value) => {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "kick":
|
case "kick":
|
||||||
@ -228,12 +234,16 @@ const adminActions = (game, action, value) => {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
console.log(`Kicking ${value} from ${game.id}.`);
|
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({
|
game.chat.push({
|
||||||
date: Date.now(),
|
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;
|
||||||
}
|
}
|
||||||
return `Unable to find active session for ${color} (${value})`;
|
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;
|
let message;
|
||||||
|
|
||||||
session.name = name;
|
session.name = name;
|
||||||
|
|
||||||
if (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 {
|
} else {
|
||||||
message = `${old} no longer has a name.`;
|
message = `Nobody is playing ${old} any more.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
game.chat.push({
|
game.chat.push({
|
||||||
@ -287,11 +301,10 @@ const setPlayerColor = (game, session, color) => {
|
|||||||
|
|
||||||
if (player) {
|
if (player) {
|
||||||
/* Deselect currently active player for this session */
|
/* Deselect currently active player for this session */
|
||||||
player.status = 'Not active';
|
clearPlayer(player);
|
||||||
player.lastActive = 0;
|
|
||||||
game.chat.push({
|
game.chat.push({
|
||||||
date: Date.now(),
|
date: Date.now(),
|
||||||
message: `${session.color} is no longer claimed.`
|
message: `${name} is no longer ${session.color}.`
|
||||||
});
|
});
|
||||||
session.player = undefined;
|
session.player = undefined;
|
||||||
session.color = undefined;
|
session.color = undefined;
|
||||||
@ -328,7 +341,7 @@ const setPlayerColor = (game, session, color) => {
|
|||||||
session.color = color;
|
session.color = color;
|
||||||
game.chat.push({
|
game.chat.push({
|
||||||
date: Date.now(),
|
date: Date.now(),
|
||||||
message: `${color} is now '${session.name}'.`
|
message: `${session.name} has chosen to play as ${color}.`
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user