How to use score method in hypothesis

Best Python code snippet using hypothesis

game_revisiting.js

Source:game_revisiting.js Github

copy

Full Screen

1const firstContainer = document.querySelector('#gameButtons')2const secondContainer = document.querySelector('#scores')3const invisibleButton = document.querySelector('button')4let startRound = document.createElement('div');5const updatedResult = document.createElement('div');6const updatedScores = document.createElement('div');7var newcomputerSelection;8var playerScore = 0;9var computerScore = 0;10var drawScore = 0;11const rockbtn = document.querySelector('#rockbtn');12const paperbtn = document.querySelector('#paperbtn');13const scizzorsbtn = document.querySelector('#scizzorsbtn');14// DOM Manipulation15startRound.textContent = "Choose one to play a round of Rock, Paper, Scizzors. First to 5 wins!";16startRound.style.cssText = "border: 2px solid black; font-size: 20px; display:inline-block; padding: 15px;"17updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;18updatedResult.textContent = "Play a round to see the result!"19secondContainer.appendChild(startRound);20secondContainer.appendChild(updatedScores);21secondContainer.appendChild(updatedResult);22// Click event listeners to play the game23rockbtn.addEventListener('click', function (e) {24 let roundResult = playRound('Rock');25 if (roundResult.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.26 playerScore++;27 console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);28 updatedResult.textContent = "You won! Your opponent chose" + " " + "Scizzors" + " " + "which loses to" + " " + "Rock" + ".";29 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;30 }31 if (roundResult.charAt(4) === 'l'){32 computerScore++;33 console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);34 updatedResult.textContent = "You lost! Your opponent chose" + " " + "Paper" + " " + "which beats" + " " + "Rock" + ".";35 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;36 }37 if (roundResult.charAt(0) === 'I'){38 drawScore++;39 console.log("No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");40 updatedResult.textContent = "It's a draw! No Points have been added. Your opponent also chose" + " " + "Rock" + ".";41 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer's Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;42 }43 // Ends the game if either the player or computer reaches a score of 544 if (playerScore === 5) {45 startRound.textContent = "The game has ended. You won! Refresh the page to play again."46 // Makes buttons disappear so you can't play anymore47 rockbtn.style.display = "none";48 paperbtn.style.display = "none";49 scizzorsbtn.style.display = "none";50 } else if (computerScore === 5){51 startRound.textContent = "The game has ended. You lost! Refresh the page to play again."52 // Makes buttons disappear so you can't play anymore53 rockbtn.style.display = "none";54 paperbtn.style.display = "none";55 scizzorsbtn.style.display = "none";56 } 57});58paperbtn.addEventListener('click', function (e) {59 let roundResult = playRound('Paper');60 if (roundResult.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.61 playerScore++;62 console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);63 updatedResult.textContent = "You won! Your opponent chose" + " " + "Rock" + " " + "which loses to" + " " + "Paper" + ".";64 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore; 65 }66 if (roundResult.charAt(4) === 'l'){67 computerScore++;68 console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);69 updatedResult.textContent = "You lost! Your opponent chose" + " " + "Scizzors" + " " + "which beats" + " " + "Paper" + ".";70 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;71 }72 if (roundResult.charAt(0) === 'I'){73 drawScore++;74 console.log("No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");75 updatedResult.textContent = "It's a draw! No Points have been added. Your opponent also chose" + " " + "Paper" + ".";76 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer's Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;77 }78 // Ends the game if either the player or computer reaches a score of 579 if (playerScore === 5) {80 startRound.textContent = "The game has ended. You won! Refresh the page to play again."81 // Makes buttons disappear so you can't play anymore82 rockbtn.style.display = "none";83 paperbtn.style.display = "none";84 scizzorsbtn.style.display = "none";85 } else if (computerScore === 5){86 startRound.textContent = "The game has ended. You lost! Refresh the page to play again."87 88 // Makes buttons disappear so you can't play anymore89 rockbtn.style.display = "none";90 paperbtn.style.display = "none";91 scizzorsbtn.style.display = "none";92 } 93});94scizzorsbtn.addEventListener('click', function (e) {95 let roundResult = playRound('Scizzors');96 if (roundResult.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.97 playerScore++;98 console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);99 updatedResult.textContent = "You won! Your opponent chose" + " " + "Paper" + " " + "which loses to" + " " + "Scizzors" + ".";100 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;101 }102 if (roundResult.charAt(4) === 'l'){103 computerScore++;104 console.log("The score is" + " " + playerScore + " " + "to" + " " + computerScore);105 updatedResult.textContent = "You lost! Your opponent chose" + " " + "Rock" + " " + "which beats" + " " + "Scizzors" + ".";106 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer'\s Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;107 }108 if (roundResult.charAt(0) === 'I'){109 drawScore++;110 console.log("No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");111 updatedResult.textContent = "It's a draw! No Points have been added. Your opponent also chose" + " " + "Scizzors" + ".";112 updatedScores.textContent = "Your Score:" + " " + playerScore + " | " + "Computer's Score:" + " " + computerScore + " | " + "Draws:" + " " + drawScore;113 }114 // Ends the game if either the player or computer reaches a score of 5115 if (playerScore === 5) {116 startRound.textContent = "The game has ended. You won! Refresh the page to play again."117 // Makes buttons disappear so you can't play anymore118 rockbtn.style.display = "none";119 paperbtn.style.display = "none";120 scizzorsbtn.style.display = "none";121 } else if (computerScore === 5){122 startRound.textContent = "The game has ended. You lost! Refresh the page to play again."123 124 // Makes buttons disappear so you can't play anymore125 rockbtn.style.display = "none";126 paperbtn.style.display = "none";127 scizzorsbtn.style.display = "none";128 } 129});130// Opponent chooses a hand shape using random number generator131function computerPlay(){132 randomNumber = Math.floor(Math.random()*3) + 1;133 if (randomNumber === 1) {134 return "rock";135 } else if (randomNumber === 2) {136 return "paper";137 } else {138 return "scizzors";139 }140}141// Stores the player and the opponent's hand shape:142function playRound(buttonClicked){143 let newcomputerSelection = computerPlay();144 let playerPrompt = buttonClicked;145 //console.log(playerPrompt);146 let playerSelectionLowerCase = playerPrompt.toLowerCase(); // Makes the prompt input case insensitive, the the rest of the function reads lower case strings.147 //console.log(playerSelectionLowerCase);148 if ((playerSelectionLowerCase === "rock" && newcomputerSelection === "paper") 149 || (playerSelectionLowerCase === "scizzors" && newcomputerSelection === "rock") 150 || (playerSelectionLowerCase === "paper" && newcomputerSelection === "scizzors")) {151 console.log("You lost! Your opponent chose" + " " + newcomputerSelection + " " + "which beats" + " " + playerSelectionLowerCase + ".");152 return "You lost! Your opponent chose" + " " + newcomputerSelection + " " + "which beats" + " " + playerSelectionLowerCase + ".";153 /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.154 console.log(playerSelectionLowerCase);155 console.log(newcomputerSelection); */156 } else if (playerSelectionLowerCase === newcomputerSelection){157 console.log("It's a draw! Your opponent also chose" + " " + newcomputerSelection + ".");158 return "It's a draw! Your opponent also chose" + " " + newcomputerSelection + ".";159 /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.160 console.log(playerSelectionLowerCase);161 console.log(newcomputerSelection); */162 } else if ((playerSelectionLowerCase === "rock" && newcomputerSelection === "scizzors") 163 || (playerSelectionLowerCase === "scizzors" && newcomputerSelection === "paper") 164 || (playerSelectionLowerCase === "paper" && newcomputerSelection === "rock")) {165 console.log("You won! Your opponent chose" + " " + newcomputerSelection + " " + "which loses to" + " " + playerSelectionLowerCase + ".");166 return "You won! Your opponent chose" + " " + newcomputerSelection + " " + "which loses to" + " " + playerSelectionLowerCase + ".";167 /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.168 console.log(playerSelectionLowerCase);169 console.log(newcomputerSelection); */170 } else {171 console.log("Please enter a valid option, the input must be 'rock', 'paper', or 'scizzors' only). This round will count as a draw.");172 return "Please enter a valid option, the input must be 'rock', 'paper', or 'scizzors' only). This round will count as a draw."173 /* I had these two console.log lines to test and make sure that both the player and opponent's hands were being stored correctly in the function.174 console.log(playerSelectionLowerCase);175 console.log(newcomputerSelection); */176 }177}178// FROM MY ORIGINAL ROCK PAPER SCIZZORS PROJECT, DO NOT USE IN THIS REVISITED VERSION!179// function game() {180// // Start player's scores at 0.181 182// let roundOne = playRound();183// console.log(roundOne); // Lets you know how you won, lost, or drew the round.184// // Round 1185// if (roundOne.charAt(4) === 'w'){ // This is used to recognize the outcome from the playRound(); function.186// playerScore++;187// console.log("Round 1: The score is" + " " + playerScore + " " + "to" + " " + computerScore);188// }189// if (roundOne.charAt(4) === 'l'){190// computerScore++;191// console.log("Round 1: The score is" + " " + playerScore + " " + "to" + " " + computerScore);192// }193// if (roundOne.charAt(0) === 'I'){194// console.log("Round 1: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");195// }196// if (roundOne.charAt(0) === 'P'){197// console.log("Round 1: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");198// }199 200// //Round 2201// let roundTwo = playRound();202// console.log(roundTwo);203// if (roundTwo.charAt(4) === 'w'){204// playerScore++;205// console.log("Round 2: The score is" + " " + playerScore + " " + "to" + " " + computerScore);206// }207// if (roundTwo.charAt(4) === 'l'){208// computerScore++;209// console.log("Round 2: The score is" + " " + playerScore + " " + "to" + " " + computerScore);210// }211// if (roundTwo.charAt(0) === 'I'){212// console.log("Round 2: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");213// }214// if (roundTwo.charAt(0) === 'P'){215// console.log("Round 2: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");216// }217// // Round 3218// let roundThree = playRound();219// console.log(roundThree);220// if (roundThree.charAt(4) === 'w'){221// playerScore++;222// console.log("Round 3: The score is" + " " + playerScore + " " + "to" + " " + computerScore);223// }224// if (roundThree.charAt(4) === 'l'){225// computerScore++;226// console.log("Round 3: The score is" + " " + playerScore + " " + "to" + " " + computerScore);227// }228// if (roundThree.charAt(0) === 'I'){229// console.log("Round 3: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");230// }231// if (roundThree.charAt(0) === 'P'){232// console.log("Round 3: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");233// }234// //Round 4235// let roundFour = playRound();236// console.log(roundFour);237// if (roundFour.charAt(4) === 'w'){238// playerScore++;239// console.log("Round 4: The score is" + " " + playerScore + " " + "to" + " " + computerScore);240// }241// if (roundFour.charAt(4) === 'l'){242// computerScore++;243// console.log("Round 4: The score is" + " " + playerScore + " " + "to" + " " + computerScore);244// }245// if (roundFour.charAt(0) === 'I'){246// console.log("Round 4: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");247// }248 249// if (roundFour.charAt(0) === 'P'){250// console.log("Round 4: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");251// }252// //Round 5253// let roundFive = playRound();254// console.log(roundFive);255// if (roundFive.charAt(4) === 'w'){256// playerScore++;257// console.log("Round 5: The final score is" + " " + playerScore + " " + "to" + " " + computerScore);258// }259// if (roundFive.charAt(4) === 'l'){260// computerScore++;261// console.log("Round 5: The final score is" + " " + playerScore + " " + "to" + " " + computerScore);262// }263// if (roundFive.charAt(0) === 'I'){264// console.log("Round 5: No points added to either player. The final score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");265// }266// if (roundFive.charAt(0) === 'P'){267// console.log("Round 5: No points added to either player. The current score is" + " " + playerScore + " " + "to" + " " + computerScore + ".");268// }269// if (playerScore > computerScore) {270// return "You won the game of 5! The game is now complete, thanks for playing!"271// } else if (playerScore < computerScore) {272// return "You lost the game of 5! The game is now complete, thanks for playing!"273// } else {274// return "It's a draw! The game is now complete, thanks for playing!"275// }...

Full Screen

Full Screen

stat.js

Source:stat.js Github

copy

Full Screen

1import Mock from 'mockjs';2const AllStats = [3 {4 studentno: '2011360114',5 examno: '20110511',6 studentname: '张正午',7 class: '六年级 (5) 班',8 subjectScores: {9 score: '82.5',10 classRank: '4',11 gradeRank: '14',12 rank: 'A+'13 },14 totalScores: {15 score: '273.5',16 classRank: '1',17 gradeRank: '1',18 rank: 'A+'19 }20 },21 {22 studentno: '2011360115',23 examno: '20110512',24 studentname: '刘飞',25 class: '六年级 (6) 班',26 subjectScores: {27 score: '87.5',28 classRank: '3',29 gradeRank: '8',30 rank: 'A+'31 },32 totalScores: {33 score: '281.5',34 classRank: '1',35 gradeRank: '1',36 rank: 'A+'37 }38 },39 {40 studentno: '2011360116',41 examno: '20110513',42 studentname: '白好英',43 class: '六年级 (7) 班',44 subjectScores: {45 score: '65.5',46 classRank: '7',47 gradeRank: '24',48 rank: 'B+'49 },50 totalScores: {51 score: '225.5',52 classRank: '3',53 gradeRank: '3',54 rank: 'B+'55 }56 },57 {58 studentno: '2011360117',59 examno: '20110514',60 studentname: '李近坟',61 class: '六年级 (8) 班',62 subjectScores: {63 score: '76.5',64 classRank: '3',65 gradeRank: '16',66 rank: 'A+'67 },68 totalScores: {69 score: '243.5',70 classRank: '2',71 gradeRank: '2',72 rank: 'B+'73 }74 },75 {76 studentno: '2011360118',77 examno: '20110515',78 studentname: '叶文',79 class: '六年级 (9) 班',80 subjectScores: {81 score: '78.5',82 classRank: '2',83 gradeRank: '11',84 rank: 'A+'85 },86 totalScores: {87 score: '267.5',88 classRank: '1',89 gradeRank: '1',90 rank: 'A+'91 }92 }93];94const PersonStats = [95 {96 title: '易嘎呈(2018360247)个人成绩册',97 scores: [98 {99 examname: '2016学年上学期 期末考试',100 subjectScores: [101 {102 dictname: '语文',103 score: '90'104 },105 {106 dictname: '数学',107 score: '95'108 },109 {110 dictname: '英文',111 score: '85'112 },113 {114 dictname: '化学',115 score: '89.5'116 },117 {118 dictname: '物理',119 score: '90'120 }121 ],122 totalScore: '485.5'123 },124 {125 examname: '2017学年上学期 期末考试',126 subjectScores: [127 {128 dictname: '语文',129 score: '75'130 },131 {132 dictname: '数学',133 score: '80'134 },135 {136 dictname: '英文',137 score: '90'138 },139 {140 dictname: '化学',141 score: '90.5'142 },143 {144 dictname: '物理',145 score: '80'146 }147 ],148 totalScore: '467.5'149 },150 {151 examname: '2018学年上学期 期末考试',152 subjectScores: [153 {154 dictname: '语文',155 score: '90'156 },157 {158 dictname: '数学',159 score: '95'160 },161 {162 dictname: '英文',163 score: '85'164 },165 {166 dictname: '化学',167 score: '89.5'168 },169 {170 dictname: '物理',171 score: '90'172 }173 ],174 totalScore: '485.5'175 },176 {177 examname: '2019学年上学期 期末考试',178 subjectScores: [179 {180 dictname: '语文',181 score: '90'182 },183 {184 dictname: '数学',185 score: '95'186 },187 {188 dictname: '英文',189 score: '85'190 },191 {192 dictname: '化学',193 score: '89.5'194 },195 {196 dictname: '物理',197 score: '90'198 }199 ],200 totalScore: '485.5'201 },202 {203 examname: '2020学年上学期 期末考试',204 subjectScores: [205 {206 dictname: '语文',207 score: '90'208 },209 {210 dictname: '数学',211 score: '95'212 },213 {214 dictname: '英文',215 score: '85'216 },217 {218 dictname: '化学',219 score: '89.5'220 },221 {222 dictname: '物理',223 score: '90'224 }225 ],226 totalScore: '485.5'227 }228 ]229 },230 {231 title: '李近坟(2018360247)个人成绩册',232 scores: [233 {234 examname: '2016学年上学期 期末考试',235 subjectScores: [236 {237 dictname: '语文',238 score: '90'239 },240 {241 dictname: '数学',242 score: '95'243 },244 {245 dictname: '英文',246 score: '85'247 },248 {249 dictname: '化学',250 score: '89.5'251 },252 {253 dictname: '物理',254 score: '90'255 }256 ],257 totalScore: '485.5'258 },259 {260 examname: '2017学年上学期 期末考试',261 subjectScores: [262 {263 dictname: '语文',264 score: '90'265 },266 {267 dictname: '数学',268 score: '95'269 },270 {271 dictname: '英文',272 score: '85'273 },274 {275 dictname: '化学',276 score: '89.5'277 },278 {279 dictname: '物理',280 score: '90'281 }282 ],283 totalScore: '485.5'284 },285 {286 examname: '2018学年上学期 期末考试',287 subjectScores: [288 {289 dictname: '语文',290 score: '90'291 },292 {293 dictname: '数学',294 score: '95'295 },296 {297 dictname: '英文',298 score: '85'299 },300 {301 dictname: '化学',302 score: '89.5'303 },304 {305 dictname: '物理',306 score: '90'307 }308 ],309 totalScore: '485.5'310 },311 {312 examname: '2019学年上学期 期末考试',313 subjectScores: [314 {315 dictname: '语文',316 score: '90'317 },318 {319 dictname: '数学',320 score: '95'321 },322 {323 dictname: '英文',324 score: '85'325 },326 {327 dictname: '化学',328 score: '89.5'329 },330 {331 dictname: '物理',332 score: '90'333 }334 ],335 totalScore: '485.5'336 },337 {338 examname: '2020学年上学期 期末考试',339 subjectScores: [340 {341 dictname: '语文',342 score: '90'343 },344 {345 dictname: '数学',346 score: '95'347 },348 {349 dictname: '英文',350 score: '85'351 },352 {353 dictname: '化学',354 score: '89.5'355 },356 {357 dictname: '物理',358 score: '90'359 }360 ],361 totalScore: '485.5'362 }363 ]364 },365 {366 title: '怕革(2018360247)个人成绩册',367 scores: [368 {369 examname: '2018学年上学期 期末考试',370 subjectScores: [371 {372 dictname: '语文',373 score: '90'374 },375 {376 dictname: '数学',377 score: '95'378 },379 {380 dictname: '英文',381 score: '85'382 },383 {384 dictname: '化学',385 score: '89.5'386 },387 {388 dictname: '物理',389 score: '90'390 }391 ],392 totalScore: '485.5'393 },394 {395 examname: '2019学年上学期 期末考试',396 subjectScores: [397 {398 dictname: '语文',399 score: '90'400 },401 {402 dictname: '数学',403 score: '95'404 },405 {406 dictname: '英文',407 score: '85'408 },409 {410 dictname: '化学',411 score: '89.5'412 },413 {414 dictname: '物理',415 score: '90'416 }417 ],418 totalScore: '485.5'419 },420 {421 examname: '2020学年上学期 期末考试',422 subjectScores: [423 {424 dictname: '语文',425 score: '90'426 },427 {428 dictname: '数学',429 score: '95'430 },431 {432 dictname: '英文',433 score: '85'434 },435 {436 dictname: '化学',437 score: '89.5'438 },439 {440 dictname: '物理',441 score: '90'442 }443 ],444 totalScore: '485.5'445 },446 {447 examname: '2021学年上学期 期末考试',448 subjectScores: [449 {450 dictname: '语文',451 score: '90'452 },453 {454 dictname: '数学',455 score: '95'456 },457 {458 dictname: '英文',459 score: '85'460 },461 {462 dictname: '化学',463 score: '89.5'464 },465 {466 dictname: '物理',467 score: '90'468 }469 ],470 totalScore: '485.5'471 },472 {473 examname: '2022学年上学期 期末考试',474 subjectScores: [475 {476 dictname: '语文',477 score: '90'478 },479 {480 dictname: '数学',481 score: '95'482 },483 {484 dictname: '英文',485 score: '85'486 },487 {488 dictname: '化学',489 score: '89.5'490 },491 {492 dictname: '物理',493 score: '90'494 }495 ],496 totalScore: '485.5'497 }498 ]499 }500];...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1function getValues(){2 let player1_joker = $(".player1 #joker-amt").val();3 let player2_joker = $(".player2 #joker-amt").val();4 let player3_joker = $(".player3 #joker-amt").val();5 let player4_joker = $(".player4 #joker-amt").val();6 let jv = $("#joker-value").val();7 let player1_placement = $(".player1 #place").val();8 let player2_placement = $(".player2 #place").val();9 let player3_placement = $(".player3 #place").val();10 let player4_placement = $(".player4 #place").val();11 calcAll(player1_joker,player2_joker,player3_joker,player4_joker,player1_placement,player2_placement,player3_placement,player4_placement,jv)12 updateTotalScore()13}14var player1_score = 0;15var player2_score = 0;16var player3_score = 0;17var player4_score = 0;18function updateTotalScore(){19 $(".total-score .player1").html(Math.round(player1_score*100)/100);20 $(".total-score .player2").html(Math.round(player2_score*100)/100);21 $(".total-score .player3").html(Math.round(player3_score*100)/100);22 $(".total-score .player4").html(Math.round(player4_score*100)/100);23}24function calcAll(p1_j,p2_j,p3_j,p4_j,p1_p,p2_p,p3_p,p4_p,j_val){25 let lose_first = 4.5;26 let lose_second = -1;27 let lose_third = -1.5;28 let lose_forth = -2;29 let joker_value = parseFloat(j_val);30 let p1_joker = (parseFloat(p1_j) * joker_value);31 let p2_joker = (parseFloat(p2_j) * joker_value);32 let p3_joker = (parseFloat(p3_j) * joker_value);33 let p4_joker = (parseFloat(p4_j) * joker_value);34 let p1_placement = p1_p;35 let p2_placement = p2_p;36 let p3_placement = p3_p;37 let p4_placement = p4_p;38 //Player 1 earns Joker39 player1_score += p1_joker * 3;40 player2_score -= p1_joker;41 player3_score -= p1_joker;42 player4_score -= p1_joker;43 //Player 2 earns Joker44 player1_score -= p2_joker;45 player2_score += p2_joker * 3;46 player3_score -= p2_joker;47 player4_score -= p2_joker;48 //Player 3 earns Joker49 player1_score -= p3_joker;50 player2_score -= p3_joker;51 player3_score += p3_joker * 3;52 player4_score -= p3_joker;53 //Player 4 earns Joker54 player1_score -= p4_joker;55 player2_score -= p4_joker;56 player3_score -= p4_joker;57 player4_score += p4_joker * 3;58 if(p1_placement == "win"){59 player1_score += 6;60 player2_score -= 2;61 player3_score -= 2;62 player4_score -= 2;63 }else if(p2_placement == "win"){64 player1_score -= 2;65 player2_score += 6;66 player3_score -= 2;67 player4_score -= 2;68 }else if(p3_placement == "win"){69 player1_score -= 2;70 player2_score -= 2;71 player3_score += 6;72 player4_score -= 2;73 }else if(p4_placement == "win"){74 player1_score -= 2;75 player2_score -= 2;76 player3_score -= 2;77 player4_score += 6;78 }else if(p1_placement == "lose" || p2_placement == "lose" || p3_placement == "lose" || p4_placement == "lose"){79 switch (p1_placement){80 case "lose":81 player1_score += lose_forth;82 break;83 case "3":84 player1_score += lose_third;85 break;86 case "2":87 player1_score += lose_second;88 break;89 case "1":90 player1_score += lose_first;91 break;92 }93 switch (p2_placement){94 case "lose":95 player2_score += lose_forth;96 break;97 case "3":98 player2_score += lose_third;99 break;100 case "2":101 player2_score += lose_second;102 break;103 case "1":104 player2_score += lose_first;105 break;106 }107 switch (p3_placement){108 case "lose":109 player3_score += lose_forth;110 break;111 case "3":112 player3_score += lose_third;113 break;114 case "2":115 player3_score += lose_second;116 break;117 case "1":118 player3_score += lose_first;119 break;120 }121 switch (p4_placement){122 case "lose":123 player4_score += lose_forth;124 break;125 case "3":126 player4_score += lose_third;127 break;128 case "2":129 player4_score += lose_second;130 break;131 case "1":132 player4_score += lose_first;133 break;134 }135 }else{136 switch (p1_placement){137 case "4":138 player1_score -= 1.5;139 break;140 case "3":141 player1_score -= 1;142 break;143 case "2":144 player1_score -= 0.5;145 break;146 case "1":147 player1_score += 3;148 break;149 }150 switch (p2_placement){151 case "4":152 player2_score -= 1.5;153 break;154 case "3":155 player2_score -= 1;156 break;157 case "2":158 player2_score -= 0.5;159 break;160 case "1":161 player2_score += 3;162 break;163 }164 switch (p3_placement){165 case "4":166 player3_score -= 1.5;167 break;168 case "3":169 player3_score -= 1;170 break;171 case "2":172 player3_score -= 0.5;173 break;174 case "1":175 player3_score += 3;176 break;177 }178 switch (p4_placement){179 case "4":180 player4_score -= 1.5;181 break;182 case "3":183 player4_score -= 1;184 break;185 case "2":186 player4_score -= 0.5;187 break;188 case "1":189 player4_score += 3;190 break;191 }192 }193 let p1_name = $(".player1 input").val();194 $(".player1 span").html(p1_name);195 $(".player1 input").css("display","none");196 let p2_name = $(".player2 input").val();197 $(".player2 span").html(p2_name);198 $(".player2 input").css("display","none");199 let p3_name = $(".player3 input").val();200 $(".player3 span").html(p3_name);201 $(".player3 input").css("display","none");202 let p4_name = $(".player4 input").val();203 $(".player4 span").html(p4_name);204 $(".player4 input").css("display","none");...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

1function logText(e) {2 console.log(this.classList.value);3 e.stopPropagation(); // stop bubbling!4 console.log(this);5}6const bulbasaur = document.querySelector('.bulbasaur');7const squirtle = document.querySelector('.squirtle');8const charmander = document.querySelector('.charmander');9bulbasaur.addEventListener('click', playRound)10squirtle.addEventListener('click', playRound)11charmander.addEventListener('click', playRound)12let playerScore = 0;13let compScore = 0;14let roundScore = 0;15// while (playerScore < 5 || compScore < 5) {16function playRound() {17 const myArray = ["bulbasaur", "squirtle", "charmander"];18 const computerSelection = computerPlay();19 let playerSelection = this.classList.value.toUpperCase();20 function computerPlay() {21 y = myArray[~~(Math.random() * myArray.length)].toUpperCase();22 return (y);23 }24 if (computerSelection === "BULBASAUR") {25 if (playerSelection === computerSelection) {26 playerScore = playerScore + 0;27 compScore = compScore + 0;28 roundScore = roundScore + 1;29 var result = ("Bulbasaur vs Bulbasaur, it's a TIE!")30 } else if (playerSelection === "SQUIRTLE") {31 playerScore = playerScore + 0;32 compScore = compScore + 1;33 roundScore = roundScore + 1;34 var result = ("Bulbasaur beats Squirtle, you LOSE!")35 } else {36 playerScore = playerScore + 1;37 compScore = compScore + 0;38 roundScore = roundScore + 1;39 var result = ("Charmander beats Bulbasaur, you WIN!")40 } 41 } else if (computerSelection === "CHARMANDER") {42 if (playerSelection === computerSelection) {43 roundScore = roundScore + 1;44 playerScore = playerScore + 0;45 compScore = compScore + 0;46 var result = ("Charmander vs Charmander, it's a TIE!")47 } else if (playerSelection === "BULBASAUR") {48 roundScore = roundScore + 1;49 playerScore = playerScore + 0;50 compScore = compScore + 1;51 var result = ("Charmander beats Bulbasaur, you Lose!")52 } else {53 roundScore = roundScore + 1;54 playerScore = playerScore + 1;55 compScore = compScore + 0;56 var result = ("Squirtle beats Charmander, you Win!")57 } 58 } else if (computerSelection === "SQUIRTLE") {59 if (playerSelection === computerSelection) {60 roundScore = roundScore + 1;61 playerScore = playerScore + 0;62 compScore = compScore + 0;63 var result = ("Squirtle vs Squirtle, it's a Tie!")64 } else if (playerSelection === "CHARMANDER") {65 roundScore = roundScore + 1;66 playerScore = playerScore + 0;67 compScore = compScore + 1;68 var result = ("Squirtle beats Charmander, You Lose!")69 } else {70 roundScore = roundScore + 1;71 playerScore = playerScore + 1;72 compScore = compScore + 0;73 var result = ("Bulbasaur beats Squirtle, You Win!")74 } 75 }76 console.log(result);77 console.log(roundScore);78 console.log('player score: ' + playerScore);79 console.log('computer score: ' + compScore);80 81 const resultContainer = document.querySelector('.resultContainer');82 83 resultContainer.innerText = "Round " + roundScore + "...FIGHT!" + "\r\n";84 resultContainer.innerText += result + "\r\n";85 resultContainer.innerText += "Player Score: " + playerScore + " vs Computer Score: " + compScore + "\r\n";86 if (playerScore === 5) {87 resultContainer.innerText += "\r\n YOU ARE THE WINNER!";88 roundScore = 0;89 playerScore = 0;90 compScore = 0;91 } else if (compScore === 5) {92 resultContainer.innerText += "\r\n COMPUTER WINS, you LOSE :(";93 roundScore = 0;94 playerScore = 0;95 compScore = 0;96 } 97}98document.getElementsByClassName("playerScore").innerHTML = playRound[0];99// }100// if (playerScore > compScore) {101// console.log("YOU WIN! :) you beat the computer by scoring "+playerScore +" while the computer only scored " + compScore)102// } else if (playerScore === compScore) {103// console.log("Ya'll Tie! The final score was "+ playerScore + " vs " + compScore)104// } else {105// console.log("YOU LOSE :(. The computer beat you by scoring " + compScore + " and you only scored " + playerScore)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful