Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ICT100_Tutorials_T3_2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Vitale
ICT100_Tutorials_T3_2022
Commits
d2d7823f
Commit
d2d7823f
authored
2 years ago
by
Jonathan Vitale
Browse files
Options
Downloads
Patches
Plain Diff
Update code for tutorial 2
parent
eb7ba0cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game-logic.js
+28
-1
28 additions, 1 deletion
game-logic.js
with
28 additions
and
1 deletion
game-logic.js
+
28
−
1
View file @
d2d7823f
const
gameState
=
{
playerWallet
:
100
,
currentBet
:
null
}
function
collectBet
(){
let
currentBet
;
let
isValidBet
=
false
;
//let counter = 0;
do
{
console
.
log
(
"
please provide your bet
"
)
currentBet
=
10
;
// mocking up with a value
console
.
log
(
`You provided the bet being
${
currentBet
}
`
);
if
(
currentBet
<=
0
||
currentBet
>
gameState
.
playerWallet
){
console
.
log
(
'
Your bet is not valid!
'
);
//counter++;
}
else
{
isValidBet
=
true
;
}
}
while
(
!
isValidBet
)
//&& counter < 4);
return
currentBet
;
}
function
blackjack
(){
// decide the bet, collect it
gameState
.
currentBet
=
collectBet
();
// we deal the first 2 cards for the player
// check immediately that the player has blackjack
...
...
@@ -29,4 +54,6 @@ function blackjack(){
// if player's score > dealer's score: player wins
// -> pay 2 times the bet
// end the game
}
\ No newline at end of file
}
blackjack
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment