commit
a8db700449
6 changed files with 38 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -8,6 +8,8 @@ server/dist/*
|
|||
server/resources/*
|
||||
*.log
|
||||
*.sh
|
||||
test.*
|
||||
*.ignore*
|
||||
|
||||
#=============================================================================#
|
||||
# The files that were auto-generated into a .gitignore by Vue-cli
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export default (io: Server, socket: Socket, data: ResetGame) => {
|
|||
let game = games[data.game_code];
|
||||
game.log.info(`Resetting game`);
|
||||
|
||||
game.teams.forEach(t => t.resetHand());
|
||||
game.teams.forEach(t => t.reset());
|
||||
game.questions.reset();
|
||||
game.resetObject();
|
||||
game.ingame = false;
|
||||
|
|
|
|||
|
|
@ -24,9 +24,14 @@ export default (io: Server, socket: Socket, data: SendCard) => {
|
|||
|
||||
// Draw new cards for team
|
||||
deck.discard(data.text);
|
||||
team.addCardsToHand(game.questions.draw(conf.game.hand_size - team.hand.length));
|
||||
team.selectQuestion(data.text);
|
||||
|
||||
// Get any additional cards needed
|
||||
let needed_cards = conf.game.hand_size - team.hand.length;
|
||||
if (needed_cards > 0) {
|
||||
team.addCardsToHand(game.questions.draw(needed_cards));
|
||||
};
|
||||
|
||||
socket.emit(`UpdateHand`, {
|
||||
status: 200,
|
||||
mode: "replace",
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ export default (io: Server, socket: Socket, data: StartGame) => {
|
|||
};
|
||||
|
||||
// Ensure the questions deck got populated
|
||||
if (game.questions.size <= 0) {
|
||||
game.log.error(`Questions deck has no cards before the game started.`);
|
||||
if (game.questions?.size <= 0) {
|
||||
game.log.error(`The questions deck has no cards in the deck.`);
|
||||
socket.emit(`GameStarted`, {
|
||||
status: 507,
|
||||
message: `Questions deck failed to parse, try again in a few seconds or start a new game.`,
|
||||
|
|
|
|||
|
|
@ -36,11 +36,13 @@ export class Team {
|
|||
};
|
||||
|
||||
|
||||
public resetHand(): void {
|
||||
public reset(): void {
|
||||
/**
|
||||
* Removes all the cards from the guesser's hand
|
||||
* Resets all the per-game data related to this team
|
||||
*/
|
||||
this._hand = [];
|
||||
this._questions = [];
|
||||
this._answers = new Array<string>(8).fill(``);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
:key="`card_${cardIndex}`"
|
||||
@click.self="handleCardClick(cardIndex)"
|
||||
>
|
||||
<span
|
||||
class="card-id"
|
||||
v-if="multipleGuessersOnTeam"
|
||||
>
|
||||
{{ cardIndex }}
|
||||
</span>
|
||||
<p class="card-text centre">
|
||||
{{ questions[cardIndex - 1] }}
|
||||
</p>
|
||||
|
|
@ -66,7 +72,7 @@ export default {
|
|||
return this.$store.state.writer_card_button;
|
||||
} else {
|
||||
return `Unknown Role`;
|
||||
}
|
||||
};
|
||||
},
|
||||
questions() {
|
||||
return this.$store.state.questions;
|
||||
|
|
@ -85,6 +91,15 @@ export default {
|
|||
};
|
||||
return false;
|
||||
},
|
||||
multipleGuessersOnTeam() {
|
||||
let player_count = 0;
|
||||
for (var player of this.$store.state.players) {
|
||||
if (player.team === this.$store.state.team && this.userRole === player.role) {
|
||||
player_count++;
|
||||
};
|
||||
};
|
||||
return player_count > 1;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
sendCard(cardIndex) {
|
||||
|
|
@ -201,11 +216,18 @@ export default {
|
|||
flex-direction: column;
|
||||
width: calc(100% / 9);
|
||||
border-radius: 10px;
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
.card-id {
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
.card-text {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue