summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-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;
}
}