scripts/index.js
/** Decide what to do when interval time runs out */
Decide what to do when interval time runs out
Decide what to do when interval time runs out
function intervalTimeout() {
    --countdownTime;
    $(".gameplay-area-timer-number").html(countdownTime);
    if (countdownTime == 0) {
        clearInterval(timerInterval);
        $(".gameplay-area-timer-circle circle").removeClass("timer-countdown-animation");
        $(".gameplay-area-timer-circle circle").addClass("timer-reset-animation");
        let wordListElement = $(".gameplay-area-word-list");
        let solved = parseInt(wordListElement.attr("data-solved"));
        if (settings.extraPointOnCompletion && solved === wordListElement.children().length) {
            ++solved;
        }
        teams[teamIndex].score += solved;
        wordListElement.attr("data-solved", "0");
        $(".team-scores-list").empty();
        teams.forEach(t => {
            let e = document.createElement("LI");
            e.innerHTML = `${t.name}: ${t.score}`;
            $(".team-scores-list").append(e);
        });
        if ((currentRound === settings.amountOfRounds - 1) && (teamIndex === teams.length - 1)) {
            openGameArea(GameAreaIDs.SCORE, GameAreaHeights.SCORE);
            $(GameAreaIDs.GAMEPLAY).css("height", "0");
            let topScore = 0;
            let winnerIndex;
            teams.forEach((t, i) => {
                if (t.score > topScore) {
                    topScore = t.score;
                    winnerIndex = i;
                }
            });
            $(".winner-team-name").html(teams[winnerIndex].name);
        } else {
            openGameArea(GameAreaIDs.INTERMEDIATE, GameAreaHeights.INTERMEDIATE);
            $(GameAreaIDs.GAMEPLAY).css("height", "0");
            ++teamIndex;
            if (teamIndex > teams.length - 1) {
                ++currentRound;
                teamIndex = 0;
            }
            $(".intermediate-area-next-team").html(teams[teamIndex].name);
        }
    }
}
function intervalTimeout ( ) { -- countdownTime ; $ ( ".gameplay-area-timer-number" ) . html ( countdownTime ) ; if ( countdownTime == 0 ) { clearInterval ( timerInterval ) ; $ ( ".gameplay-area-timer-circle circle" ) . removeClass ( "timer-countdown-animation" ) ; $ ( ".gameplay-area-timer-circle circle" ) . addClass ( "timer-reset-animation" ) ; let wordListElement = $ ( ".gameplay-area-word-list" ) ; let solved = parseInt ( wordListElement . attr ( "data-solved" ) ) ; if ( settings . extraPointOnCompletion && solved === wordListElement . children ( ) . length ) { ++ solved ; } teams [ teamIndex ] . score += solved ; wordListElement . attr ( "data-solved" , "0" ) ; $ ( ".team-scores-list" ) . empty ( ) ; teams . forEach ( t => { let e = document . createElement ( "LI" ) ; e . innerHTML = ` ${ t . name } ${ t . score } ` ; $ ( ".team-scores-list" ) . append ( e ) ; } ) ; if ( ( currentRound === settings . amountOfRounds - 1 ) && ( teamIndex === teams . length - 1 ) ) { openGameArea ( GameAreaIDs . SCORE , GameAreaHeights . SCORE ) ; $ ( GameAreaIDs . GAMEPLAY ) . css ( "height" , "0" ) ; let topScore = 0 ; let winnerIndex ; teams . forEach ( ( t , i ) => { if ( t . score > topScore ) { topScore = t . score ; winnerIndex = i ; } } ) ; $ ( ".winner-team-name" ) . html ( teams [ winnerIndex ] . name ) ; } else { openGameArea ( GameAreaIDs . INTERMEDIATE , GameAreaHeights . INTERMEDIATE ) ; $ ( GameAreaIDs . GAMEPLAY ) . css ( "height" , "0" ) ; ++ teamIndex ; if ( teamIndex > teams . length - 1 ) { ++ currentRound ; teamIndex = 0 ; } $ ( ".intermediate-area-next-team" ) . html ( teams [ teamIndex ] . name ) ; } } }
Decide what to do when interval time runs out
Decide what to do when interval time runs out
// Should finish here // Add score to the current team // It completed all items and we're supposed to award an extra point when all // are completed // And clear current points // Populate lists with team names and scores // If we're at the last round and the last team just went, open score screen // Otherwise, prepare for next team // Populate name of winner // Populate name of next team