From 287f4591ce83aaaec4ab7e5bcca61964a1403dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 9 Dec 2015 16:38:34 +0100 Subject: Battle: use getWinner() and getNextPlayer() --- core/src/ch/asynk/rustanddust/game/Battle.java | 2 -- core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java | 11 +++++++++-- core/src/ch/asynk/rustanddust/game/battles/BattleTest.java | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/Battle.java b/core/src/ch/asynk/rustanddust/game/Battle.java index 86d95a7..c54f9f4 100644 --- a/core/src/ch/asynk/rustanddust/game/Battle.java +++ b/core/src/ch/asynk/rustanddust/game/Battle.java @@ -21,8 +21,6 @@ public interface Battle public void start(); - public Player getVictor(); - public boolean actionDone(); public boolean turnDone(); diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index 0cc2189..e84961f 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -31,6 +31,8 @@ public abstract class BattleCommon implements Battle protected HashMap unitEntry = new HashMap(); protected HashMap unitExit = new HashMap(); + public abstract Player getWinner(); + public BattleCommon(Factory factory) { this.factory = factory; @@ -85,17 +87,22 @@ public abstract class BattleCommon implements Battle { map.turnDone(); currentPlayer.turnEnd(); - Player winner = getVictor(); + Player winner = getWinner(); if (winner != null) { currentPlayer = winner; return true; } else { - currentPlayer = getOpponent(); + currentPlayer = getNextPlayer(); currentPlayer.turnStart(); return false; } } + public Player getNextPlayer() + { + return getOpponent(); + } + @Override public Player getPlayer() { diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java index f161a36..fc6f453 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleTest.java @@ -37,7 +37,7 @@ public class BattleTest extends BattleCommon } @Override - public Player getVictor() + public Player getWinner() { if (usPlayer.getTurnDone() > 2) return usPlayer; -- cgit v1.1-2-g2b99