commit
44f7d93fef
3 changed files with 62 additions and 1 deletions
|
|
@ -16,6 +16,11 @@ export default (io: Server, socket: Socket, data: RandomizeTeams) => {
|
|||
};
|
||||
let game = games[data.game_code];
|
||||
|
||||
// Remove all players from all teams
|
||||
for (var team of game.teams) {
|
||||
team.removePlayers();
|
||||
};
|
||||
|
||||
let players = [...game.players];
|
||||
// game.log.info(players);
|
||||
let new_team: 1|2 = 1;
|
||||
|
|
@ -39,6 +44,9 @@ export default (io: Server, socket: Socket, data: RandomizeTeams) => {
|
|||
player.role = `guesser`;
|
||||
player.team = new_team;
|
||||
|
||||
// Update the team object
|
||||
game.teams[new_team - 1].guessers.push(player);
|
||||
|
||||
// Add the next player to the other team
|
||||
new_team = new_team == 1 ? 2 : 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,27 @@ export class Team {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Removes all players from the team.
|
||||
*/
|
||||
public removePlayers() {
|
||||
|
||||
// Reset the writer
|
||||
if (this.writer) {
|
||||
this.writer.team = null;
|
||||
this.writer.role = null;
|
||||
this.writer = null;
|
||||
};
|
||||
|
||||
// Reset all the guessers
|
||||
for (var player of this.guessers) {
|
||||
player.team = null;
|
||||
player.role = null;
|
||||
}
|
||||
this.guessers = [];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Resets all the per-game data related to this team
|
||||
*/
|
||||
|
|
@ -44,7 +65,7 @@ export class Team {
|
|||
this._hand.guesser = [];
|
||||
this._questions = [];
|
||||
this._answers = new Array<string>(8).fill(``);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,16 @@
|
|||
<template>
|
||||
<div id="app" class="maximize">
|
||||
<transition name="top-slide">
|
||||
<div
|
||||
id="disconnect-error"
|
||||
v-if="$socket.disconnected && ready"
|
||||
>
|
||||
No connection to the game server.
|
||||
<br>
|
||||
If you are in the middle of a game, reload the website and you
|
||||
can reconnect to the game by using the EXACT same name.
|
||||
</div>
|
||||
</transition>
|
||||
<div v-if="!isMobile" class="maximize">
|
||||
<transition name="top-slide">
|
||||
<div
|
||||
|
|
@ -59,6 +70,7 @@ export default {
|
|||
message: null,
|
||||
type: null,
|
||||
},
|
||||
ready: false,
|
||||
}},
|
||||
computed: {
|
||||
gameState() {
|
||||
|
|
@ -108,6 +120,11 @@ export default {
|
|||
};
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
this.ready = true;
|
||||
}, 1000);
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -126,6 +143,21 @@ html, body {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
#disconnect-error {
|
||||
background-color: red;
|
||||
justify-content: center;
|
||||
font-weight: bolder;
|
||||
text-align: center;
|
||||
position: fixed;
|
||||
display: flex;
|
||||
color: black;
|
||||
padding: 10px;
|
||||
width: 100vw;
|
||||
z-index: 50;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.alert-bar {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue