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
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/app.js"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/Blackjack.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
24 changes: 24 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}
29 changes: 29 additions & 0 deletions Blackjack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";
var Blackjack = /** @class */ (function () {
function Blackjack() {
this.dealer = new Dealer();
this.player = new Player();
this.dealerHand = [];
this.playerHand = [];
this.deck = new Deck();
}

Blackjack.prototype.newHand = function (hand) {
var card1 = this.deck.dealCard;
var card2 = this.deck.dealCard;
var hand = [card1, card2];
return hand;
};
Blackjack.prototype.getHand = function (hand) {
return hand.toString;
};
Blackjack.prototype.hit = function (hand) {
var addedCard = this.deck.dealCard;
hand.push(this.deck.dealCard);
};
Blackjack.prototype.getWinner = function () {
};
Blackjack.prototype.startGame = function () {
};
return Blackjack;
}());
36 changes: 36 additions & 0 deletions Blackjack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class Blackjack {
public dealer = new Dealer();
public player = new Player();
public dealerHand = [];
public playerHand = [];
public deck = new Deck();

newHand(){
var card1 =this.deck.dealCard;
var card2 = this.deck.dealCard;
var cards = [card1, card2];
return cards;
}

getHand(hand : Card[]){
return hand.toString
}

// hit(hand : Card[]){
// var addedCard = this.deck.dealCard;
// hand.push(addedCard);
// }
getWinner(){

}
startGame(){
}



}





17 changes: 17 additions & 0 deletions Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";
var Card = /** @class */ (function () {
function Card(suit, value) {
this.suit = suit;
this.value = value;
}
Card.prototype.getSuit = function () {
return Suit[this.suit];
};
Card.prototype.getValue = function () {
return CardRank[this.value];
};
Card.prototype.showCard = function () {
return this.getValue + " of " + this.getSuit();
};
return Card;
}());
42 changes: 42 additions & 0 deletions Card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
enum Suit {
CLUB = 1,
DIAMOND = 2,
HEART = 3,
SPADE =4
}

enum CardRank{
ACE = 1 || 11,
TWO = 2,
THREE = 3,
FOUR = 4,
FIVE = 5,
SIX = 6,
SEVEN = 7,
EIGHT = 8,
NINE = 9,
TEN = 10,
JACK = 10,
QUEEN = 10,
KING = 10
}

class Card{

constructor(public suit: Suit, public value: CardRank){

}

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

getValue():string {
return CardRank[this.value];
}

showCard():string {
return this.getValue + " of " + this.getSuit();
}
}

18 changes: 18 additions & 0 deletions Dealer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"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 __());
};
})();
var Dealer = /** @class */ (function (_super) {
__extends(Dealer, _super);
function Dealer() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Dealer;
}(Player));
5 changes: 5 additions & 0 deletions Dealer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Dealer extends Player{



}
41 changes: 41 additions & 0 deletions Deck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";
var Deck = /** @class */ (function () {
function Deck() {
this.cards = [];
this.shuffle();
}
Deck.prototype.newCards = function () {
for (var i = 1; i <= 4; i++) {
for (var n = 1; n <= 13; n++) {
this.cards.push(new Card(i, n));
}
}
return this.cards;
};
Deck.prototype.shuffle = function () {
this.cards = [];
for (var suitIndex = 0; suitIndex < 4; suitIndex++) {
for (var cardRankIndex = 0; cardRankIndex < 13; cardRankIndex++) {
this.cards.push(new Card(suitIndex, cardRankIndex));
}
}
var currentIndex = this.cards.length;
var swap;
var randomIndex;
//always puts a random card in the last index and moves the previous index
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
swap = this.cards[currentIndex];
this.cards[currentIndex] = this.cards[randomIndex];
this.cards[randomIndex] = swap;
}
};
Deck.prototype.cardsLeft = function () {
return this.cards.length;
};
Deck.prototype.dealCard = function () {
return this.cards.shift();
};
return Deck;
}());
51 changes: 51 additions & 0 deletions Deck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class Deck {

public cards: Card[] = [];

constructor(){
this.shuffle();
}

newCards():Card[] {
for(var i = 1; i <= 4; i++){
for(var n = 1; n <= 13; n++){
this.cards.push(new Card(i,n));
}
}
return this.cards;
}

shuffle():void{
this.cards = [];
for(var suitIndex = 0; suitIndex < 4; suitIndex++){
for(var cardRankIndex = 0; cardRankIndex< 13; cardRankIndex++){
this.cards.push(new Card(suitIndex, cardRankIndex))
}
}

var currentIndex: number = this.cards.length;
var swap: Card;
var randomIndex: number;
//always puts a random card in the last index and moves the previous index
while (0 !== currentIndex) {

randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;

swap = this.cards[currentIndex];

this.cards[currentIndex] = this.cards[randomIndex];
this.cards[randomIndex] = swap;
}
}
cardsLeft(){
return this.cards.length;
}

dealCard(){
return this.cards.shift();
}

}


17 changes: 17 additions & 0 deletions Player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";
var Player = /** @class */ (function () {
function Player() {
this.cards = [];
this.stacks = [];
}
Player.prototype.getProfile = function () {
throw new Error("Method not implemented.");
};
Player.prototype.getName = function () {
throw new Error("Method not implemented.");
};
Player.prototype.getId = function () {
throw new Error("Method not implemented.");
};
return Player;
}());
16 changes: 16 additions & 0 deletions Player.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Player implements PlayerInterface {
getProfile(): Profile {
throw new Error("Method not implemented.");
}
getName(): string {
throw new Error("Method not implemented.");
}
getId(): number {
throw new Error("Method not implemented.");
}

public cards: Card[] = [];
public stacks:Card[] = [];


}
1 change: 1 addition & 0 deletions PlayerInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
6 changes: 6 additions & 0 deletions PlayerInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface PlayerInterface {

getProfile(): Profile;
getName() :string;
getId(): number;
}
9 changes: 9 additions & 0 deletions Profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";
var Profile = /** @class */ (function () {
function Profile(profileId, username, balance) {
this.id = profileId;
this.name = username;
this.balance = balance;
}
return Profile;
}());
29 changes: 29 additions & 0 deletions Profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Profile{

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

constructor (profileId:string, username: any, balance:number){
this.id = profileId;
this.name = username;
this.balance = balance;

}

getId(){
return this.id;
}

getName(){
return this.name;
}

getBalance(){
return this.balance;
}

}

var username = document.getElementById("username");
console.log(username);
1 change: 1 addition & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ article p { margin-bottom: 20px;}
section {margin:10px;}
h1 {font-weight: bold; margin-left: 10px;}
#main {


}
#display {
Expand Down
Loading