summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-17 14:50:36 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-17 14:50:36 +0200
commit4decd2fd1ed29700d41a3b4570f1156bf890a74d (patch)
treef9d8fa834b5ec9baddf40c9f67190e7d66b0d22b /core/src/ch/asynk/tankontank/game
parentaadc15ec9504f9cbebf7e4babe96d2ee10b7d3d4 (diff)
downloadRustAndDust-4decd2fd1ed29700d41a3b4570f1156bf890a74d.zip
RustAndDust-4decd2fd1ed29700d41a3b4570f1156bf890a74d.tar.gz
Army: goes from game to engine
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Army.java18
-rw-r--r--core/src/ch/asynk/tankontank/game/Ctrl.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Factory.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Player.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java23
5 files changed, 9 insertions, 37 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Army.java b/core/src/ch/asynk/tankontank/game/Army.java
deleted file mode 100644
index 852dbe9..0000000
--- a/core/src/ch/asynk/tankontank/game/Army.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package ch.asynk.tankontank.game;
-
-public enum Army
-{
- GE("German"), US("US");
- private String s;
- Army(String s) { this.s = s; }
-
- public boolean isEnemy(Army other)
- {
- return (this != other);
- }
-
- public String toString()
- {
- return s;
- }
-}
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java
index ca2ca64..2a8c99a 100644
--- a/core/src/ch/asynk/tankontank/game/Ctrl.java
+++ b/core/src/ch/asynk/tankontank/game/Ctrl.java
@@ -3,6 +3,7 @@ package ch.asynk.tankontank.game;
import com.badlogic.gdx.utils.Disposable;
import ch.asynk.tankontank.TankOnTank;
+import ch.asynk.tankontank.engine.Army;
import ch.asynk.tankontank.game.states.StateCommon;
import ch.asynk.tankontank.game.states.StateSelect;
import ch.asynk.tankontank.game.states.StateMove;
diff --git a/core/src/ch/asynk/tankontank/game/Factory.java b/core/src/ch/asynk/tankontank/game/Factory.java
index 86db346..fe0ffaa 100644
--- a/core/src/ch/asynk/tankontank/game/Factory.java
+++ b/core/src/ch/asynk/tankontank/game/Factory.java
@@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.GridPoint2;
import ch.asynk.tankontank.TankOnTank;
+import ch.asynk.tankontank.engine.Army;
import ch.asynk.tankontank.engine.Board;
import ch.asynk.tankontank.engine.Orientation;
import ch.asynk.tankontank.game.Unit.UnitId;
diff --git a/core/src/ch/asynk/tankontank/game/Player.java b/core/src/ch/asynk/tankontank/game/Player.java
index 2dbc1b6..b9bba70 100644
--- a/core/src/ch/asynk/tankontank/game/Player.java
+++ b/core/src/ch/asynk/tankontank/game/Player.java
@@ -12,6 +12,7 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import ch.asynk.tankontank.TankOnTank;
+import ch.asynk.tankontank.engine.Army;
import ch.asynk.tankontank.engine.Pawn;
import ch.asynk.tankontank.engine.gfx.Image;
import ch.asynk.tankontank.engine.gfx.Drawable;
@@ -122,7 +123,7 @@ public class Player implements Drawable, Disposable
public boolean isEnemy(Pawn pawn)
{
- return ((Unit) pawn).isEnemy(army);
+ return pawn.isEnemy(army);
}
public boolean canPromote(Pawn pawn)
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index c33e721..ce652b2 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -3,6 +3,7 @@ package ch.asynk.tankontank.game;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
+import ch.asynk.tankontank.engine.Army;
import ch.asynk.tankontank.engine.Pawn;
import ch.asynk.tankontank.engine.Tile;
import ch.asynk.tankontank.engine.HeadedPawn;
@@ -51,20 +52,18 @@ public class Unit extends HeadedPawn
public int mp;
public UnitType type;
public UnitId id;
- public Army army;
private boolean hasMoved;
private boolean hasFired;
- protected Unit(TextureAtlas atlas, String pawn, String head)
+ protected Unit(Army army, TextureAtlas atlas, String pawn, String head)
{
- super(atlas, pawn, head);
+ super(army, atlas, pawn, head);
}
// hard tager
public Unit(Army army, UnitId id, UnitType type, int range, int defense, int movementPoints, TextureAtlas atlas, String unit, String head)
{
- super(atlas, unit, head);
- this.army = army;
+ super(army, atlas, unit, head);
this.rng = range;
this.def = defense;
this.mp = movementPoints;
@@ -78,8 +77,7 @@ public class Unit extends HeadedPawn
// soft tager
public Unit(Army army, UnitId id, UnitType type, int range, int defense, int concealedDefense, int movementPoints, TextureAtlas atlas, String unit, String head)
{
- super(atlas, unit, head);
- this.army = army;
+ super(army, atlas, unit, head);
this.rng = range;
this.def = defense;
this.cdef = concealedDefense;
@@ -91,11 +89,6 @@ public class Unit extends HeadedPawn
this.descr = id.toString() + " (" + rng + "-" + def + "/" + cdef + "-" + mp + ")";
}
- public boolean isEnemy(Army other)
- {
- return army.isEnemy(other);
- }
-
@Override
public int getMovementPoints()
{
@@ -150,12 +143,6 @@ public class Unit extends HeadedPawn
}
@Override
- public boolean isEnemy(Pawn other)
- {
- return army.isEnemy(((Unit) other).army);
- }
-
- @Override
public boolean canRotate()
{
if (type == UnitType.HARD_TARGET) return !hasMoved;