Browse Source

upload commit, working

feature/split
Nero Ignis 5 years ago
commit
e41db04307
  1. 1
      .gitignore
  2. 17
      css/app.css
  3. 12
      css/bootstrap.min.css
  4. BIN
      img/cardBack_blue1.png
  5. BIN
      img/cardBack_blue2.png
  6. BIN
      img/cardBack_blue3.png
  7. BIN
      img/cardBack_blue4.png
  8. BIN
      img/cardBack_blue5.png
  9. BIN
      img/cardBack_green1.png
  10. BIN
      img/cardBack_green2.png
  11. BIN
      img/cardBack_green3.png
  12. BIN
      img/cardBack_green4.png
  13. BIN
      img/cardBack_green5.png
  14. BIN
      img/cardBack_red1.png
  15. BIN
      img/cardBack_red2.png
  16. BIN
      img/cardBack_red3.png
  17. BIN
      img/cardBack_red4.png
  18. BIN
      img/cardBack_red5.png
  19. BIN
      img/clubs10.png
  20. BIN
      img/clubs2.png
  21. BIN
      img/clubs3.png
  22. BIN
      img/clubs4.png
  23. BIN
      img/clubs5.png
  24. BIN
      img/clubs6.png
  25. BIN
      img/clubs7.png
  26. BIN
      img/clubs8.png
  27. BIN
      img/clubs9.png
  28. BIN
      img/clubsa.png
  29. BIN
      img/clubsj.png
  30. BIN
      img/clubsk.png
  31. BIN
      img/clubsq.png
  32. BIN
      img/diamonds10.png
  33. BIN
      img/diamonds2.png
  34. BIN
      img/diamonds3.png
  35. BIN
      img/diamonds4.png
  36. BIN
      img/diamonds5.png
  37. BIN
      img/diamonds6.png
  38. BIN
      img/diamonds7.png
  39. BIN
      img/diamonds8.png
  40. BIN
      img/diamonds9.png
  41. BIN
      img/diamondsa.png
  42. BIN
      img/diamondsj.png
  43. BIN
      img/diamondsk.png
  44. BIN
      img/diamondsq.png
  45. BIN
      img/hearts10.png
  46. BIN
      img/hearts2.png
  47. BIN
      img/hearts3.png
  48. BIN
      img/hearts4.png
  49. BIN
      img/hearts5.png
  50. BIN
      img/hearts6.png
  51. BIN
      img/hearts7.png
  52. BIN
      img/hearts8.png
  53. BIN
      img/hearts9.png
  54. BIN
      img/heartsa.png
  55. BIN
      img/heartsj.png
  56. BIN
      img/heartsk.png
  57. BIN
      img/heartsq.png
  58. BIN
      img/joker.png
  59. BIN
      img/spades10.png
  60. BIN
      img/spades2.png
  61. BIN
      img/spades3.png
  62. BIN
      img/spades4.png
  63. BIN
      img/spades5.png
  64. BIN
      img/spades6.png
  65. BIN
      img/spades7.png
  66. BIN
      img/spades8.png
  67. BIN
      img/spades9.png
  68. BIN
      img/spadesa.png
  69. BIN
      img/spadesj.png
  70. BIN
      img/spadesk.png
  71. BIN
      img/spadesq.png
  72. 57
      index.htm
  73. 205
      js/app.js
  74. 11965
      js/vue.js

1
.gitignore vendored

@ -0,0 +1 @@ @@ -0,0 +1 @@
.idea/

17
css/app.css

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
body {
background-color: #0f0f0f;
color: white;
}
.container {
padding-top: 3em;
}
.playing-card {
max-width: 100%;
}
#status {
color: darkred;
text-align: center;
}

12
css/bootstrap.min.css vendored

File diff suppressed because one or more lines are too long

BIN
img/cardBack_blue1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

BIN
img/cardBack_blue2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
img/cardBack_blue3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

BIN
img/cardBack_blue4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
img/cardBack_blue5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
img/cardBack_green1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 B

BIN
img/cardBack_green2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
img/cardBack_green3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

BIN
img/cardBack_green4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
img/cardBack_green5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
img/cardBack_red1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

BIN
img/cardBack_red2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
img/cardBack_red3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

BIN
img/cardBack_red4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
img/cardBack_red5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
img/clubs10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
img/clubs2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/clubs3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/clubs4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
img/clubs5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
img/clubs6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
img/clubs7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
img/clubs8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
img/clubs9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
img/clubsa.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
img/clubsj.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/clubsk.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/clubsq.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
img/diamonds10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/diamonds2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
img/diamonds3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
img/diamonds4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
img/diamonds5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
img/diamonds6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/diamonds7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/diamonds8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
img/diamonds9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/diamondsa.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
img/diamondsj.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
img/diamondsk.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/diamondsq.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
img/hearts10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/hearts2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
img/hearts3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
img/hearts4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
img/hearts5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/hearts6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/hearts7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/hearts8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
img/hearts9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/heartsa.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
img/heartsj.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
img/heartsk.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
img/heartsq.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
img/joker.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
img/spades10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/spades2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
img/spades3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
img/spades4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
img/spades5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
img/spades6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/spades7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
img/spades8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
img/spades9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
img/spadesa.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
img/spadesj.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
img/spadesk.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
img/spadesq.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

57
index.htm

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>BlackJack ♠</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/app.css">
<link rel="icon" href="favicon.ico">
</head>
<body>
<div class="container" id="root">
<div class="row">
<div class="col-md-12">
<button @click="testRound" v-if="!roundActive">Start round</button>
<button @click="drawAnotherCard" v-if="roundActive">Draw</button>
<button @click="pass" v-if="roundActive">Pass</button>
<button @click="endRound" v-if="roundActive">End round</button>
</div>
</div>
<!-- <div class="row">-->
<!-- <div class="col-md-1" v-for="card in cards">-->
<!-- <img :src="card.asset" :alt="card.symbol + '_' + card.points" class="playing-card">-->
<!-- </div>-->
<!-- </div>-->
<div class="row">
<div class="col-md-6">
<h4>Dealer <template v-if="!roundActive">({{ dealerScore }})</template></h4>
<div class="row">
<div class="col-md-4" v-for="(card, index) in dealersHand">
<img :src="index > 0 ? card.asset : roundActive ? cardBack : card.asset" :alt="card.symbol + '_' + card.points" class="playing-card">
</div>
</div>
</div>
<div class="col-md-6">
<h4>Hand ({{ handScore === 21 && usersHand.count < 2 ? 'BlackJack' : handScore > 21 ? 'Plus! ' + handScore : handScore }})</h4>
<div class="row">
<div class="col-md-4" v-for="card in usersHand">
<img :src="card.asset" :alt="card.symbol + '_' + card.points" class="playing-card">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12" id="status">
<h1 v-text="status"></h1>
</div>
</div>
</div>
</body>
<script src="js/vue.js"></script>
<script src="js/app.js"></script>
</html>

205
js/app.js

@ -0,0 +1,205 @@ @@ -0,0 +1,205 @@
let app = new Vue({
el: '#root',
data: {
roundActive: false,
cardBack: 'img/cardBack_red5.png',
cards: [],
cardDeck: [],
usersHand: [],
dealersHand: [],
lastCard: null,
handScore: 0,
dealerScore: 0,
status: '',
},
methods: {
generateDeck() {
const symbolNames = ['spades', 'clubs', 'diamonds', 'hearts'];
const highCards = ['j', 'q', 'k'];
let cardDeck = [];
symbolNames.forEach((symbolName) => {
for (let cardPoints = 1; cardPoints <= 10; cardPoints++) {
let cardSymbol = cardPoints;
let points = cardPoints;
let isAnAce = false;
if (cardPoints === 1) {
points = 11;
cardSymbol = 'a';
isAnAce = true;
}
cardDeck.push({
ace: isAnAce,
points: points,
symbol: cardSymbol,
asset: 'img/' + symbolName + cardSymbol + '.png'
});
}
highCards.forEach((highCard) => {
cardDeck.push({
ace: false,
points: 10,
symbol: symbolName,
asset: 'img/' + symbolName + highCard + '.png'
})
});
});
return cardDeck;
},
shuffleDeck() {
let shuffledDeck = this.cards;
let cardCount = shuffledDeck.length, t, i;
while (cardCount) {
i = Math.floor(Math.random() * cardCount--);
t = shuffledDeck[cardCount];
shuffledDeck[cardCount] = shuffledDeck[i];
shuffledDeck[i] = t;
}
this.cards = shuffledDeck;
},
drawCardToUser() {
let vue = this;
let drawnCard = vue.cards.shift();
vue.usersHand.push(drawnCard);
if (drawnCard.ace && vue.handScore > 10) {
drawnCard.points = 1;
}
if ((vue.handScore + drawnCard.points) > 21) {
let aceCount = this.handIncludesAces(this.usersHand);
console.log(aceCount + ' aces should be decreased in value');
}
vue.handScore += drawnCard.points;
},
drawCardToDealer() {
let vue = this;
let drawnCard = vue.cards.shift();
vue.dealersHand.push(drawnCard);
if (drawnCard.ace && vue.dealerScore > 10) {
drawnCard.points = 1;
}
if ((vue.dealerScore + drawnCard.points) > 21) {
let aceCount = this.handIncludesAces(this.dealersHand);
console.log(aceCount + ' aces should be decreased in value');
}
vue.dealerScore += drawnCard.points;
},
handIncludesAces(hand) {
let aceCount = 0;
hand.forEach((card) => {
if (card.ace === true) {
aceCount++;
}
});
return aceCount;
},
handHasBlackJack(score) {
return score === 21;
},
isPlus(score) {
return score > 21;
},
startRound() {
this.endRound();
this.roundActive = true;
this.drawCardToUser();
this.drawCardToDealer();
this.drawCardToUser();
this.drawCardToDealer();
if (this.handHasBlackJack(this.dealerScore)) {
this.dealerWon();
}
if (this.handScore === 21) {
this.pass();
}
},
drawAnotherCard() {
this.drawCardToUser();
if (this.isPlus(this.handScore)) {
this.status = 'Hand is plus, you lose.';
this.roundActive = false;
}
},
pass() {
if (this.dealerScore === this.handScore) {
this.roundActive = false;
this.status = 'Draw!'
} else if (this.dealerScore > 22) {
this.roundActive = false;
this.status = 'Dealer is plus, you win';
} else if (this.dealerScore > this.handScore) {
this.roundActive = false;
this.status = 'Dealer Wins';
} else if (this.dealerScore < 17) {
this.roundActive = false;
this.drawCardToDealer();
this.pass();
// this.status = 'Dealer drawing not yet implemented';
} else if (this.handScore > this.dealerScore && this.handScore < 22) {
this.roundActive = false;
this.status = 'You win!';
}
},
endRound() {
this.roundActive = false;
this.lastCard = null;
this.status = null;
this.dealersHand = [];
this.dealerScore = 0;
this.usersHand = [];
this.handScore = 0;
this.cards = this.generateDeck();
this.shuffleDeck();
},
dealerWon() {
console.log('House wins')
},
userWon() {
console.log('You win')
},
testRound() {
this.startRound();
}
},
created() {
this.cardDeck = this.generateDeck();
this.cards = this.generateDeck();
this.shuffleDeck();
}
});

11965
js/vue.js

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save