diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 16:47:36 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 16:47:36 +0100 |
commit | 62b676bc73b68a340b8497c1936a69af060ff305 (patch) | |
tree | 06edcaa71651d151dee2174cd5b40703622ebfc4 | |
parent | cd44e92ec822b4bf4cb75ed00f4bfe426c00f280 (diff) | |
download | RustAndDust-62b676bc73b68a340b8497c1936a69af060ff305.zip RustAndDust-62b676bc73b68a340b8497c1936a69af060ff305.tar.gz |
Tile,Hex: replace int defenseFor(Pawn, Pawn, Board.PawnCollection) with int defense()
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 32 |
2 files changed, 3 insertions, 31 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index ed861db..8a1e778 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -28,7 +28,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> private StackedImages overlays; private ArrayDeque<Pawn> stack; - public abstract int defenseFor(Pawn pawn, Pawn target, Board.PawnCollection foes); + public abstract int defense(); public abstract int costFrom(Pawn pawn, Orientation side); public abstract boolean isOffMap(); diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index 0499924..63f4422 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -116,36 +116,8 @@ public class Hex extends Tile } @Override - public int defenseFor(Pawn pawn, Pawn target, Board.PawnCollection foes) + public int defense() { - Unit u = (Unit) target; - boolean terrainBonus = true; - - for (Pawn foe : foes) { - if (foe.isA(UnitType.INFANTRY)) - terrainBonus = false; - } - - int tdef = 0; - int def = u.def; - switch(terrain) { - case HILLS: - if (!u.isA(UnitType.HARD_TARGET)) - def = u.cdef; - break; - case WOODS: - case TOWN: - if (!u.isA(UnitType.HARD_TARGET)) - def = u.cdef; - if (terrainBonus) - tdef = 1; - break; - default: - def = ((Unit) target).def; - break; - } - - pawn.engagement.calculus += " >= " + def + " + " + tdef; - return (def + tdef); + return (isA(Terrain.TOWN) ? 1 : 0); } } |