Skip to content

.. #31

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

.. #31

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
Empty file added casinoGameApp/DeckOfCards.ts
Empty file.
6 changes: 6 additions & 0 deletions casinoGameApp/GameEngine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"use strict";
var GameEngine = /** @class */ (function () {
function GameEngine() {
}
return GameEngine;
}());
15 changes: 15 additions & 0 deletions casinoGameApp/GameEngine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PlayerInterface } from "./PlayerInterface";

namespace Casino {



export abstract class GameEngine<GameTypePlayer extends PlayerInterface, GameTypePlayer extends GameInterface<GameTypePlayer>>
implements GameEngineInterface<GameTypePlayer, GameType>{

abstract getGame(): GameType;
abstract evaluateTurn(player: GameTypePlayer): void;
abstract run(): void;
}

}
1 change: 1 addition & 0 deletions casinoGameApp/GameEngineInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
15 changes: 15 additions & 0 deletions casinoGameApp/GameEngineInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PlayerInterface } from "./PlayerInterface";

namespace Casino {
export interface GameEngineInterface <GamePlayerType extends PlayerInterface, GameType extends GameInterface<GameTypePlayer>> {
getGame(): GameType;
//return the composite Game object to the client.\

evaluateTurn(player: T);
//evaluate the turn of a player.

run();
//begin game.
}

}
1 change: 1 addition & 0 deletions casinoGameApp/GameInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
17 changes: 17 additions & 0 deletions casinoGameApp/GameInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Casino{

export interface GameInterface<T extends PlayerInterface> {
//represents a game which handles some type of player
//should implement Runnable - done

getPlayers(): T[];

getPlayer(playerId: number): T;

addPlayer(player: T): void;

removePlayer(player: T): void;

contains(player: T): Boolean;
}
}
48 changes: 48 additions & 0 deletions casinoGameApp/MainMenu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace Casino {
export class MainMenu {
displayElement: HTMLElement = document.getElementById("display");
submitButton: HTMLElement = document.getElementById("submit_button");
private userProfile: Profile;

//constructor
constructor(){
this.menuStart = this.menuStart.bind(this);
this.createProfile = this.createProfile.bind(this);
this.gamePicker = this.gamePicker.bind(this);
}

public menuStart(){
this.displayElement.innerHTML = "Enter your name here";
this.submitButton.addEventListener("click",(e: Event)=> this.createProfile(), {once: true});
}

private createProfile(){
this.userProfile = new Profile(Input.getInput());
this.displayElement.innerHTML += "<br>Hello " + this.userProfile.getUserName() + "!";
this.displayElement.innerHTML += "<br>Please select a game. <br>1. Slots";
this.submitButton.addEventListener("click", (e: Event) => this.gamePicker(), {once: true});
}

private gamePicker(){
if(Input.getInput().toLowerCase() === 'gofish'){
var gofishGame = new gofishGame();
gofishGame.startGame();
}
}















}
}
19 changes: 19 additions & 0 deletions casinoGameApp/Player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";
var Player = /** @class */ (function () {
function Player() {
}
//represents a player within the context of a game
//should cease to exist upon termination of a game. - HOW?
//player should implement playerinterface - done
//player objecs should be created within the context of a game.
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;
}());
28 changes: 28 additions & 0 deletions casinoGameApp/Player.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Casino{
class Player implements PlayerInterface {
private playerProfile: Profile;

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

//represents a player within the context of a game
//should cease to exist upon termination of a game. - HOW?

//player should implement playerinterface - done
//player objecs should be created within the context of a game.

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


}
}
1 change: 1 addition & 0 deletions casinoGameApp/PlayerInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
18 changes: 18 additions & 0 deletions casinoGameApp/PlayerInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Casino{
export interface PlayerInterface{
//is a contract to ensure that all players have reference to a profile, name and id


//needs 3 methods
//Profile getProfile()
//String getName()
//Long getId()

//how do you make a method in typescript
getProfile(): Profile;

getName(): string;

getId(): number;
}
}
36 changes: 36 additions & 0 deletions casinoGameApp/Profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";
var Profile = /** @class */ (function () {
function Profile(profileId, username, balance) {
this.id = profileId;
this.name = username;
this.balance = balance;
}
Object.defineProperty(Profile.prototype, "_id", {
get: function () {
return this._id;
},
set: function (id) {
this._id = id;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Profile.prototype, "_name", {
get: function () {
return this._name;
},
set: function (name) {
this._name = name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Profile.prototype, "_balance", {
get: function () {
return this._balance;
},
enumerable: true,
configurable: true
});
return Profile;
}());
28 changes: 28 additions & 0 deletions casinoGameApp/Profile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

namespace Casino{
export class Profile {
private userId: number;
private userName: string;
private balance: number;

constructor(userName: string){
this.userId = Math.random()*100;
this.userName = userName;
this.balance = 250;
}

public getUserId(){
return this.userId;
}

public getUserName(){
return this.userName;
}

public getUserBalance(){
return this.balance;
}

}
}

Empty file added casinoGameApp/WarGame.ts
Empty file.
23 changes: 23 additions & 0 deletions casinoGameApp/casinoGameApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Casino {
window.addEventListener("DOMContentLoaded", (e:Event)=>loadMainMenu());

export class Input {
private static userinput: string;
public static getInputEntered() {
var element: HTMLInputElement = <HTMLInputElement>document.getElementById("user_input");
this.userinput = element.value;
element.value = "";
}

public static getInput(): string {
return this.userinput;
}
}

document.getElementById("submit_button").addEventListener("click", (e: Event) => Input.getInputEntered);

function loadMainMenu() {
var menu: MainMenu = new loadMainMenu();
menu.menuStart();
}
}
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ <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" id="submit_button">
</div>
</section>

<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/casinoGameApp.js"></script>

</body>
</html>
2 changes: 2 additions & 0 deletions js/casinoGameApp.js/DeckOfCards.js

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

1 change: 1 addition & 0 deletions js/casinoGameApp.js/DeckOfCards.js.map

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

12 changes: 12 additions & 0 deletions js/casinoGameApp.js/GameEngine.js

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

1 change: 1 addition & 0 deletions js/casinoGameApp.js/GameEngine.js.map

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

3 changes: 3 additions & 0 deletions js/casinoGameApp.js/GameEngineInterface.js

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

1 change: 1 addition & 0 deletions js/casinoGameApp.js/GameEngineInterface.js.map

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

2 changes: 2 additions & 0 deletions js/casinoGameApp.js/GameInterface.js

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

1 change: 1 addition & 0 deletions js/casinoGameApp.js/GameInterface.js.map

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

11 changes: 11 additions & 0 deletions js/casinoGameApp.js/GoFish.js

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

1 change: 1 addition & 0 deletions js/casinoGameApp.js/GoFish.js.map

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

2 changes: 2 additions & 0 deletions js/casinoGameApp.js/GoldFish.js

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

1 change: 1 addition & 0 deletions js/casinoGameApp.js/GoldFish.js.map

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

35 changes: 35 additions & 0 deletions js/casinoGameApp.js/MainMenu.js

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

1 change: 1 addition & 0 deletions js/casinoGameApp.js/MainMenu.js.map

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

Loading