diff --git a/index.html b/index.html index d2c3c254..2c240ae1 100644 --- a/index.html +++ b/index.html @@ -19,13 +19,24 @@

TypeScript Casino

-
+
+
+ +
+ + + + + +
- - + + diff --git a/js/app.js b/js/app.js new file mode 100644 index 00000000..34481ffe --- /dev/null +++ b/js/app.js @@ -0,0 +1,329 @@ +var BlackJack = /** @class */ (function () { + function BlackJack() { + this.gameDeck = new Deck(); + this.playerHand = new Hand(); + this.dealerHand = new Hand(); + this.gameDeck = new Deck(); + } + //deal two cards to player + //check player score. If player or dealer= 21--gameover + //player hit or stay. if hit, deal card. check score. if above 21: busted. + //if player stay:: deal two cards to dealer. + //if dealer below 17: deal again. + BlackJack.prototype.println = function (input) { + display.innerHTML = input; + }; + BlackJack.prototype.startGameDealTwoToPlayer = function () { + this.playerHand.addCard(this.gameDeck.draw()); + this.playerHand.addCard(this.gameDeck.draw()); + }; + BlackJack.prototype.startGameDealTwoToDealer = function () { + this.dealerHand.addCard(this.gameDeck.draw()); + this.dealerHand.addCard(this.gameDeck.draw()); + }; + BlackJack.prototype.play = function () { + this.startGameDealTwoToPlayer(); + this.startGameDealTwoToDealer(); + var gameOver = this.checkBlackJack(); + if (!gameOver) { + this.println('
' + "Dealer's face up card is a " + this.dealerHand.handOfCards[0].toCardName + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
'); + } + }; + BlackJack.prototype.checkBlackJack = function () { + if (this.checkPlayerBlackJack()) { + if (this.checkDealerBlackJack()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "It's a Push"); + return true; + } + else { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "You Win!"); + return true; + } + } + else if (this.checkDealerBlackJack()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "You Lose!"); + return true; + } + else + return false; + }; + BlackJack.prototype.getWinner = function () { + var gameOver = this.checkBlackJack(); + }; + BlackJack.prototype.stay = function () { + //this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + //+ "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
'); + //if(this.dealerHand.handValue() < 17){ + if (this.dealerHand.handValue() < 17) { + do { + this.dealerHand.addCard(this.gameDeck.draw()); + } while (this.dealerHand.handValue() < 17); + { + if (this.dealerHand.handValue() > 22) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "You Win!"); + } + if (this.dealerHand.handValue() < 22 && this.dealerHand.handValue() > this.playerHand.handValue()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "You Lose!"); + } + else if (this.playerHand.handValue() < 22 && this.playerHand.handValue() > this.dealerHand.handValue()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "You Win!"); + } + else if (this.playerHand.handValue() == this.dealerHand.handValue()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "It's a Push"); + } + } + } + if (this.dealerHand.handValue() < 22 && this.dealerHand.handValue() > this.playerHand.handValue()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "You Lose!"); + } + else if (this.playerHand.handValue() < 22 && this.playerHand.handValue() > this.dealerHand.handValue()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "You Win!"); + } + else if (this.playerHand.handValue() == this.dealerHand.handValue()) { + this.println('
' + "Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "It's a Push"); + } + }; + BlackJack.prototype.checkPlayerBlackJack = function () { + return this.playerHand.handValue() === 21; + }; + BlackJack.prototype.checkDealerBlackJack = function () { + return this.dealerHand.handValue() === 21; + }; + BlackJack.prototype.hit = function () { + //this.playerHand.addCard(this.gameDeck.draw()); + var gameOver = this.checkBlackJack() || this.playerHand.handValue() > 22; + if (!gameOver) { + this.playerHand.addCard(this.gameDeck.draw()); + this.println('
' + "Dealer's face up card is a " + this.dealerHand.handOfCards[0].toCardName + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
'); + } + if (this.playerHand.handValue() > 21) { + this.println('
' + "Dealer's face up card is a " + this.dealerHand.handOfCards[0].toCardName + '
' + + "Your cards: " + this.playerHand.handToString() + " Your hand value = " + this.playerHand.handValue() + '
' + + "Bust! You lose!"); + } + }; + return BlackJack; +}()); +var Suit; +(function (Suit) { + Suit[Suit["Spades"] = 0] = "Spades"; + Suit[Suit["Clubs"] = 1] = "Clubs"; + Suit[Suit["Hearts"] = 2] = "Hearts"; + Suit[Suit["Diamonds"] = 3] = "Diamonds"; +})(Suit || (Suit = {})); +; +var Card = /** @class */ (function () { + function Card(rank, suit) { + this.rank = rank; + this.suit = suit; + } + Object.defineProperty(Card.prototype, "rankName", { + get: function () { + return Card.rankNames[this.rank - 1]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Card.prototype, "suitName", { + get: function () { + return Suit[this.suit]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Card.prototype, "toCardName", { + get: function () { + return this.rankName + ' of ' + this.suitName; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Card.prototype, "value", { + get: function () { + if (this.rankName === 'Ace') { + return 1; + } + else if (this.rankName === '2') { + return 2; + } + else if (this.rankName === '3') { + return 3; + } + else if (this.rankName === '4') { + return 4; + } + else if (this.rankName === '5') { + return 5; + } + else if (this.rankName === '6') { + return 6; + } + else if (this.rankName === '7') { + return 7; + } + else if (this.rankName === '8') { + return 8; + } + else if (this.rankName === '9') { + return 9; + } + else if (this.rankName === '10') { + return 10; + } + else if (this.rankName === 'Jack') { + return 10; + } + else if (this.rankName === 'Queen') { + return 10; + } + else if (this.rankName === 'King') { + return 10; + } + else { + return 0; + } + }, + enumerable: true, + configurable: true + }); + Card.rankNames = [ + 'Ace', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '10', + 'Jack', + 'Queen', + 'King', + ]; + return Card; +}()); +var Deck = /** @class */ (function () { + function Deck() { + this.cards = []; + for (var s = 0; s < 4; s++) { + for (var r = 1; r <= 13; r++) { + this.cards.push(new Card(r, s)); + } + } + } + Deck.prototype.shuffle = function () { + for (var i = 0; i < this.cards.length; i++) { + var j = Math.floor(Math.random() * this.cards.length); + var temp = this.cards[i]; + this.cards[i] = this.cards[j]; + this.cards[j] = temp; + } + }; + Deck.prototype.draw = function () { + return this.cards.shift(); + }; + return Deck; +}()); +var Hand = /** @class */ (function () { + function Hand() { + this.handOfCards = []; + } + Hand.prototype.addCard = function (Card) { + this.handOfCards.push(Card); + }; + Hand.prototype.numberOfCardsInHand = function () { + return this.handOfCards.length; + }; + Hand.prototype.handToString = function () { + var cardsInHand = ''; + for (var i = 0; i < this.handOfCards.length; i++) { + cardsInHand += this.handOfCards[i].toCardName + ' / '; + } + return cardsInHand; + }; + Hand.prototype.handValue = function () { + var isAce = false; + var size = this.numberOfCardsInHand(); + var totalHandValue = 0; + for (var i = 0; i < size; i++) { + totalHandValue += this.handOfCards[i].value; + if (this.handOfCards[i].value === 1) { + isAce = true; + } + } + //if there is an Ace present (previously counted as 1) and total is 11 or less, + //add 10 so ace is worth 11 + if (isAce && totalHandValue <= 11) { + return totalHandValue + 10; + } + else { + return totalHandValue; + } + }; + return Hand; +}()); +var Player = /** @class */ (function () { + function Player() { + this.name = name; + } + Object.defineProperty(Player.prototype, "getName", { + get: function () { + return this.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Player.prototype, "setName", { + set: function (usernameInput) { + this.name = usernameInput; + }, + enumerable: true, + configurable: true + }); + return Player; +}()); +var blackJack = new BlackJack(); +blackJack.gameDeck.shuffle(); +//blackJack.play(); +// display.innerHTML+= gameRunner.startGameDealTwoToPlayer(); +// gameRunner.startGameDealTwoToDealer(); +//display.innerHTML+= "
"+ gameRunner.askHitOrStay(); +// let d = new Deck(); +// let h = new Hand(); +// d.shuffle(); +// console.log(d.draw().toCardName); +// h.addCard(d.draw()); +// h.addCard(d.draw()); +// h.addCard(d.draw()); +// let test1 = d.draw().toCardName; +// let test2 =d.draw().value; +// let test3 = h.handToString(); +// function greeter(person):string { +// return person; +// } +//document.getElementById("display1").innerHTML = greeter(test2); +//document.getElementById("display2").innerHTML = greeter(test3); +//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/js/app.js.map b/js/app.js.map new file mode 100644 index 00000000..1c9e604c --- /dev/null +++ b/js/app.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.js","sourceRoot":"","sources":["../ts/BlackJack.ts","../ts/Card.ts","../ts/Deck.ts","../ts/Hand.ts","../ts/Player.ts","../ts/run.ts"],"names":[],"mappings":"AAAA;IAKI;QAFO,aAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;QAGzB,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,IA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CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,MAAM,CAAC,cAAc,CAAC;QAC1B,CAAC;IACL,CAAC;IAIL,WAAC;AAAD,CAAC,AA5CD,IA4CC;AC5CD;IAGI;QACI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,sBAAW,2BAAO;aAAlB;YACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAW,2BAAO;aAAlB,UAAmB,aAAqB;YACpC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC9B,CAAC;;;OAAA;IACL,aAAC;AAAD,CAAC,AAdD,IAcC;ACdD,IAAI,SAAS,GAAE,IAAI,SAAS,EAAE,CAAC;AAC/B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;AAC7B,mBAAmB;AACnB,6DAA6D;AAC7D,yCAAyC;AACzC,wDAAwD;AAExD,sBAAsB;AACtB,sBAAsB;AACtB,eAAe;AACf,oCAAoC;AACpC,uBAAuB;AACvB,uBAAuB;AACvB,uBAAuB;AACvB,mCAAmC;AACnC,6BAA6B;AAC7B,gCAAgC;AAChC,oCAAoC;AACpC,qBAAqB;AACrB,IAAI;AACJ,iEAAiE;AACjE,iEAAiE"} \ No newline at end of file diff --git a/ts/BlackJack.ts b/ts/BlackJack.ts new file mode 100644 index 00000000..261cb868 --- /dev/null +++ b/ts/BlackJack.ts @@ -0,0 +1,134 @@ +class BlackJack { + public playerHand; + public dealerHand; + public gameDeck = new Deck(); + + constructor() { + this.playerHand = new Hand(); + this.dealerHand = new Hand(); + this.gameDeck = new Deck(); + } + //deal two cards to player + //check player score. If player or dealer= 21--gameover + //player hit or stay. if hit, deal card. check score. if above 21: busted. + //if player stay:: deal two cards to dealer. + //if dealer below 17: deal again. + public println(input){ + display.innerHTML = input; + } + + public startGameDealTwoToPlayer() { + this.playerHand.addCard(this.gameDeck.draw()); + this.playerHand.addCard(this.gameDeck.draw()); + } + + public startGameDealTwoToDealer() { + this.dealerHand.addCard(this.gameDeck.draw()); + this.dealerHand.addCard(this.gameDeck.draw()); + } + + public play() { + this.startGameDealTwoToPlayer(); + this.startGameDealTwoToDealer(); + let gameOver = this.checkBlackJack(); + if(!gameOver){ + this.println('
' +"Dealer's face up card is a " + this.dealerHand.handOfCards[0].toCardName + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+'
'); + } + } + + public checkBlackJack(){ + if(this.checkPlayerBlackJack()){ + if(this.checkDealerBlackJack()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "It's a Push"); + return true; + } else{ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "You Win!"); + return true; + } + } else if(this.checkDealerBlackJack()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "You Lose!"); + return true; + } else return false; + } + + public getWinner(){ + let gameOver = this.checkBlackJack(); + + } + + public stay(){ + //this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + //+ "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
'); + //if(this.dealerHand.handValue() < 17){ + if(this.dealerHand.handValue() < 17){ + do{ + this.dealerHand.addCard(this.gameDeck.draw()) + } while(this.dealerHand.handValue() < 17){ + if(this.dealerHand.handValue() > 22){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "You Win!"); + } + if(this.dealerHand.handValue() < 22 && this.dealerHand.handValue() > this.playerHand.handValue()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "You Lose!"); + } else if(this.playerHand.handValue() < 22 && this.playerHand.handValue() > this.dealerHand.handValue()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "You Win!"); + } else if(this.playerHand.handValue() == this.dealerHand.handValue()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "It's a Push"); + } + } + } + + + if(this.dealerHand.handValue() < 22 && this.dealerHand.handValue() > this.playerHand.handValue()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "You Lose!"); + } else if(this.playerHand.handValue() < 22 && this.playerHand.handValue() > this.dealerHand.handValue()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "You Win!"); + } else if(this.playerHand.handValue() == this.dealerHand.handValue()){ + this.println('
' +"Dealer's cards:" + this.dealerHand.handToString() + this.dealerHand.handValue() + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+ '
' + + "It's a Push"); + } + } + + + public checkPlayerBlackJack(){ + return this.playerHand.handValue() === 21; + } + + public checkDealerBlackJack(){ + return this.dealerHand.handValue() === 21; + } + + public hit(){ + //this.playerHand.addCard(this.gameDeck.draw()); + let gameOver = this.checkBlackJack() || this.playerHand.handValue() > 22; + if(!gameOver){ + this.playerHand.addCard(this.gameDeck.draw()); + this.println('
' +"Dealer's face up card is a " + this.dealerHand.handOfCards[0].toCardName + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+'
'); + } + if(this.playerHand.handValue() > 21){ + this.println('
' +"Dealer's face up card is a " + this.dealerHand.handOfCards[0].toCardName + '
' + + "Your cards: " + this.playerHand.handToString()+" Your hand value = "+ this.playerHand.handValue()+'
' + + "Bust! You lose!"); + } + } +} \ No newline at end of file diff --git a/ts/Card.ts b/ts/Card.ts new file mode 100644 index 00000000..6c447432 --- /dev/null +++ b/ts/Card.ts @@ -0,0 +1,89 @@ +enum Suit { + Spades, + Clubs, + Hearts, + Diamonds, +}; + +class Card { + public rank: number; + public suit: number; + public _value: number; + + public constructor (rank: number, suit: Suit) { + this.rank = rank; + this.suit = suit; + } + + public static rankNames = [ + 'Ace', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '10', + 'Jack', + 'Queen', + 'King', + ]; + + public get rankName(): string { + return Card.rankNames[this.rank - 1]; + } + + public get suitName(): string { + return Suit[this.suit]; + } + + public get toCardName(): string { + return this.rankName + ' of ' + this.suitName; + } + + public get value(): number{ + if(this.rankName === 'Ace'){ + return 1; + } + else if(this.rankName === '2'){ + return 2; + } + else if(this.rankName === '3'){ + return 3; + } + else if(this.rankName === '4'){ + return 4; + } + else if(this.rankName === '5'){ + return 5; + } + else if(this.rankName === '6'){ + return 6; + } + else if(this.rankName === '7'){ + return 7; + } + else if(this.rankName === '8'){ + return 8; + } + else if(this.rankName === '9'){ + return 9; + } + else if(this.rankName === '10'){ + return 10; + } + else if(this.rankName === 'Jack'){ + return 10; + } + else if(this.rankName === 'Queen'){ + return 10; + } + else if(this.rankName === 'King'){ + return 10; + }else{ + return 0; + } + } +} \ No newline at end of file diff --git a/ts/Deck.ts b/ts/Deck.ts new file mode 100644 index 00000000..ee81e4c2 --- /dev/null +++ b/ts/Deck.ts @@ -0,0 +1,25 @@ +class Deck { + private cards: Card[]; + + public constructor () { + this.cards = []; + for (let s = 0; s < 4; s++) { + for (let r = 1; r <= 13; r++) { + this.cards.push(new Card(r, s)); + } + } + } + + public shuffle(): void { + for (var i = 0; i < this.cards.length; i++) { + var j = Math.floor(Math.random() * this.cards.length); + var temp = this.cards[i]; + this.cards[i] = this.cards[j]; + this.cards[j] = temp; + } +} + + public draw(): Card { + return this.cards.shift(); + } +} \ No newline at end of file diff --git a/ts/Hand.ts b/ts/Hand.ts new file mode 100644 index 00000000..00b50ffe --- /dev/null +++ b/ts/Hand.ts @@ -0,0 +1,45 @@ +class Hand { + + handOfCards: Card[]; + + public constructor() { + this.handOfCards = []; + } + public addCard(Card) { + this.handOfCards.push(Card); + } + public numberOfCardsInHand(): number { + return this.handOfCards.length; + } + + public handToString(): string{ + var cardsInHand = ''; + for (var i = 0; i < this.handOfCards.length; i++) { + cardsInHand += this.handOfCards[i].toCardName + ' / '; + } + return cardsInHand; + } + + public handValue(): number{ + var isAce:boolean = false; + var size: Number = this.numberOfCardsInHand(); + var totalHandValue: number = 0; + + for (var i = 0; i < size; i++) { + totalHandValue += this.handOfCards[i].value; + if (this.handOfCards[i].value === 1) { + isAce = true; + } + } + //if there is an Ace present (previously counted as 1) and total is 11 or less, + //add 10 so ace is worth 11 + if (isAce && totalHandValue <= 11) { + return totalHandValue + 10; + } else { + return totalHandValue; + } + } + + + +} \ No newline at end of file diff --git a/ts/Player.ts b/ts/Player.ts new file mode 100644 index 00000000..b949b08a --- /dev/null +++ b/ts/Player.ts @@ -0,0 +1,15 @@ +class Player { + name: string; + + public constructor () { + this.name = name; + } + + public get getName (): string { + return this.name; + } + + public set setName(usernameInput: string){ + this.name = usernameInput; + } +} \ No newline at end of file diff --git a/ts/run.js b/ts/run.js new file mode 100644 index 00000000..3918c74e --- /dev/null +++ b/ts/run.js @@ -0,0 +1 @@ +"use strict"; diff --git a/ts/run.ts b/ts/run.ts new file mode 100644 index 00000000..1f6cfd81 --- /dev/null +++ b/ts/run.ts @@ -0,0 +1,22 @@ +let blackJack= new BlackJack(); +blackJack.gameDeck.shuffle(); +//blackJack.play(); +// display.innerHTML+= gameRunner.startGameDealTwoToPlayer(); +// gameRunner.startGameDealTwoToDealer(); +//display.innerHTML+= "
"+ gameRunner.askHitOrStay(); + +// let d = new Deck(); +// let h = new Hand(); +// d.shuffle(); +// console.log(d.draw().toCardName); +// h.addCard(d.draw()); +// h.addCard(d.draw()); +// h.addCard(d.draw()); +// let test1 = d.draw().toCardName; +// let test2 =d.draw().value; +// let test3 = h.handToString(); +// function greeter(person):string { +// return person; +// } +//document.getElementById("display1").innerHTML = greeter(test2); +//document.getElementById("display2").innerHTML = greeter(test3); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..39b01d69 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "outFile": "./js/app.js", + "target": "es5", + "noImplicitThis": true, + "strictNullChecks": true, + "sourceMap": true + }, + "include": [ + "./ts/**.ts" + ] +} \ No newline at end of file