Penance cycle

This commit is contained in:
2025-02-08 23:51:15 -08:00
parent 8c917df618
commit 2361b880eb
9 changed files with 433 additions and 52 deletions

View File

@ -5,6 +5,7 @@ export class PlayerProgress {
#name: string
#stats: Record<Stat, number>
#talents: Record<Stat, number>
#isInPenance: boolean;
#wish: Wish | null;
#exp: number;
#blood: number
@ -16,6 +17,7 @@ export class PlayerProgress {
this.#name = asSuccessor.name;
this.#stats = {...asSuccessor.stats};
this.#talents = {...asSuccessor.talents};
this.#isInPenance = asSuccessor.inPenance;
this.#wish = withWish;
this.#exp = 0;
this.#blood = 0;
@ -28,7 +30,7 @@ export class PlayerProgress {
applyEndOfTurn() {
for (let stat of ALL_STATS.values()) {
this.#stats[stat] += this.#talents[stat];
this.add(stat, this.#talents[stat]);
}
}
@ -36,11 +38,15 @@ export class PlayerProgress {
return this.#name;
}
get isInPenance(): boolean {
return this.#isInPenance;
}
refill() {
this.#blood = 2000;
let learnableSkills = []; // TODO: Also include costing info
for (let skill of getSkills().getAllAvailableSkills().values()) {
for (let skill of getSkills().getAvailableSkills(this.#isInPenance).values()) {
if (this.#canBeAvailable(skill)) {
learnableSkills.push(skill);
}
@ -99,10 +105,8 @@ export class PlayerProgress {
if (amount != Math.floor(amount)) {
throw `stat increment must be integer: ${amount}`
}
if (amount <= 0) {
throw `stat increment must be >0: ${amount}`
}
this.#stats[stat] += amount;
this.#stats[stat] = Math.min(Math.max(this.#stats[stat], -99), 999);
}
addExperience(amt: number) {
@ -169,7 +173,9 @@ export class PlayerProgress {
}
return learnedSkills;
}
}
getStats() { return {...this.#stats} }
getTalents() { return {...this.#talents} } }
let active: PlayerProgress | null = null;