Juego De Blackjack En Javascript
- Juego Blackjack Javascript
- Juego De Blackjack En Javascript Compiler
- Juego De Blackjack En Javascript Play
- Juego De Blackjack En Javascript Gratis
- Juego De Blackjack En Javascript W3schools
In general, I think you did a good job overall. That is, getting the game logic to run without serious issue. There were a couple of errors that caused the game to not run correctly. One was if the player
gets a blackjack the game exits without prompting the user for further action:
LOGIC
I shortened the code up here but you can see since you do your check outside of 'hand-loop' and call break
you will exit the program. This goes for if there is a push on blackjack too.
El objetivo del clasico juego de cartas Black Jack es tratar de completar 21, o una suma de cartas mayor a la que podria completar el que reparte las cartas, en este caso el computador! Click sobre Deal para empezar un nuevo juego. Click sobre Hit Me! Para pedir otra carta. Bonus valid for 14 days. 30 Spins on preselected games Juego De Blackjack En Javascript will be credited instantly + then 30 per day for 9 days. Free Spins valid for 72 hours from credit. Max Free Spins winnings £100. Skrill + Neteller Juego De Blackjack En Javascript excluded. Always refer to Bonus Terms.
Exhausting the deck
, where you only reset the deck if the player hits. This is because of how you are drawing cards by calling .pop
.
If you keep standing on every turn you will eventually get an IndexError
. You could just call random.choice
on the deck and not have to worry about it while using some other condition to reset the deck
:
STYLE
Juego Blackjack Javascript
There are some style issues here too. These usually come down to personal preferences but if you are having others read your code its best to stay close to pep8 which is a general consesus for helpful style choices.
OOP
You also make use of global
variables quite a bit. Usually using global
s are considered bad practice. What you could do is think about where each one of these functions and variables would logically make sense to be grouped together. Then create a class to encapsulate the variables and functions, adhering to good OOP principles. You do this to a certain degree but you could further it by adding in the global
s too:
CODE DUPLICATION
You also have several spots of code duplication. Keeping with DRY (don't repeat yourself) you could use a loop or recursion to cut down on some of this:
Where you could pass in a list
or any other kind of iterable
and loop for them:
Juego De Blackjack En Javascript Compiler
There are places where you are using counters too where iterating over the list itself or a range would be fine:
would be:
Juego De Blackjack En Javascript Play
STANDARD LIBRARY
Juego De Blackjack En Javascript Gratis
One of the great things about Python is that there are a rich collection of libraries/modules already made by really intelligent people. Use this to your advantage and get to know different modules and what they offer:
becomes:
Juego De Blackjack En Javascript W3schools
Where you can use itertools.product
to create a cartesian product
I re-wrote your program by creating a different game-loop and making a couple of different classes: