diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..081e1f6e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "attach", + "name": "Attach", + "port": 9229 + }, + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/app.js" + }, + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/Blackjack.ts", + "outFiles": [ + "${workspaceFolder}/**/*.js" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..3b498ffa --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,24 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "msbuild", + "args": [ + // Ask msbuild to generate full paths for file names. + "/property:GenerateFullPaths=true", + "/t:build" + ], + "group": "build", + "presentation": { + // Reveal the output only if unrecognized errors occur. + "reveal": "silent" + }, + // Use the standard MS compiler pattern to detect errors, warnings and infos + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Blackjack.js b/Blackjack.js new file mode 100644 index 00000000..e6a0af28 --- /dev/null +++ b/Blackjack.js @@ -0,0 +1,29 @@ +"use strict"; +var Blackjack = /** @class */ (function () { + function Blackjack() { + this.dealer = new Dealer(); + this.player = new Player(); + this.dealerHand = []; + this.playerHand = []; + this.deck = new Deck(); + } + + Blackjack.prototype.newHand = function (hand) { + var card1 = this.deck.dealCard; + var card2 = this.deck.dealCard; + var hand = [card1, card2]; + return hand; + }; + Blackjack.prototype.getHand = function (hand) { + return hand.toString; + }; + Blackjack.prototype.hit = function (hand) { + var addedCard = this.deck.dealCard; + hand.push(this.deck.dealCard); + }; + Blackjack.prototype.getWinner = function () { + }; + Blackjack.prototype.startGame = function () { + }; + return Blackjack; +}()); diff --git a/Blackjack.ts b/Blackjack.ts new file mode 100644 index 00000000..721259d9 --- /dev/null +++ b/Blackjack.ts @@ -0,0 +1,36 @@ +class Blackjack { + public dealer = new Dealer(); + public player = new Player(); + public dealerHand = []; + public playerHand = []; + public deck = new Deck(); + + newHand(){ + var card1 =this.deck.dealCard; + var card2 = this.deck.dealCard; + var cards = [card1, card2]; + return cards; + } + + getHand(hand : Card[]){ + return hand.toString + } + + // hit(hand : Card[]){ + // var addedCard = this.deck.dealCard; + // hand.push(addedCard); + // } + getWinner(){ + + } + startGame(){ + } + + + +} + + + + + diff --git a/Card.js b/Card.js new file mode 100644 index 00000000..f8f80496 --- /dev/null +++ b/Card.js @@ -0,0 +1,17 @@ +"use strict"; +var Card = /** @class */ (function () { + function Card(suit, value) { + this.suit = suit; + this.value = value; + } + Card.prototype.getSuit = function () { + return Suit[this.suit]; + }; + Card.prototype.getValue = function () { + return CardRank[this.value]; + }; + Card.prototype.showCard = function () { + return this.getValue + " of " + this.getSuit(); + }; + return Card; +}()); diff --git a/Card.ts b/Card.ts new file mode 100644 index 00000000..397f09a4 --- /dev/null +++ b/Card.ts @@ -0,0 +1,42 @@ +enum Suit { + CLUB = 1, + DIAMOND = 2, + HEART = 3, + SPADE =4 +} + +enum CardRank{ + ACE = 1 || 11, + TWO = 2, + THREE = 3, + FOUR = 4, + FIVE = 5, + SIX = 6, + SEVEN = 7, + EIGHT = 8, + NINE = 9, + TEN = 10, + JACK = 10, + QUEEN = 10, + KING = 10 +} + +class Card{ + + constructor(public suit: Suit, public value: CardRank){ + + } + + getSuit():string { + return Suit[this.suit]; + } + + getValue():string { + return CardRank[this.value]; + } + + showCard():string { + return this.getValue + " of " + this.getSuit(); + } +} + diff --git a/Dealer.js b/Dealer.js new file mode 100644 index 00000000..36044f57 --- /dev/null +++ b/Dealer.js @@ -0,0 +1,18 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Dealer = /** @class */ (function (_super) { + __extends(Dealer, _super); + function Dealer() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Dealer; +}(Player)); diff --git a/Dealer.ts b/Dealer.ts new file mode 100644 index 00000000..c9e86ec2 --- /dev/null +++ b/Dealer.ts @@ -0,0 +1,5 @@ +class Dealer extends Player{ + + + +} \ No newline at end of file diff --git a/Deck.js b/Deck.js new file mode 100644 index 00000000..7b18fb9d --- /dev/null +++ b/Deck.js @@ -0,0 +1,41 @@ +"use strict"; +var Deck = /** @class */ (function () { + function Deck() { + this.cards = []; + this.shuffle(); + } + Deck.prototype.newCards = function () { + for (var i = 1; i <= 4; i++) { + for (var n = 1; n <= 13; n++) { + this.cards.push(new Card(i, n)); + } + } + return this.cards; + }; + Deck.prototype.shuffle = function () { + this.cards = []; + for (var suitIndex = 0; suitIndex < 4; suitIndex++) { + for (var cardRankIndex = 0; cardRankIndex < 13; cardRankIndex++) { + this.cards.push(new Card(suitIndex, cardRankIndex)); + } + } + var currentIndex = this.cards.length; + var swap; + var randomIndex; + //always puts a random card in the last index and moves the previous index + while (0 !== currentIndex) { + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex -= 1; + swap = this.cards[currentIndex]; + this.cards[currentIndex] = this.cards[randomIndex]; + this.cards[randomIndex] = swap; + } + }; + Deck.prototype.cardsLeft = function () { + return this.cards.length; + }; + Deck.prototype.dealCard = function () { + return this.cards.shift(); + }; + return Deck; +}()); diff --git a/Deck.ts b/Deck.ts new file mode 100644 index 00000000..275f4d65 --- /dev/null +++ b/Deck.ts @@ -0,0 +1,51 @@ +class Deck { + + public cards: Card[] = []; + + constructor(){ + this.shuffle(); + } + + newCards():Card[] { + for(var i = 1; i <= 4; i++){ + for(var n = 1; n <= 13; n++){ + this.cards.push(new Card(i,n)); + } + } + return this.cards; + } + + shuffle():void{ + this.cards = []; + for(var suitIndex = 0; suitIndex < 4; suitIndex++){ + for(var cardRankIndex = 0; cardRankIndex< 13; cardRankIndex++){ + this.cards.push(new Card(suitIndex, cardRankIndex)) + } + } + + var currentIndex: number = this.cards.length; + var swap: Card; + var randomIndex: number; +//always puts a random card in the last index and moves the previous index + while (0 !== currentIndex) { + + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex -= 1; + + swap = this.cards[currentIndex]; + + this.cards[currentIndex] = this.cards[randomIndex]; + this.cards[randomIndex] = swap; + } + } + cardsLeft(){ + return this.cards.length; + } + + dealCard(){ + return this.cards.shift(); + } + +} + + diff --git a/Player.js b/Player.js new file mode 100644 index 00000000..e8ebe9c7 --- /dev/null +++ b/Player.js @@ -0,0 +1,17 @@ +"use strict"; +var Player = /** @class */ (function () { + function Player() { + this.cards = []; + this.stacks = []; + } + Player.prototype.getProfile = function () { + throw new Error("Method not implemented."); + }; + Player.prototype.getName = function () { + throw new Error("Method not implemented."); + }; + Player.prototype.getId = function () { + throw new Error("Method not implemented."); + }; + return Player; +}()); diff --git a/Player.ts b/Player.ts new file mode 100644 index 00000000..8add7275 --- /dev/null +++ b/Player.ts @@ -0,0 +1,16 @@ +class Player implements PlayerInterface { + getProfile(): Profile { + throw new Error("Method not implemented."); + } + getName(): string { + throw new Error("Method not implemented."); + } + getId(): number { + throw new Error("Method not implemented."); + } + + public cards: Card[] = []; + public stacks:Card[] = []; + + +} \ No newline at end of file diff --git a/PlayerInterface.js b/PlayerInterface.js new file mode 100644 index 00000000..3918c74e --- /dev/null +++ b/PlayerInterface.js @@ -0,0 +1 @@ +"use strict"; diff --git a/PlayerInterface.ts b/PlayerInterface.ts new file mode 100644 index 00000000..1ffd9b3e --- /dev/null +++ b/PlayerInterface.ts @@ -0,0 +1,6 @@ +interface PlayerInterface { + + getProfile(): Profile; + getName() :string; + getId(): number; +} diff --git a/Profile.js b/Profile.js new file mode 100644 index 00000000..de8e2712 --- /dev/null +++ b/Profile.js @@ -0,0 +1,9 @@ +"use strict"; +var Profile = /** @class */ (function () { + function Profile(profileId, username, balance) { + this.id = profileId; + this.name = username; + this.balance = balance; + } + return Profile; +}()); diff --git a/Profile.ts b/Profile.ts new file mode 100644 index 00000000..bf83b325 --- /dev/null +++ b/Profile.ts @@ -0,0 +1,29 @@ +class Profile{ + + private id:string; + private name: string; + private balance: number; + + constructor (profileId:string, username: any, balance:number){ + this.id = profileId; + this.name = username; + this.balance = balance; + + } + + getId(){ + return this.id; + } + + getName(){ + return this.name; + } + + getBalance(){ + return this.balance; + } + +} + +var username = document.getElementById("username"); +console.log(username); diff --git a/css/style.css b/css/style.css index cc704eef..0b9a43a1 100644 --- a/css/style.css +++ b/css/style.css @@ -113,6 +113,7 @@ article p { margin-bottom: 20px;} section {margin:10px;} h1 {font-weight: bold; margin-left: 10px;} #main { + } #display { diff --git a/index.html b/index.html index d2c3c254..ea752a8e 100644 --- a/index.html +++ b/index.html @@ -19,13 +19,42 @@