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];
|
let game = games[data.game_code];
|
||||||
|
|
||||||
|
// Remove all players from all teams
|
||||||
|
for (var team of game.teams) {
|
||||||
|
team.removePlayers();
|
||||||
|
};
|
||||||
|
|
||||||
let players = [...game.players];
|
let players = [...game.players];
|
||||||
// game.log.info(players);
|
// game.log.info(players);
|
||||||
let new_team: 1|2 = 1;
|
let new_team: 1|2 = 1;
|
||||||
|
|
@ -39,6 +44,9 @@ export default (io: Server, socket: Socket, data: RandomizeTeams) => {
|
||||||
player.role = `guesser`;
|
player.role = `guesser`;
|
||||||
player.team = new_team;
|
player.team = new_team;
|
||||||
|
|
||||||
|
// Update the team object
|
||||||
|
game.teams[new_team - 1].guessers.push(player);
|
||||||
|
|
||||||
// Add the next player to the other team
|
// Add the next player to the other team
|
||||||
new_team = new_team == 1 ? 2 : 1;
|
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
|
* Resets all the per-game data related to this team
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,7 +65,7 @@ export class Team {
|
||||||
this._hand.guesser = [];
|
this._hand.guesser = [];
|
||||||
this._questions = [];
|
this._questions = [];
|
||||||
this._answers = new Array<string>(8).fill(``);
|
this._answers = new Array<string>(8).fill(``);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="app" class="maximize">
|
<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">
|
<div v-if="!isMobile" class="maximize">
|
||||||
<transition name="top-slide">
|
<transition name="top-slide">
|
||||||
<div
|
<div
|
||||||
|
|
@ -59,6 +70,7 @@ export default {
|
||||||
message: null,
|
message: null,
|
||||||
type: null,
|
type: null,
|
||||||
},
|
},
|
||||||
|
ready: false,
|
||||||
}},
|
}},
|
||||||
computed: {
|
computed: {
|
||||||
gameState() {
|
gameState() {
|
||||||
|
|
@ -108,6 +120,11 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.ready = true;
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -126,6 +143,21 @@ html, body {
|
||||||
margin: 0;
|
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 {
|
.alert-bar {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue