diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-17 15:43:43 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-17 15:43:43 +0200 |
commit | 4af430e68750e56cc62ddba117f48ef9aff65619 (patch) | |
tree | bde45aae7b7aeedf7bd8c70a61679c4d28a8d77d | |
parent | 46d5fa56a41a07c2dee3c433a0cf14dc1cec207a (diff) | |
download | RustAndDust-4af430e68750e56cc62ddba117f48ef9aff65619.zip RustAndDust-4af430e68750e56cc62ddba117f48ef9aff65619.tar.gz |
Army: engine/Army -> interface engine/Faction + enum game/Army implements Faction
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Army.java | 22 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Faction.java | 6 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/HeadedPawn.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Army.java | 29 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Factory.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Player.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 1 |
9 files changed, 43 insertions, 34 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Army.java b/core/src/ch/asynk/tankontank/engine/Army.java deleted file mode 100644 index 878fe89..0000000 --- a/core/src/ch/asynk/tankontank/engine/Army.java +++ /dev/null @@ -1,22 +0,0 @@ -package ch.asynk.tankontank.engine; - -public enum Army -{ - GE("German"), - US("US"), - USSR("Soviet"), - EN("English"); - - 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/engine/Faction.java b/core/src/ch/asynk/tankontank/engine/Faction.java new file mode 100644 index 0000000..c697894 --- /dev/null +++ b/core/src/ch/asynk/tankontank/engine/Faction.java @@ -0,0 +1,6 @@ +package ch.asynk.tankontank.engine; + +public interface Faction +{ + public boolean isEnemy(Faction other); +} diff --git a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java index 8965a6e..cbe4cd5 100644 --- a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java +++ b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java @@ -14,9 +14,9 @@ public abstract class HeadedPawn extends Pawn private Image head; protected Orientation orientation; - public HeadedPawn(Army army, TextureAtlas atlas, String pawn, String head) + public HeadedPawn(Faction faction, TextureAtlas atlas, String pawn, String head) { - super(army, atlas, pawn); + super(faction, atlas, pawn); this.head = new Image(atlas.findRegion(head)); this.orientation = Orientation.KEEP; this.descr += " " + orientation; diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index f7bb830..eb5953f 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -34,7 +34,7 @@ public abstract class Pawn implements Moveable, Disposable private Vector3 position = new Vector3(0f, 0f, 0f); private Vector3 prevPosition = new Vector3(0f, 0f, 0f); - protected Army army; + protected Faction faction; protected String descr; private Image image; private StackedImages overlays; @@ -67,9 +67,9 @@ public abstract class Pawn implements Moveable, Disposable { } - public Pawn(Army army, TextureAtlas atlas, String name) + public Pawn(Faction faction, TextureAtlas atlas, String name) { - this.army = army; + this.faction = faction; this.descr = descr; this.image = new Image(atlas.findRegion(name)); this.overlays = new StackedImages(atlas); @@ -87,14 +87,14 @@ public abstract class Pawn implements Moveable, Disposable image.dispose(); } - public boolean isEnemy(Army other) + public boolean isEnemy(Faction other) { - return army.isEnemy(other); + return faction.isEnemy(other); } public boolean isEnemy(Pawn other) { - return army.isEnemy(other.army); + return faction.isEnemy(other.faction); } public boolean isFlankAttack() diff --git a/core/src/ch/asynk/tankontank/game/Army.java b/core/src/ch/asynk/tankontank/game/Army.java new file mode 100644 index 0000000..9e729c6 --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/Army.java @@ -0,0 +1,29 @@ +package ch.asynk.tankontank.game; + +import ch.asynk.tankontank.engine.Faction; + +public enum Army implements Faction +{ + GE("German"), + US("US"), + USSR("Soviet"), + EN("English"); + + private String s; + + Army(String s) { + this.s = s; + } + + @Override + public boolean isEnemy(Faction other) + { + return (this != other); + } + + @Override + 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 2a8c99a..ca2ca64 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -3,7 +3,6 @@ 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 fe0ffaa..86db346 100644 --- a/core/src/ch/asynk/tankontank/game/Factory.java +++ b/core/src/ch/asynk/tankontank/game/Factory.java @@ -9,7 +9,6 @@ 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 d63a3f9..15efea0 100644 --- a/core/src/ch/asynk/tankontank/game/Player.java +++ b/core/src/ch/asynk/tankontank/game/Player.java @@ -12,7 +12,6 @@ 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; diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index ce652b2..f047de4 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -3,7 +3,6 @@ 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; |