-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #537 from ABarpanda/main
Fixed some issues in chess.py
- Loading branch information
Showing
5 changed files
with
95 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,54 @@ | ||
let runs = 0; | ||
let outs = 0; | ||
let runs1 = 0; | ||
let outs1 = 0; | ||
let runs2 = 0; | ||
let outs2 = 0; | ||
|
||
function hit() { | ||
const randomNumber = Math.floor(Math.random() * 10); // Generates random number between 0 and 9 | ||
if (randomNumber === 0) { | ||
outs++; | ||
} else if (randomNumber === 1 || randomNumber === 2 || randomNumber === 3 || randomNumber === 4 || randomNumber === 6) { | ||
runs += randomNumber; | ||
function hit1() { | ||
const randomNumber1 = Math.floor(Math.random() * 10); // Generates random number between 0 and 9 | ||
if (randomNumber1 === 0 || randomNumber1 === 5) { | ||
outs1++; | ||
} else if (randomNumber1 === 1 || randomNumber1 === 2 || randomNumber1 === 3 || randomNumber1 === 4 || randomNumber1 === 6) { | ||
runs1 += randomNumber1; | ||
} else { | ||
runs1 += 1; | ||
current1 = 0; | ||
} | ||
updateScore(); | ||
current1 = randomNumber1; | ||
updateScore1(); | ||
} | ||
|
||
function updateScore() { | ||
document.getElementById("score").textContent = runs; | ||
document.getElementById("outs").textContent = outs; | ||
function updateScore1() { | ||
document.getElementById("score1").textContent = runs1; | ||
document.getElementById("outs1").textContent = outs1; | ||
document.getElementById("current1").textContent = current1; | ||
} | ||
|
||
// function hit2() { | ||
// const randomNumber2 = Math.floor(Math.random() * 10); // Generates random number between 0 and 9 | ||
// if (randomNumber2 === 0 || randomNumber2 === 5) { | ||
// outs2++; | ||
// } else if (randomNumber2 === 1 || randomNumber2 === 2 || randomNumber2 === 3 || randomNumber2 === 4 || randomNumber2 === 6) { | ||
// runs2 += randomNumber2; | ||
// } else { | ||
// runs2 += 1; | ||
// current2 = 0; | ||
// } | ||
// current2 = randomNumber2; | ||
// updateScore2(); | ||
// } | ||
|
||
// function updateScore2() { | ||
// document.getElementById("score2").textContent = runs2; | ||
// document.getElementById("outs2").textContent = outs2; | ||
// document.getElementById("current2").textContent = current2; | ||
// } | ||
|
||
// if (outs1>=10 || outs2>=10){ | ||
// if (runs1 === runs2){ | ||
// return ("The game is a tie") | ||
// } else if (runs1 > runs2) { | ||
// return ("Player 1 is the winner") | ||
// } else { | ||
// return ("Player 2 is the winner") | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters