Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my first commit #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions slot_machine.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>TRY YOUR LUCK!</h1>

<img src="slotmachinepicture.png" alt="slotmachinepicture">

<section id="allSlots">
<p id="slot1"></p>
<p id="slot2"></p>
<p id="slot3"></p>
</section>
<section>
<p id="results"></p>
</section>

<section>
<p>YOUR SCORE IS:<span id="playerScore"></span></p>
</section>

<button type="button" id="submit1">Minimum Bet 10 Tokens</button>

<button type="button" id="submit2">Maximum Bet 50 Tokens</button>

<script src="slot_machine.js"></script>
</body>
61 changes: 61 additions & 0 deletions slot_machine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
let symbols1 = [':)', '<3', ':(', '$', '&']
var playerScore = 100;
document.querySelector("#playerScore").innerText = playerScore
let slot1 = symbols1[Math.floor(Math.random() * 5)]
let slot2 = symbols1[Math.floor(Math.random() * 5)]
let slot3 = symbols1[Math.floor(Math.random() * 5)]
document.querySelector("#slot1").innerText = slot1
document.querySelector("#slot2").innerText = slot2
document.querySelector("#slot3").innerText = slot3

function getRamdomCharacter() {
let slot1 = symbols1[Math.floor(Math.random() * 5)]
let slot2 = symbols1[Math.floor(Math.random() * 5)]
let slot3 = symbols1[Math.floor(Math.random() * 5)]
document.querySelector("#slot1").innerText = slot1
document.querySelector("#slot2").innerText = slot2
document.querySelector("#slot3").innerText = slot3

if (slot1 == slot2 && slot2 == slot3) {
document.querySelector("#results").innerText = 'JACKPOT! YOU WIN 100 POINTS'
playerScore += 100

if (playerScore >= 500) {
document.querySelector("#results").innerText = 'CONGRATULATIONS! 500+ POINTS YOU WIN THE GAME'
}
}

else {
document.querySelector("#results").innerText = 'YOU lOSE 10 POINTS'
playerScore -= 10
}
document.querySelector("#playerScore").innerText = playerScore
}

document.querySelector("#submit1").addEventListener("click", getRamdomCharacter);

function getRamdomCharacter2() {
let slot1 = symbols1[Math.floor(Math.random() * 5)]
let slot2 = symbols1[Math.floor(Math.random() * 5)]
let slot3 = symbols1[Math.floor(Math.random() * 5)]
document.querySelector("#slot1").innerText = slot1
document.querySelector("#slot2").innerText = slot2
document.querySelector("#slot3").innerText = slot3

if (slot1 == slot2 && slot2 == slot3) {
document.querySelector("#results").innerText = 'JACKPOT! YOU WIN 300 POINTS'
playerScore += 300

if (playerScore >= 500) {
document.querySelector("#results").innerText = 'CONGRATULATIONS! 500+ POINTS YOU WIN THE GAME'
}
}

else {
document.querySelector("#results").innerText = 'YOU lOSE 50 POINTS'
playerScore -= 50
}
document.querySelector("#playerScore").innerText = playerScore
}

document.querySelector("#submit2").addEventListener("click", getRamdomCharacter2);
Binary file added slotmachinepicture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
h1{
color: red;
}

#allSlots{
display: flex;
flex-direction: row;
justify-content: center;
}

#slot1, #slot2, #slot3{
text-align: center;
padding-left: 25px;
}

body{
text-align: center;
}