From bd5d71e22c6c12c2e9d8659348105b201360763e Mon Sep 17 00:00:00 2001 From: Bo Lee Date: Sun, 25 Mar 2018 21:38:21 -0400 Subject: [PATCH 1/2] In progress --- .vscode/launch.json | 24 +++++++++++++++++++ .vscode/tasks.json | 24 +++++++++++++++++++ Bins.js | 13 +++++++++++ Bins.ts | 16 +++++++++++++ Blackjack.js | 36 ++++++++++++++++++++++++++++ Blackjack.ts | 36 ++++++++++++++++++++++++++++ Card.js | 17 ++++++++++++++ Card.ts | 19 +++++++++++++++ CardRank.js | 17 ++++++++++++++ CardRank.ts | 16 +++++++++++++ Dealer.js | 18 ++++++++++++++ Dealer.ts | 5 ++++ Deck.js | 41 ++++++++++++++++++++++++++++++++ Deck.ts | 51 ++++++++++++++++++++++++++++++++++++++++ Dice.js | 14 +++++++++++ Dice.ts | 15 ++++++++++++ Player.js | 17 ++++++++++++++ Player.ts | 16 +++++++++++++ PlayerInterface.js | 1 + PlayerInterface.ts | 6 +++++ Profile.js | 9 +++++++ Profile.ts | 15 ++++++++++++ Suit.js | 8 +++++++ Suit.ts | 6 +++++ css/style.css | 1 + index.html | 33 ++++++++++++++++++++++++-- js/app.js | 2 ++ tsconfig.json | 57 +++++++++++++++++++++++++++++++++++++++++++++ 28 files changed, 531 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 Bins.js create mode 100644 Bins.ts create mode 100644 Blackjack.js create mode 100644 Blackjack.ts create mode 100644 Card.js create mode 100644 Card.ts create mode 100644 CardRank.js create mode 100644 CardRank.ts create mode 100644 Dealer.js create mode 100644 Dealer.ts create mode 100644 Deck.js create mode 100644 Deck.ts create mode 100644 Dice.js create mode 100644 Dice.ts create mode 100644 Player.js create mode 100644 Player.ts create mode 100644 PlayerInterface.js create mode 100644 PlayerInterface.ts create mode 100644 Profile.js create mode 100644 Profile.ts create mode 100644 Suit.js create mode 100644 Suit.ts create mode 100644 js/app.js create mode 100644 tsconfig.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..e4c5fec2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // 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": "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/Bins.js b/Bins.js new file mode 100644 index 00000000..5e448498 --- /dev/null +++ b/Bins.js @@ -0,0 +1,13 @@ +"use strict"; +var Bins = /** @class */ (function () { + function Bins(startingBound, endingBound, rollSums) { + if (rollSums === void 0) { rollSums = []; } + this.endingBound = this.startingBound * 6; + this.rollSums = []; + this.startingBound = startingBound; + this.endingBound = endingBound; + this.rollSums = rollSums; + } + ; + return Bins; +}()); diff --git a/Bins.ts b/Bins.ts new file mode 100644 index 00000000..1d6131c3 --- /dev/null +++ b/Bins.ts @@ -0,0 +1,16 @@ +class Bins{ + startingBound: number; + endingBound = this.startingBound * 6;; + rollSums = []; + + constructor(startingBound:number, endingBound:number, rollSums:any = []){ + this.startingBound = startingBound; + this.endingBound = endingBound; + this.rollSums = rollSums; + } + + // incrementBins(value:number){ + // this.rollSums[value] =this.rollSums[value]+1; + // } + +} \ No newline at end of file diff --git a/Blackjack.js b/Blackjack.js new file mode 100644 index 00000000..8b867cf8 --- /dev/null +++ b/Blackjack.js @@ -0,0 +1,36 @@ +"use strict"; +var Blackjack = /** @class */ (function () { + function Blackjack() { + this.dealer = new Dealer(); + this.player = new Player(); + this.dealerHand = []; + this.playerHand = []; + this.deck = new Deck(); + } + // getWinner(dealer.ge) + // playAsDealer(){ + // var dealer = new Hand(); + // while(dealer.score() < 17){ + // dealer.hitMe(); + // } + // return dealer; + // } + 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..a010020b --- /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(hand:Card []){ + var card1 =this.deck.dealCard; + var card2 = this.deck.dealCard; + hand.push(card1); + return hand; + } + + getHand(hand : Card[]){ + return hand.toString + } + + hit(hand : Card[]){ + var addedCard = this.deck.dealCard; + hand.push(this.deck.dealCard); + } + 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..518289df --- /dev/null +++ b/Card.ts @@ -0,0 +1,19 @@ + +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(); + } +} \ No newline at end of file diff --git a/CardRank.js b/CardRank.js new file mode 100644 index 00000000..54248f48 --- /dev/null +++ b/CardRank.js @@ -0,0 +1,17 @@ +"use strict"; +var CardRank; +(function (CardRank) { + CardRank[CardRank["ACE"] = 1 || 11] = "ACE"; + CardRank[CardRank["TWO"] = 2] = "TWO"; + CardRank[CardRank["THREE"] = 3] = "THREE"; + CardRank[CardRank["FOUR"] = 4] = "FOUR"; + CardRank[CardRank["FIVE"] = 5] = "FIVE"; + CardRank[CardRank["SIX"] = 6] = "SIX"; + CardRank[CardRank["SEVEN"] = 7] = "SEVEN"; + CardRank[CardRank["EIGHT"] = 8] = "EIGHT"; + CardRank[CardRank["NINE"] = 9] = "NINE"; + CardRank[CardRank["TEN"] = 10] = "TEN"; + CardRank[CardRank["JACK"] = 10] = "JACK"; + CardRank[CardRank["QUEEN"] = 10] = "QUEEN"; + CardRank[CardRank["KING"] = 10] = "KING"; +})(CardRank || (CardRank = {})); diff --git a/CardRank.ts b/CardRank.ts new file mode 100644 index 00000000..b16b7556 --- /dev/null +++ b/CardRank.ts @@ -0,0 +1,16 @@ +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 + +} \ No newline at end of file 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/Dice.js b/Dice.js new file mode 100644 index 00000000..4974d346 --- /dev/null +++ b/Dice.js @@ -0,0 +1,14 @@ +"use strict"; +var Dice = /** @class */ (function () { + function Dice(numOfDice) { + this.numOfDice = numOfDice; + } + Dice.prototype.tossAndSum = function () { + var sumOfToss = 0; + for (var toss = 0; toss < this.numOfDice; toss++) { + sumOfToss += Math.floor(Math.random() * 6); + } + return sumOfToss; + }; + return Dice; +}()); diff --git a/Dice.ts b/Dice.ts new file mode 100644 index 00000000..1f03bf01 --- /dev/null +++ b/Dice.ts @@ -0,0 +1,15 @@ +class Dice{ + numOfDice: number; + + constructor(numOfDice:number){ + this.numOfDice = numOfDice; + } + + tossAndSum(){ + var sumOfToss: number = 0; + for(var toss = 0; toss < this.numOfDice; toss++){ + sumOfToss+=Math.floor(Math.random()*6); + } + return sumOfToss; + } +} \ No newline at end of file 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..242962ef --- /dev/null +++ b/Profile.ts @@ -0,0 +1,15 @@ +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; + + } + +} + diff --git a/Suit.js b/Suit.js new file mode 100644 index 00000000..34582c83 --- /dev/null +++ b/Suit.js @@ -0,0 +1,8 @@ +"use strict"; +var Suit; +(function (Suit) { + Suit[Suit["CLUB"] = 1] = "CLUB"; + Suit[Suit["DIAMOND"] = 2] = "DIAMOND"; + Suit[Suit["HEART"] = 3] = "HEART"; + Suit[Suit["SPADE"] = 4] = "SPADE"; +})(Suit || (Suit = {})); diff --git a/Suit.ts b/Suit.ts new file mode 100644 index 00000000..75599f9c --- /dev/null +++ b/Suit.ts @@ -0,0 +1,6 @@ +enum Suit { + CLUB = 1, + DIAMOND = 2, + HEART = 3, + SPADE =4 +} \ No newline at end of file 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..883cd5e7 100644 --- a/index.html +++ b/index.html @@ -19,13 +19,42 @@

TypeScript Casino

-
+ +
+ + +
+ + + + + + + + +

Blackjack

+ + + + +
+
+
Your Score: 0 Record: 0 / 0
+ + + +
+
- + + + + + diff --git a/js/app.js b/js/app.js new file mode 100644 index 00000000..99bd3d77 --- /dev/null +++ b/js/app.js @@ -0,0 +1,2 @@ +console.log("hello world"); +let currentCard = Deck.currentCard; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..cb57cd13 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,57 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file From 1e0fa02b5561d7536d76b1e2d5189d9cee3e065a Mon Sep 17 00:00:00 2001 From: Bo Lee Date: Sun, 25 Mar 2018 22:27:21 -0400 Subject: [PATCH 2/2] Need to continue with Blackjack.ts --- .vscode/launch.json | 7 ++++++- Bins.js | 13 ------------- Bins.ts | 16 ---------------- Blackjack.js | 9 +-------- Blackjack.ts | 14 +++++++------- Card.ts | 25 ++++++++++++++++++++++++- CardRank.js | 17 ----------------- CardRank.ts | 16 ---------------- Dice.js | 14 -------------- Dice.ts | 15 --------------- Profile.ts | 14 ++++++++++++++ Suit.js | 8 -------- Suit.ts | 6 ------ index.html | 4 ++-- 14 files changed, 54 insertions(+), 124 deletions(-) delete mode 100644 Bins.js delete mode 100644 Bins.ts delete mode 100644 CardRank.js delete mode 100644 CardRank.ts delete mode 100644 Dice.js delete mode 100644 Dice.ts delete mode 100644 Suit.js delete mode 100644 Suit.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index e4c5fec2..081e1f6e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,7 +4,12 @@ // 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", diff --git a/Bins.js b/Bins.js deleted file mode 100644 index 5e448498..00000000 --- a/Bins.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -var Bins = /** @class */ (function () { - function Bins(startingBound, endingBound, rollSums) { - if (rollSums === void 0) { rollSums = []; } - this.endingBound = this.startingBound * 6; - this.rollSums = []; - this.startingBound = startingBound; - this.endingBound = endingBound; - this.rollSums = rollSums; - } - ; - return Bins; -}()); diff --git a/Bins.ts b/Bins.ts deleted file mode 100644 index 1d6131c3..00000000 --- a/Bins.ts +++ /dev/null @@ -1,16 +0,0 @@ -class Bins{ - startingBound: number; - endingBound = this.startingBound * 6;; - rollSums = []; - - constructor(startingBound:number, endingBound:number, rollSums:any = []){ - this.startingBound = startingBound; - this.endingBound = endingBound; - this.rollSums = rollSums; - } - - // incrementBins(value:number){ - // this.rollSums[value] =this.rollSums[value]+1; - // } - -} \ No newline at end of file diff --git a/Blackjack.js b/Blackjack.js index 8b867cf8..e6a0af28 100644 --- a/Blackjack.js +++ b/Blackjack.js @@ -7,14 +7,7 @@ var Blackjack = /** @class */ (function () { this.playerHand = []; this.deck = new Deck(); } - // getWinner(dealer.ge) - // playAsDealer(){ - // var dealer = new Hand(); - // while(dealer.score() < 17){ - // dealer.hitMe(); - // } - // return dealer; - // } + Blackjack.prototype.newHand = function (hand) { var card1 = this.deck.dealCard; var card2 = this.deck.dealCard; diff --git a/Blackjack.ts b/Blackjack.ts index a010020b..721259d9 100644 --- a/Blackjack.ts +++ b/Blackjack.ts @@ -5,21 +5,21 @@ class Blackjack { public playerHand = []; public deck = new Deck(); - newHand(hand:Card []){ + newHand(){ var card1 =this.deck.dealCard; var card2 = this.deck.dealCard; - hand.push(card1); - return hand; + var cards = [card1, card2]; + return cards; } getHand(hand : Card[]){ return hand.toString } - hit(hand : Card[]){ - var addedCard = this.deck.dealCard; - hand.push(this.deck.dealCard); - } + // hit(hand : Card[]){ + // var addedCard = this.deck.dealCard; + // hand.push(addedCard); + // } getWinner(){ } diff --git a/Card.ts b/Card.ts index 518289df..397f09a4 100644 --- a/Card.ts +++ b/Card.ts @@ -1,3 +1,25 @@ +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{ @@ -16,4 +38,5 @@ class Card{ showCard():string { return this.getValue + " of " + this.getSuit(); } -} \ No newline at end of file +} + diff --git a/CardRank.js b/CardRank.js deleted file mode 100644 index 54248f48..00000000 --- a/CardRank.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -var CardRank; -(function (CardRank) { - CardRank[CardRank["ACE"] = 1 || 11] = "ACE"; - CardRank[CardRank["TWO"] = 2] = "TWO"; - CardRank[CardRank["THREE"] = 3] = "THREE"; - CardRank[CardRank["FOUR"] = 4] = "FOUR"; - CardRank[CardRank["FIVE"] = 5] = "FIVE"; - CardRank[CardRank["SIX"] = 6] = "SIX"; - CardRank[CardRank["SEVEN"] = 7] = "SEVEN"; - CardRank[CardRank["EIGHT"] = 8] = "EIGHT"; - CardRank[CardRank["NINE"] = 9] = "NINE"; - CardRank[CardRank["TEN"] = 10] = "TEN"; - CardRank[CardRank["JACK"] = 10] = "JACK"; - CardRank[CardRank["QUEEN"] = 10] = "QUEEN"; - CardRank[CardRank["KING"] = 10] = "KING"; -})(CardRank || (CardRank = {})); diff --git a/CardRank.ts b/CardRank.ts deleted file mode 100644 index b16b7556..00000000 --- a/CardRank.ts +++ /dev/null @@ -1,16 +0,0 @@ -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 - -} \ No newline at end of file diff --git a/Dice.js b/Dice.js deleted file mode 100644 index 4974d346..00000000 --- a/Dice.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -var Dice = /** @class */ (function () { - function Dice(numOfDice) { - this.numOfDice = numOfDice; - } - Dice.prototype.tossAndSum = function () { - var sumOfToss = 0; - for (var toss = 0; toss < this.numOfDice; toss++) { - sumOfToss += Math.floor(Math.random() * 6); - } - return sumOfToss; - }; - return Dice; -}()); diff --git a/Dice.ts b/Dice.ts deleted file mode 100644 index 1f03bf01..00000000 --- a/Dice.ts +++ /dev/null @@ -1,15 +0,0 @@ -class Dice{ - numOfDice: number; - - constructor(numOfDice:number){ - this.numOfDice = numOfDice; - } - - tossAndSum(){ - var sumOfToss: number = 0; - for(var toss = 0; toss < this.numOfDice; toss++){ - sumOfToss+=Math.floor(Math.random()*6); - } - return sumOfToss; - } -} \ No newline at end of file diff --git a/Profile.ts b/Profile.ts index 242962ef..bf83b325 100644 --- a/Profile.ts +++ b/Profile.ts @@ -11,5 +11,19 @@ class Profile{ } + getId(){ + return this.id; + } + + getName(){ + return this.name; + } + + getBalance(){ + return this.balance; + } + } +var username = document.getElementById("username"); +console.log(username); diff --git a/Suit.js b/Suit.js deleted file mode 100644 index 34582c83..00000000 --- a/Suit.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -var Suit; -(function (Suit) { - Suit[Suit["CLUB"] = 1] = "CLUB"; - Suit[Suit["DIAMOND"] = 2] = "DIAMOND"; - Suit[Suit["HEART"] = 3] = "HEART"; - Suit[Suit["SPADE"] = 4] = "SPADE"; -})(Suit || (Suit = {})); diff --git a/Suit.ts b/Suit.ts deleted file mode 100644 index 75599f9c..00000000 --- a/Suit.ts +++ /dev/null @@ -1,6 +0,0 @@ -enum Suit { - CLUB = 1, - DIAMOND = 2, - HEART = 3, - SPADE =4 -} \ No newline at end of file diff --git a/index.html b/index.html index 883cd5e7..ea752a8e 100644 --- a/index.html +++ b/index.html @@ -33,10 +33,10 @@

TypeScript Casino

Blackjack

- + - +
Your Score: 0 Record: 0 / 0