Another refactor
This commit is contained in:
59
src/engine/ProgressionManager.ts
Normal file
59
src/engine/ProgressionManager.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { type CombatantActor, type Stats } from "../core/types";
|
||||
|
||||
export class ProgressionManager {
|
||||
allocateStat(player: CombatantActor, statName: string) {
|
||||
if (!player.stats || player.stats.statPoints <= 0) return;
|
||||
|
||||
player.stats.statPoints--;
|
||||
if (statName === "strength") {
|
||||
player.stats.strength++;
|
||||
player.stats.maxHp += 2;
|
||||
player.stats.hp += 2;
|
||||
player.stats.attack += 0.2;
|
||||
} else if (statName === "dexterity") {
|
||||
player.stats.dexterity++;
|
||||
player.speed += 1;
|
||||
} else if (statName === "intelligence") {
|
||||
player.stats.intelligence++;
|
||||
if (player.stats.intelligence % 5 === 0) {
|
||||
player.stats.defense++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allocatePassive(player: CombatantActor, nodeId: string) {
|
||||
if (!player.stats || player.stats.skillPoints <= 0) return;
|
||||
if (player.stats.passiveNodes.includes(nodeId)) return;
|
||||
|
||||
player.stats.skillPoints--;
|
||||
player.stats.passiveNodes.push(nodeId);
|
||||
|
||||
// Apply bonuses
|
||||
switch (nodeId) {
|
||||
case "off_1":
|
||||
player.stats.attack += 2;
|
||||
break;
|
||||
case "off_2":
|
||||
player.stats.attack += 4;
|
||||
break;
|
||||
case "def_1":
|
||||
player.stats.maxHp += 10;
|
||||
player.stats.hp += 10;
|
||||
break;
|
||||
case "def_2":
|
||||
player.stats.defense += 2;
|
||||
break;
|
||||
case "util_1":
|
||||
player.speed += 5;
|
||||
break;
|
||||
case "util_2":
|
||||
player.stats.expToNextLevel = Math.floor(player.stats.expToNextLevel * 0.9);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
calculateStats(baseStats: Stats): Stats {
|
||||
return baseStats;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user