A few minor fixes

This commit is contained in:
eTronic
2018-07-13 19:31:07 -04:00
parent 0ec2744e0b
commit b98dbee96e
4 changed files with 14 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ export default class Player {
this.playerPingInterval = null;
this.hasExtraLife = false;
this.canSendAnswer = false;
this.usedExtraLifeThisQuestion = false;
}
async connect(controller, broadcast) {
@@ -99,10 +100,14 @@ export default class Player {
this.canSendAnswer = false;
break;
case 'questionSummary':
const { question, youGotItRight } = parsed;
const { question, youGotItRight, savedByExtraLife } = parsed;
if (!youGotItRight) {
this.logger.logSilent(`Player ${this.username} got ${question} wrong.`);
}
if (!savedByExtraLife && this.usedExtraLifeThisQuestion) {
this.logger.logSilent(`Player ${this.username} used extra life but was not saved on question: ${question}.`);
this.usedExtraLifeThisQuestion = false;
}
break;
case 'questionFinished':
break;
@@ -143,6 +148,7 @@ export default class Player {
try {
this.socket.send(JSON.stringify(extraLifePackage));
this.hasExtraLife = false;
this.usedExtraLifeThisQuestion = true;
this.logger.log(`Player ${this.username} has been saved by an extra life!`);
} catch (error) {
this.logger.log(`WebSocket error: ${this.username} can\'t send extra life.`, LOG_TYPES.ERROR);

View File

@@ -117,6 +117,7 @@ export default class Searcher {
'furthest', // experimental
'hasnt',
'isnt',
'least',
'never',
'not',
'rejected', // experimental

View File

@@ -54,7 +54,9 @@ export default class Summary {
winRatio = Math.round(winCount / gamesPlayed * 100);
}
console.log(`${username}\t${balance}\t ${total}\t ${lives} Lives ${winCount} Wins\t${gamesPlayed}\t\t${winRatio}%`);
const extraT = username.length < 8 ? '\t' : '';
console.log(`${username}${extraT}\t${balance}\t ${total}\t ${lives} Lives ${winCount} Wins\t${gamesPlayed}\t\t${winRatio}%`);
} catch (error) {
console.log('Error\n', error.toString('utf8'));
}

View File

@@ -280,9 +280,9 @@ export default class Trivia {
let players = this.players.slice(0);
if (PREDICT_SAVAGE) {
let possiblySavage = false;
if (this.game.savageCount === 0 && [4,5].includes(questionNumber)) {
/*if (this.game.savageCount === 0 && [4,5].includes(questionNumber)) {
possiblySavage = true;
}
}*/
if ([0,1].includes(this.game.savageCount) && [8,9,10].includes(questionNumber)) {
possiblySavage = true;
}
@@ -410,7 +410,7 @@ export default class Trivia {
this.players.forEach(player => {
if (player.lastAnswerId !== correctAnswer.answerId) {
const potentialPot = this.game.prizePerPlayer * this.players.length;
if (player.hasExtraLife && potentialPot >= USE_EXTRA_LIFE_MIN_PRIZE) {
if (player.hasExtraLife && potentialPot >= USE_EXTRA_LIFE_MIN_PRIZE && this.game.questionNumber < this.game.questionCount) {
player.sendExtraLife(questionId);
} else {
wrongPlayers.push(player.userId);