1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-16 11:41:50 +00:00

Goal totals now change to the new upgrade amount when upgrading.

This commit is contained in:
hexagonhexagon 2020-06-05 22:35:05 -04:00
parent a2ee16589f
commit 0fce0962c6

View File

@ -3,7 +3,7 @@ import { ClickDetector } from "../../../core/click_detector";
import { formatBigNumber, makeDiv } from "../../../core/utils";
import { ShapeDefinition } from "../../shape_definition";
import { BaseHUDPart } from "../base_hud_part";
import { blueprintShape } from "../../upgrades";
import { blueprintShape, UPGRADES } from "../../upgrades";
import { enumHubGoalRewards } from "../../tutorial_goals";
export class HUDPinnedShapes extends BaseHUDPart {
@ -34,6 +34,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
this.root.signals.storyGoalCompleted.add(this.rerenderFull, this);
this.root.signals.postLoadHook.add(this.rerenderFull, this);
this.root.signals.upgradePurchased.add(this.recalculateGoals, this);
this.root.hud.signals.shapePinRequested.add(this.pinNewShape, this);
}
@ -88,6 +89,28 @@ export class HUDPinnedShapes extends BaseHUDPart {
}
}
recalculateGoals(upgradeId) {
const amountForUpgradeShape = {};
const currentTier = this.root.hubGoals.getUpgradeLevel(upgradeId);
const currentUpgrade = UPGRADES[upgradeId].tiers[currentTier];
const currentRequired = currentUpgrade.required;
for (let i = 0; i < currentRequired.length; i++) {
const upgradeShape = currentRequired[i].shape;
const amount = currentRequired[i].amount;
amountForUpgradeShape[upgradeShape] = amount;
}
for (let i = 0; i < this.pinnedShapes.length; ++i) {
const key = this.pinnedShapes[i].key;
if (key in amountForUpgradeShape) {
this.pinnedShapes[i].goal = amountForUpgradeShape[key];
}
}
this.rerenderFull();
}
/**
* Pins a shape
* @param {string} key