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