From bf0e936181237de1cc078a13d685944caafc8f3f Mon Sep 17 00:00:00 2001 From: Kibret Tecle Date: Sun, 25 Mar 2018 18:54:05 -0400 Subject: [PATCH 1/3] saving --- ts/Card.ts | 24 +++++++++++++++ ts/CardSuit.ts | 6 ++++ ts/Casino.ts | 39 +++++++++++++++++++++++++ ts/Deck.ts | 50 ++++++++++++++++++++++++++++++++ ts/Gamble.ts | 0 ts/GameEngine.ts | 0 ts/GameEngineInterface.ts | 0 ts/GameInterface.ts | 0 ts/GoFish.ts | 18 ++++++++++++ ts/Hand.ts | 30 +++++++++++++++++++ ts/Player.ts | 16 ++++++++++ ts/PlayerInterface.ts | 0 ts/Profile.ts | 31 ++++++++++++++++++++ ts/app.js | 12 ++++++++ ts/app.js.map | 1 + ts/app.ts | 13 +++++++++ ts/casinoProject | 0 ts/enum CardRank.ts | 16 ++++++++++ ts/js/Card.js | 20 +++++++++++++ ts/js/Card.js.map | 1 + ts/js/CardSuit.js | 8 +++++ ts/js/CardSuit.js.map | 1 + ts/js/Casino.js | 31 ++++++++++++++++++++ ts/js/Casino.js.map | 1 + ts/js/Deck.js | 43 +++++++++++++++++++++++++++ ts/js/Deck.js.map | 1 + ts/js/Gamble.js | 1 + ts/js/Gamble.js.map | 1 + ts/js/GameEngine.js | 1 + ts/js/GameEngine.js.map | 1 + ts/js/GameEngineInterface.js | 1 + ts/js/GameEngineInterface.js.map | 1 + ts/js/GameInterface.js | 1 + ts/js/GameInterface.js.map | 1 + ts/js/GoFish.js | 27 +++++++++++++++++ ts/js/GoFish.js.map | 1 + ts/js/Hand.js | 29 ++++++++++++++++++ ts/js/Hand.js.map | 1 + ts/js/Player.js | 15 ++++++++++ ts/js/Player.js.map | 1 + ts/js/PlayerInterface.js | 1 + ts/js/PlayerInterface.js.map | 1 + ts/js/Profile.js | 27 +++++++++++++++++ ts/js/Profile.js.map | 1 + ts/js/app.js | 12 ++++++++ ts/js/app.js.map | 1 + ts/js/enum CardRank.js | 17 +++++++++++ ts/js/enum CardRank.js.map | 1 + 48 files changed, 505 insertions(+) create mode 100644 ts/Card.ts create mode 100644 ts/CardSuit.ts create mode 100644 ts/Casino.ts create mode 100644 ts/Deck.ts create mode 100644 ts/Gamble.ts create mode 100644 ts/GameEngine.ts create mode 100644 ts/GameEngineInterface.ts create mode 100644 ts/GameInterface.ts create mode 100644 ts/GoFish.ts create mode 100644 ts/Hand.ts create mode 100644 ts/Player.ts create mode 100644 ts/PlayerInterface.ts create mode 100644 ts/Profile.ts create mode 100644 ts/app.js create mode 100644 ts/app.js.map create mode 100644 ts/app.ts create mode 100644 ts/casinoProject create mode 100644 ts/enum CardRank.ts create mode 100644 ts/js/Card.js create mode 100644 ts/js/Card.js.map create mode 100644 ts/js/CardSuit.js create mode 100644 ts/js/CardSuit.js.map create mode 100644 ts/js/Casino.js create mode 100644 ts/js/Casino.js.map create mode 100644 ts/js/Deck.js create mode 100644 ts/js/Deck.js.map create mode 100644 ts/js/Gamble.js create mode 100644 ts/js/Gamble.js.map create mode 100644 ts/js/GameEngine.js create mode 100644 ts/js/GameEngine.js.map create mode 100644 ts/js/GameEngineInterface.js create mode 100644 ts/js/GameEngineInterface.js.map create mode 100644 ts/js/GameInterface.js create mode 100644 ts/js/GameInterface.js.map create mode 100644 ts/js/GoFish.js create mode 100644 ts/js/GoFish.js.map create mode 100644 ts/js/Hand.js create mode 100644 ts/js/Hand.js.map create mode 100644 ts/js/Player.js create mode 100644 ts/js/Player.js.map create mode 100644 ts/js/PlayerInterface.js create mode 100644 ts/js/PlayerInterface.js.map create mode 100644 ts/js/Profile.js create mode 100644 ts/js/Profile.js.map create mode 100644 ts/js/app.js create mode 100644 ts/js/app.js.map create mode 100644 ts/js/enum CardRank.js create mode 100644 ts/js/enum CardRank.js.map diff --git a/ts/Card.ts b/ts/Card.ts new file mode 100644 index 00000000..53e37f34 --- /dev/null +++ b/ts/Card.ts @@ -0,0 +1,24 @@ +class Card{ + + private suit : CardSuit; + private rank : CardRank; + + constructor(suit : CardSuit,rank : CardRank){ + this.suit = suit; + this.rank = rank; + } + public getSuit(){ + return this.suit; + } + public getRank (){ + return this.rank; + } + public setSuit(suit : CardSuit){ + this.suit = suit; + } + public setRank(rank : CardRank){ + this.rank = rank; + } + + +} \ No newline at end of file diff --git a/ts/CardSuit.ts b/ts/CardSuit.ts new file mode 100644 index 00000000..bebbb593 --- /dev/null +++ b/ts/CardSuit.ts @@ -0,0 +1,6 @@ +enum CardSuit{ + CLUBS, + DIAMONDS, + HEARTS, + SPADES +} \ No newline at end of file diff --git a/ts/Casino.ts b/ts/Casino.ts new file mode 100644 index 00000000..37b10840 --- /dev/null +++ b/ts/Casino.ts @@ -0,0 +1,39 @@ +class CasinoApp { + static userInput = document.getElementById("user_input"); + static window = document.getElementById('display'); + static button = document.getElementById('submit'); + static _lastInput: any; + private static _instance: CasinoApp; + + private constructor() { + CasinoApp.button.addEventListener("click", (e: Event) => { CasinoApp._lastInput = CasinoApp.userInput.value }); + CasinoApp.button.addEventListener("click", (e: Event) => { CasinoApp.userInput.value = '' }); + } + + static display(input: string): void { + this.window.innerText += input + '\n'; + } + + static clearScreen(): void { + this.window.innerText = ''; + } + + public static get Instance(): CasinoApp { + return this._instance || (this._instance = new CasinoApp()); + } + + public static get lastInput(): any { + return this._lastInput; + } + + + +} + +class App{ + public static main(): void{ + CasinoApp.display("Welcome To KT Casino"); + } +} +const instance = CasinoApp.Instance; +App.main(); diff --git a/ts/Deck.ts b/ts/Deck.ts new file mode 100644 index 00000000..06502146 --- /dev/null +++ b/ts/Deck.ts @@ -0,0 +1,50 @@ + +class Deck{ + public cards : Card[]=[]; + + constructor(){ + this.createDeck(); + this.shuffle(this.cards); + } + public createDeck() { + this.cards =[]; + var suitLength =4; + var rankLength =13; + for(var indexOfSuit=0;indexOfSuit0){ + let index = Math.floor(Math.random()*length); + length--; + + let tempCard = array[length]; + array[length]= array[index]; + array[index]= tempCard; + } + return array; + } + + public getCard(){ + return this.cards.pop(); + } + + public countRemainingCards(){ + return this.cards.length; + } + public addCard(aCard : Card){ + this.cards.push(aCard); + } + public peek(){ + return this.cards[this.cards.length-1]; + } + +} \ No newline at end of file diff --git a/ts/Gamble.ts b/ts/Gamble.ts new file mode 100644 index 00000000..e69de29b diff --git a/ts/GameEngine.ts b/ts/GameEngine.ts new file mode 100644 index 00000000..e69de29b diff --git a/ts/GameEngineInterface.ts b/ts/GameEngineInterface.ts new file mode 100644 index 00000000..e69de29b diff --git a/ts/GameInterface.ts b/ts/GameInterface.ts new file mode 100644 index 00000000..e69de29b diff --git a/ts/GoFish.ts b/ts/GoFish.ts new file mode 100644 index 00000000..69c5ab3d --- /dev/null +++ b/ts/GoFish.ts @@ -0,0 +1,18 @@ +class GoFish extends Player{ + private user : Player; + private dealer : Player; + private dealerProfile: Profile; + + constructor(userProfile : Profile){ + super(userProfile); + this.user = new Player(userProfile); + this.dealerProfile = new Profile("dealer",0,1); + this.dealer = new Player(this.dealerProfile); + } + + public deal(){ + for(var i =0;i<7;i++){ + // user.getHand().addCard + } + } +} \ No newline at end of file diff --git a/ts/Hand.ts b/ts/Hand.ts new file mode 100644 index 00000000..a67e860d --- /dev/null +++ b/ts/Hand.ts @@ -0,0 +1,30 @@ +class Hand{ + private cards : Card[]; + + constructor(){ + let cards : Card[]= new Array(); + } + + public addCard(aCard : Card){ + this.cards.push(aCard); + } + public removeCard(aCard : Card){ + var index = this.cards.indexOf(aCard,0); + if(index>-1){ + this.cards.slice(index,1); + } + } + public clear(){ + while(this.cards.length>0){ + this.cards.pop(); + } + } + // public hasCard(aCard : Card){ + // //if(aCard in this.cards){ + // return true; + // } + // } + public sortArray(){ + return this.cards.sort(); + } +} \ No newline at end of file diff --git a/ts/Player.ts b/ts/Player.ts new file mode 100644 index 00000000..3abeffc5 --- /dev/null +++ b/ts/Player.ts @@ -0,0 +1,16 @@ +class Player{ + private PlayerProfile : Profile; + constructor(aProfile : Profile){ + this.PlayerProfile = aProfile; + } + public Player(){ + + } + public setProfile(aProfile : Profile){ + this.PlayerProfile = aProfile; + } + + public getProfile(){ + return this.PlayerProfile; + } +} \ No newline at end of file diff --git a/ts/PlayerInterface.ts b/ts/PlayerInterface.ts new file mode 100644 index 00000000..e69de29b diff --git a/ts/Profile.ts b/ts/Profile.ts new file mode 100644 index 00000000..8ca62267 --- /dev/null +++ b/ts/Profile.ts @@ -0,0 +1,31 @@ +class Profile{ + private name : string; + private accountBalance : number; + private id : number; + constructor (name : string, accountBalance : number, id : number){ + this.name = name; + this.accountBalance = accountBalance; + this.id= id + } + + public getName (){ + return this.name; + } + public getAccountBalance(){ + return this.accountBalance; + } + public getId(){ + return this.id; + } + + public setName(name : string){ + this.name = name; + } + public setAccountBalance(accountBalance : number){ + this.accountBalance = accountBalance; + } + public setId(id : number){ + this.id =id; + } + +} \ No newline at end of file diff --git a/ts/app.js b/ts/app.js new file mode 100644 index 00000000..d3847274 --- /dev/null +++ b/ts/app.js @@ -0,0 +1,12 @@ +function startGame() { + var playerName = 'Kibret'; + logPlayer(playerName); + var messagesElement = document.getElementById('display'); + messagesElement.innerText = 'Welcome to KT Casion Starting a new game...'; + console.log('Starting a new Game.'); +} +function logPlayer(name) { + console.log("New game starting for Player: " + name); +} +document.getElementById('startGame').addEventListener('click', startGame); +//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/ts/app.js.map b/ts/app.js.map new file mode 100644 index 00000000..8a47fe84 --- /dev/null +++ b/ts/app.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.js","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,UAAU,GAAY,QAAQ,CAAC;IACnC,SAAS,CAAC,UAAU,CAAC,CAAC;IAEtB,IAAI,eAAe,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACzD,eAAe,CAAC,SAAS,GAAG,6CAA6C,CAAC;IAC1E,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AACxC,CAAC;AACD,mBAAmB,IAAI;IACnB,OAAO,CAAC,GAAG,CAAC,mCAAiC,IAAM,CAAC,CAAC;AACzD,CAAC;AAED,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAC,SAAS,CAAC,CAAC"} \ No newline at end of file diff --git a/ts/app.ts b/ts/app.ts new file mode 100644 index 00000000..b966ae4b --- /dev/null +++ b/ts/app.ts @@ -0,0 +1,13 @@ +function startGame(){ + let playerName : string = 'Kibret'; + logPlayer(playerName); + + var messagesElement = document.getElementById('display'); + messagesElement.innerText = 'Welcome to KT Casion Starting a new game...'; + console.log('Starting a new Game.'); +} +function logPlayer(name){ + console.log(`New game starting for Player: ${name}`); +} + +document.getElementById('submit').addEventListener('click',startGame); \ No newline at end of file diff --git a/ts/casinoProject b/ts/casinoProject new file mode 100644 index 00000000..e69de29b diff --git a/ts/enum CardRank.ts b/ts/enum CardRank.ts new file mode 100644 index 00000000..c7e51140 --- /dev/null +++ b/ts/enum CardRank.ts @@ -0,0 +1,16 @@ +enum CardRank{ + TWO = 2, + THREE = 3, + FOUR =4, + FIVE = 5, + SIX = 6, + SEVEN =7, + EIGHT =8, + NINE =9, + TEN =10, + JACK =11, + QUEEN =12, + KING =13, + ACE =11, + +} \ No newline at end of file diff --git a/ts/js/Card.js b/ts/js/Card.js new file mode 100644 index 00000000..7f373b3b --- /dev/null +++ b/ts/js/Card.js @@ -0,0 +1,20 @@ +var Card = /** @class */ (function () { + function Card(suit, rank) { + this.suit = suit; + this.rank = rank; + } + Card.prototype.getSuit = function () { + return this.suit; + }; + Card.prototype.getRank = function () { + return this.rank; + }; + Card.prototype.setSuit = function (suit) { + this.suit = suit; + }; + Card.prototype.setRank = function (rank) { + this.rank = rank; + }; + return Card; +}()); +//# sourceMappingURL=Card.js.map \ No newline at end of file diff --git a/ts/js/Card.js.map b/ts/js/Card.js.map new file mode 100644 index 00000000..e33158f7 --- /dev/null +++ b/ts/js/Card.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Card.js","sourceRoot":"","sources":["../Card.ts"],"names":[],"mappings":"AAAA;IAKI,cAAY,IAAe,EAAC,IAAe;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACO,sBAAO,GAAf;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACM,sBAAO,GAAd;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACM,sBAAO,GAAd,UAAe,IAAe;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACM,sBAAO,GAAd,UAAe,IAAe;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAGL,WAAC;AAAD,CAAC,AAvBD,IAuBC"} \ No newline at end of file diff --git a/ts/js/CardSuit.js b/ts/js/CardSuit.js new file mode 100644 index 00000000..045ec6f8 --- /dev/null +++ b/ts/js/CardSuit.js @@ -0,0 +1,8 @@ +var CardSuit; +(function (CardSuit) { + CardSuit[CardSuit["CLUBS"] = 0] = "CLUBS"; + CardSuit[CardSuit["DIAMONDS"] = 1] = "DIAMONDS"; + CardSuit[CardSuit["HEARTS"] = 2] = "HEARTS"; + CardSuit[CardSuit["SPADES"] = 3] = "SPADES"; +})(CardSuit || (CardSuit = {})); +//# sourceMappingURL=CardSuit.js.map \ No newline at end of file diff --git a/ts/js/CardSuit.js.map b/ts/js/CardSuit.js.map new file mode 100644 index 00000000..72e25499 --- /dev/null +++ b/ts/js/CardSuit.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CardSuit.js","sourceRoot":"","sources":["../CardSuit.ts"],"names":[],"mappings":"AAAA,IAAK,QAKJ;AALD,WAAK,QAAQ;IACT,yCAAK,CAAA;IACL,+CAAQ,CAAA;IACR,2CAAM,CAAA;IACN,2CAAM,CAAA;AACV,CAAC,EALI,QAAQ,KAAR,QAAQ,QAKZ"} \ No newline at end of file diff --git a/ts/js/Casino.js b/ts/js/Casino.js new file mode 100644 index 00000000..c7bc0fc7 --- /dev/null +++ b/ts/js/Casino.js @@ -0,0 +1,31 @@ +var UI = /** @class */ (function () { + function UI() { + UI.button.addEventListener("click", function (e) { UI._lastInput = UI.userInput.value; }); + UI.button.addEventListener("click", function (e) { UI.userInput.value = ''; }); + } + UI.display = function (input) { + this.window.innerText += input + '\n'; + }; + UI.clearScreen = function () { + this.window.innerText = ''; + }; + Object.defineProperty(UI, "Instance", { + get: function () { + return this._instance || (this._instance = new UI()); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(UI, "lastInput", { + get: function () { + return this._lastInput; + }, + enumerable: true, + configurable: true + }); + UI.userInput = document.getElementById("user_input"); + UI.window = document.getElementById('display'); + UI.button = document.getElementById('submit'); + return UI; +}()); +//# sourceMappingURL=Casino.js.map \ No newline at end of file diff --git a/ts/js/Casino.js.map b/ts/js/Casino.js.map new file mode 100644 index 00000000..ccdb86e5 --- /dev/null +++ b/ts/js/Casino.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Casino.js","sourceRoot":"","sources":["../Casino.ts"],"names":[],"mappings":"AAAA;IAOI;QACI,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAC,CAAQ,IAAO,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAA,CAAC,CAAC,CAAC,CAAC;QAC1F,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAC,CAAQ,IAAO,EAAE,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAA,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC;IAEM,UAAO,GAAd,UAAe,KAAa;QACxB,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,KAAK,GAAG,IAAI,CAAC;IAC1C,CAAC;IAEM,cAAW,GAAlB;QACI,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,EAAE,CAAC;IAC/B,CAAC;IAED,sBAAkB,cAAQ;aAA1B;YACI,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC;QACzD,CAAC;;;OAAA;IAED,sBAAkB,eAAS;aAA3B;YACI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;;;OAAA;IAzBM,YAAS,GAAqB,QAAQ,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACpE,SAAM,GAAmB,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC5D,SAAM,GAAmB,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAyBtE,SAAC;CAAA,AA5BD,IA4BC"} \ No newline at end of file diff --git a/ts/js/Deck.js b/ts/js/Deck.js new file mode 100644 index 00000000..0eec66c9 --- /dev/null +++ b/ts/js/Deck.js @@ -0,0 +1,43 @@ +var Deck = /** @class */ (function () { + function Deck() { + this.cards = []; + this.createDeck(); + this.shuffle(this.cards); + } + Deck.prototype.createDeck = function () { + this.cards = []; + var suitLength = 4; + var rankLength = 13; + for (var indexOfSuit = 0; indexOfSuit < suitLength; indexOfSuit++) { + for (var indexOfRank = 0; indexOfRank < rankLength; indexOfRank++) { + this.cards.push(new Card(indexOfSuit, indexOfRank)); + } + } + return this.cards; + }; + Deck.prototype.shuffle = function (array) { + var length = array.length; + while (length > 0) { + var index = Math.floor(Math.random() * length); + length--; + var tempCard = array[length]; + array[length] = array[index]; + array[index] = tempCard; + } + return array; + }; + Deck.prototype.getCard = function () { + return this.cards.pop(); + }; + Deck.prototype.countRemainingCards = function () { + return this.cards.length; + }; + Deck.prototype.addCard = function (aCard) { + this.cards.push(aCard); + }; + Deck.prototype.peek = function () { + return this.cards[this.cards.length - 1]; + }; + return Deck; +}()); +//# sourceMappingURL=Deck.js.map \ No newline at end of file diff --git a/ts/js/Deck.js.map b/ts/js/Deck.js.map new file mode 100644 index 00000000..bcc2ec9f --- /dev/null +++ b/ts/js/Deck.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Deck.js","sourceRoot":"","sources":["../Deck.ts"],"names":[],"mappings":"AACA;IAGI;QAFO,UAAK,GAAU,EAAE,CAAC;QAGrB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACM,yBAAU,GAAjB;QACI,IAAI,CAAC,KAAK,GAAE,EAAE,CAAC;QACf,IAAI,UAAU,GAAE,CAAC,CAAC;QAClB,IAAI,UAAU,GAAE,EAAE,CAAC;QACnB,GAAG,CAAA,CAAC,IAAI,WAAW,GAAC,CAAC,EAAC,WAAW,GAAC,UAAU,EAAC,WAAW,EAAE,EAAC,CAAC;YACxD,GAAG,CAAA,CAAC,IAAI,WAAW,GAAG,CAAC,EAAC,WAAW,GAAC,UAAU,EAAC,WAAW,EAAE,EAAC,CAAC;gBAC1D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAC,WAAW,CAAC,CAAC,CAAC;YACvD,CAAC;QACL,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEM,sBAAO,GAAd,UAAe,KAAK;QAChB,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAE1B,OAAM,MAAM,GAAC,CAAC,EAAC,CAAC;YACZ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAC,MAAM,CAAC,CAAC;YAC7C,MAAM,EAAE,CAAC;YAET,IAAI,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,KAAK,CAAC,MAAM,CAAC,GAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAC5B,KAAK,CAAC,KAAK,CAAC,GAAE,QAAQ,CAAC;QAC3B,CAAC;QACD,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAEM,sBAAO,GAAd;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IAC5B,CAAC;IAEM,kCAAmB,GAA1B;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;IACM,sBAAO,GAAd,UAAe,KAAY;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACM,mBAAI,GAAX;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAEL,WAAC;AAAD,CAAC,AAhDD,IAgDC"} \ No newline at end of file diff --git a/ts/js/Gamble.js b/ts/js/Gamble.js new file mode 100644 index 00000000..134367e6 --- /dev/null +++ b/ts/js/Gamble.js @@ -0,0 +1 @@ +//# sourceMappingURL=Gamble.js.map \ No newline at end of file diff --git a/ts/js/Gamble.js.map b/ts/js/Gamble.js.map new file mode 100644 index 00000000..13976381 --- /dev/null +++ b/ts/js/Gamble.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Gamble.js","sourceRoot":"","sources":["../Gamble.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/ts/js/GameEngine.js b/ts/js/GameEngine.js new file mode 100644 index 00000000..f78eb737 --- /dev/null +++ b/ts/js/GameEngine.js @@ -0,0 +1 @@ +//# sourceMappingURL=GameEngine.js.map \ No newline at end of file diff --git a/ts/js/GameEngine.js.map b/ts/js/GameEngine.js.map new file mode 100644 index 00000000..a7db4566 --- /dev/null +++ b/ts/js/GameEngine.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GameEngine.js","sourceRoot":"","sources":["../GameEngine.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/ts/js/GameEngineInterface.js b/ts/js/GameEngineInterface.js new file mode 100644 index 00000000..a0a73ec2 --- /dev/null +++ b/ts/js/GameEngineInterface.js @@ -0,0 +1 @@ +//# sourceMappingURL=GameEngineInterface.js.map \ No newline at end of file diff --git a/ts/js/GameEngineInterface.js.map b/ts/js/GameEngineInterface.js.map new file mode 100644 index 00000000..4aee2f2f --- /dev/null +++ b/ts/js/GameEngineInterface.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GameEngineInterface.js","sourceRoot":"","sources":["../GameEngineInterface.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/ts/js/GameInterface.js b/ts/js/GameInterface.js new file mode 100644 index 00000000..157d9a34 --- /dev/null +++ b/ts/js/GameInterface.js @@ -0,0 +1 @@ +//# sourceMappingURL=GameInterface.js.map \ No newline at end of file diff --git a/ts/js/GameInterface.js.map b/ts/js/GameInterface.js.map new file mode 100644 index 00000000..a7949ff6 --- /dev/null +++ b/ts/js/GameInterface.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GameInterface.js","sourceRoot":"","sources":["../GameInterface.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/ts/js/GoFish.js b/ts/js/GoFish.js new file mode 100644 index 00000000..5f97ecc0 --- /dev/null +++ b/ts/js/GoFish.js @@ -0,0 +1,27 @@ +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 GoFish = /** @class */ (function (_super) { + __extends(GoFish, _super); + function GoFish(userProfile) { + var _this = _super.call(this, userProfile) || this; + _this.user = new Player(userProfile); + _this.dealerProfile = new Profile("dealer", 0, 1); + _this.dealer = new Player(_this.dealerProfile); + return _this; + } + GoFish.prototype.deal = function () { + for (var i = 0; i < 7; i++) { + // user.getHand().addCard + } + }; + return GoFish; +}(Player)); +//# sourceMappingURL=GoFish.js.map \ No newline at end of file diff --git a/ts/js/GoFish.js.map b/ts/js/GoFish.js.map new file mode 100644 index 00000000..422258f8 --- /dev/null +++ b/ts/js/GoFish.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GoFish.js","sourceRoot":"","sources":["../GoFish.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;IAAqB,0BAAM;IAKvB,gBAAY,WAAqB;QAAjC,YACI,kBAAM,WAAW,CAAC,SAIrB;QAHG,KAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;QACpC,KAAI,CAAC,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC;QAC/C,KAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC;;IACjD,CAAC;IAEM,qBAAI,GAAX;QACI,GAAG,CAAA,CAAC,IAAI,CAAC,GAAE,CAAC,EAAC,CAAC,GAAC,CAAC,EAAC,CAAC,EAAE,EAAC,CAAC;YAClB,yBAAyB;QAC7B,CAAC;IACL,CAAC;IACL,aAAC;AAAD,CAAC,AAjBD,CAAqB,MAAM,GAiB1B"} \ No newline at end of file diff --git a/ts/js/Hand.js b/ts/js/Hand.js new file mode 100644 index 00000000..046e0335 --- /dev/null +++ b/ts/js/Hand.js @@ -0,0 +1,29 @@ +var Hand = /** @class */ (function () { + function Hand() { + var cards = new Array(); + } + Hand.prototype.addCard = function (aCard) { + this.cards.push(aCard); + }; + Hand.prototype.removeCard = function (aCard) { + var index = this.cards.indexOf(aCard, 0); + if (index > -1) { + this.cards.slice(index, 1); + } + }; + Hand.prototype.clear = function () { + while (this.cards.length > 0) { + this.cards.pop(); + } + }; + // public hasCard(aCard : Card){ + // //if(aCard in this.cards){ + // return true; + // } + // } + Hand.prototype.sortArray = function () { + return this.cards.sort(); + }; + return Hand; +}()); +//# sourceMappingURL=Hand.js.map \ No newline at end of file diff --git a/ts/js/Hand.js.map b/ts/js/Hand.js.map new file mode 100644 index 00000000..d057757a --- /dev/null +++ b/ts/js/Hand.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Hand.js","sourceRoot":"","sources":["../Hand.ts"],"names":[],"mappings":"AAAA;IAGI;QACG,IAAK,KAAK,GAAW,IAAI,KAAK,EAAE,CAAC;IACpC,CAAC;IAEM,sBAAO,GAAd,UAAe,KAAY;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACM,yBAAU,GAAjB,UAAkB,KAAY;QAC1B,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAC,CAAC,CAAC,CAAC;QACxC,EAAE,CAAA,CAAC,KAAK,GAAC,CAAC,CAAC,CAAC,CAAA,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAC,CAAC,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;IACM,oBAAK,GAAZ;QACI,OAAM,IAAI,CAAC,KAAK,CAAC,MAAM,GAAC,CAAC,EAAC,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACrB,CAAC;IACL,CAAC;IACD,gCAAgC;IAChC,iCAAiC;IACjC,uBAAuB;IACvB,QAAQ;IACR,IAAI;IACG,wBAAS,GAAhB;QACI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IACL,WAAC;AAAD,CAAC,AA7BD,IA6BC"} \ No newline at end of file diff --git a/ts/js/Player.js b/ts/js/Player.js new file mode 100644 index 00000000..f19258f1 --- /dev/null +++ b/ts/js/Player.js @@ -0,0 +1,15 @@ +var Player = /** @class */ (function () { + function Player(aProfile) { + this.PlayerProfile = aProfile; + } + Player.prototype.Player = function () { + }; + Player.prototype.setProfile = function (aProfile) { + this.PlayerProfile = aProfile; + }; + Player.prototype.getProfile = function () { + return this.PlayerProfile; + }; + return Player; +}()); +//# sourceMappingURL=Player.js.map \ No newline at end of file diff --git a/ts/js/Player.js.map b/ts/js/Player.js.map new file mode 100644 index 00000000..cd4105c4 --- /dev/null +++ b/ts/js/Player.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Player.js","sourceRoot":"","sources":["../Player.ts"],"names":[],"mappings":"AAAA;IAEI,gBAAY,QAAkB;QAC1B,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;IAClC,CAAC;IACM,uBAAM,GAAb;IAEA,CAAC;IACM,2BAAU,GAAjB,UAAkB,QAAkB;QAChC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;IAClC,CAAC;IAEM,2BAAU,GAAjB;QACI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IACL,aAAC;AAAD,CAAC,AAfD,IAeC"} \ No newline at end of file diff --git a/ts/js/PlayerInterface.js b/ts/js/PlayerInterface.js new file mode 100644 index 00000000..efe3ade6 --- /dev/null +++ b/ts/js/PlayerInterface.js @@ -0,0 +1 @@ +//# sourceMappingURL=PlayerInterface.js.map \ No newline at end of file diff --git a/ts/js/PlayerInterface.js.map b/ts/js/PlayerInterface.js.map new file mode 100644 index 00000000..b75a07d0 --- /dev/null +++ b/ts/js/PlayerInterface.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PlayerInterface.js","sourceRoot":"","sources":["../PlayerInterface.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/ts/js/Profile.js b/ts/js/Profile.js new file mode 100644 index 00000000..106a14b6 --- /dev/null +++ b/ts/js/Profile.js @@ -0,0 +1,27 @@ +var Profile = /** @class */ (function () { + function Profile(name, accountBalance, id) { + this.name = name; + this.accountBalance = accountBalance; + this.id = id; + } + Profile.prototype.getName = function () { + return this.name; + }; + Profile.prototype.getAccountBalance = function () { + return this.accountBalance; + }; + Profile.prototype.getId = function () { + return this.id; + }; + Profile.prototype.setName = function (name) { + this.name = name; + }; + Profile.prototype.setAccountBalance = function (accountBalance) { + this.accountBalance = accountBalance; + }; + Profile.prototype.setId = function (id) { + this.id = id; + }; + return Profile; +}()); +//# sourceMappingURL=Profile.js.map \ No newline at end of file diff --git a/ts/js/Profile.js.map b/ts/js/Profile.js.map new file mode 100644 index 00000000..71327019 --- /dev/null +++ b/ts/js/Profile.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Profile.js","sourceRoot":"","sources":["../Profile.ts"],"names":[],"mappings":"AAAA;IAII,iBAAa,IAAa,EAAE,cAAuB,EAAE,EAAW;QAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,EAAE,GAAE,EAAE,CAAA;IACf,CAAC;IAEM,yBAAO,GAAd;QACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IACM,mCAAiB,GAAxB;QACI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IACM,uBAAK,GAAZ;QACI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACnB,CAAC;IAEM,yBAAO,GAAd,UAAe,IAAa;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IACM,mCAAiB,GAAxB,UAAyB,cAAuB;QAC5C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IACM,uBAAK,GAAZ,UAAa,EAAW;QACpB,IAAI,CAAC,EAAE,GAAE,EAAE,CAAC;IAChB,CAAC;IAEL,cAAC;AAAD,CAAC,AA9BD,IA8BC"} \ No newline at end of file diff --git a/ts/js/app.js b/ts/js/app.js new file mode 100644 index 00000000..9fc6f99d --- /dev/null +++ b/ts/js/app.js @@ -0,0 +1,12 @@ +function startGame() { + var playerName = 'Kibret'; + logPlayer(playerName); + var messagesElement = document.getElementById('display'); + messagesElement.innerText = 'Welcome to KT Casion Starting a new game...'; + console.log('Starting a new Game.'); +} +function logPlayer(name) { + console.log("New game starting for Player: " + name); +} +document.getElementById('submit').addEventListener('click', startGame); +//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/ts/js/app.js.map b/ts/js/app.js.map new file mode 100644 index 00000000..811ab830 --- /dev/null +++ b/ts/js/app.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.js","sourceRoot":"","sources":["../app.ts"],"names":[],"mappings":"AAAA;IACI,IAAI,UAAU,GAAY,QAAQ,CAAC;IACnC,SAAS,CAAC,UAAU,CAAC,CAAC;IAEtB,IAAI,eAAe,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACzD,eAAe,CAAC,SAAS,GAAG,6CAA6C,CAAC;IAC1E,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AACxC,CAAC;AACD,mBAAmB,IAAI;IACnB,OAAO,CAAC,GAAG,CAAC,mCAAiC,IAAM,CAAC,CAAC;AACzD,CAAC;AAED,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAC,SAAS,CAAC,CAAC"} \ No newline at end of file diff --git a/ts/js/enum CardRank.js b/ts/js/enum CardRank.js new file mode 100644 index 00000000..4a92f9a3 --- /dev/null +++ b/ts/js/enum CardRank.js @@ -0,0 +1,17 @@ +var CardRank; +(function (CardRank) { + 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"] = 11] = "JACK"; + CardRank[CardRank["QUEEN"] = 12] = "QUEEN"; + CardRank[CardRank["KING"] = 13] = "KING"; + CardRank[CardRank["ACE"] = 11] = "ACE"; +})(CardRank || (CardRank = {})); +//# sourceMappingURL=enum CardRank.js.map \ No newline at end of file diff --git a/ts/js/enum CardRank.js.map b/ts/js/enum CardRank.js.map new file mode 100644 index 00000000..679692b9 --- /dev/null +++ b/ts/js/enum CardRank.js.map @@ -0,0 +1 @@ +{"version":3,"file":"enum CardRank.js","sourceRoot":"","sources":["../enum CardRank.ts"],"names":[],"mappings":"AAAA,IAAK,QAeJ;AAfD,WAAK,QAAQ;IACT,qCAAO,CAAA;IACP,yCAAS,CAAA;IACT,uCAAO,CAAA;IACP,uCAAQ,CAAA;IACR,qCAAO,CAAA;IACP,yCAAQ,CAAA;IACR,yCAAQ,CAAA;IACR,uCAAO,CAAA;IACP,sCAAO,CAAA;IACP,wCAAQ,CAAA;IACR,0CAAS,CAAA;IACT,wCAAQ,CAAA;IACR,sCAAO,CAAA;AAEX,CAAC,EAfI,QAAQ,KAAR,QAAQ,QAeZ"} \ No newline at end of file From 99c144fe974f73cc2f6598a90aa4b15d8c9bd1d8 Mon Sep 17 00:00:00 2001 From: Kibret Tecle Date: Sun, 25 Mar 2018 21:24:19 -0400 Subject: [PATCH 2/3] saving --- ts/Casino.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ts/Casino.ts b/ts/Casino.ts index 37b10840..6cb4a4c8 100644 --- a/ts/Casino.ts +++ b/ts/Casino.ts @@ -7,6 +7,7 @@ class CasinoApp { private constructor() { CasinoApp.button.addEventListener("click", (e: Event) => { CasinoApp._lastInput = CasinoApp.userInput.value }); + CasinoApp.button.addEventListener("click", (e: Event) => console.log(CasinoApp.lastInput)); CasinoApp.button.addEventListener("click", (e: Event) => { CasinoApp.userInput.value = '' }); } @@ -25,14 +26,21 @@ class CasinoApp { public static get lastInput(): any { return this._lastInput; } + public chooseGame(){ + if(CasinoApp._lastInput=="GoFish"|| CasinoApp._lastInput=="goFish"){ + CasinoApp.display("Go Fish game is not finished yet.") + } + } - } + class App{ public static main(): void{ CasinoApp.display("Welcome To KT Casino"); + CasinoApp.display("choose a game"); + } } const instance = CasinoApp.Instance; From 11b2de914cd5c1809e4df382c5646530ca183e14 Mon Sep 17 00:00:00 2001 From: Kibret Tecle Date: Mon, 26 Mar 2018 08:07:45 -0400 Subject: [PATCH 3/3] made changes to GoFish.ts --- ts/GoFish.ts | 5 +++-- ts/Hand.ts | 1 + ts/Player.ts | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ts/GoFish.ts b/ts/GoFish.ts index 69c5ab3d..128e0dbc 100644 --- a/ts/GoFish.ts +++ b/ts/GoFish.ts @@ -3,16 +3,17 @@ class GoFish extends Player{ private dealer : Player; private dealerProfile: Profile; + constructor(userProfile : Profile){ super(userProfile); this.user = new Player(userProfile); this.dealerProfile = new Profile("dealer",0,1); this.dealer = new Player(this.dealerProfile); } - public deal(){ for(var i =0;i<7;i++){ - // user.getHand().addCard + // this.user.getHand().addCard(Deck.getCard()); + // this.dealer.getHand().addCard(Deck.getCard()); } } } \ No newline at end of file diff --git a/ts/Hand.ts b/ts/Hand.ts index a67e860d..b631c4c0 100644 --- a/ts/Hand.ts +++ b/ts/Hand.ts @@ -27,4 +27,5 @@ class Hand{ public sortArray(){ return this.cards.sort(); } + } \ No newline at end of file diff --git a/ts/Player.ts b/ts/Player.ts index 3abeffc5..0c944511 100644 --- a/ts/Player.ts +++ b/ts/Player.ts @@ -1,11 +1,16 @@ class Player{ private PlayerProfile : Profile; + private playerHand : Hand; constructor(aProfile : Profile){ this.PlayerProfile = aProfile; } public Player(){ + this.playerHand = new Hand(); } + public getHand(){ + return this.playerHand; + } public setProfile(aProfile : Profile){ this.PlayerProfile = aProfile; }