]> www.infradead.org Git - users/mchehab/andors-trail.git/commitdiff
Added alignments & factions to the player object. This will be used to make several...
authoroskar.wiksten <oskar.wiksten@08aca716-68be-ccc6-4d58-36f5abd142ac>
Thu, 5 Jan 2012 21:17:50 +0000 (21:17 +0000)
committeroskar.wiksten <oskar.wiksten@08aca716-68be-ccc6-4d58-36f5abd142ac>
Thu, 5 Jan 2012 21:17:50 +0000 (21:17 +0000)
git-svn-id: https://andors-trail.googlecode.com/svn/trunk@211 08aca716-68be-ccc6-4d58-36f5abd142ac

AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/MainActivity.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/ConversationController.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/conversation/Phrase.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/MonsterType.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Player.java
AndorsTrail/src/com/gpl/rpg/AndorsTrail/resource/parsers/MonsterTypeParser.java

index 2ecf4e6d45573efc6b20d397d237f28719f41a69..e117b94a81233d29d99abc8a3aee69a3c4225826 100644 (file)
@@ -19,7 +19,7 @@ public final class AndorsTrailApplication extends Application {
        public static final boolean DEVELOPMENT_DEBUGBUTTONS = false;\r
        public static final boolean DEVELOPMENT_VALIDATEDATA = false;\r
        public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;\r
-       public static final int CURRENT_VERSION = 25;\r
+       public static final int CURRENT_VERSION = 26;\r
        public static final String CURRENT_VERSION_DISPLAY = "0.6.11dev";\r
        \r
        public final WorldContext world = new WorldContext();\r
index beff64ac538f6fe1148fac6a6c76bfc470441a11..4694d101a29ecea5034240591b17b9e24bfa5e04 100644 (file)
@@ -10,6 +10,7 @@ import com.gpl.rpg.AndorsTrail.Savegames;
 import com.gpl.rpg.AndorsTrail.context.ViewContext;
 import com.gpl.rpg.AndorsTrail.context.WorldContext;
 import com.gpl.rpg.AndorsTrail.controller.CombatController;
+import com.gpl.rpg.AndorsTrail.controller.MovementController;
 import com.gpl.rpg.AndorsTrail.model.actor.Monster;
 import com.gpl.rpg.AndorsTrail.model.actor.Player;
 import com.gpl.rpg.AndorsTrail.model.item.ItemContainer.ItemEntry;
@@ -120,6 +121,7 @@ public final class MainActivity extends Activity {
                        }
                        break;
                case INTENTREQUEST_CONVERSATION:
+                       MovementController.refreshMonsterAggressiveness(world.model.currentMap, world.model.player);
                        if (resultCode == ConversationActivity.ACTIVITYRESULT_ATTACK) {
                                final Coord p = world.model.player.nextPosition;
                                Monster m = world.model.currentMap.getMonsterAt(p);
index 44bbb3aa6ee6e237053c68ae76549adf50e9050a..2f5f0984402fd84ad3d8109b845e5d79b029e86b 100644 (file)
@@ -50,6 +50,9 @@ public final class ConversationController {
                                        }\r
                                }\r
                                break;\r
+                       case Reward.REWARD_TYPE_ALIGNMENT_CHANGE:\r
+                               player.addAlignment(reward.rewardID, reward.value);\r
+                               break;\r
                        }\r
                }\r
                \r
index e33a7fa1211b5b0e1073fecdab4ed04f9721c8b3..bdafddb523efd7eed4561be6e1f57e2956527dc7 100644 (file)
@@ -83,6 +83,8 @@ public final class MovementController implements TimedMessageTask.Callback {
                
                if (!newMap.visited) playerVisitsMapFirstTime(world, newMap);
                else playerVisitsMap(world, newMap);
+               
+               refreshMonsterAggressiveness(newMap, model.player);
        }
     
        private static void playerVisitsMapFirstTime(final WorldContext world, PredefinedMap m) {
@@ -300,4 +302,13 @@ public final class MovementController implements TimedMessageTask.Callback {
                
        return true;
        }
+
+       public static void refreshMonsterAggressiveness(final PredefinedMap map, final Player player) {
+               for(MonsterSpawnArea a : map.spawnAreas) {
+                       for (Monster m : a.monsters) {
+                               if (m.faction == null) continue;
+                               if (player.getAlignment(m.faction) < 0) m.forceAggressive = true;
+                       }
+               }
+       }
 }
index f9915a002c0e3a09a9fde6d911faad4df03525f6..35bdca01283afe6655e194e839b9d51d16ce9038 100644 (file)
@@ -49,6 +49,7 @@ public final class Phrase {
                public static final int REWARD_TYPE_DROPLIST = 1;
                public static final int REWARD_TYPE_SKILL_INCREASE = 2;
                public static final int REWARD_TYPE_ACTOR_CONDITION = 3;
+               public static final int REWARD_TYPE_ALIGNMENT_CHANGE = 4;
                
                public final int rewardType;
                public final String rewardID;
index 5dcf648392182996504777469cc144451d5709bc..7c95758e7a3e29d4fd62d1fe7518d02fa173788b 100644 (file)
@@ -24,6 +24,7 @@ public final class Monster extends Actor {
        public final String phraseID;
        public final int exp;
        public final DropList dropList;
+       public final String faction;
        
        public Monster(MonsterType monsterType, Coord position) {
                super(monsterType, false);
@@ -34,6 +35,7 @@ public final class Monster extends Actor {
                this.phraseID = monsterType.phraseID;
                this.exp = monsterType.exp;
                this.dropList = monsterType.dropList;
+               this.faction = monsterType.faction;
        }
 
        public void createLoot(Loot container, Player player) {
@@ -72,6 +74,7 @@ public final class Monster extends Actor {
                this.exp = monsterType.exp;
                this.dropList = monsterType.dropList;
                this.forceAggressive = src.readBoolean();
+               this.faction = monsterType.faction;
        }
 
        private static Monster readFromParcel_pre_v0610(DataInputStream src, int fileversion, MonsterType monsterType) throws IOException {
index 65f428732669cd147ca921c34fdae32be0c2fdc5..f340a31bcaefc3dddd8792066505fc564ce9d633 100644 (file)
@@ -12,6 +12,7 @@ public final class MonsterType extends ActorTraits {
        public final DropList dropList;
        public final String phraseID;
        public boolean isRespawnable = true;
+       public final String faction;
 
        public MonsterType(
                        String id, 
@@ -26,7 +27,8 @@ public final class MonsterType extends ActorTraits {
                        ItemTraits_OnUse onHitEffects,
                        int exp, 
                        DropList dropList, 
-                       String phraseID) {
+                       String phraseID,
+                       String faction) {
                super(iconID, tileSize, baseCombatTraits, moveCost, onHitEffects == null ? null : new ItemTraits_OnUse[] { onHitEffects });
                this.id = id;
                this.spawnGroup = spawnGroup;
@@ -37,5 +39,6 @@ public final class MonsterType extends ActorTraits {
                this.moveCost = moveCost;
                this.dropList = dropList;
                this.phraseID = phraseID;
+               this.faction = faction;
        }
 }
index 23a9ec09aebb206de194b98df0d30c2ff3c7246a..ec64dc3dd9d6c5cfb78bf0e6556cbf95631d4301 100644 (file)
@@ -37,6 +37,7 @@ public final class Player extends Actor {
        public String spawnMap;
        public String spawnPlace;
        public int availableSkillIncreases = 0;
+       private final HashMap<String, Integer> alignments = new HashMap<String, Integer>();
        
        public Player() {
                super(new ActorTraits(TileManager.CHAR_HERO, new Size(1, 1), new CombatTraits(), DEFAULT_PLAYER_MOVECOST, null), true);
@@ -70,6 +71,7 @@ public final class Player extends Actor {
                totalExperience = 1;
                availableSkillIncreases = 0;
                skillLevels.clear();
+               alignments.clear();
                recalculateLevelExperience();
                
                Loot startItems = new Loot();
@@ -160,6 +162,16 @@ public final class Player extends Actor {
                return availableSkillIncreases > 0;
        }
 
+       public int getAlignment(String faction) {
+               Integer v = alignments.get(faction);
+               if (v == null) return 0;
+               return v;
+       }
+       public void addAlignment(String faction, int delta) {
+               int newValue = getAlignment(faction) + delta;
+               alignments.put(faction, newValue);
+       }
+
        
        
        // ====== PARCELABLE ===================================================================
@@ -264,6 +276,15 @@ public final class Player extends Actor {
                        if (hasExactQuestProgress("prim_hunt", 240)) addQuestProgress(new QuestProgress("bwm_agent", 250));
                        if (hasExactQuestProgress("bwm_agent", 240)) addQuestProgress(new QuestProgress("prim_hunt", 250));
                }
+               
+               if (fileversion < 26) return;
+               
+               final int size3 = src.readInt();
+               for(int i = 0; i < size3; ++i) {
+                       final String faction = src.readUTF();
+                       final int alignment = src.readInt();
+                       alignments.put(faction, alignment);
+               }
        }
        
        public void writeToParcel(DataOutputStream dest, int flags) throws IOException {
@@ -291,6 +312,11 @@ public final class Player extends Actor {
                        }
                }
                dest.writeInt(availableSkillIncreases);
+               dest.writeInt(alignments.size());
+               for(Entry<String, Integer> e : alignments.entrySet()) {
+                       dest.writeUTF(e.getKey());
+                       dest.writeInt(e.getValue());
+               }
        }
 }
 
index ddf8f9526771d5297115810c64301a0792607c6e..e2fc2bcf81d766a67d102a5aa0e8d9a084c48443 100644 (file)
@@ -47,6 +47,7 @@ public final class MonsterTypeParser extends ResourceParserFor<MonsterType> {
                        , exp                                                                                   // Exp
                        , droplists.getDropList(parts[16])                              // Droplist
                        , ResourceParserUtils.parseNullableString(parts[17]) // PhraseID
+                       , null                                                                                  // Faction
                ));
        }