-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# BlackjackApp | ||
``` | ||
Javascript | ||
HTML | ||
CSS | ||
bootstrap -v 5.0.0.beta3 | ||
``` | ||
Esta es un aplicación con la que se puede comenzar a trabajar profesionalmente en JavaScript. | ||
BlackjackApp es mi versión del juego de cartas llamado Blackjack. |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
|
||
let deck = []; | ||
const tipos = ['C', 'D', 'H', 'S']; | ||
const especiales = ['A', 'J', 'Q', 'K']; | ||
|
||
//función que crea un nuevo deck | ||
const crearDeck = () => { | ||
|
||
for (let i = 2 ; i <= 10 ; i++){ | ||
for (let tipo of tipos){ | ||
deck.push (i + tipo); | ||
|
||
} | ||
} | ||
|
||
for (let tipo of tipos){ | ||
for (let esp of especiales){ | ||
deck.push(esp + tipo); | ||
} | ||
} | ||
|
||
deck = _.shuffle(deck); | ||
console.log(deck); | ||
return deck; | ||
} | ||
|
||
|
||
//Mandar llamar al deck | ||
crearDeck(); | ||
|
||
|
||
//Esta función me permite pedir una carta | ||
|
||
const pedirCarta = () => { | ||
|
||
if(deck.length <= 0){ | ||
throw ' No hay más cartas el el deck.'; | ||
} | ||
|
||
const carta = deck.shift(); | ||
|
||
console.log(deck); | ||
console.log(carta); | ||
return carta; | ||
} | ||
|
||
//pedirCarta(); | ||
|
||
// for (let i = 0 ; i <= 100 ; i ++){ | ||
// pedirCarta(); | ||
// } | ||
|
||
|
||
const valorCarta = ( carta ) =>{ | ||
|
||
const valor = carta.substring( 0, carta.length - 1 ); | ||
return(isNaN (valor))? | ||
(valor ==='A')? 11 : 10 | ||
:(valor * 1 ); | ||
|
||
} | ||
const valor = valorCarta( pedirCarta() ); | ||
console.log({valor}); |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "02-blackjack", | ||
"version": "0.0.1", | ||
"description": "Juego de cartas llamado Blackjack", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/verdizone/BlackjackApp.git" | ||
}, | ||
"keywords": [ | ||
"juego", | ||
"blackjack", | ||
"javascript" | ||
], | ||
"author": "Jeroham Miranda", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/verdizone/BlackjackApp/issues" | ||
}, | ||
"homepage": "https://github.com/verdizone/BlackjackApp#readme", | ||
"dependencies": {} | ||
} |