Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions ts/Card.ts
Original file line number Diff line number Diff line change
@@ -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;
}


}
6 changes: 6 additions & 0 deletions ts/CardSuit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum CardSuit{
CLUBS,
DIAMONDS,
HEARTS,
SPADES
}
47 changes: 47 additions & 0 deletions ts/Casino.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class CasinoApp {
static userInput = <HTMLInputElement>document.getElementById("user_input");
static window = <HTMLDivElement>document.getElementById('display');
static button = <HTMLDivElement>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) => console.log(CasinoApp.lastInput));
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;
}
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;
App.main();
50 changes: 50 additions & 0 deletions ts/Deck.ts
Original file line number Diff line number Diff line change
@@ -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;indexOfSuit<suitLength;indexOfSuit++){
for(var indexOfRank = 0;indexOfRank<rankLength;indexOfRank++){
this.cards.push(new Card(indexOfSuit,indexOfRank));
}
}

return this.cards;
}

public shuffle(array){
let length = array.length;

while(length>0){
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];
}

}
Empty file added ts/Gamble.ts
Empty file.
Empty file added ts/GameEngine.ts
Empty file.
Empty file added ts/GameEngineInterface.ts
Empty file.
Empty file added ts/GameInterface.ts
Empty file.
19 changes: 19 additions & 0 deletions ts/GoFish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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++){
// this.user.getHand().addCard(Deck.getCard());
// this.dealer.getHand().addCard(Deck.getCard());
}
}
}
31 changes: 31 additions & 0 deletions ts/Hand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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();
}

}
21 changes: 21 additions & 0 deletions ts/Player.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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;
}

public getProfile(){
return this.PlayerProfile;
}
}
Empty file added ts/PlayerInterface.ts
Empty file.
31 changes: 31 additions & 0 deletions ts/Profile.ts
Original file line number Diff line number Diff line change
@@ -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;
}

}
12 changes: 12 additions & 0 deletions ts/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ts/app.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions ts/app.ts
Original file line number Diff line number Diff line change
@@ -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);
Empty file added ts/casinoProject
Empty file.
16 changes: 16 additions & 0 deletions ts/enum CardRank.ts
Original file line number Diff line number Diff line change
@@ -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,

}
20 changes: 20 additions & 0 deletions ts/js/Card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ts/js/Card.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions ts/js/CardSuit.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ts/js/CardSuit.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions ts/js/Casino.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ts/js/Casino.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading