Meta upgrades

This commit is contained in:
Martin
2022-12-16 13:52:54 +01:00
parent c85345cba0
commit 499fbac2b2
15 changed files with 688 additions and 415 deletions

View File

@@ -1,16 +1,26 @@
import { MetaUpgradeSettings } from "../../Data/GameSettings";
import { MetaUpgradesSettings } from "../../Data/GameSettings";
import { MetaUpgradesData } from "../../Data/UserData";
import { MetaUpgradeType } from "../../Upgrades/UpgradeType";
export class MetaUpgrades {
private upgradeTypeToValue = new Map<MetaUpgradeType, number>();
public constructor(data: MetaUpgradesData, settings: MetaUpgradeSettings) {
this.upgradeTypeToValue.set(MetaUpgradeType.MaxHp, data.maxHpLevel * settings.healthPointsPerLevel);
this.upgradeTypeToValue.set(MetaUpgradeType.OverallDamage, data.bonusDamageLevel * settings.bonusDamagePerLevel);
this.upgradeTypeToValue.set(MetaUpgradeType.ProjectilePiercing, data.projectilePiercingLevel * settings.projectilePiercingPerLevel);
this.upgradeTypeToValue.set(MetaUpgradeType.MovementSpeed, data.movementSpeedLevel * settings.movementSpeedPerLevel);
this.upgradeTypeToValue.set(MetaUpgradeType.XPGatherer, data.xpGathererLevel * settings.xpBonusPerLevel);
this.upgradeTypeToValue.set(MetaUpgradeType.GoldGatherer, data.goldGathererLevel * settings.goldBonusPerLevel);
public constructor(data: MetaUpgradesData, settings: MetaUpgradesSettings) {
this.upgradeTypeToValue.set(MetaUpgradeType.Health, this.getBonusValue(data.healthLevel, settings.health.bonuses));
this.upgradeTypeToValue.set(MetaUpgradeType.OverallDamage, this.getBonusValue(data.overallDamageLevel, settings.overallDamage.bonuses));
this.upgradeTypeToValue.set(
MetaUpgradeType.ProjectilePiercing,
this.getBonusValue(data.projectilePiercingLevel, settings.projectilePiercing.bonuses)
);
this.upgradeTypeToValue.set(MetaUpgradeType.MovementSpeed, this.getBonusValue(data.movementSpeedLevel, settings.movementSpeed.bonuses));
this.upgradeTypeToValue.set(MetaUpgradeType.XPGatherer, this.getBonusValue(data.xpGathererLevel, settings.xpGatherer.bonuses));
this.upgradeTypeToValue.set(MetaUpgradeType.GoldGatherer, this.getBonusValue(data.goldGathererLevel, settings.goldGatherer.bonuses));
}
private getBonusValue(level: number, bonuses: number[]): number {
if (level <= 0) return 0;
if (bonuses.length < level) throw new Error(`Meta upgrade does not have settings for level ${level}`);
return bonuses[level - 1];
}
public getUpgradeValue(type: MetaUpgradeType): number {