From 9b42b246bb7ce461f816a2f2b8dec368bb28963b Mon Sep 17 00:00:00 2001 From: Zukero Date: Sun, 27 Aug 2017 10:21:04 +0200 Subject: [PATCH] Reapply item-borne condition prevented by a now worn out temporary immunity. --- .../controller/ActorStatsController.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java index 35db6bf30..49db85c4d 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java @@ -406,6 +406,32 @@ public final class ActorStatsController { c.duration -= 1; actorConditionListeners.onActorConditionImmunityDurationChanged(actor, c); } + if (actor instanceof Player) { + Player player = (Player) actor; + //Looking for still-equipped items that would reapply this actor condition. + List toReapply = new ArrayList(); + for (Inventory.WearSlot slot : Inventory.WearSlot.values()) { + ItemType t = player.inventory.getItemTypeInWearSlot(slot); + if (t == null) continue; + + ItemTraits_OnEquip equipEffects = t.effects_equip; + if (equipEffects == null) continue; + if (equipEffects.addedConditions == null) continue; + for (ActorConditionEffect e : equipEffects.addedConditions) { + if (!e.conditionType.conditionTypeID.equals(c.conditionType.conditionTypeID)) continue; + //There's another immunity (a temporary one for example) active. No need to keep looking. + if (e.isImmunity()) { + toReapply.clear(); + break; + } + // The player is wearing some other item that gives this formerly immune actor condition + toReapply.add(e); + } + } + for (ActorConditionEffect e : toReapply) { + applyActorCondition(player, e, ActorCondition.DURATION_FOREVER); + } + } } if (removedAnyConditions) { recalculateActorCombatTraits(actor);