Package net.sf.colossus.game
Class BattleUnit
- java.lang.Object
-
- net.sf.colossus.game.BattleUnit
-
- All Implemented Interfaces:
BattleCritter
public final class BattleUnit extends java.lang.Object implements BattleCritter
Class BattleUnit represents a Creature in a specific Battle. GUI aspects moved to new Class GUIBattleChit. TODO This should at some point extend Creature, or perhaps Creature can take care of all so no extend is needed; but right now, Creature handles some things (e.g. how to change the hexes) differently than how it's done here, so can not "just delegate it" - needs investigation and checking.- Author:
- David Ripton, Clemens Katzer (strip GUI issues out, to own new Class)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BattleUnit.Listener
Listeners who needs to be notified if (currently) hits or dead values change, to trigger repaint: a GUIBattleChit representing this creature
-
Field Summary
Fields Modifier and Type Field Description private CreatureType
creatureType
private BattleHex
currentHex
private boolean
dead
private boolean
defender
private int
hits
private java.lang.String
id
private Legion
legion
private java.util.Set<BattleUnit.Listener>
listeners
Listeners to be informed when something changes, e.g.private static java.util.logging.Logger
LOGGER
private boolean
moved
private int
poison
private int
poisonDamage
private int
slowed
private int
slows
private BattleHex
startingHex
private boolean
struck
private int
tag
-
Constructor Summary
Constructors Constructor Description BattleUnit(java.lang.String id, boolean defender, int tag, BattleHex currentHex, CreatureType type, Legion legion)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(BattleUnit.Listener listener)
void
addPoisonDamage(int damage)
void
addSlowed(int slowValue)
BattleHex
getCurrentHex()
java.lang.String
getDescription()
int
getHits()
java.lang.String
getId()
int
getIdBasedTitanPower()
Legion
getLegion()
int
getPointValue()
int
getPoison()
int
getPoisonDamage()
int
getPower()
int
getSkill()
int
getSlowed()
int
getSlows()
BattleHex
getStartingHex()
int
getTag()
int
getTitanPower()
int
getTitanPowerViaLegionAndPlayer()
CreatureType
getType()
boolean
hasMoved()
boolean
hasStruck()
boolean
isDead()
boolean
isDefender()
boolean
isDemiLord()
boolean
isLord()
boolean
isRangestriker()
boolean
isTitan()
void
moveToHex(BattleHex hex)
void
notifyListeners()
void
removeListener(BattleUnit.Listener listener)
void
setCurrentHex(BattleHex hex)
void
setDead(boolean dead)
void
setHits(int hits)
void
setMoved(boolean moved)
void
setPoison(int damage)
void
setPoisonDamage(int damage)
void
setSlowed(int slowValue)
void
setSlows(int slowValue)
void
setStruck(boolean struck)
java.lang.String
toString()
boolean
useMagicMissile()
boolean
wouldDieFrom(int hits)
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
tag
private final int tag
-
id
private final java.lang.String id
-
defender
private final boolean defender
-
creatureType
private final CreatureType creatureType
-
legion
private final Legion legion
-
hits
private int hits
-
poisonDamage
private int poisonDamage
-
poison
private int poison
-
slows
private int slows
-
slowed
private int slowed
-
currentHex
private BattleHex currentHex
-
startingHex
private BattleHex startingHex
-
moved
private boolean moved
-
struck
private boolean struck
-
dead
private boolean dead
-
listeners
private final java.util.Set<BattleUnit.Listener> listeners
Listeners to be informed when something changes, e.g. right now only GUIBattleChit that needs to repaint if dead or hits change.
-
-
Constructor Detail
-
BattleUnit
public BattleUnit(java.lang.String id, boolean defender, int tag, BattleHex currentHex, CreatureType type, Legion legion)
-
-
Method Detail
-
getLegion
public Legion getLegion()
-
getTag
public int getTag()
- Specified by:
getTag
in interfaceBattleCritter
-
getHits
public int getHits()
- Specified by:
getHits
in interfaceBattleCritter
-
setHits
public void setHits(int hits)
- Specified by:
setHits
in interfaceBattleCritter
-
setPoison
public void setPoison(int damage)
-
setPoisonDamage
public void setPoisonDamage(int damage)
- Specified by:
setPoisonDamage
in interfaceBattleCritter
-
addPoisonDamage
public void addPoisonDamage(int damage)
- Specified by:
addPoisonDamage
in interfaceBattleCritter
-
setSlowed
public void setSlowed(int slowValue)
- Specified by:
setSlowed
in interfaceBattleCritter
-
addSlowed
public void addSlowed(int slowValue)
- Specified by:
addSlowed
in interfaceBattleCritter
-
setSlows
public void setSlows(int slowValue)
-
wouldDieFrom
public boolean wouldDieFrom(int hits)
- Specified by:
wouldDieFrom
in interfaceBattleCritter
-
setDead
public void setDead(boolean dead)
- Specified by:
setDead
in interfaceBattleCritter
-
isDead
public boolean isDead()
- Specified by:
isDead
in interfaceBattleCritter
-
getCurrentHex
public BattleHex getCurrentHex()
- Specified by:
getCurrentHex
in interfaceBattleCritter
-
getStartingHex
public BattleHex getStartingHex()
- Specified by:
getStartingHex
in interfaceBattleCritter
-
setCurrentHex
public void setCurrentHex(BattleHex hex)
- Specified by:
setCurrentHex
in interfaceBattleCritter
-
moveToHex
public void moveToHex(BattleHex hex)
- Specified by:
moveToHex
in interfaceBattleCritter
-
hasMoved
public boolean hasMoved()
- Specified by:
hasMoved
in interfaceBattleCritter
-
setMoved
public void setMoved(boolean moved)
- Specified by:
setMoved
in interfaceBattleCritter
-
hasStruck
public boolean hasStruck()
- Specified by:
hasStruck
in interfaceBattleCritter
-
setStruck
public void setStruck(boolean struck)
- Specified by:
setStruck
in interfaceBattleCritter
-
getType
public CreatureType getType()
- Specified by:
getType
in interfaceBattleCritter
-
isDefender
public boolean isDefender()
- Specified by:
isDefender
in interfaceBattleCritter
-
getId
public java.lang.String getId()
-
isTitan
public boolean isTitan()
- Specified by:
isTitan
in interfaceBattleCritter
-
isLord
public boolean isLord()
- Specified by:
isLord
in interfaceBattleCritter
-
isDemiLord
public boolean isDemiLord()
- Specified by:
isDemiLord
in interfaceBattleCritter
-
getPower
public int getPower()
- Specified by:
getPower
in interfaceBattleCritter
-
getTitanPower
public int getTitanPower()
- Specified by:
getTitanPower
in interfaceBattleCritter
-
getIdBasedTitanPower
public int getIdBasedTitanPower()
-
getTitanPowerViaLegionAndPlayer
public int getTitanPowerViaLegionAndPlayer()
-
getSkill
public int getSkill()
- Specified by:
getSkill
in interfaceBattleCritter
-
getPointValue
public int getPointValue()
- Specified by:
getPointValue
in interfaceBattleCritter
-
getPoison
public int getPoison()
- Specified by:
getPoison
in interfaceBattleCritter
-
getPoisonDamage
public int getPoisonDamage()
- Specified by:
getPoisonDamage
in interfaceBattleCritter
-
getSlowed
public int getSlowed()
- Specified by:
getSlowed
in interfaceBattleCritter
-
getSlows
public int getSlows()
- Specified by:
getSlows
in interfaceBattleCritter
-
isRangestriker
public boolean isRangestriker()
- Specified by:
isRangestriker
in interfaceBattleCritter
-
useMagicMissile
public boolean useMagicMissile()
- Specified by:
useMagicMissile
in interfaceBattleCritter
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceBattleCritter
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
addListener
public void addListener(BattleUnit.Listener listener)
-
removeListener
public void removeListener(BattleUnit.Listener listener)
-
notifyListeners
public void notifyListeners()
-
-