]> www.infradead.org Git - users/mchehab/andors-trail.git/commitdiff
Regeneration skill only applies when not adjacent to a monster.
authorOskar Wiksten <oskar.wiksten@gmail.com>
Mon, 30 Jul 2012 11:51:58 +0000 (13:51 +0200)
committerOskar Wiksten <oskar.wiksten@gmail.com>
Mon, 30 Jul 2012 11:51:58 +0000 (13:51 +0200)
AndorsTrail/res/values/strings.xml
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ActorStatsController.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/CombatController.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/GameRoundController.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java

index 30075e76ead5c9a31bf14af39ebfa5e986dcb489..d3121e40a42ad6e1138d717d54e4c5efa9a2374d 100644 (file)
     <string name="skill_longdescription_eater">Gives +%1$d health points (HP) on every kill per skill level.</string>
     <string name="skill_longdescription_fortitude">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.</string>
     <string name="skill_longdescription_evasion">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 %%.</string>
-    <string name="skill_longdescription_regeneration">Gain +%1$d health points (HP) on every round per skill level.</string>
+    <string name="skill_longdescription_regeneration">Gain +%1$d health points (HP) on every round per skill level when no monsters are directly adjacent.</string>
     <string name="skill_longdescription_lower_exploss">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.</string>
     <string name="skill_longdescription_magicfinder">Increases the chance of finding non-ordinary items by %1$d %% for every skill level.</string>
     <string name="skill_longdescription_resistance_mental">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.</string>
index 67312d029b6c2529eb56c25080717e47e817079c..0d53eab0efb9e5fc32e9b5ec1d0d2be695c12625 100644 (file)
@@ -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();
+                       }
                }
        }
 }
index 8a36325a4b417ad621d740d9a2dad3c6c03d37bb..a0911b735028757ce8ede446bef741adfcf91f0b 100644 (file)
@@ -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) {
index 76b22d85be64fbc15ad08c4ebc409c70c64acfc9..df94d67b66c1276904faaeaef3e432d335c4b0fb 100644 (file)
@@ -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);
index 72660fc3b991b909586fa7cb0cc0b25796ed65a7..279211cb40f54922fab0cc8d7c35f7001dcb39ab 100644 (file)
@@ -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;
+       }
 }