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 @@

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