Skip to content

su #38

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

su #38

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
12 changes: 12 additions & 0 deletions .idea/CR-MacroLabs-TypeScript-Casino.iml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

419 changes: 419 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions app/BlackJack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import CardDeck from "./CardDeck";
import Player from "./Player"

class BlackJack {
private bjdeck = new CardDeck;
private player = new Player;
private dealer = new Player;

}

function dealFirstCards{

}
17 changes: 17 additions & 0 deletions app/Card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import CardRank from "./CardRank";
import CardSuit from "./CardSuit";

class Card {
suit: CardSuit;
rank: CardRank;

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

toString(): string {
return CardRank[this.rank] + " of " + CardSuit[this.suit];
}

}
25 changes: 25 additions & 0 deletions app/CardDeck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Card from "./Card";

class CardDeck {
private deck: Card[];

public constructor() {
this.deck = [];

for (let suit = 0; suit < 4; suit++) {
for (let rank = 1; rank < 14 ; 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[i];
this.deck[j] = swap;
}
}
}
15 changes: 15 additions & 0 deletions app/CardRank.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
enum CardRank {
two,
three,
four,
five,
six,
seven,
eight,
nine,
ten,
jack,
queen,
king,
Ace,
}
6 changes: 6 additions & 0 deletions app/CardSuit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
enum CardSuit {
Clubs,
Diamonds,
Hearts,
Spades
}
Empty file added app/Gamble.ts
Empty file.
13 changes: 13 additions & 0 deletions app/Player.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Card from "./Card"
class Player {
private name: string;
private cardHand: Card[];

constructor(){
this.name = name;
this.cardHand = cardHand;
}



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

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

public static main():void{
UserInterfaceClass.display("Welcome to BlackJack!!! Enter your name in the text field below the display window and click submit.");

}

}
class UserInterfaceClass {

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: UserInterfaceClass

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

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

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

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

public static get lastInput(): any {
return this._lastInput;
}
}
12 changes: 12 additions & 0 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.base",
"compilerOptions": {
"removeComments": true,
"module": "commonjs",
"moduleResolution": "node",
"traceResolution": false,
},
"files": [
"*/**.ts"
]
}
15 changes: 13 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,21 @@ <h1>TypeScript Casino</h1>
<div id="display"></div>
<div id="input">
<input type="text" name="user_input" id="user_input">
<input type="submit" value="submit">
<input type="submit" value="submit">
<input type="submit" value="Hit!">
<input type="submit" value="Stand">
<input type="submit" value="PlayBlackJack">
</div>
</section>

<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/Card.js"></script>
<script type="text/javascript" src="js/CardDeck.js"></script>
<script type="text/javascript" src="js/CardSuit.js"></script>
<script type="text/javascript" src="js/CardRank.js"></script>
<script type="text/javascript" src="js/BlackJack.js"></script>
<script type="text/javascript" src="js/Player.js"></script>
<script type="text/javascript" src="js/Profile.js"></script>

</body>
</html>
10 changes: 10 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"sourceMap": true,
"watch": true,
"outDir": "js",
"strictNullChecks": true
}
}