forked from rocketacademy/basics-beat-that
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
585 lines (546 loc) Β· 19.7 KB
/
script.js
File metadata and controls
585 lines (546 loc) Β· 19.7 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
//global variables
//gameTypes
const SELECTION_MODE = `selectionMode`;
const BASE = `base`;
const VARIABLE_DICE_NUM = `variableDiceNum`;
const VARIABLE_PLAYER_NUM = `variablePlayerNum`;
const KNOCKOUT_MODE = `knockoutMode`;
//modes in a gameType
const START_TURN = `startTurn`;
const SELECT_DICE_ORDER = `selectOrder`;
const END_GAME = `endGame`;
const WAITING_FOR_DICE_COUNT = `waitingForDiceCount`;
const SELECTING_KO_PLAYERS = `selectKoPlayers`;
const CHECK_BRACKET = `checkBracket`;
const END_KO_GAME = `endKoGame`;
//brackets for knockout mode
const UPPER = `upper`;
const LOWER = `lower`;
let bracket = UPPER;
//reused Msgs
const SUBMIT_TO_CONTINUE_MSG = `Press Submit to continue.`;
const INVALID_INPUT_MSG = `This is an invalid input. Please enter a number that is 2 or greater.`;
const INVALID_KO_MSG = `This is an invalid input. Please enter a number that is 4 or greater.`;
//game settings
let mode = ``;
let gameType = ``;
let lowestCombinedMode = false;
let aiMode = false;
let currentPlayer = 1;
let numberOfPlayers;
let numberOfDice;
const playerProfiles = [];
const playersDiceRolls = [];
//knockout game settings
let koPlayerOne;
let koPlayerTwo;
let prevPlayer;
let endKoGame = false;
const knockoutBrackets = [[], [], []];
//END of global variables
//functions
//helper functions
function initPlayersData(numberOfPlayers) {
for (
let playerCounter = 1;
playerCounter <= numberOfPlayers;
playerCounter += 1
) {
playerProfiles.push({
id: playerCounter,
diceResult: 0,
score: 0,
});
playersDiceRolls.push(0);
}
}
//text for selecting gameTypes
function inquireGameType() {
return `Please select from the following game modes: <br> <br> 1: Default (Base Rules) <br> 2: Lowest Combined (Lowest combined dice number wins instead) <br> 3: Variable Number of Dice (Computer will automatically select dice order) <br> 4: Variable Number of Players (Rules are same as Default otherwise) <br> 5: Knockout Format (Multiple Players, computer will automatically select dice order) <br> <br> Input 000 to toggle an option for the computer to automatically generate the optimal dice roll order`;
}
function selectGameType(playerChoice) {
switch (playerChoice) {
case `1`:
gameType = BASE;
return `Initiating the base game! ${SUBMIT_TO_CONTINUE_MSG}`;
case `2`:
gameType = BASE;
lowestCombinedMode = !lowestCombinedMode;
return `Reminder that the smallest combined number wins! ${SUBMIT_TO_CONTINUE_MSG}`;
case `3`:
gameType = VARIABLE_DICE_NUM;
aiMode = true;
return `Input the number of dice the players would like to play with! ${SUBMIT_TO_CONTINUE_MSG}`;
case `4`:
gameType = VARIABLE_PLAYER_NUM;
return `Input the number of players joining the game! ${SUBMIT_TO_CONTINUE_MSG}`;
case `5`:
gameType = KNOCKOUT_MODE;
aiMode = true;
numberOfPlayers = 0;
return `Input the number of players entering the knockout tournament! ${SUBMIT_TO_CONTINUE_MSG}`;
case `000`:
aiMode = !aiMode;
let aiMsg;
gameType = ``;
if (aiMode == true) {
aiMsg = `AI mode is now ON. There is no need to select the dice order in this mode.`;
} else {
aiMsg = `AI mode is now OFF.`;
}
return `${aiMsg} ${SUBMIT_TO_CONTINUE_MSG}`;
default:
gameType = ``;
return `This is an invalid input. Please select between 1 to 5.`;
}
}
function validateInput(playerChoice) {
if (gameType == KNOCKOUT_MODE && (isNaN(playerChoice) || playerChoice < 4)) {
return true;
}
if (isNaN(playerChoice) || playerChoice < 2) {
return true;
}
}
function rollDice() {
return Math.floor(Math.random() * 6) + 1;
}
function randomizeDiceRolls(numOfDice) {
const diceRolls = [];
let diceRollMsg = ``;
for (let diceCounter = 1; diceCounter <= numOfDice; diceCounter += 1) {
const diceRoll = rollDice();
diceRolls.push(diceRoll);
diceRollMsg += `Dice ${diceCounter}: ${diceRoll} <br>`;
}
const playerIndex = currentPlayer - 1;
playersDiceRolls[playerIndex] = diceRolls;
if (aiMode) {
return `Welcome Player ${currentPlayer}. You rolled: <br> <br> ${diceRollMsg} <br> ${SUBMIT_TO_CONTINUE_MSG}`;
}
return `Welcome Player ${currentPlayer}. You rolled: <br> <br> ${diceRollMsg} <br> Please choose the order of the dice by inputting 1 or 2.`;
}
function compareByDescendingDiceResult(a, b) {
return b.diceResult - a.diceResult;
}
function compareByAscendingDiceResult(a, b) {
return a.diceResult - b.diceResult;
}
//helper function for checking winner / after all players roll
function checkForWinner() {
const checkResultsArray = playerProfiles.toSorted(
compareByDescendingDiceResult
);
if (lowestCombinedMode) {
checkResultsArray.sort(compareByAscendingDiceResult);
}
const indexOneResult = checkResultsArray[0].diceResult;
const indexTwoResult = checkResultsArray[1].diceResult;
let diceResultsMsg = ``;
for (
let playerCounter = 1;
playerCounter <= numberOfPlayers;
playerCounter += 1
) {
let playerIndex = playerCounter - 1;
diceResultsMsg += `Player ${playerCounter} chose ${playerProfiles[playerIndex].diceResult}. <br>`;
}
if (indexOneResult === indexTwoResult) {
return `${diceResultsMsg} <br> It's a draw!`;
}
return `${diceResultsMsg} <br> Player ${checkResultsArray[0].id} wins!`;
}
//validate dice order input
function validateDiceOrderInput(playerChoice) {
if (playerChoice != 1 && playerChoice != 2) {
return true;
}
}
//dice order selection - manual + 2 dice
function selectDiceOrderForTwo(playersDiceRolls, playerChoice) {
if (validateDiceOrderInput(playerChoice)) {
return `This is an invalid input. Please select 1 or 2.`;
}
const playerIndex = currentPlayer - 1;
const diceRolls = playersDiceRolls[playerIndex];
const diceOne = Number(diceRolls[0]);
const diceTwo = Number(diceRolls[1]);
let diceResult;
if (playerChoice == 1) {
diceResult = diceOne * 10 + diceTwo;
} else if (playerChoice == 2) {
diceResult = diceTwo * 10 + diceOne;
}
playerProfiles[playerIndex].diceResult = diceResult;
playerProfiles[playerIndex].score += diceResult;
const diceResultMsg = `Player ${currentPlayer}, you chose Dice ${playerChoice} first. <br> Your number is ${diceResult}. <br>`;
currentPlayer = (currentPlayer % numberOfPlayers) + 1;
if (currentPlayer === 1) {
const endGame = checkForWinner();
mode = END_GAME;
return `${diceResultMsg} <br> ${endGame}`;
}
mode = START_TURN;
return `${diceResultMsg} <br> It is now Player ${currentPlayer}'s turn.`;
}
//optimal dice choice if computer mode = true;
function automateDiceOrder(playersDiceRolls) {
const playerIndex = currentPlayer - 1;
const diceRolls = playersDiceRolls[playerIndex].toSorted();
if (!lowestCombinedMode) {
diceRolls.reverse();
}
const diceResultString = diceRolls.join("");
const diceResult = Number(diceResultString);
playerProfiles[playerIndex].diceResult = diceResult;
playerProfiles[playerIndex].score += diceResult;
const diceResultMsg = `Player ${currentPlayer}, your number is ${diceResult}. <br>`;
currentPlayer = (currentPlayer % numberOfPlayers) + 1;
if (currentPlayer === 1) {
const endGame = checkForWinner();
mode = END_GAME;
return `${diceResultMsg} <br> ${endGame}`;
}
mode = START_TURN;
return `${diceResultMsg} <br> It is now Player ${currentPlayer}'s turn.`;
}
//initializes setting for multi dice game
function initMultiDiceGame(playerChoice) {
numberOfPlayers = 2;
if (validateInput(playerChoice)) {
return `${INVALID_INPUT_MSG}`;
}
numberOfDice = playerChoice;
initPlayersData(numberOfPlayers);
mode = START_TURN;
return `The players have opted to roll ${numberOfDice} dices this round.`;
}
function compareByDescendingScore(a, b) {
return b.score - a.score;
}
function compareByAscendingScore(a, b) {
return a.score - b.score;
}
function displayLeaderBoard() {
const leaderBoardArray = playerProfiles.toSorted(compareByAscendingScore);
if (!lowestCombinedMode) {
leaderBoardArray.sort(compareByDescendingScore);
}
const leadingPlayer = leaderBoardArray[0].id;
let leadPlayerMsg = `Player ${leadingPlayer} is leading! π <br> <br>`;
if (leaderBoardArray[0].score == leaderBoardArray[1].score) {
leadPlayerMsg = `No one is in the lead at the moment. Try your best! β <br> <br>`;
}
let leaderBoardMsg = ``;
for (
let playerCounter = 0;
playerCounter < playerProfiles.length;
playerCounter += 1
) {
leaderBoardMsg += `Player ${leaderBoardArray[playerCounter].id}: ${leaderBoardArray[playerCounter].score} <br>`;
}
if (gameType == VARIABLE_DICE_NUM) {
mode = WAITING_FOR_DICE_COUNT;
return `${leadPlayerMsg} Leaderboard <br>${leaderBoardMsg} <br> <br> Input the number of dice the players would like to play with next round. ${SUBMIT_TO_CONTINUE_MSG}`;
}
return `${leadPlayerMsg} Leaderboard <br>${leaderBoardMsg} <br> <br> Press Submit to start a new round.`;
}
//non KO gametypes logic
//play base, lowest combined or variable players
function playBaseGame(playerChoice) {
if (mode === ``) {
numberOfPlayers = 2;
numberOfDice = 2;
if (gameType == VARIABLE_PLAYER_NUM) {
if (validateInput(playerChoice)) {
return `${INVALID_INPUT_MSG}`;
}
numberOfPlayers = playerChoice;
}
initPlayersData(numberOfPlayers);
mode = START_TURN;
}
if (mode === START_TURN) {
const diceRollResult = randomizeDiceRolls(numberOfDice);
mode = SELECT_DICE_ORDER;
return `${diceRollResult}`;
}
if (mode === SELECT_DICE_ORDER) {
if (aiMode) {
const gameProgressMsg = automateDiceOrder(playersDiceRolls);
return gameProgressMsg;
}
const gameProgressMsg = selectDiceOrderForTwo(
playersDiceRolls,
playerChoice
);
return gameProgressMsg;
}
if (mode === END_GAME) {
mode = START_TURN;
return displayLeaderBoard();
}
}
function playMultiDiceGame(playerChoice) {
if (mode == ``) {
return initMultiDiceGame(playerChoice);
}
if (mode === WAITING_FOR_DICE_COUNT) {
if (validateInput(playerChoice)) {
return `${INVALID_INPUT_MSG}`;
}
numberOfDice = playerChoice;
mode = START_TURN;
return `The players have opted to roll ${numberOfDice} dices this round.`;
}
if (mode == START_TURN) {
const diceRollResult = randomizeDiceRolls(numberOfDice);
mode = SELECT_DICE_ORDER;
return `${diceRollResult}`;
}
if (mode == SELECT_DICE_ORDER) {
const gameProgressMsg = automateDiceOrder(playersDiceRolls);
return gameProgressMsg;
}
if (mode === END_GAME) {
mode = START_TURN;
return displayLeaderBoard();
}
}
//end non KO gametypes logic
//KO game helper functions//
//initializes each round of the KO game
function initKnockOutBracket(playerChoice) {
if (validateInput(playerChoice)) {
return `${INVALID_KO_MSG}`;
}
numberOfPlayers = playerChoice;
initPlayersData(numberOfPlayers);
const competitionArray = [];
const lowerBracket = [];
for (
let playerCounter = 1;
playerCounter <= numberOfPlayers;
playerCounter += 1
) {
competitionArray.push(playerCounter);
}
for (let i = 0; i < numberOfPlayers / 2; i += 1) {
randomIndex = Math.random() * competitionArray.length;
const lowerBracketPlayers = competitionArray.splice(randomIndex, 1);
lowerBracket.push(lowerBracketPlayers[0]);
}
knockoutBrackets[0] = [...competitionArray];
knockoutBrackets[1] = [...lowerBracket];
return `${numberOfPlayers} players are taking part in this tournament π`;
}
//random selection of players for KO game
function selectPlayersforBracket() {
if (knockoutBrackets[0].length == 1 && knockoutBrackets[1].length == 1) {
koPlayerOne = knockoutBrackets[0][0];
koPlayerTwo = knockoutBrackets[1][0];
currentPlayer = koPlayerOne;
return `Player ${koPlayerOne} and Player ${koPlayerTwo} are competing for the championship! ββ <br> <br> Player ${koPlayerOne} will take the first turn.`;
}
let bracketIndex;
if (bracket == UPPER) {
bracketIndex = 0;
} else {
bracketIndex = 1;
}
const bracketPulls = knockoutBrackets[bracketIndex];
const randomIndex = Math.random() * bracketPulls.length;
const koPlayerOneArr = bracketPulls.splice(randomIndex, 1);
koPlayerOne = koPlayerOneArr[0];
const randomIndexTwo = Math.random() * bracketPulls.length;
const koPlayerTwoArr = bracketPulls.splice(randomIndexTwo, 1);
koPlayerTwo = koPlayerTwoArr[0];
currentPlayer = koPlayerOne;
return `Player ${koPlayerOne} and Player ${koPlayerTwo} are up this time! <br> <br> Player ${koPlayerOne} will take the first turn.`;
}
//automates dice order for both players in each match for KO game, can be refactored alongside function ${automateDiceOrder}
function automateKoDiceOrder(playersDiceRolls) {
const playerIndex = currentPlayer - 1;
const diceRolls = playersDiceRolls[playerIndex].toSorted();
if (!lowestCombinedMode) {
diceRolls.reverse();
}
const diceResultString = diceRolls.join("");
const diceResult = Number(diceResultString);
playerProfiles[playerIndex].diceResult = diceResult;
playerProfiles[playerIndex].score += diceResult;
const diceResultMsg = `Player ${currentPlayer}, your number is ${diceResult}. <br>`;
if (currentPlayer === koPlayerTwo) {
const endMatch = checkForKoWinner();
return `${diceResultMsg} <br> ${endMatch}`;
}
prevPlayer = koPlayerOne;
currentPlayer = koPlayerTwo;
mode = START_TURN;
return `${diceResultMsg} <br> It is now Player ${currentPlayer}'s turn.`;
}
//inputs players who won into active player arrays
function insertWinningPlayers() {
let bracketIndex;
if (bracket == UPPER) {
bracketIndex = 0;
} else {
bracketIndex = 1;
}
const winningPlayers = knockoutBrackets[2].length;
for (let i = 0; i < winningPlayers; i += 1) {
const playerId = knockoutBrackets[2].shift();
knockoutBrackets[bracketIndex].push(playerId);
}
}
function displayRemainingPlayers() {
const upBracketPlayers = [...knockoutBrackets[0]].toSorted();
const lowBracketPlayerCount = [...knockoutBrackets[1]].toSorted();
return `- Championship Contenders - <br> <br> Upper Bracket Players: ${upBracketPlayers} <br> Lower Bracket Players: ${lowBracketPlayerCount}`;
}
//change brackets and manages byes/free wins -> need ideas to refactor
function checkBracketStatus() {
const upBracketCheck = knockoutBrackets[0].length;
const lowBracketCheck = knockoutBrackets[1].length;
const END_UP_BRACKET_MSG = `The upper bracket matches have ended. The lower bracket matches will now commence.`;
const END_LOW_BRACKET_MSG = `The lower bracket matches have ended. The upper bracket matches will now commence.`;
if (bracket === LOWER) {
if (upBracketCheck == 1 && lowBracketCheck == 0) {
insertWinningPlayers();
const playerCountMsg = displayRemainingPlayers();
bracket = UPPER;
endKoGame = true;
return `And up next... our final contestants! π <br> <br> ${playerCountMsg}`;
}
if (upBracketCheck > 1 && lowBracketCheck == 1) {
const byePlayer = knockoutBrackets[1][0];
insertWinningPlayers();
const playerCountMsg = displayRemainingPlayers();
bracket = UPPER;
return `Player ${byePlayer} has got a bye! ${END_LOW_BRACKET_MSG} <br> <br> ${playerCountMsg}`;
}
if (upBracketCheck > 1 && lowBracketCheck == 0) {
insertWinningPlayers();
const playerCountMsg = displayRemainingPlayers();
bracket = UPPER;
return `${END_LOW_BRACKET_MSG} <br> <br> ${playerCountMsg}`;
}
if (upBracketCheck == 1 && lowBracketCheck == 1) {
const byePlayer = knockoutBrackets[1][0];
insertWinningPlayers();
const playerCountMsg = displayRemainingPlayers();
return `Player ${byePlayer} has got a bye! As the upper bracket has finished, the next match will be decisive for the lower bracket. <br> <br> ${playerCountMsg}`;
}
return `Onto the next match in the lower bracket π`;
}
if (upBracketCheck == 1 && lowBracketCheck > 1) {
const byePlayer = knockoutBrackets[0][0];
insertWinningPlayers();
const playerCountMsg = displayRemainingPlayers();
bracket = LOWER;
return `Player ${byePlayer} has got a bye! ${END_UP_BRACKET_MSG} <br> <br> ${playerCountMsg}`;
}
if (upBracketCheck == 0 && lowBracketCheck > 1) {
insertWinningPlayers();
const playerCountMsg = displayRemainingPlayers();
bracket = LOWER;
return `${END_UP_BRACKET_MSG} <br> <br> ${playerCountMsg}`;
}
return `Onto the next match in the upper bracket π`;
}
//checks for game results and pushes winner into holding area for winners
function checkForKoWinner() {
const prevPlayerIndex = prevPlayer - 1;
const playerIndex = currentPlayer - 1;
const indexOneResult = playerProfiles[prevPlayerIndex].diceResult;
const indexTwoResult = playerProfiles[playerIndex].diceResult;
let diceResultsMsg = `Player ${prevPlayer} chose ${indexOneResult}. <br> Player ${currentPlayer} chose ${indexTwoResult}. `;
if (indexOneResult === indexTwoResult) {
currentPlayer = prevPlayer;
mode = START_TURN;
return `${diceResultsMsg} <br> It's a draw! Time to roll again. <br> <br> It is now Player ${prevPlayer}'s turn.`;
}
if (indexOneResult < indexTwoResult) {
if (endKoGame) {
mode = END_KO_GAME;
return `${diceResultsMsg} <br> <br> Player ${prevPlayer} has been eliminated. <br> Player ${currentPlayer} is the final winner! πππ`;
}
knockoutBrackets[2].push(currentPlayer);
mode = CHECK_BRACKET;
return `${diceResultsMsg} <br> <br> Player ${prevPlayer} has been eliminated. <br> Player ${currentPlayer} advances to the next round!`;
}
if (endKoGame) {
mode = END_KO_GAME;
return `${diceResultsMsg} <br> <br> Player ${currentPlayer} has been eliminated. <br> Player ${prevPlayer} is the final winner! πππ`;
}
knockoutBrackets[2].push(prevPlayer);
mode = CHECK_BRACKET;
return `${diceResultsMsg} <br> <br> Player ${currentPlayer} has been eliminated. <br> Player ${prevPlayer} advances to the next round!`;
}
//resets all parameters of the KO game that can affect a new game
function resetKnockOutGame() {
mode = ``;
playerProfiles.splice(0);
playersDiceRolls.splice(0);
knockoutBrackets[0].splice(0);
knockoutBrackets[1].splice(0);
endKoGame = false;
numberOfPlayers = 0;
return `Game has been reset. To start a new game, input the number of players entering the knockout tournament! ${SUBMIT_TO_CONTINUE_MSG}`;
}
//end KO game helper functions
function playKnockoutGame(playerChoice) {
numberOfDice = 2;
if (mode == ``) {
mode = SELECTING_KO_PLAYERS;
return initKnockOutBracket(playerChoice);
}
if (mode == SELECTING_KO_PLAYERS) {
if (numberOfPlayers != 0) {
mode = START_TURN;
return selectPlayersforBracket();
} else {
return initKnockOutBracket(playerChoice);
}
}
if (mode == START_TURN) {
const diceResult = randomizeDiceRolls(numberOfDice);
mode = SELECT_DICE_ORDER;
return `${diceResult}`;
}
if (mode == SELECT_DICE_ORDER) {
const gameProgressMsg = automateKoDiceOrder(playersDiceRolls);
return gameProgressMsg;
}
if (mode == CHECK_BRACKET) {
const bracketMsg = checkBracketStatus();
mode = SELECTING_KO_PLAYERS;
return bracketMsg;
}
if (mode == END_KO_GAME) {
return resetKnockOutGame();
}
}
function main(input) {
let myOutputValue = ``;
if (gameType == ``) {
gameType = SELECTION_MODE;
return inquireGameType();
}
if (gameType == SELECTION_MODE) {
return selectGameType(input);
}
if (gameType == BASE || gameType == VARIABLE_PLAYER_NUM) {
const baseGame = playBaseGame(input);
myOutputValue = baseGame;
}
if (gameType == VARIABLE_DICE_NUM) {
const multiDiceGame = playMultiDiceGame(input);
myOutputValue = multiDiceGame;
}
if (gameType == KNOCKOUT_MODE) {
const knockoutGame = playKnockoutGame(input);
myOutputValue = knockoutGame;
}
return myOutputValue;
}