Game settings, tool to regenerate

This commit is contained in:
Martin
2022-11-24 13:17:05 +01:00
parent b1f8f66499
commit 1c30cb93ea
14 changed files with 156 additions and 40 deletions

View File

@@ -1,9 +1,12 @@
export enum UpgradeType {
MaxHP,
WeaponLength,
WeaponDamage,
HorizontalProjectile,
VerticalProjectile,
OverallDamage,
Regeneration
}
export enum MetaUpgradeType {
MaxHp,
OverallDamage
}

View File

@@ -5,16 +5,13 @@ export class Upgrader {
private player: Player;
private typeToAction: Map<UpgradeType, () => void> = new Map<UpgradeType, () => void>();
private typeToLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
private typeToMaxLevel: Map<UpgradeType, number> = new Map<UpgradeType, number>();
public constructor(player: Player) {
this.player = player;
this.typeToAction.set(UpgradeType.MaxHP, this.upgradeMaxHp);
this.typeToAction.set(UpgradeType.WeaponLength, this.upgradeWeaponLength);
this.typeToAction.set(UpgradeType.WeaponDamage, this.upgradeWeaponDamage);
this.typeToLevel.set(UpgradeType.MaxHP, 0);
this.typeToLevel.set(UpgradeType.WeaponLength, 0);
this.setTypeMaps(UpgradeType.WeaponLength, this.upgradeWeaponLength, 5);
this.setTypeMaps(UpgradeType.WeaponDamage, this.upgradeWeaponDamage, 5);
}
public upgradeSkill(type: UpgradeType): void {
@@ -22,11 +19,10 @@ export class Upgrader {
this.typeToAction.get(type)();
}
private upgradeMaxHp(): void {
const healthIncrease = 5;
const currentMax: number = this.player.Health.MaxHealthPoints;
this.player.Health.setMaxHealth(currentMax + healthIncrease);
this.player.Health.heal(healthIncrease);
private setTypeMaps(upgradeType: UpgradeType, action: () => void, maxLevel: number): void {
this.typeToAction.set(upgradeType, action);
this.typeToLevel.set(upgradeType, 0);
this.typeToMaxLevel.set(upgradeType, maxLevel);
}
private upgradeWeaponLength(): void {