diff --git a/Games/DiceWar/Dices/0.png b/Games/DiceWar/Dices/0.png new file mode 100644 index 0000000..6b15753 Binary files /dev/null and b/Games/DiceWar/Dices/0.png differ diff --git a/Games/DiceWar/Dices/1.png b/Games/DiceWar/Dices/1.png new file mode 100644 index 0000000..ee9dd0c Binary files /dev/null and b/Games/DiceWar/Dices/1.png differ diff --git a/Games/DiceWar/Dices/2.png b/Games/DiceWar/Dices/2.png new file mode 100644 index 0000000..0d53674 Binary files /dev/null and b/Games/DiceWar/Dices/2.png differ diff --git a/Games/DiceWar/Dices/3.png b/Games/DiceWar/Dices/3.png new file mode 100644 index 0000000..5515f93 Binary files /dev/null and b/Games/DiceWar/Dices/3.png differ diff --git a/Games/DiceWar/Dices/4.png b/Games/DiceWar/Dices/4.png new file mode 100644 index 0000000..cd06bc0 Binary files /dev/null and b/Games/DiceWar/Dices/4.png differ diff --git a/Games/DiceWar/Dices/5.png b/Games/DiceWar/Dices/5.png new file mode 100644 index 0000000..f561fc8 Binary files /dev/null and b/Games/DiceWar/Dices/5.png differ diff --git a/Games/DiceWar/Dices/6.png b/Games/DiceWar/Dices/6.png new file mode 100644 index 0000000..4a33870 Binary files /dev/null and b/Games/DiceWar/Dices/6.png differ diff --git a/Games/DiceWar/Dices/7.png b/Games/DiceWar/Dices/7.png new file mode 100644 index 0000000..2f2ce22 Binary files /dev/null and b/Games/DiceWar/Dices/7.png differ diff --git a/Games/DiceWar/index.html b/Games/DiceWar/index.html new file mode 100644 index 0000000..a5d1360 --- /dev/null +++ b/Games/DiceWar/index.html @@ -0,0 +1,41 @@ + + + + + + + + + + Dice War + + +
+
+
+ Enemy Dice + Enemy Dice + Enemy Dice + Enemy Dice + Enemy Dice +
+

Enemy score: 0

+
+
+

Your score: 0

+
+ Player Dice + Player Dice + Player Dice + Player Dice + Player Dice +
+
+

Do you think that you have score then the Enemy?

+ +
+
+
+ + + \ No newline at end of file diff --git a/Games/DiceWar/main.js b/Games/DiceWar/main.js new file mode 100644 index 0000000..fb9fe3d --- /dev/null +++ b/Games/DiceWar/main.js @@ -0,0 +1,70 @@ +let enemy = [ + document.querySelector('#enDice1'), + document.querySelector('#enDice2'), + document.querySelector('#enDice3'), + document.querySelector('#enDice4'), + document.querySelector('#enDice5'), +]; +let player = [ + document.querySelector('#plDice1'), + document.querySelector('#plDice2'), + document.querySelector('#plDice3'), + document.querySelector('#plDice4'), + document.querySelector('#plDice5'), +]; +let enScore = document.querySelector('#enemyScore'); +let plaScore = document.querySelector('#playerScore'); + +let enemyScore = 0; +let playerScore = 0; + +function ranD6(){ + return Math.floor(Math.random()*6)+1; +} + +function enemyRoll(){ + enemyScore = 0; + enemy.forEach(e => { + const point = ranD6(); + enemyScore += point; + e.src = `./Dices/${point}.png`; + e.classList.value=""; + e.classList.add("pop"); + setTimeout(() => { + e.classList.remove('pop'); + },500); + }); + enScore.innerHTML = enemyScore; +} + +function playerRoll(){ + playerScore = 0; + + player.forEach(e => { + const point = ranD6(); + playerScore += point; + e.src = `./Dices/${point}.png`; + e.classList.value=""; + e.classList.add("pop"); + setTimeout(() => { + e.classList.remove('pop'); + },500); + }); + plaScore.innerHTML = playerScore; +} + +function gamble(){ + enemyRoll(); + playerRoll(); + setTimeout(() => { + if(playerScore>enemyScore){ + alert('You won!'); + }else if(playerScore2048 RockPaperScissors QuessNumber-1D6 + DiceWar \ No newline at end of file