All files / gameFiles/backend GameSession.js

0% Statements 0/63
100% Branches 1/1
100% Functions 1/1
0% Lines 0/63

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73                                                                                                                                                 
 
/**
 * This class manages the game session and rounds on the server
 */
class GameSession{
    /**
     * Creates an instance of an GameSession to track data about the current game session
     * 
     * @param {string} sessionID The unique ID of the current game session
     * @param {Player[]} players The array of player objects linked to the game session
     * @param {number} roundsCompleted The counter of number of rounds completed in the current game session
     * @param {Player} winner The declared winner of the game session
     */
    constructor(sessionID, players, roundsCompleted, winner){
        this.sessionID = sessionID;
        this.players = players;
        this.roundsCompleted = roundsCompleted;
        this.winner = winner;
    }
 
    /**
     * Starts a new game session
     * 
     * @throws An error if it cannot start a new game session
     */
    startSession(){
        try {
 
        } catch (err){
            console.log("Could not start new game session");
        }
    }
 
    /**
     * Ends an existing game session
     * 
     * @throws An error if it cannot end an existing game session
     */
    endSession(){
        try {
 
        } catch (err){
            console.log("Could not end game session");
        }
    }
 
    /**
     * Starts a new round in an existing game session
     * 
     * @throws An error if it cannot start a new round in an existing game session
     */
    startRound(){
        try {
 
        } catch (err){
            console.log("Could not start new round");
        }
    }
 
    /**
     * Ends a round in an existing game session
     * 
     * @throws An error if it cannot end a round in an existing game session
     */
    endRound(){
        try {
 
        } catch (err){
            console.log("Could not end round");
        }
    }
}