From: Oskar Wiksten Date: Mon, 30 Jul 2012 11:51:58 +0000 (+0200) Subject: Regeneration skill only applies when not adjacent to a monster. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c2bdcb25f2ea4ae7942536c062c9b77d1dd6c9c4;p=users%2Fmchehab%2Fandors-trail.git Regeneration skill only applies when not adjacent to a monster. --- diff --git a/AndorsTrail/res/values/strings.xml b/AndorsTrail/res/values/strings.xml index 30075e7..d3121e4 100644 --- a/AndorsTrail/res/values/strings.xml +++ b/AndorsTrail/res/values/strings.xml @@ -431,7 +431,7 @@ Gives +%1$d health points (HP) on every kill per skill level. On every subsequent level-up, maximum health points (HP) will be raised by %1$d per skill level. This is not applied retroactively, only subsequent level-ups will be affected. For every skill level, reduces both the chance of failed flee attempts by %1$d %% and the chance that an adjacent monster will attack by %2$d %%. - Gain +%1$d health points (HP) on every round per skill level. + Gain +%1$d health points (HP) on every round per skill level when no monsters are directly adjacent. For every skill level, reduces the amount of lost experience caused by death by %1$d %% (percentage of existing exp loss value, not percentage points). %2$d levels will remove all experience loss caused by death. Increases the chance of finding non-ordinary items by %1$d %% for every skill level. Lowers the chance of being afflicted with mental conditions by %1$d %% for every skill level, up to a maximum of %2$d %%. This includes conditions caused by monster attacks such as Dazed or Weapon Feebleness. diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java index 67312d0..0d53eab 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java @@ -375,10 +375,14 @@ public class ActorStatsController { } } - public void applySkillEffectsForNewRound(Player player) { - boolean changed = player.health.add(player.getSkillLevel(SkillCollection.SKILL_REGENERATION) * SkillCollection.PER_SKILLPOINT_INCREASE_REGENERATION, false); - if (changed) { - view.mainActivity.updateStatus(); + public void applySkillEffectsForNewRound(Player player, PredefinedMap currentMap) { + int level = player.getSkillLevel(SkillCollection.SKILL_REGENERATION); + if (level > 0) { + boolean hasAdjacentMonster = MovementController.hasAdjacentAggressiveMonster(currentMap, player.position); + if (!hasAdjacentMonster) { + boolean changed = player.health.add(level * SkillCollection.PER_SKILLPOINT_INCREASE_REGENERATION, false); + if (changed) view.mainActivity.updateStatus(); + } } } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java index 8a36325..a0911b7 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java @@ -135,16 +135,8 @@ public final class CombatController implements VisualEffectCompletedCallback { } public boolean canExitCombat() { return getAdjacentMonster() == null; } - private Monster getAdjacentMonster() { - for (MonsterSpawnArea a : model.currentMap.spawnAreas) { - for (Monster m : a.monsters) { - if (!m.isAgressive()) continue; - if (m.rectPosition.isAdjacentTo(model.player.position)) { - return m; - } - } - } - return null; + private Monster getAdjacentMonster() { + return MovementController.getAdjacentAggressiveMonster(model.currentMap, model.player.position); } public void executeMoveAttack(int dx, int dy) { diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java index 76b22d8..df94d67 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java @@ -17,15 +17,13 @@ public final class GameRoundController implements TimedMessageTask.Callback { this.view = context; this.world = context; this.model = world.model; - //this.id = ModelContainer.rnd.nextInt(); this.roundTimer = new TimedMessageTask(this, Constants.TICK_DELAY, true); } private int ticksUntilNextRound = Constants.TICKS_PER_ROUND; private int ticksUntilNextFullRound = Constants.TICKS_PER_FULLROUND; public boolean onTick(TimedMessageTask task) { - //L.log(id + " : Controller::tick()"); - if (!model.uiSelections.isMainActivityVisible) return false; + if (!model.uiSelections.isMainActivityVisible) return false; if (model.uiSelections.isInCombat) return false; onNewTick(); @@ -67,7 +65,7 @@ public final class GameRoundController implements TimedMessageTask.Callback { } public void onNewPlayerRound() { view.actorStatsController.applyConditionsToPlayer(model.player, false); - view.actorStatsController.applySkillEffectsForNewRound(model.player); + view.actorStatsController.applySkillEffectsForNewRound(model.player, model.currentMap); } public void onNewMonsterRound() { view.actorStatsController.applyConditionsToMonsters(model.currentMap, false); diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java index 72660fc..279211c 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java @@ -308,4 +308,17 @@ public final class MovementController implements TimedMessageTask.Callback { } } } + + public static boolean hasAdjacentAggressiveMonster(PredefinedMap map, Coord position) { + return getAdjacentAggressiveMonster(map, position) != null; + } + public static Monster getAdjacentAggressiveMonster(PredefinedMap map, Coord position) { + for (MonsterSpawnArea a : map.spawnAreas) { + for (Monster m : a.monsters) { + if (!m.isAgressive()) continue; + if (m.rectPosition.isAdjacentTo(position)) return m; + } + } + return null; + } }