diff --git a/bugs.md b/bugs.md index 4f70b60..91d5648 100644 --- a/bugs.md +++ b/bugs.md @@ -1,2 +1,2 @@ - [x] #001 dealer wins 22v20 -- [ ] #002 draw uses strings to payout \ No newline at end of file +- [x] #002 draw uses strings to payout \ No newline at end of file diff --git a/index.htm b/index.htm index 0837dbc..94f0890 100644 --- a/index.htm +++ b/index.htm @@ -182,6 +182,8 @@ + + \ No newline at end of file diff --git a/js/Blackjack.js b/js/Blackjack.js new file mode 100644 index 0000000..6fdb494 --- /dev/null +++ b/js/Blackjack.js @@ -0,0 +1,8 @@ +class Blackjack { + deck; + bank; + + constructor() { + this.bank = new LunaBank(); + } +} \ No newline at end of file diff --git a/js/Card.js b/js/Card.js new file mode 100644 index 0000000..e457b17 --- /dev/null +++ b/js/Card.js @@ -0,0 +1,19 @@ +class Card { + color; + symbol; + points; + ace = false; + assetUrl; + + constructor(color, symbol, points, ace, assetBaseUrl = 'img/') { + this.color = color; + this.symbol = symbol; + this.points = points; + this.ace = ace; + this.assetUrl = this.createAssetPath(assetBaseUrl); + } + + createAssetPath(assetBaseUrl) { + return assetBaseUrl + this.color + this.symbol + '.png' + } +} diff --git a/js/CardDeck.js b/js/CardDeck.js new file mode 100644 index 0000000..84cfcef --- /dev/null +++ b/js/CardDeck.js @@ -0,0 +1,99 @@ +class CardDeck { + constructor() { + this.generateDeck(); + } + + create() { + return new CardDeck(); + } + + createAndShuffle() { + let cardDeck = new CardDeck(); + cardDeck.shuffle(); + + return cardDeck; + } + + generateDeck() { + const colors = ['spades', 'clubs', 'diamonds', 'hearts']; + const highCards = ['j', 'q', 'k']; + + let cardDeck = []; + + colors.forEach((color) => { + for (let cardPoints = 1; cardPoints <= 10; cardPoints++) { + let symbol = cardPoints; + let points = cardPoints; + let isAnAce = false; + + if (cardPoints === 1) { + points = 11; + symbol = 'a'; + isAnAce = true; + } + + let card = new Card( + color, + symbol, + points, + isAnAce + ) + + cardDeck.push(card); + } + + highCards.forEach((highCard) => { + let card = new Card( + color, + highCard, + 10, + false + ) + + cardDeck.push(card); + }); + + this.deck = cardDeck; + }) + } + + shuffle(runs = 1) { + let cardCount = this.deck.length, t, i; + + for (let run = 0; run === runs; run++) { + while (cardCount) { + i = Math.floor(Math.random() * cardCount--); + t = this.deck[cardCount]; + this.deck[cardCount] = this.deck[i]; + this.deck[i] = t; + } + } + } + + cardsInStack() { + return this.deck.length; + } + + deckIsEmpty() { + return this.deck.length > 0 ? true : false; + } + + takeOneCard(cardsToDraw = 1) { + if (this.cardsInStack() > 0) { + + } + + return this.deck.shift(); + } + + takeCards(cardsToDraw) { + let drawnCards = []; + + for (let run = 0; run === cardsToDraw; run++) { + drawnCards.push(this.deck.shift()); + } + + return drawnCards; + } +} + diff --git a/js/LunaBank.js b/js/LunaBank.js new file mode 100644 index 0000000..ef0108a --- /dev/null +++ b/js/LunaBank.js @@ -0,0 +1,5 @@ +class LunaBank { + constructor(application) { + + } +} \ No newline at end of file diff --git a/js/app.js b/js/app.js index a940aa7..7b5bde8 100644 --- a/js/app.js +++ b/js/app.js @@ -24,12 +24,12 @@ let app = new Vue({ }, methods: { generateDeck() { - const symbolNames = ['spades', 'clubs', 'diamonds', 'hearts']; + const names = ['spades', 'clubs', 'diamonds', 'hearts']; const highCards = ['j', 'q', 'k']; let cardDeck = []; - symbolNames.forEach((symbolName) => { + names.forEach((symbolName) => { for (let cardPoints = 1; cardPoints <= 10; cardPoints++) { let cardSymbol = cardPoints; let points = cardPoints; diff --git a/kenney_casinoaudio (1).zip b/kenney_casinoaudio (1).zip deleted file mode 100644 index 28941e7..0000000 Binary files a/kenney_casinoaudio (1).zip and /dev/null differ