Skip to content

Commit

Permalink
Poison immunity
Browse files Browse the repository at this point in the history
  • Loading branch information
hubol committed Aug 15, 2024
1 parent 661987f commit d67a11a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/igua/rpg/rpg-enemy-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export namespace RpgEnemyClass {
value: status?.poison?.value ?? 0,
max: status?.poison?.max ?? 100,
level: status?.poison?.level ?? 0,
immune: status?.poison?.immune ?? false,
},
quirks: {
emotionalDamageIsFatal: status?.quirks?.emotionalDamageIsFatal ?? false,
Expand Down
3 changes: 2 additions & 1 deletion src/igua/rpg/rpg-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ export const RpgPlayer = {
return 45 + RpgProgress.character.attributes.health * 5;
},
poison: {
immune: false,
max: 100,
get level() {
return RpgProgress.character.status.poison.level;
},
set level(value) {
RpgProgress.character.status.poison.level = value;
},
max: 100,
get value() {
return RpgProgress.character.status.poison.value;
},
Expand Down
11 changes: 7 additions & 4 deletions src/igua/rpg/rpg-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export namespace RpgStatus {
invulnerable: number;
invulnerableMax: number;
poison: {
immune: boolean;
level: number;
value: number;
max: number;
Expand Down Expand Up @@ -71,10 +72,12 @@ export namespace RpgStatus {

const ailments = attack.poison > 0;

model.poison.value += attack.poison;
if (model.poison.value >= model.poison.max) {
model.poison.value = 0;
model.poison.level += 1;
if (!model.poison.immune) {
model.poison.value += attack.poison;
if (model.poison.value >= model.poison.max) {
model.poison.value = 0;
model.poison.level += 1;
}
}

// TODO should resistances to damage be factored here?
Expand Down

0 comments on commit d67a11a

Please sign in to comment.