Skip to content

Commit

Permalink
build($Everything): Stuff
Browse files Browse the repository at this point in the history
No

BREAKING CHANGE: No
  • Loading branch information
Ronin11 committed May 30, 2017
1 parent 8df9c90 commit 0bc561a
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 4 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
.DS_Store
node_modules
21 changes: 21 additions & 0 deletions src/Base.ts
@@ -0,0 +1,21 @@
export abstract class Base {
protected count: number;
constructor(readonly name: string){
this.count = 0;
}
getName(){
return this.name;
}
getCount(){
return this.count;
}
setCount(newCount: number){
this.count = newCount;
}
incrementCount(amount = 1){
this.count += amount;
}
decrementCount(amount = 1){
this.count -= amount;
}
}
4 changes: 4 additions & 0 deletions src/Engine.ts
@@ -0,0 +1,4 @@
import { Harvester } from "./Harvester";
import { Resource } from "./Resource";
import { Upgrade } from "./Upgrade";

21 changes: 21 additions & 0 deletions src/Harvester.ts
@@ -0,0 +1,21 @@
import { Base } from "./Base";

export class Harvester extends Base{
private multiplier: number;
constructor(name: string, public cost: Function, public update: Function){
super(name);
this.multiplier = 1;
}
getMultiplier(){
return this.multiplier;
}
setMultiplier(newMultiplier: number){
this.multiplier = newMultiplier;
}
incrementMultiplier(amount = 1){
this.multiplier += amount;
}
decrementMultiplier(amount = 1){
this.multiplier -= amount;
}
}
17 changes: 13 additions & 4 deletions src/Resource.ts
@@ -1,6 +1,15 @@
export class Resource {
constructor(private name: string){}
getName(){
return `Name: ${this.name}`
import { Base } from "./Base";

export class Resource extends Base {
constructor(name: string){
super(name);
}
decrementCount(num: number){
if(num > this.count){
throw("Not enough " + this.name);
}else{
this.count -= num;
}
}

}
22 changes: 22 additions & 0 deletions src/Upgrade.ts
@@ -0,0 +1,22 @@
import { Base } from "./Base";

export class Upgrade extends Base{
private maxCount: number;
constructor( name: string, theCount: number, theMax: number, public cost: Function, public effect: Function){
super(name);
this.maxCount = 0;
}
getMaxCount(){
return this.maxCount;
}
setMaxCount(newMax: number){
this.maxCount = newMax;
}
incrementMaxCount(amount = 1){
this.maxCount += amount;
}
decrementMaxCount(amount = 1){
this.maxCount -= amount;
}

}
Empty file added src/__tests__/Harvester.spec.ts
Empty file.
Empty file added src/__tests__/Upgrade.spec.ts
Empty file.

0 comments on commit 0bc561a

Please sign in to comment.