Skip to content

Still working through but close to user input #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions CasinoType/Blackjack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Blackjack {


}
19 changes: 19 additions & 0 deletions CasinoType/Card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Card {

private rank: CardValue;
private suit: CardSuit;

constructor(rank: CardValue, suit: CardSuit) {
this.rank = rank;
this.suit = suit;

}

toString(): string {

return CardValue[this.rank] + " of " + CardSuit[this.suit];
}



}
8 changes: 8 additions & 0 deletions CasinoType/CardSuit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enum CardSuit {
Clubs,
Diamonds,
Hearts,
Spades


}
19 changes: 19 additions & 0 deletions CasinoType/CardValue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
enum CardValue {
Two = 2,
Three = 3,
Four = 4,
Five = 5,
Six = 6,
Seven = 7,
Eight = 8,
Nine = 9,
Ten = 10,
Jack = 10,
Queen = 10,
King = 10,
Ace = 11

}



31 changes: 31 additions & 0 deletions CasinoType/Casino.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Casino {



constructor(){
this.chooseGame = this.chooseGame.bind(this);

}


start() {
UI.display("Thank you for coming to my Blackjack Casino")
UI.display("What game would you like to play? Blackjack, Blackjack, Blackjack or Blackjack");
UI.button.addEventListener("click", this.chooseGame);
}

chooseGame(): void {
UI.button.removeEventListener("click", this.chooseGame);
if (UI.lastInput === "Blackjack") {

// Blackjack.start();

} else {
UI.button.addEventListener("click", this.chooseGame);
}

}



}
7 changes: 7 additions & 0 deletions CasinoType/Dealer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Dealer {

//TheDeck = new deck needed



}
42 changes: 42 additions & 0 deletions CasinoType/DeckOfCards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class DeckOfCards {

private newDeck: Card[] = [];
//private inPlayDeck: Card[] = [];

suits:CardSuit[] = [CardSuit.Spades, CardSuit.Clubs, CardSuit.Diamonds, CardSuit.Hearts];
ranks:CardValue[] = [CardValue.Ace, CardValue.Two, CardValue.Three, CardValue.Four, CardValue.Five,
CardValue.Six, CardValue.Seven, CardValue.Eight, CardValue.Nine, CardValue.Ten,
CardValue.Jack, CardValue.Queen, CardValue.King];

deck:Card[] = [];
constructor(){

this.suits.forEach((suit) =>
this.ranks.forEach((rank) =>
this.deck.push(new Card(rank, suit))));

}

shuffle(): void {
for (let i = this.deck.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
let swap = this.deck[i];
this.deck[i] = this.deck[j];
this.deck[j] = swap;
}

}


toString(): string {
return this.deck.join("\n")
}

}







4 changes: 4 additions & 0 deletions CasinoType/Gamble.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface Gamble {


}
3 changes: 3 additions & 0 deletions CasinoType/GameEngine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class GambleEngine {

}
4 changes: 4 additions & 0 deletions CasinoType/GameEngineInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface GameEngineInterface {


}
7 changes: 7 additions & 0 deletions CasinoType/GameInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface GameInterface {





}
11 changes: 11 additions & 0 deletions CasinoType/MainApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class MainApp {

constructor() {
let casino = new Casino();
casino.start();
}




}
3 changes: 3 additions & 0 deletions CasinoType/PitBoss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class PitBoss {

}
23 changes: 23 additions & 0 deletions CasinoType/Player.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Player implements PlayerInterface {


private playerProfile: Profile;
private hand: Card[];

constructor(aProfile: Profile) {
this.playerProfile = aProfile;
}



getProfile() : Profile {
return this.playerProfile;
}
getName() : string {
return this.playerProfile.getName;
}
getId() : number {
return this.playerProfile.getId;
}

}
8 changes: 8 additions & 0 deletions CasinoType/PlayerInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
interface PlayerInterface {

getProfile() : Profile;
getName() :string;
getId() : number;


}
43 changes: 43 additions & 0 deletions CasinoType/Profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class Profile {

private id: number;
private name: string;
private balance: number;

public casinoProfiles:Profile[];

constructor(id: number, name: string, balance: number) {
this.id = id;
this.name =name;
this.balance = balance;
}

set setId(id: number) {
this.id = id;
}

set setName(name: string) {
this.name = name;
}

set setBalance(balance: number) {
this.balance = balance;
}

get getName() {
return this.name;
}

get getId() {
return this.id;
}

get getBalance() {
return this.balance;
}

addPlayer(aplayer:Profile) : void {
this.casinoProfiles.push(aplayer);
}

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

private constructor() {
UI.button.addEventListener("click", (e: Event) => { UI._lastInput = UI.userInput.value });
UI.button.addEventListener("click", (e: Event) => { UI.userInput.value = '' });
}

static display(input: string): void {
this.window.innerText += input + '\n';
}

static clearScreen(): void {
this.window.innerText = '';
}

public static get Instance(): UI {
return this._instance || (this._instance = new UI());
}

public static get lastInput(): any {
return this._lastInput;
}

}
Loading