diff options
3 files changed, 27 insertions, 40 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java index 5a6a3eb..411b6aa 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/Battle00.java +++ b/core/src/ch/asynk/rustanddust/game/battles/Battle00.java @@ -44,25 +44,7 @@ public class Battle00 extends BattleCommon @Override public Player getWinner() { - if (!abTurnDone()) - return null; - - if (gePlayer.unitsLeft() == 0) - return usPlayer; - if (usPlayer.unitsLeft() == 0) - return gePlayer; - - if (gePlayer.getTurnDone() <= 8) - return null; - - usPlayer.objectivesWon = map.objectivesCount(Army.US); - gePlayer.objectivesWon = map.objectivesCount(Army.GE); - - if (usPlayer.objectivesWon >= gePlayer.objectivesWon) { - return usPlayer; - } else { - return gePlayer; - } + return getWinner(8); } @Override diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index 6ea1046..2f57d95 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -107,11 +107,35 @@ public abstract class BattleCommon implements Battle return burn; } - protected boolean abTurnDone() + protected boolean turnDoneForBoth() { return ((currentPlayer.getTurnDone() > 0) && (currentPlayer.getTurnDone() == getOpponent().getTurnDone())); } + protected Player getWinner(int minTurns) + { + if (!turnDoneForBoth()) + return null; + + if (gePlayer.unitsLeft() == 0) + return usPlayer; + if (usPlayer.unitsLeft() == 0) + return gePlayer; + + if (gePlayer.getTurnDone() <= minTurns) + return null; + + usPlayer.objectivesWon = map.objectivesCount(Army.US); + gePlayer.objectivesWon = map.objectivesCount(Army.GE); + + if (usPlayer.objectivesWon > gePlayer.objectivesWon) + return usPlayer; + else if (usPlayer.objectivesWon < gePlayer.objectivesWon) + return gePlayer; + + return null; + } + @Override public boolean turnDone() { diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index 26e9999..6daf61a 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -41,26 +41,7 @@ public class BattleTest extends BattleCommon @Override public Player getWinner() { - if (!abTurnDone()) - return null; - - if (gePlayer.unitsLeft() == 0) - return usPlayer; - if (usPlayer.unitsLeft() == 0) - return gePlayer; - - if (gePlayer.getTurnDone() <= 4) - return null; - - usPlayer.objectivesWon = map.objectivesCount(Army.US); - gePlayer.objectivesWon = map.objectivesCount(Army.GE); - - if (usPlayer.objectivesWon > gePlayer.objectivesWon) - return usPlayer; - if (usPlayer.objectivesWon < gePlayer.objectivesWon) - return gePlayer; - - return null; + return getWinner(4); } @Override |