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 |
class |
BattleUnit.Listener
Listeners who needs to be notified if (currently) hits or dead values
change, to trigger repaint: a GUIBattleChit representing this creature |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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
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.
BattleUnit
public BattleUnit(java.lang.String id,
boolean defender,
int tag,
BattleHex currentHex,
CreatureType type,
Legion legion)
deriveCreatureNameFromId
public java.lang.String deriveCreatureNameFromId()
getLegion
public Legion getLegion()
getTag
public int getTag()
- Specified by:
getTag
in interface BattleCritter
getHits
public int getHits()
- Specified by:
getHits
in interface BattleCritter
setHits
public void setHits(int hits)
- Specified by:
setHits
in interface BattleCritter
wouldDieFrom
public boolean wouldDieFrom(int hits)
- Specified by:
wouldDieFrom
in interface BattleCritter
setDead
public void setDead(boolean dead)
- Specified by:
setDead
in interface BattleCritter
isDead
public boolean isDead()
- Specified by:
isDead
in interface BattleCritter
getCurrentHex
public BattleHex getCurrentHex()
- Specified by:
getCurrentHex
in interface BattleCritter
getStartingHex
public BattleHex getStartingHex()
- Specified by:
getStartingHex
in interface BattleCritter
setCurrentHex
public void setCurrentHex(BattleHex hex)
- Specified by:
setCurrentHex
in interface BattleCritter
moveToHex
public void moveToHex(BattleHex hex)
- Specified by:
moveToHex
in interface BattleCritter
hasMoved
public boolean hasMoved()
- Specified by:
hasMoved
in interface BattleCritter
setMoved
public void setMoved(boolean moved)
- Specified by:
setMoved
in interface BattleCritter
hasStruck
public boolean hasStruck()
- Specified by:
hasStruck
in interface BattleCritter
setStruck
public void setStruck(boolean struck)
- Specified by:
setStruck
in interface BattleCritter
getCreatureType
public CreatureType getCreatureType()
- Specified by:
getCreatureType
in interface BattleCritter
isDefender
public boolean isDefender()
- Specified by:
isDefender
in interface BattleCritter
getId
public java.lang.String getId()
isTitan
public boolean isTitan()
- Specified by:
isTitan
in interface BattleCritter
isLord
public boolean isLord()
- Specified by:
isLord
in interface BattleCritter
isDemiLord
public boolean isDemiLord()
- Specified by:
isDemiLord
in interface BattleCritter
getPower
public int getPower()
- Specified by:
getPower
in interface BattleCritter
getTitanPower
public int getTitanPower()
- Specified by:
getTitanPower
in interface BattleCritter
getSkill
public int getSkill()
- Specified by:
getSkill
in interface BattleCritter
getPointValue
public int getPointValue()
- Specified by:
getPointValue
in interface BattleCritter
isRangestriker
public boolean isRangestriker()
- Specified by:
isRangestriker
in interface BattleCritter
useMagicMissile
public boolean useMagicMissile()
- Specified by:
useMagicMissile
in interface BattleCritter
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interface BattleCritter
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
addListener
public void addListener(BattleUnit.Listener listener)
removeListener
public void removeListener(BattleUnit.Listener listener)
notifyListeners
public void notifyListeners()