Finished player choosing entry implementation; TODO: Award in non Buzzer Interaction

This commit is contained in:
EisiBaer committed 2023-07-13 20:22:46 +02:00
1 parent a798ec1558
commit 5ef8ea86bb
12 files changed
+200 -74

No files matched your search

@@ -63,26 +63,6 @@ exports.setAllPlayersAcceptAnswers = ( playerIds, acceptAnswersValue ) => {
});
}
/**
* Sets one player as isChoosing and other players as isChoosing false
* @param {String} choosingPlayerId
* @param {Array} notChoosingPlayerIds
* @returns A promise which resolves with the choosing player
*/
exports.setAllPlayersAcceptAnswers = ( choosingPlayerId, notChoosingPlayerIds ) => {
return new Promise((resolve, reject) => {
let promiseSetChoosing = PlayerModel.updateOne( { _id: choosingPlayerId }, { isChoosing: true } );
let promiseSetNotChoosing = PlayerModel.updateMany( { _id: { $in : notChoosingPlayerIds } }, { isChoosing: false } );
Promise.all( [ promiseSetChoosing, promiseSetNotChoosing ] )
.then( ( resArr ) => {
resolve( resArr[0] );
})
.catch( ( err ) => {
reject( err );
})
});
}
/**
* Checks if a player is allowed to currently answer a question
* @param {String} playerId