Package net.sf.colossus.client
Class BattleClientSide
- java.lang.Object
-
- net.sf.colossus.game.Battle
-
- net.sf.colossus.client.BattleClientSide
-
public class BattleClientSide extends Battle
Contains a lot of Battle related data Currently contains also many methods that were earlier in "Strike.java" (client package). First moved to here to make it easier to unify them with the server side version or possibly even with Battle from game package. TODO One handicap right now is isInContact(...) This method is used by getDice, getAttackerSkill and getStrikeNumber; they ask this from Client (and thus need client as argument). On server side, those methods are in CreatureServerSide (do they belong there?? IMHO not, because those calls are valid to to only during a battle, which might not always be the case and nothing prevents calling it then) and CreatureServerSide is able to resolve that question by itself.
-
-
Field Summary
Fields Modifier and Type Field Description private Player
battleActivePlayer
private BattlePhase
battlePhase
private java.util.List<BattleUnit>
battleUnits
private static java.util.logging.Logger
LOGGER
-
Fields inherited from class net.sf.colossus.game.Battle
attacker, battleTurnNumber, defender, game
-
-
Constructor Summary
Constructors Constructor Description BattleClientSide(Game game, Legion attacker, Legion defender, MasterHex location)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
anyOffboardCreatures()
boolean
canStrike(BattleCritter striker, BattleCritter target)
Tell whether a given creature can strike (rangestrike included) the given potential target TODO duplicated in CreatureServerSidevoid
cleanupBattle()
BattleUnit
createBattleUnit(java.lang.String imageName, boolean isDefender, int tag, BattleHex hex, CreatureType type, Legion legion)
(package private) java.util.Set<BattleHex>
findCrittersWithTargets(Client client)
Return the set of hexes with critters that have valid strike targets.java.util.Set<BattleHex>
findTargets(int tag)
java.util.Set<BattleHex>
findTargets(BattleCritter battleUnit, boolean rangestrike)
Return a set of hexes containing targets that the critter may strike TODO duplicated in BattleServerSidejava.util.List<BattleUnit>
getActiveBattleUnits()
java.util.List<BattleCritter>
getAllCritters()
Get all BattleCritters / BattleUnits Abstract because currently implementation is different, but needed on both side, e.g.Legion
getBattleActiveLegion()
Player
getBattleActivePlayer()
BattlePhase
getBattlePhase()
java.lang.String
getBattlePhaseName()
(package private) BattleUnit
getBattleUnit(int tag)
Get the BattleUnit with this tag.BattleUnit
getBattleUnit(BattleHex hex)
BattleUnit
getBattleUnitCS(BattleHex hex)
java.util.List<BattleUnit>
getBattleUnits()
java.util.List<BattleUnit>
getBattleUnits(BattleHex hex)
GameClientSide
getGameClientSide()
java.util.List<BattleUnit>
getInactiveBattleUnits()
void
init(int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase)
boolean
isBattlePhase(BattlePhase phase)
boolean
isCritterOffboard(BattleCritter critter)
boolean
isInContact(BattleCritter striker, boolean countDead)
Return true if there are any enemies adjacent to this battleChit.private boolean
isRangestrikePossible(BattleCritter striker, BattleCritter target)
Deprecated.Should use an extension of Battle instead of Strike, with extension of Creature instead of BattleCritter and extra BattleHexboolean
isTitanOffboard(Player player)
void
markOffboardCreaturesDead()
int
minRangeToEnemy(BattleCritter critter)
Deprecated.Should use an extension of Battle instead of Strike // END OLD COMMENT Now this is moved from Strike to BattleClientSide.void
removeDeadBattleChits()
void
resetAllBattleMoves()
void
setBattleActivePlayer(Player battleActivePlayer)
void
setBattlePhase(BattlePhase battlePhase)
void
setupBattleFight(BattlePhase battlePhase, Player battleActivePlayer)
void
setupPhase(BattlePhase phase, Player battleActivePlayer, int battleTurnNumber)
-
Methods inherited from class net.sf.colossus.game.Battle
computeSkillPenaltyRangestrikeThrough, countBrambleHexes, getAttackingLegion, getBattleTurnNumber, getCritter, getDefendingLegion, getDirection, getGame, getLegionByPlayer, getLocation, getRange, isLOSBlocked, isLOSBlockedDir, isObstacle, isOccupied, isRangestrikePossible, setBattleTurnNumber, toLeft
-
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
battlePhase
private BattlePhase battlePhase
-
battleActivePlayer
private Player battleActivePlayer
-
battleUnits
private final java.util.List<BattleUnit> battleUnits
-
-
Method Detail
-
init
public void init(int battleTurnNumber, Player battleActivePlayer, BattlePhase battlePhase)
-
getGameClientSide
public GameClientSide getGameClientSide()
-
getBattleActivePlayer
public Player getBattleActivePlayer()
-
cleanupBattle
public void cleanupBattle()
-
getBattleActiveLegion
public Legion getBattleActiveLegion()
- Specified by:
getBattleActiveLegion
in classBattle
-
getBattlePhase
public BattlePhase getBattlePhase()
-
setBattlePhase
public void setBattlePhase(BattlePhase battlePhase)
-
isBattlePhase
public boolean isBattlePhase(BattlePhase phase)
-
setupPhase
public void setupPhase(BattlePhase phase, Player battleActivePlayer, int battleTurnNumber)
-
getBattlePhaseName
public java.lang.String getBattlePhaseName()
-
setBattleActivePlayer
public void setBattleActivePlayer(Player battleActivePlayer)
-
setupBattleFight
public void setupBattleFight(BattlePhase battlePhase, Player battleActivePlayer)
-
createBattleUnit
public BattleUnit createBattleUnit(java.lang.String imageName, boolean isDefender, int tag, BattleHex hex, CreatureType type, Legion legion)
-
anyOffboardCreatures
public boolean anyOffboardCreatures()
-
isCritterOffboard
public boolean isCritterOffboard(BattleCritter critter)
-
isTitanOffboard
public boolean isTitanOffboard(Player player)
-
getActiveBattleUnits
public java.util.List<BattleUnit> getActiveBattleUnits()
-
getInactiveBattleUnits
public java.util.List<BattleUnit> getInactiveBattleUnits()
-
getAllCritters
public java.util.List<BattleCritter> getAllCritters()
Description copied from class:Battle
Get all BattleCritters / BattleUnits Abstract because currently implementation is different, but needed on both side, e.g. for BattleMovement- Specified by:
getAllCritters
in classBattle
-
getBattleUnits
public java.util.List<BattleUnit> getBattleUnits()
-
getBattleUnits
public java.util.List<BattleUnit> getBattleUnits(BattleHex hex)
-
getBattleUnitCS
public BattleUnit getBattleUnitCS(BattleHex hex)
-
getBattleUnit
public BattleUnit getBattleUnit(BattleHex hex)
-
getBattleUnit
BattleUnit getBattleUnit(int tag)
Get the BattleUnit with this tag.
-
resetAllBattleMoves
public void resetAllBattleMoves()
-
markOffboardCreaturesDead
public void markOffboardCreaturesDead()
-
removeDeadBattleChits
public void removeDeadBattleChits()
-
findCrittersWithTargets
java.util.Set<BattleHex> findCrittersWithTargets(Client client)
Return the set of hexes with critters that have valid strike targets.- Parameters:
client
- The client.
-
canStrike
public boolean canStrike(BattleCritter striker, BattleCritter target)
Tell whether a given creature can strike (rangestrike included) the given potential target TODO duplicated in CreatureServerSide- Parameters:
striker
- The creature strikingtarget
- The potential target- Returns:
- whether striking target is a valid strike
-
findTargets
public java.util.Set<BattleHex> findTargets(int tag)
-
findTargets
public java.util.Set<BattleHex> findTargets(BattleCritter battleUnit, boolean rangestrike)
Return a set of hexes containing targets that the critter may strike TODO duplicated in BattleServerSide- Parameters:
battleUnit
- the striking creaturerangestrike
- Whether to include rangestrike targets- Returns:
- a set of hexes containing targets
-
isRangestrikePossible
@Deprecated private boolean isRangestrikePossible(BattleCritter striker, BattleCritter target)
Deprecated.Should use an extension of Battle instead of Strike, with extension of Creature instead of BattleCritter and extra BattleHexReturn true if the rangestrike is possible. /* WARNING: this is a duplication from code in Battle ; caller should use a Battle instance instead.
-
minRangeToEnemy
@Deprecated public int minRangeToEnemy(BattleCritter critter)
Deprecated.Should use an extension of Battle instead of Strike // END OLD COMMENT Now this is moved from Strike to BattleClientSide. IMHO this is not a total duplicate of a method in Battle: Battle does not have a minRangeToEnemy, just minRange between concrete hexes, which IS actually called here. TODO can they be unified? Or move to e.g. some class in ai.helper package?Return the titan range (inclusive at both ends) from the critter to the closest enemy critter. Return OUT_OF_RANGE if there are none. // BEGIN OLD COMMENT (when it was in Strike.java): WARNING: this is a duplication from code in Battle ; caller should use a Battle instance instead.
-
isInContact
public boolean isInContact(BattleCritter striker, boolean countDead)
Return true if there are any enemies adjacent to this battleChit. Dead critters count as being in contact only if countDead is true.- Specified by:
isInContact
in classBattle
-
-