net.sf.colossus.game
Class BattleUnit

java.lang.Object
  extended by 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
 
Field Summary
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
BattleUnit(java.lang.String id, boolean defender, int tag, BattleHex currentHex, CreatureType type, Legion legion)
           
 
Method Summary
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 interface BattleCritter

getHits

public int getHits()
Specified by:
getHits in interface BattleCritter

setHits

public void setHits(int hits)
Specified by:
setHits in interface BattleCritter

setPoison

public void setPoison(int damage)

setPoisonDamage

public void setPoisonDamage(int damage)
Specified by:
setPoisonDamage in interface BattleCritter

addPoisonDamage

public void addPoisonDamage(int damage)
Specified by:
addPoisonDamage in interface BattleCritter

setSlowed

public void setSlowed(int slowValue)
Specified by:
setSlowed in interface BattleCritter

addSlowed

public void addSlowed(int slowValue)
Specified by:
addSlowed in interface BattleCritter

setSlows

public void setSlows(int slowValue)

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

getType

public CreatureType getType()
Specified by:
getType 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

getIdBasedTitanPower

public int getIdBasedTitanPower()

getTitanPowerViaLegionAndPlayer

public int getTitanPowerViaLegionAndPlayer()

getSkill

public int getSkill()
Specified by:
getSkill in interface BattleCritter

getPointValue

public int getPointValue()
Specified by:
getPointValue in interface BattleCritter

getPoison

public int getPoison()
Specified by:
getPoison in interface BattleCritter

getPoisonDamage

public int getPoisonDamage()
Specified by:
getPoisonDamage in interface BattleCritter

getSlowed

public int getSlowed()
Specified by:
getSlowed in interface BattleCritter

getSlows

public int getSlows()
Specified by:
getSlows 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()