diff --git a/javelin/controller/action/world/CastSpells.java b/javelin/controller/action/world/CastSpells.java index 10feb776f..0b599fc65 100644 --- a/javelin/controller/action/world/CastSpells.java +++ b/javelin/controller/action/world/CastSpells.java @@ -69,7 +69,8 @@ int selecttarget() { for (Combatant m : Squad.active.members) { targets.add(m.source.toString()); } - int targetindex = Javelin.choose("Cast on...", targets, false, false); + int targetindex = Javelin.choose("Cast on...", targets, + targets.size() > 4, false); return targetindex; } diff --git a/javelin/controller/action/world/Dismiss.java b/javelin/controller/action/world/Dismiss.java index 4bb59ce51..17636f80f 100644 --- a/javelin/controller/action/world/Dismiss.java +++ b/javelin/controller/action/world/Dismiss.java @@ -50,6 +50,10 @@ public void perform(WorldScreen screen) { if (choice == dismissmercenaries) { dismissmercenaries(mercenaries); } else if (choice >= 0) { + if (dismissmercenaries != Integer.MIN_VALUE + && choice >= dismissmercenaries) { + choice -= 1; + } dismiss(squad.get(choice)); } } diff --git a/javelin/controller/fight/Fight.java b/javelin/controller/fight/Fight.java index ae0f400b2..c7470e778 100644 --- a/javelin/controller/fight/Fight.java +++ b/javelin/controller/fight/Fight.java @@ -468,7 +468,8 @@ public void meld(Combatant hero, Meld m) { * @return Created meld. */ public Meld addmeld(int x, int y, Combatant dead, BattleState s) { - if (dead.summoned || dead.getnumericstatus() != Combatant.STATUSDEAD) { + if (dead.summoned || dead.getnumericstatus() != Combatant.STATUSDEAD + || !dead.source.isalive()) { return null; } Meld m = new Meld(x, y, s.next.ap + 1, dead); diff --git a/javelin/controller/upgrade/classes/ClassLevelUpgrade.java b/javelin/controller/upgrade/classes/ClassLevelUpgrade.java index 7c8452da8..0149decd8 100644 --- a/javelin/controller/upgrade/classes/ClassLevelUpgrade.java +++ b/javelin/controller/upgrade/classes/ClassLevelUpgrade.java @@ -1,6 +1,7 @@ package javelin.controller.upgrade.classes; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import javelin.Javelin; @@ -149,6 +150,8 @@ private void upgradeattack(List sequences, * Prevents an upgrade to reach a level where the character will receive a * new attack per turn, which would need to modify the {@link Monster} to * the point of creating new attacks, calculating 2-handed weapon bonuses... + * + * TODO can be converted to a {@link HashMap} */ public int checkfornewattack(Monster m, int babdelta) { switch (m.getbaseattackbonus() + babdelta) { diff --git a/javelin/model/unit/Monster.java b/javelin/model/unit/Monster.java index ef4c7f1d5..12330c239 100644 --- a/javelin/model/unit/Monster.java +++ b/javelin/model/unit/Monster.java @@ -822,4 +822,9 @@ public ArrayList getattacks() { public float eat() { return size() / 2f; } + + public boolean isalive() { + String type = this.type.toLowerCase(); + return !type.contains("undead") && !type.contains("construct"); + } } diff --git a/javelin/model/unit/attack/AttackSequence.java b/javelin/model/unit/attack/AttackSequence.java index 525bcc75b..5c7b4b4c9 100644 --- a/javelin/model/unit/attack/AttackSequence.java +++ b/javelin/model/unit/attack/AttackSequence.java @@ -1,7 +1,7 @@ package javelin.model.unit.attack; -import java.util.ArrayList; - +import javelin.model.unit.CloneableList; +import javelin.model.unit.feat.attack.PowerAttack; import javelin.model.unit.feat.attack.shot.RapidShot; import javelin.view.screen.StatisticsScreen; @@ -11,26 +11,20 @@ * * @author alex */ -public class AttackSequence extends ArrayList { +public class AttackSequence extends CloneableList { + /** @see PowerAttack */ public boolean powerful = false; - /** - * See {@link RapidShot} - */ + /** @see RapidShot */ public boolean rapid = false; @Override public String toString() { return toString(null); - }; + } @Override public AttackSequence clone() { - final AttackSequence clone = (AttackSequence) super.clone(); - final int size = size(); - for (int i = 0; i < size; i++) { - clone.set(i, get(i).clone()); - } - return clone; + return (AttackSequence) super.clone(); } public String toString(Combatant target) { diff --git a/javelin/model/world/location/fortification/Trove.java b/javelin/model/world/location/fortification/Trove.java index 5ef02b507..fe0afc0ed 100644 --- a/javelin/model/world/location/fortification/Trove.java +++ b/javelin/model/world/location/fortification/Trove.java @@ -23,11 +23,17 @@ * Since the actual fight gives no xp or gold these results are doubled as * treasure. * + * TODO experience was a nice reward but too explotiable. You could dismiss + * mercenaries and have a larger XP reward, or divide the squad and have only + * reiceve all XP, which is super explotaible. If could trigger + * {@link #reward(Reward)} just after the battle is over, this could be easily + * solved. + * * @author alex */ public class Trove extends Fortification { enum Reward { - GOLD, EXPERIENCE, KEY, WORKER, RUBY; + GOLD, /* EXPERIENCE, */ KEY, WORKER, RUBY; static Reward getrandom() { Reward[] all = values(); @@ -45,7 +51,7 @@ static Reward getrandom() { public Trove() { super(DESCRIPTION, DESCRIPTION, 1, 20); if (World.scenario.simpletroves) { - rewards[0] = Reward.EXPERIENCE; + rewards[0] = Reward.GOLD; rewards[1] = Reward.GOLD; } else { rewards[0] = Reward.getrandom(); @@ -107,10 +113,11 @@ public boolean interact() { } String reward(Reward reward) { - if (reward == Reward.EXPERIENCE) { - return RewardCalculator.rewardxp(Squad.active.members, - Squad.active.members, originalgarrison, 2); - } + /* + * if (reward == Reward.EXPERIENCE) { return + * RewardCalculator.rewardxp(Squad.active.members, Squad.active.members, + * originalgarrison, 2); } + */ if (reward == Reward.GOLD) { int gold = RewardCalculator.receivegold(originalgarrison) * 2; Squad.active.gold += gold; diff --git a/javelin/view/screen/SquadScreen.java b/javelin/view/screen/SquadScreen.java index 336e666a5..1e2aca7f9 100644 --- a/javelin/view/screen/SquadScreen.java +++ b/javelin/view/screen/SquadScreen.java @@ -2,10 +2,10 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.List; import javelin.Javelin; +import javelin.controller.comparator.MonsterNameComparator; import javelin.model.unit.Monster; import javelin.model.unit.Squad; import javelin.model.unit.attack.Combatant; @@ -29,20 +29,13 @@ public class SquadScreen extends InfoScreen { List tier = Javelin.MONSTERSBYCR.get(cr); if (tier != null) { for (Monster candidate : tier) { - String type = candidate.type.toLowerCase(); - if (!type.contains("undead") - && !type.contains("construct")) { + if (candidate.isalive()) { CANDIDATES.add(candidate); } } } } - Collections.sort(CANDIDATES, new Comparator() { - @Override - public int compare(Monster o1, Monster o2) { - return o1.toString().compareTo(o2.toString()); - } - }); + Collections.sort(CANDIDATES, MonsterNameComparator.INSTANCE); } ArrayList squad = new ArrayList(); diff --git a/javelin/view/screen/StatisticsScreen.java b/javelin/view/screen/StatisticsScreen.java index e0ef74eb0..db4b49cb2 100644 --- a/javelin/view/screen/StatisticsScreen.java +++ b/javelin/view/screen/StatisticsScreen.java @@ -12,6 +12,7 @@ import javelin.model.unit.Monster; import javelin.model.unit.Skills; import javelin.model.unit.Spawner; +import javelin.model.unit.Squad; import javelin.model.unit.abilities.BreathWeapon; import javelin.model.unit.abilities.spell.Spell; import javelin.model.unit.attack.AttackSequence; @@ -126,10 +127,12 @@ static public String gettext(Combatant c, boolean toggle) { } static String showhp(Combatant c, Monster m) { + boolean isally = Fight.state == null ? Squad.active.members.contains(c) + : Fight.state.blueTeam.contains(c); final String hp; if (Javelin.DEBUG) { hp = Integer.toString(c.hp); - } else if (Fight.state.blueTeam.contains(c)) { + } else if (isally) { hp = Integer.toString(c.maxhp); } else { hp = "~" + c.source.hd.average(); diff --git a/javelin/view/screen/WorldScreen.java b/javelin/view/screen/WorldScreen.java index a3f945943..e216656fb 100644 --- a/javelin/view/screen/WorldScreen.java +++ b/javelin/view/screen/WorldScreen.java @@ -157,6 +157,7 @@ void perform(KeyEvent keyEvent) { for (final WorldAction a : WorldAction.ACTIONS) { for (final String s : a.morekeys) { if (s.equals(Character.toString(keyEvent.getKeyChar()))) { + Game.messagepanel.clear(); a.perform(this); return; } @@ -165,6 +166,7 @@ void perform(KeyEvent keyEvent) { for (final WorldAction a : WorldAction.ACTIONS) { for (final int s : a.keys) { if (s == keyEvent.getKeyCode()) { + Game.messagepanel.clear(); a.perform(this); return; }