Thrall item pickups

This commit is contained in:
2025-02-17 22:17:41 -08:00
parent 5939384b7c
commit 08fcbaf4e2
14 changed files with 285 additions and 25 deletions

View File

@ -1,6 +1,6 @@
import { ALL_STATS, Skill, Stat, SuccessorOption, Wish } from "./datatypes.ts";
import { getSkills } from "./skills.ts";
import { getThralls, LifeStage, Thrall } from "./thralls.ts";
import { getThralls, ItemStage, LifeStage, Thrall } from "./thralls.ts";
export class PlayerProgress {
#name: string;
@ -15,6 +15,8 @@ export class PlayerProgress {
#untrimmedSkillsAvailable: Skill[];
#thrallsUnlocked: number[];
#thrallDamage: Record<number, number>;
#thrallsObtainedItem: number[];
#thrallsDeliveredItem: number[];
constructor(asSuccessor: SuccessorOption, withWish: Wish | null) {
this.#name = asSuccessor.name;
@ -29,6 +31,8 @@ export class PlayerProgress {
this.#untrimmedSkillsAvailable = [];
this.#thrallsUnlocked = [];
this.#thrallDamage = {};
this.#thrallsObtainedItem = [];
this.#thrallsDeliveredItem = [];
this.refill();
}
@ -232,7 +236,6 @@ export class PlayerProgress {
getThrallLifeStage(thrall: Thrall): LifeStage {
let damage = this.#thrallDamage[thrall.id] ?? 0;
console.log(`damage: ${damage}`);
if (damage < 0.5) {
return LifeStage.Fresh;
}
@ -247,6 +250,30 @@ export class PlayerProgress {
}
return LifeStage.Dead;
}
obtainThrallItem(thrall: Thrall) {
if (this.#thrallsObtainedItem.indexOf(thrall.id) != -1) {
return;
}
this.#thrallsObtainedItem.push(thrall.id);
}
deliverThrallItem(thrall: Thrall) {
if (this.#thrallsDeliveredItem.indexOf(thrall.id) != -1) {
return;
}
this.#thrallsDeliveredItem.push(thrall.id);
}
getThrallItemStage(thrall: Thrall): ItemStage {
if (this.#thrallsDeliveredItem.indexOf(thrall.id) != -1) {
return ItemStage.Delivered;
}
if (this.#thrallsObtainedItem.indexOf(thrall.id) != -1) {
return ItemStage.Obtained;
}
return ItemStage.Untouched;
}
}
let active: PlayerProgress | null = null;