summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-09 16:59:10 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-09 16:59:10 +0100
commit0eb5c308137c6a64a09d4d67f26c8454c3a682be (patch)
treefa8796ae8662aae0b0ea02de1627c203e5596713
parent287f4591ce83aaaec4ab7e5bcca61964a1403dcc (diff)
downloadRustAndDust-0eb5c308137c6a64a09d4d67f26c8454c3a682be.zip
RustAndDust-0eb5c308137c6a64a09d4d67f26c8454c3a682be.tar.gz
Player,BattleCommon: AP computation goes into Battle
-rw-r--r--core/src/ch/asynk/rustanddust/game/Player.java25
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java18
2 files changed, 21 insertions, 22 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Player.java b/core/src/ch/asynk/rustanddust/game/Player.java
index 6aa2657..539bed2 100644
--- a/core/src/ch/asynk/rustanddust/game/Player.java
+++ b/core/src/ch/asynk/rustanddust/game/Player.java
@@ -1,6 +1,5 @@
package ch.asynk.rustanddust.game;
-import java.util.Random;
import java.util.List;
import ch.asynk.rustanddust.RustAndDust;
@@ -9,8 +8,6 @@ public class Player
{
private static final float MOVE_TIME = 0.4f;
- private static Random rand = new Random();
-
private int turn;
private int apSpent;
private int actionPoints;
@@ -174,26 +171,12 @@ public class Player
unit.reset();
}
- public void turnStart()
- {
- if (isDeploymentDone())
- computeActionPoints();
- }
-
- public int d6()
- {
- return rand.nextInt(6) + 1;
- }
-
- private void computeActionPoints()
+ public void turnStart(int aps)
{
- this.actionPoints = 2;
- if (d6() > 2) {
- this.actionPoints += 1;
- if (d6() > 3)
- this.actionPoints += 1;
+ if (isDeploymentDone()) {
+ actionPoints = aps;
+ apSpent = 0;
}
- apSpent = 0;
}
public boolean canPromote(Unit unit)
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
index e84961f..0cd753e 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
@@ -33,6 +33,22 @@ public abstract class BattleCommon implements Battle
public abstract Player getWinner();
+ private int d6()
+ {
+ return random.nextInt(6) + 1;
+ }
+
+ protected int getActionPoints()
+ {
+ int aps = 2;
+ if (d6() > 2) {
+ aps += 1;
+ if (d6() > 3)
+ aps += 1;
+ }
+ return aps;
+ }
+
public BattleCommon(Factory factory)
{
this.factory = factory;
@@ -93,7 +109,7 @@ public abstract class BattleCommon implements Battle
return true;
} else {
currentPlayer = getNextPlayer();
- currentPlayer.turnStart();
+ currentPlayer.turnStart(getActionPoints());
return false;
}
}