summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java41
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Engagement.java11
3 files changed, 44 insertions, 12 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index d5a14bb..7de65db 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -249,9 +249,9 @@ public class Hud implements Disposable
pushDialog(okCancel);
}
- public void engagementSummary(int d1, int d2, int cnt, int flk, int def, int tdf, int wdf, String msg)
+ public void engagementSummary(Map.Engagement e)
{
- engagement.show(d1, d2, cnt, flk, def, tdf, wdf, msg, Position.BOTTOM_CENTER);
+ engagement.show(e, Position.BOTTOM_CENTER);
pushDialog(engagement);
}
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 0c42b8f..d0828ba 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -46,6 +46,36 @@ public abstract class Map extends Board
protected abstract void setup();
+ public class Engagement
+ {
+ public int d1;
+ public int d2;
+ public int unitCount;
+ public int flankBonus;
+ public int unitDefense;
+ public int terrainDefense;
+ public int weatherDefense;
+ public int attack;
+ public int defense;
+ public String msg;
+
+ public void set(int d1, int d2, int cnt, int flk, int def, int tdf, int wdf, String msg)
+ {
+ this.d1 = d1;
+ this.d2 = d2;
+ this.unitCount = cnt;
+ this.flankBonus = flk;
+ this.unitDefense = def;
+ this.terrainDefense = tdf;
+ this.weatherDefense = wdf;
+ this.msg = msg;
+ this.attack = (d1 + d2 + unitCount + flankBonus);
+ this.defense = (unitDefense + terrainDefense + weatherDefense);
+ }
+ }
+
+ private Engagement engagement;
+
public int d6()
{
return rand.nextInt(6) + 1;
@@ -79,6 +109,7 @@ public abstract class Map extends Board
objectives = new ObjectiveSet(this, 4);
meteorology = new Meteorology();
+ engagement = new Engagement();
}
@Override
@@ -288,10 +319,10 @@ public abstract class Map extends Board
boolean success = false;
if (die == 2) {
- ctrl.hud.engagementSummary(d1, d2, 0, 0, 0, 0, 0, target.toString() + " is destroyed");
+ engagement.set(d1, d2, 0, 0, 0, 0, 0, target.toString() + " is destroyed");
success = false;
} else if (die == 12) {
- ctrl.hud.engagementSummary(d1, d2, 0, 0, 0, 0, 0, target.toString() + " resisted the assault");
+ engagement.set(d1, d2, 0, 0, 0, 0, 0, target.toString() + " resisted the assault");
success = true;
} else {
@@ -329,9 +360,11 @@ public abstract class Map extends Board
int s2 = (def + tdf + wdf);
success = (s1 >= s2);
- ctrl.hud.engagementSummary(d1, d2, cnt, flk, def, tdf, wdf,
- target.toString() + (success ? " is destroyed" : " resisted the assault"));
+ engagement.set(d1, d2, cnt, flk, def, tdf, wdf, target.toString() + (success ? " is destroyed" : " resisted the assault"));
}
+
+ ctrl.hud.engagementSummary(engagement);
+
return success;
}
diff --git a/core/src/ch/asynk/tankontank/game/hud/Engagement.java b/core/src/ch/asynk/tankontank/game/hud/Engagement.java
index fdaf84d..9a06a42 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Engagement.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Engagement.java
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import ch.asynk.tankontank.game.Player;
+import ch.asynk.tankontank.game.Map;
public class Engagement extends Bg
{
@@ -33,13 +34,11 @@ public class Engagement extends Bg
this.padding = padding;
}
- public void show(int d1, int d2, int cnt, int flk, int def, int tdf, int wdf, String m, Position position)
+ public void show(Map.Engagement e, Position position)
{
- int atk = (d1 + d2 + cnt + flk);
- int df = (def + tdf + wdf);
- attackV.write(String.format("%d\n%d + %d\n%d\n%d", atk, d1, d2, cnt, flk));
- defenseV.write(String.format("%d\n%d\n%d\n%d", df, def, tdf, wdf));
- msg.write(m);
+ attackV.write(String.format("%d\n%d + %d\n%d\n%d", e.attack, e.d1, e.d2, e.unitCount, e.flankBonus));
+ defenseV.write(String.format("%d\n%d\n%d\n%d", e.defense, e.unitDefense, e.terrainDefense, e.weatherDefense));
+ msg.write(e.msg);
float height = (attack.getHeight() + okBtn.getHeight() + msg.getHeight() + (4 * padding));
float width = (attack.getWidth() + defense.getWidth() + attackV.getWidth() + defenseV.getWidth() + (5 * padding));