Skip to content

Commit e8e76a7

Browse files
committed
Remove clickercookie param from Building class
1 parent 4645cf9 commit e8e76a7

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/ts/buildings.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export interface BuildingSave {
3131
}
3232

3333
export class Building implements SaveProvider<BuildingSave> {
34-
private _clickercookie: ClickerCookie;
35-
3634
name: string;
3735
namePlural: string;
3836
quote: string;
@@ -68,10 +66,7 @@ export class Building implements SaveProvider<BuildingSave> {
6866
}
6967

7068
html: HTMLDivElement;
71-
// todo: clickercookie should not be passed as a parameter
72-
constructor(clickercookie: ClickerCookie, data: BuildingData) {
73-
this._clickercookie = clickercookie;
74-
69+
constructor(data: BuildingData) {
7570
// setup HTML (uses indentation to show structure)
7671
this.html = document.createElement("div");
7772
this.html.className = "building";
@@ -141,8 +136,10 @@ export class Building implements SaveProvider<BuildingSave> {
141136
}
142137

143138
buy() {
144-
if (this._clickercookie.cookies >= this.upgradeCost) {
145-
this._clickercookie.cookies -= this.upgradeCost;
139+
const game = Game.getInstance(); //? should we do this? historically clickercookie was a parameter but i threw that out for easier creation; perhaps we can figure another method out?
140+
141+
if (game.clickercookie.cookies >= this.upgradeCost) {
142+
game.clickercookie.cookies -= this.upgradeCost;
146143
this.bought++;
147144
this.CPSGiven += this.CPSGain;
148145
this.hovered();

src/ts/clickercookie.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ export default class ClickerCookie extends Mod<ClickerCookieSaveData> {
152152
}
153153
};
154154

155-
this.keyboard = new Building(this, this.BUILDINGS_DATA.keyboard); // conditional returns true by default
156-
this.grandpa = new Building(this, this.BUILDINGS_DATA.grandpa);
157-
this.ranch = new Building(this, this.BUILDINGS_DATA.ranch);
158-
this.television = new Building(this, this.BUILDINGS_DATA.television);
159-
this.worker = new Building(this, this.BUILDINGS_DATA.worker);
160-
this.wallet = new Building(this, this.BUILDINGS_DATA.wallet);
161-
this.church = new Building(this, this.BUILDINGS_DATA.church);
155+
this.keyboard = new Building(this.BUILDINGS_DATA.keyboard); // conditional returns true by default
156+
this.grandpa = new Building(this.BUILDINGS_DATA.grandpa);
157+
this.ranch = new Building(this.BUILDINGS_DATA.ranch);
158+
this.television = new Building(this.BUILDINGS_DATA.television);
159+
this.worker = new Building(this.BUILDINGS_DATA.worker);
160+
this.wallet = new Building(this.BUILDINGS_DATA.wallet);
161+
this.church = new Building(this.BUILDINGS_DATA.church);
162162

163163
// upgrades
164164
const keyboardBoughtFunc = () => {

src/ts/exmod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class NewMod extends Mod<ModSave> {
2222

2323
this.superCookies = 5;
2424

25-
this.banana = new Building(Game.getInstance().clickercookie, {
25+
this.banana = new Building({
2626
name: "banaan",
2727
namePlural: "many bannaa",
2828
quote: "i love anana",

0 commit comments

Comments
 (0)