Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No BREAKING CHANGE: No
- Loading branch information
Showing
9 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Harvester } from "./Harvester"; | ||
import { Resource } from "./Resource"; | ||
import { Upgrade } from "./Upgrade"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
Empty file.