Skip to content
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

Still needs work #40

Open
wants to merge 1 commit 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
9 changes: 9 additions & 0 deletions .idea/TypeScript-Casino.iml

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

22 changes: 22 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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.

7 changes: 7 additions & 0 deletions .idea/typescript-compiler.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.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

### `Profile` class
* **Description:**
* `Profile` stores a casino-visitor's `id`, `name`, and `balance`.
* `Profile` stores a casino-visitor's `id`, `name`, and `balance`.
* `Profile` objects should be created within the context of a casino.
* `Profile` objects store `profileId`, `username`, and `balance`.

Expand Down
14 changes: 14 additions & 0 deletions classes/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
exports.__esModule = true;
///<reference path="CasinoPlayer.ts"/>
var BlackJack_1 = require("./blackjack/BlackJack");
var App = /** @class */ (function () {
function App() {
}
App.main = function () {
var blackjack;
blackjack = new BlackJack_1.BlackJack('player', 'dealer');
blackjack.start();
};
return App;
}());
13 changes: 13 additions & 0 deletions classes/App.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///<reference path="CasinoPlayer.ts"/>
import {BlackJack} from "./blackjack/BlackJack";
import {CasinoPlayer} from "./CasinoPlayer";

class App {

public static main(): void {
var blackjack: BlackJack;
blackjack = new BlackJack('player', 'dealer')
blackjack.start();

}
}
32 changes: 32 additions & 0 deletions classes/CardGame/CardGame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
///<reference path="../CardUtils/Card.ts"/>
///<reference path="../CardUtils/Deck.ts"/>
exports.__esModule = true;
var Deck_1 = require("../CardUtils/Deck");
var CardGame = /** @class */ (function () {
function CardGame() {
this.deck = new Deck_1.Deck().getDeck();
}
CardGame.prototype.dealCards = function (dealer, player, amount) {
//clear hands
dealer.clearHand();
player.clearHand();
for (var i = 0; i < amount; i++) {
dealer.addCard(this.deck.pop());
player.addCard(this.deck.pop());
}
};
CardGame.prototype.dealCard = function (player, amount) {
for (var i = 0; i < amount; i++) {
player.addCard(this.deck.pop());
}
};
CardGame.prototype.createNewDeck = function () {
this.deck = new Deck_1.Deck().getDeck();
};
CardGame.prototype.getDeck = function () {
return this.deck;
};
return CardGame;
}());
exports.CardGame = CardGame;
40 changes: 40 additions & 0 deletions classes/CardGame/CardGame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
///<reference path="../CardUtils/Card.ts"/>
///<reference path="../CardUtils/Deck.ts"/>

import {Card} from "../CardUtils/Card";
import {Deck} from "../CardUtils/Deck";
import {CardGamePlayer} from "./CardGamePlayer";

export class CardGame {

deck : Card[];

constructor(){
this.deck = new Deck().getDeck();
}

dealCards(dealer: CardGamePlayer, player: CardGamePlayer, amount: number){
//clear hands
dealer.clearHand();
player.clearHand();

for (let i = 0; i < amount; i++) {
dealer.addCard(this.deck.pop());
player.addCard(this.deck.pop());
}
}

dealCard (player: CardGamePlayer, amount: number){
for (let i = 0; i < amount; i++) {
player.addCard(this.deck.pop());
}
}

createNewDeck():void{
this.deck = new Deck().getDeck();
}

getDeck():Card[]{
return this.deck;
}
}
52 changes: 52 additions & 0 deletions classes/CardGame/CardGamePlayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"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 __());
};
})();
exports.__esModule = true;
var CasinoPlayer_1 = require("../CasinoPlayer");
var CardGamePlayer = /** @class */ (function (_super) {
__extends(CardGamePlayer, _super);
function CardGamePlayer() {
var _this = _super.call(this, "Card Player", 1000) || this;
_this.hand = [];
return _this;
}
CardGamePlayer.prototype.getHand = function () {
return this.hand;
};
CardGamePlayer.prototype.addCard = function (card) {
this.hand.push(card);
};
CardGamePlayer.prototype.clearHand = function () {
this.hand = [];
};
CardGamePlayer.prototype.setHand = function (hand) {
this.hand = hand;
};
CardGamePlayer.prototype.sort = function () {
this.hand.sort();
};
CardGamePlayer.prototype.displayHand = function (sort) {
if (sort) {
this.sort();
}
var displayHand = document.getElementById("playerHand");
displayHand.innerHTML = "";
for (var i = 0; i < this.hand.length; i++) {
var currentCard = this.hand[i];
displayHand.innerHTML += this.cardImg(currentCard);
}
};
CardGamePlayer.prototype.cardImg = function (card) {
return card.getFace() + "_of_" + card.getSuit();
};
return CardGamePlayer;
}(CasinoPlayer_1.CasinoPlayer));
exports.CardGamePlayer = CardGamePlayer;
48 changes: 48 additions & 0 deletions classes/CardGame/CardGamePlayer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {Card} from "../CardUtils/Card";
import {CasinoPlayer} from "../CasinoPlayer";

export class CardGamePlayer extends CasinoPlayer{

hand: Card[];

constructor(){
super("Card Player", 1000);
this.hand = [];
}

getHand():Card[]{
return this.hand;
}
addCard(card:Card):void{
this.hand.push(card);
}

clearHand(){
this.hand = [];
}

setHand(hand:Card[]):void{
this.hand = hand;
}

sort():void{
this.hand.sort();
}

displayHand(sort:boolean):void{
if(sort){
this.sort()
}
let displayHand = document.getElementById("playerHand");
displayHand.innerHTML = "";
for (let i = 0; i < this.hand.length; i++) {
let currentCard: Card = this.hand[i]
displayHand.innerHTML += this.cardImg(currentCard);
}
}

cardImg(card:Card):string{
return card.getFace()+ "_of_" +card.getSuit();
}

}
26 changes: 26 additions & 0 deletions classes/CardUtils/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";
exports.__esModule = true;
var Card = /** @class */ (function () {
function Card(suit, rank, faceValue, location) {
this.suit = suit;
this.rank = rank;
this.face = faceValue;
this.location = location;
}
//generating the get methods made a GET keyword and then the name of the
//variable...I had to manually combine them.
Card.prototype.getSuit = function () {
return this.suit;
};
Card.prototype.getRank = function () {
return this.rank;
};
Card.prototype.getFace = function () {
return this.face;
};
Card.prototype.toString = function () {
return this.face + " of " + this.suit;
};
return Card;
}());
exports.Card = Card;
37 changes: 37 additions & 0 deletions classes/CardUtils/Card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export class Card {

private suit: string;
private rank: number;
private face: string;
private location: string;


constructor(suit: string, rank: number, faceValue: string, location: string) {
this.suit = suit;
this.rank = rank;
this.face = faceValue;
this.location = location;
}

//generating the get methods made a GET keyword and then the name of the
//variable...I had to manually combine them.

getSuit(): string {
return this.suit;
}

getRank(): number {
return this.rank;
}

getFace(): string {
return this.face;
}

toString(): string {
return this.face + " of " + this.suit;
}
}



45 changes: 45 additions & 0 deletions classes/CardUtils/Deck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use strict";
///<reference path = "Card.ts"/>
exports.__esModule = true;
var Card_1 = require("./Card");
var Deck = /** @class */ (function () {
function Deck() {
this.deck = [];
this.suits = ["clubs", "spades", "hearts", "diamonds"];
this.faces = ["ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "jack", "queen", "king"];
}
Deck.prototype.newDeck = function () {
//for every suit inside this.suits
for (var _i = 0, _a = this.suits; _i < _a.length; _i++) {
var suit = _a[_i];
for (var i = 0; i < this.faces.length; i++) {
//no zero value cards
var num = i + 1;
if (num > 10) {
//all faces are 10
num = 10;
}
this.deck.push(new Card_1.Card(suit, num, this.faces[i]));
}
}
this.shuffle();
};
Deck.prototype.getDeck = function () {
this.newDeck();
return this.deck;
};
Deck.prototype.shuffle = function () {
for (var i = 0; i < this.deck.length; i++) {
var ranNum = Math.floor(Math.random() * this.deck.length);
_a = [this.deck[ranNum], this.deck[i]], this.deck[i] = _a[0], this.deck[ranNum] = _a[1];
}
var _a;
};
return Deck;
}());
exports.Deck = Deck;
// checking if file works
var deck;
deck = new Deck();
deck.newDeck();
console.log(deck);
Loading