Class Figure

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    ComputerFigure, PlayerFigure

    public class Figure
    extends Thing
    Base class for all figures in a Starpoint Arena game. If placed on a field, an instance of Figure will behave as a dummy.
    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT_FIGURE_PAINTERCLASS

        public static final java.lang.String DEFAULT_FIGURE_PAINTERCLASS
        Default class for figure painting.
        See Also:
        Constant Field Values
      • UP

        public static final int UP
        Direction constant for negative y direction.
        See Also:
        Constant Field Values
      • LEFT

        public static final int LEFT
        Direction constant for negative x direction.
        See Also:
        Constant Field Values
      • DOWN

        public static final int DOWN
        Direction constant for positive y direction.
        See Also:
        Constant Field Values
      • RIGHT

        public static final int RIGHT
        Direction constant for positive x direction.
        See Also:
        Constant Field Values
      • STEPLEFT

        public static final int STEPLEFT
        Direction constant for negative x direction (3D).
        See Also:
        Constant Field Values
      • STEPRIGHT

        public static final int STEPRIGHT
        Direction constant for positive x direction (3D).
        See Also:
        Constant Field Values
      • ABSMAXENERGY

        public static final int ABSMAXENERGY
        Absolute energy maximum. 1000.
        See Also:
        Constant Field Values
      • heatLevel

        protected int heatLevel
        The heat level of the figure. Figure takes damage above 190. 200 is highest.
      • dieReason

        protected DieReason dieReason
        The die reason of the figure.
      • moved

        protected transient boolean moved
        Flag, if figure moved.
      • INITIALRAMPOWER

        protected int INITIALRAMPOWER
        Initial ram power. 40.
      • MAXHOVERHEIGHT

        public static final int MAXHOVERHEIGHT
        Maximum hover height. 3.
        See Also:
        Constant Field Values
      • side

        protected int side
        Initial image size
      • winCounter

        protected int winCounter
        The number of won levels.
      • initialEnergy

        protected int initialEnergy
        The default initial energy of this figure.
      • ramPower

        protected int ramPower
        The power of this figure when ramming.
      • speedCount

        protected int speedCount
        A counter for the number fo moves to wait until moving on.
      • points

        protected int points
        The points this figure has in the current level.
      • visibleCount

        protected int visibleCount
        Number of rounds to be invisible.
      • hoverHeight

        protected int hoverHeight
        The hover height over the point
      • hoverCount

        protected int hoverCount
        The number of rounds to hover.
      • sumPoints

        protected long sumPoints
        The total points this figure has.
      • lives

        protected int lives
        The lives this figure owns. Default 5.
      • slots

        protected int slots
        Number of slots for permanent items.
      • stunCount

        protected int stunCount
        Counter, for how many rounds the figure is stunned.
      • isRocketTarget

        protected boolean isRocketTarget
        Flag, if figure is target for rockets.
      • pointBonus

        protected int pointBonus
        The point bonus for an enemy who kills this figure.
      • maxRadius

        protected int maxRadius
        The maximum radius for the figure.
      • oldRocketXP

        protected int oldRocketXP
        The last rocket target x coordinates for sound determination.
      • oldRocketYP

        protected int oldRocketYP
        The last rocket target y coordinates for sound determination.
      • name

        protected java.lang.String name
        This figures name.
      • number

        protected int number
        The number of this computer figure. Used for name generation.
      • oldItem

        protected Item oldItem
        The item just dropped because another item was picked up.
      • imageName

        protected java.lang.String imageName
        Name of the figures image.
      • item

        protected Item item
        The item this figure owns.
      • wantsToUseItem

        protected boolean wantsToUseItem
        Flag, if figure wants to use item.
      • alreadyKilled

        protected boolean alreadyKilled
        Flag, if the killing effect was already performed on the killer.
      • viewDir

        protected Direction viewDir
        The current view direction (only relevant for 3D gaming - default is Up).
      • permItems

        protected java.util.ArrayList<ItemPermanent> permItems
        A list of permanent items this figure carries.
      • colorlistener

        protected java.util.LinkedList<FigureColorListener> colorlistener
        A list of figure event listeners
      • energylistener

        protected java.util.LinkedList<FigureEnergyListener> energylistener
        A list of figure event listeners
      • heatlistener

        protected java.util.LinkedList<FigureHeatListener> heatlistener
        A list of figure event listeners
      • hoverlistener

        protected java.util.LinkedList<FigureHoverListener> hoverlistener
        A list of figure event listeners
      • itemlistener

        protected java.util.LinkedList<FigureItemListener> itemlistener
        A list of figure event listeners
      • dieListener

        protected java.util.LinkedList<FigureKillListener> dieListener
        A list of figure event listeners
      • pointlistener

        protected java.util.LinkedList<FigurePointListener> pointlistener
        A list of figure event listeners
      • ramlistener

        protected java.util.LinkedList<FigureRamListener> ramlistener
        A list of figure event listeners
      • stunlistener

        protected java.util.LinkedList<FigureStunListener> stunlistener
        A list of figure event listeners
      • visibilitylistener

        protected java.util.LinkedList<FigureVisibilityListener> visibilitylistener
        A list of figure event listeners
      • movelistener

        protected java.util.LinkedList<FigureMoveListener> movelistener
        A list of figure event listeners
      • killer

        protected Thing killer
        The thing that killed the figure. If the figure is alive, killer is null.
      • sinker

        protected Thing sinker
        The thing that made the figure sink. If the figure is not sinking, killer is null.
      • money

        protected int money
        Money.
      • affectsBlue

        protected boolean affectsBlue
        Flag, if this figure affects blue points. true by default. Set to false in subclasses for figures that do not affect blue points.
      • penalty

        protected int penalty
        Aggregated penalty in the current round.
    • Constructor Detail

      • Figure

        public Figure​(Game game,
                      FigureInfo figureInfo)
        Creates a new figure in a game. All properties, that might change during game, are copied from the FigureInfo settings.
        Parameters:
        game - Reference to the game. Can be null, if figure is not to be used in game.
        figureInfo - The FigureInfo The field on which the figure plays.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the name of this figure.
        Specified by:
        getName in class Thing
        Returns:
        The figures name.
      • getPainterClassname

        public java.lang.String getPainterClassname()
        Gets the fully qualified classname of the Painter to use for this figure (in 2D game). The default implementation (com.starpoints.painter.arena2D.PainterFigure) paints the image as returned by getImageName(AnimationInfo), energy- and explosion fx depending on the figure state, item overlays. To implement special paint behaviour, a fully-qualified classname of a subclass of PainterFigure can be provided.
        Returns:
        "com.starpoints.painter.arena2D.PainterFigure"
      • isAvailableInEditor

        public boolean isAvailableInEditor()
        Checks, if this figure is available in level editor.
        Returns:
        true as default.
      • determineIQ

        protected int determineIQ​(FigureInfo figureInfo)
        Determines the real figures iq depending on the difficulty level.
        Parameters:
        figureInfo - The FigureInfo.
        Returns:
        The figures iq, increased by 20 in Hard mode, decreased by 20 in Easy mode.
      • determineIQ

        protected int determineIQ​(int iq)
        Determines the real figures iq depending on the difficulty level.
        Parameters:
        iq - The figures iq.
        Returns:
        The figures iq, increased by 20 in Hard mode, decreased by 20 in Easy mode.
      • setNumber

        public void setNumber​(int n)
        Sets the number of the figure.
        Parameters:
        n - The number.
      • getInitialEnergy

        public int getInitialEnergy()
        Returns the initial energy level of this thing.
        Returns:
        The initial energy.
      • drawState

        public boolean drawState()
        Checks, if the figure draws items and figure shielding.
        Returns:
        drawState as specified in FigureInfo.
      • setName

        public void setName​(java.lang.String n)
        Sets the name of the figure.
        Parameters:
        n - The name.
      • getNumber

        public int getNumber()
        Gets the number of the figure.
        Returns:
        The number.
      • getDieReason

        public DieReason getDieReason()
        Gets a reason, why this figure dies.
        Returns:
        The die reason.
      • getHeatLevel

        public int getHeatLevel()
        Gets the heat level of the figure.
        Returns:
        The heat level.
      • isDrawingNumber

        public boolean isDrawingNumber()
        Checks, if number should be drawn on this figures image.
        Returns:
        true, if number should be drawn.
      • getMaxSlots

        public int getMaxSlots()
        Gets the maximum number of slots.
        Returns:
        The maximum number of slots.
      • getSlots

        public int getSlots()
        Gets the number of inventory slots.
        Returns:
        The number of slots.
      • setSlots

        public void setSlots​(int slots)
        Sets the number of inventory slots for this figure.
        Parameters:
        slots - The new number of slots.
      • getWinCount

        public int getWinCount()
        Returns the number of won games by this figure.
        Returns:
        The win count
      • increasePointSum

        public void increasePointSum()
        Adds the figures points to the point sum. Adds extra lives if a certain point limit is reached.
      • win

        public int win​(int roundCount)
        This effect is performed when the figure won a level.
        Parameters:
        roundCount - The last round
        Returns:
        The bonus points, the figure gains for winning. 0 per default.
      • removeEnergy

        public final void removeEnergy​(int min,
                                       Thing source,
                                       DieReason reason,
                                       AnimationInfo animation)
        Removes the given amount from this things energy level (if it is not invulnerable). Any present shielding will first be removed. If the energy level is reduced to 0, the thing will explode.
        Overrides:
        removeEnergy in class Thing
        Parameters:
        min - The energy to remove
        source - The source for the energy removal
        reason - The reason for the energy loss.
        animation - The AnimationInfo.
      • onBeforeRemoveEnergy

        protected int onBeforeRemoveEnergy​(int min,
                                           Thing source,
                                           DieReason reason,
                                           AnimationInfo animation)
        Called before energy is removed from figure. Override in subclasses to modify energy losses. Returns the original energy loss by default.
        Parameters:
        min - The energy loss.
        source - the source.
        reason - The energy removal reason.
        animation - The AnimationInfo
        Returns:
        The modified energy loss.
      • addEnergy

        public void addEnergy​(int newEnergy,
                              AnimationInfo animation)
        Adds the given amount to this things energy level. The energy maximum is given by the value of MAXENERGY.
        Overrides:
        addEnergy in class Thing
        Parameters:
        newEnergy - The energy to add.
        animation - The AnimationInfo.
      • addMaxEnergy

        public void addMaxEnergy​(int plus,
                                 AnimationInfo animation)
        Adds the given amount to this things energy maximum. The maximum is given by the value of ABSMAXENERGY
        Parameters:
        plus - The value to add
        animation - The AnimationInfo
      • setMaxEnergy

        public void setMaxEnergy​(int maxEnergy)
        Sets a new energy maximum.
        Overrides:
        setMaxEnergy in class Thing
        Parameters:
        maxEnergy - The new max energy.
      • addInitialEnergy

        public void addInitialEnergy​(int plus,
                                     AnimationInfo animation)
        Adds the given amount to this figures initial energy. The maximum is given by the value of ABSMAXENERGY.
        Parameters:
        plus - The value to add
        animation - The AnimationInfo
      • setInitialEnergy

        public void setInitialEnergy​(int initialEnergy)
        Sets the initial energy when starting a new level. If the initial energy is higher then the current max energy, this is also increased.
        Parameters:
        initialEnergy - The new initial energy when starting a new level
      • addHeat

        public final int addHeat​(int heat,
                                 boolean internal,
                                 Thing source,
                                 AnimationInfo animation)
        Adds the given amount to this things heat level. The heat maximum is 200. If a level of 190 is reached, the figure loses energy each round (8 * (heatLevel-190)).
        Parameters:
        heat - The heat to add. Negative value decreases heat.
        internal - Flag, if heat comes from inside figure.
        source - The source of the heat gain.
        animation - The AnimationInfo
        Returns:
        The finally added heat
      • onAddHeat

        protected int onAddHeat​(int heat,
                                boolean internal,
                                Thing source)
        Called when heat is added. Override in subclasses to modify heat behaviour.
        Parameters:
        heat - The originally added heat
        internal - Flag, if heat was produced inside the figure.
        source - The heating source.
        Returns:
        A modified heat value.
      • beforeMove

        public boolean beforeMove​(Figure f,
                                  Point oldp,
                                  Point newp,
                                  AnimationInfo animation)
        Called, before the game handles this figures move. Calls the FigureMoveListener, which might prevent from moving.
        Parameters:
        f - The figure.
        oldp - The old point.
        newp - The point the figure wants to move to.
        animation - The AnimationInfo.
        Returns:
        true, if the figure can move.
      • die

        public final void die​(Thing source,
                              DieReason reason,
                              AnimationInfo animation)
        Sets the status of the thing to exploding (if it is not invulnerabe).
        Overrides:
        die in class Thing
        Parameters:
        source - The source
        reason - The death reason.
        animation - The AnimationInfo.
      • onBeforeDie

        protected boolean onBeforeDie​(Thing source,
                                      DieReason reason,
                                      AnimationInfo animation)
        Called before the figure dies (after event handling in FigureKillListeners). Override in subclasses for some special death protection.
        Parameters:
        source - The death source.
        reason - The death reason.
        animation - The AnimationInfo
        Returns:
        true, if figure really dies, false to prevent that. true by default.
      • playDyingSound

        protected void playDyingSound​(DieReason reason)
        Plays the sound depending on die reason.
        Parameters:
        reason - The death reason
      • getDyingClip

        protected java.lang.String getDyingClip()
        Gets the sound clip to be played if figure dies.
        Returns:
        "figure_die"
      • onEnemyKilled

        public void onEnemyKilled​(Figure enemy,
                                  int round,
                                  DieReason reason,
                                  AnimationInfo animation)
        Called, if the figure killed an enemy.
        Overrides:
        onEnemyKilled in class Thing
        Parameters:
        enemy - The killed enemy
        round - The current round
        reason - The die reason.
        animation - The AnimationInfo.
      • onExplode

        protected int onExplode​(int power,
                                Thing source,
                                AnimationInfo animation)
        Performed, when a thing stands in an explosion. Modifies the loss by the hoverheight, adds heat and returns the original energy loss. This method might be overridden in subclasses to perform a special behaviour when standing in an explosion.
        Overrides:
        onExplode in class Thing
        Parameters:
        power - The explosion power
        source - The explosion source
        animation - The AnimationInfo.
        Returns:
        A modified energy loss.
      • onAfterDeath

        protected void onAfterDeath​(Point p,
                                    AnimationInfo animation)
        Called after the figure died and was removed from the field. Does nothing.
        Parameters:
        p - The point on which the figure died.
        animation - T-he AnimationInfo
      • getExplosionClip

        protected java.lang.String getExplosionClip()
        Gets a clip that is played if this figure stands in an explosion.
        Returns:
        "explosion0".
      • getHoverHeight

        public int getHoverHeight()
        Returns the hover height of the figure.
        Returns:
        This figures hover height.
      • getHoverRounds

        public int getHoverRounds()
        Returns the hover height of the figure.
        Returns:
        This figures hover duration.
      • isHovering

        public boolean isHovering()
        Returns true, if this figure is currently hovering.
        Returns:
        true, if figure hovers.
      • sink

        public void sink​(Thing source,
                         AnimationInfo animation)
        Makes the figure sink one level.
        Parameters:
        source - The sink source.
        animation - The AnimationInfo.
      • stopSink

        public void stopSink()
        Stops this figures sinking.
      • isSinking

        public boolean isSinking()
        Returns true, if this figure is currently sinking.
        Returns:
        true, if figure sinks.
      • hover

        public void hover​(int height,
                          int length,
                          AnimationInfo animation)
        Lets this figure hover for n rounds at the given height.
        Parameters:
        height - The height the figure has during hovering.
        length - The number of rounds this figure should hover.
        animation - The AnimationInfo.
      • stopHover

        public void stopHover()
        Stops hovering.
      • setHoverHeight

        public void setHoverHeight​(int hoverheight)
        Sets the hoverheight directly.
        Parameters:
        hoverheight - The new hover height.
      • setHoverCount

        public void setHoverCount​(int hovercount)
        Sets the hoverCount directly. If the figure is hovering, the counter indicates the number of rounds the figure will hover. If the figure is sinking, it indicates the number of rounds until it sinks deeper.
        Parameters:
        hovercount - The new hover count.
      • getRamPower

        public int getRamPower​(Figure opponent)
        Returns the ram power of this figure.
        Parameters:
        opponent - The figure that rammed this figure
        Returns:
        The ram power against the opponent
      • isStunned

        public boolean isStunned()
        Returns true, if this figure is currently stunned.
        Returns:
        true, if the figure is stunned, false otherwise.
      • stun

        public void stun​(int rounds,
                         AnimationInfo animation)
        Stuns this figure for the given number of rounds (with additive effect).
        Parameters:
        rounds - The number of rounds, this figure is stunned.
        animation - The AnimationInfo.
      • getStunCount

        public int getStunCount()
        Returns the number of rounds this figure is stunned.
        Returns:
        The number of rounds.
      • isRocketTarget

        public boolean isRocketTarget()
        Checks, if this figure is a possible rocket target.
        Returns:
        true, if the figure is not set as no target.
      • setIsRocketTarget

        public void setIsRocketTarget​(boolean b)
        Sets, if this figure is a possible rocket target.
        Parameters:
        b - true, if the figure is set as target.
      • beRammed

        public void beRammed​(Figure rammer,
                             int energyLoss,
                             AnimationInfo animation)
        Performs the effect when this figure is rammed by the rammer or rams him.
        Parameters:
        rammer - The rammer or rammed figure
        energyLoss - The ram power of the rammer
        animation - The AnimationInfo.
      • getKillBonus

        protected int getKillBonus​(Figure killer)
        Returns a point bonus, when an enemy kills this figure. This does not add the bonus to the killer, it just returns the point bonus!
        Parameters:
        killer - The killer
        Returns:
        The point bonus for the killer.
      • addPoints

        public void addPoints​(int pointBonus,
                              AnimationInfo animation)
        Adds the given number of points to the current point count.
        Parameters:
        pointBonus - The number of gained points. Must be greater 0.
        animation - The AnimationInfo.
      • addPenalty

        public void addPenalty​(int penalty,
                               AnimationInfo animation)
        Removes the given number of points from the current point count. This might become negative.
        Parameters:
        penalty - The penalty points
        animation - The AnimationInfo.
      • getPointSum

        public long getPointSum()
        Gets the total points this figure has.
        Returns:
        The total points
      • getPoints

        public int getPoints()
        Gets the points this figure has in this level.
        Returns:
        The figures points
      • removePoints

        public void removePoints​(int pointLoss,
                                 AnimationInfo animation)
        Subtracts the points from the figures current point count. The point count will not be lesser than 0. Use addPenalty, if negative point count is wanted.
        Parameters:
        pointLoss - The point loss. Must be greater 0.
        animation - The AnimationInfo.
      • getItem

        public Item getItem()
        Gets the item of this figure.
        Returns:
        The figures item, or null, if none is owned.
      • invulnerable

        public void invulnerable​(int rounds)
        Makes this thing invulnerable for the given number of rounds.
        Overrides:
        invulnerable in class Thing
        Parameters:
        rounds - The number of rounds.
      • addPermanentItem

        public boolean addPermanentItem​(ItemPermanent i,
                                        AnimationInfo animation)
        Adds an item to the permanent items list, as long as the number of items is smaller then the slot count.
        Parameters:
        i - The item to add.
        animation - The AnimationInfo.
        Returns:
        true, if the item is added to the inventory.
      • addSlots

        public void addSlots​(int newSlots,
                             AnimationInfo animation)
        Adds a number of slots to the slots for permanent items.
        Parameters:
        newSlots - The number of slots to add.
        animation - The AnimationInfo.
      • addLife

        public boolean addLife()
        Adds a life.
        Returns:
        true, if life was really added (maximum is 10).
      • getLifes

        public int getLifes()
        Gets the number of lives.
        Returns:
        Lives.
      • getPermanentItems

        public java.util.List<ItemPermanent> getPermanentItems()
        Gets an unmodifyable copy of the figures permanent items.
        Returns:
        A list of permanent items.
      • hasPermanentItem

        public boolean hasPermanentItem()
        Returns true, if the figure has at least one permanent item.
        Returns:
        true, if the figure has at least one permanent item
      • losePermanentItem

        public void losePermanentItem​(AnimationInfo animation)
        Removes the last permanent item from the figures list, if the figure has one.
        Parameters:
        animation - The AnimationInfo.
      • losePermanentItem

        public void losePermanentItem​(Item i,
                                      AnimationInfo animation)
        Removes the given permanent item from the figures list, if the figure owns it.
        Parameters:
        i - The item.
        animation - The AnimationInfo
      • losePermanentItemInternal

        public void losePermanentItemInternal​(Item i,
                                              java.lang.String sound,
                                              AnimationInfo animation)
        Removes the given permanent item from the figures list, if the figure owns it, and plays the sound file. Pass null for no sound.
        Parameters:
        i - The item.
        sound - The sound to play.
        animation - The AnimationInfo.
      • sellPermanentItem

        public void sellPermanentItem​(ItemPermanent i,
                                      int price)
        Sells a permanent item and adds the price to this figures money.
        Parameters:
        i - The item.
        price - the price.
      • hasPermanentItem

        public boolean hasPermanentItem​(java.lang.String itemClass)
        Checks, if this figure has an item of the given class.
        Parameters:
        itemClass - The Classname (leading package name is optional)
        Returns:
        true, if this figure has a permanent item of the given class.
      • loseItem

        public void loseItem​(AnimationInfo animation)
        Lets the figure lose the current item.
        Parameters:
        animation - The AnimationInfo.
      • useItem

        public void useItem​(AnimationInfo animation)
        Lets the figure use the current item.
        Parameters:
        animation - The AnimationInfo.
      • entersColor

        public final boolean entersColor​(int c,
                                         AnimationInfo animation)
        Called to check, if the figure is affected by a color when entering a point. Checks supermethods return type, and additionally for hovering and event listeners results.
        Overrides:
        entersColor in class Thing
        Parameters:
        c - The color.
        animation - The AnimationInfo.
        Returns:
        true, if the color affects the figure.
      • staysOnColor

        public final boolean staysOnColor​(int c,
                                          AnimationInfo animation)
        Called to check, if the figure is affected by a color when staying on a point. Checks supermethods return type, and additionally for hovering and event listeners results.
        Overrides:
        staysOnColor in class Thing
        Parameters:
        c - The color.
        animation - The AnimationInfo.
        Returns:
        true, if the color affects the figure.
      • isAffectedByBlack

        public boolean isAffectedByBlack()
        Returns, if this thing is affected by holes.
        Overrides:
        isAffectedByBlack in class Thing
        Returns:
        true, if figure dies on holes.
      • isAffectedByGray

        public boolean isAffectedByGray()
        Returns, if this thing is affected by gray points.
        Overrides:
        isAffectedByGray in class Thing
        Returns:
        true, if figure loses energy on gray points.
      • affectsBlue

        public boolean affectsBlue()
        Returns, if this thing affects blue points.
        Overrides:
        affectsBlue in class Thing
        Returns:
        true, if figure causes explosions on blue points.
      • toString

        public java.lang.String toString()
        Return a string representation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        NAME (ID - IQ) [X/Y] EN:ENERGY
      • setItem

        public void setItem​(Item i,
                            AnimationInfo animation)
        Sets the item for this figure. If the figure already carries an item, this' items onDrop()-method is called. The items user is set to this figure.
        Parameters:
        i - The new item
        animation - The AnimationInfo.
      • takeItem

        public boolean takeItem​(Item item,
                                AnimationInfo animation)
        This method is called when the figure picks up an item, e.g. when moving to a point where an item is placed. If the figure already carries an item, this' items onDrop()-method is called.
        Parameters:
        item - The item to pick up.
        animation - The AnimationInfo.
        Returns:
        If the item cannot be picked up at all and the picker cannot enter the field.
      • reInit

        protected void reInit​(Field field)
        Reinitializes the figure after each level.
        Parameters:
        field - The field. Might be null, if reinitializing for shop or Flash Animation.
      • doCalculateNextPoint

        protected Point doCalculateNextPoint()
        Default implementation. Override in ComputerFigure subclasses to implement own move strategy.
        Returns:
        The point the figure stands on.
      • retrieveNextPoint

        public final Point retrieveNextPoint()
        This method is called each round, to get the next point for this figure when playing. This dummy figure does nothing the whole game (except for exploding maybe...)
        Returns:
        This figures current point
      • addMoney

        public void addMoney​(int gain)
        Adds the given amount fo money to this figure's.
        Parameters:
        gain - The money gain
      • getMoney

        public int getMoney()
        Gets the amount of money of this figure. If money is turned off, the value is Integer.MIN_VALUE.
        Returns:
        The money the figure owns.
      • setMoney

        public void setMoney​(int m)
        Sets the amount of money of this figure.
        Parameters:
        m - The money the figure owns.
      • wantsToUseItem

        public boolean wantsToUseItem()
        This method is called each round, if the figure has an item, to check, if the item should be used.
        Returns:
        true, if this figure wants to use it's item.
      • isVisible

        public boolean isVisible()
        Returns, if the figure is visible.
        Returns:
        true, if figure is visible
      • setVisible

        public void setVisible​(AnimationInfo animation)
        Returns, if the figure is visible.
        Parameters:
        animation - The AnimationInfo
      • setInvisible

        public void setInvisible​(int rounds,
                                 AnimationInfo animation)
        Sets the figure invisible for the given number of rounds.
        Parameters:
        rounds - The number of rounds the figure should be invisible
        animation - The AnimationInfo
      • setPoint

        public void setPoint​(Point p)
        Sets the point this figure occupies.
        Overrides:
        setPoint in class Thing
        Parameters:
        p - The point on the field.
      • updateThing

        protected final void updateThing​(AnimationInfo animation)
        This method is called after each move.
        Overrides:
        updateThing in class Thing
        Parameters:
        animation - The AnimationInfo
      • updatePoints

        protected void updatePoints()
        Resets penalties.
      • updateExplodingStatus

        protected final void updateExplodingStatus​(AnimationInfo animation)
        Handles the things status during update phase of the round when thing is exploding.
        Specified by:
        updateExplodingStatus in class Thing
        Parameters:
        animation - The AnimationInfo.
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        This method is called at the end of the regular updateThing()-method. Override this for special update needs.
        Parameters:
        animation - AnimationInfo
      • onRoundBegin

        public void onRoundBegin​(AnimationInfo animation)
        This method is called at the beginning of each round. Override this for special update needs.
        Parameters:
        animation - AnimationInfo
      • getImageName

        public java.lang.String getImageName​(AnimationInfo animation)
        Gets the image name for this figure.
        Overrides:
        getImageName in class Thing
        Parameters:
        animation - AnimationInfo.
        Returns:
        The image name.
      • addFigureColorListener

        public void addFigureColorListener​(FigureColorListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureColorListener

        public void removeFigureColorListener​(FigureColorListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureEnergyListener

        public void addFigureEnergyListener​(FigureEnergyListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureEnergyListener

        public void removeFigureEnergyListener​(FigureEnergyListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureHeatListener

        public void addFigureHeatListener​(FigureHeatListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureHeatListener

        public void removeFigureHeatListener​(FigureHeatListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureHoverListener

        public void addFigureHoverListener​(FigureHoverListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureHoverListener

        public void removeFigureHoverListener​(FigureHoverListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureItemListener

        public void addFigureItemListener​(FigureItemListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureItemListener

        public void removeFigureItemListener​(FigureItemListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureKillListener

        public void addFigureKillListener​(FigureKillListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureKillListener

        public void removeFigureKillListener​(FigureKillListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigurePointListener

        public void addFigurePointListener​(FigurePointListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigurePointListener

        public void removeFigurePointListener​(FigurePointListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureRamListener

        public void addFigureRamListener​(FigureRamListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureRamListener

        public void removeFigureRamListener​(FigureRamListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureStunListener

        public void addFigureStunListener​(FigureStunListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureStunListener

        public void removeFigureStunListener​(FigureStunListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureVisibilityListener

        public void addFigureVisibilityListener​(FigureVisibilityListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureVisibilityListener

        public void removeFigureVisibilityListener​(FigureVisibilityListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • addFigureMoveListener

        public void addFigureMoveListener​(FigureMoveListener listener)
        Adds a listener for this figures events.
        Parameters:
        listener - The listener
      • removeFigureMoveListener

        public void removeFigureMoveListener​(FigureMoveListener listener)
        Removes a listener for this figures events.
        Parameters:
        listener - The listener
      • firePickesUpExplosiveEvent

        protected boolean firePickesUpExplosiveEvent​(Item it,
                                                     AnimationInfo animation)
        Fires an event indicating that the figure is picking up something exploding. The result of this event method is checked in Item.bePickedUp, in case the status of the exploding thing EXPLODING.
        Parameters:
        it - The exploding item.
        animation - The AnimationInfo.
        Returns:
        false, if any listener protects the figure from exploding, true otherwise.
      • firePickesUpItemEvent

        protected boolean firePickesUpItemEvent​(Item it,
                                                AnimationInfo animation)
        Fires an event indicating that the figure is picking up something.
        Parameters:
        it - The item.
        animation - The AnimationInfo.
        Returns:
        false, if any listener prevents picking up the item, true otherwise.
      • fireStunEvent

        protected int fireStunEvent​(int rounds,
                                    AnimationInfo animation)
        Fires Stun event to listeners and adds the changes by listeners. Returns the resulting value (at least 0).
        Parameters:
        rounds - The stun length.
        animation - The AnimationInfo.
        Returns:
        Modified stun length.
      • fireHoverEvent

        protected int fireHoverEvent​(int length,
                                     AnimationInfo animation)
        Returns a modified hover length.
        Parameters:
        length - The hover length.
        animation - The AnimationInfo.
        Returns:
        Modified hover length.
      • fireEnergyChangeEvent

        protected int fireEnergyChangeEvent​(int change,
                                            AnimationInfo animation)
        Returns a modified energy change.
        Parameters:
        change - The energy change.
        animation - The AnimationInfo.
        Returns:
        Modified energy change.
      • fireEnergyLossEvent

        protected int fireEnergyLossEvent​(int change,
                                          DieReason reason,
                                          AnimationInfo animation)
        Returns a modified energy loss.
        Parameters:
        change - The energy loss.
        reason - The reason for the energy loss.
        animation - The AnimationInfo.
        Returns:
        Modified energy loss.
      • fireHeatChangeEvent

        protected int fireHeatChangeEvent​(int change,
                                          boolean internal,
                                          AnimationInfo animation)
        Returns a modified heat.
        Parameters:
        change - the added heat.
        internal - Flag, if heat gain from inttern source.
        animation - The AnimationInfo.
        Returns:
        Modified heat change.
      • firePointsChangeEvent

        protected int firePointsChangeEvent​(int change,
                                            AnimationInfo animation)
        Returns a modified bonus points.
        Parameters:
        change - The number of added bonus points.
        animation - The AnimationInfo.
        Returns:
        Modified Number of added bonus points.
      • firePointSumChangeEvent

        protected int firePointSumChangeEvent​(int change)
        Returns a modified point sum.
        Parameters:
        change - The number of added points.
        Returns:
        Modified number of added points.
      • fireSlotsChangeEvent

        protected int fireSlotsChangeEvent​(int change,
                                           AnimationInfo animation)
        Returns a modified slot count.
        Parameters:
        change - the number of added slots.
        animation - The AnimationInfo.
        Returns:
        modified number of added slots.
      • firePickesUpBombEvent

        protected boolean firePickesUpBombEvent​(Item bomb,
                                                AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        bomb - The bomb that is picked up by this figure.
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireUseItemEvent

        protected boolean fireUseItemEvent​(Item it,
                                           AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        it - The item permanently lost
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireLosePermanentItemEvent

        protected boolean fireLosePermanentItemEvent​(Item it,
                                                     AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        it - The item permanently lost
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireGainPermanentItemEvent

        protected boolean fireGainPermanentItemEvent​(Item it,
                                                     AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        it - The item permanently lost
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireLoseItemEvent

        protected boolean fireLoseItemEvent​(Item it,
                                            AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        it - The item permanently lost
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireLostPermanentItemEvent

        protected void fireLostPermanentItemEvent​(Item it,
                                                  AnimationInfo animation)
        Fires event after permanent item is finally removed from inventory.
        Parameters:
        it - The item permanently lost
        animation - The AnimationInfo.
      • fireRamEvent

        protected int fireRamEvent​(Figure rammer,
                                   int energyLoss,
                                   AnimationInfo animation)
        Returns the modified ram damage.
        Parameters:
        rammer - The figure ramming this figure.
        energyLoss - The ram damage.
        animation - The AnimationInfo.
        Returns:
        The ram damage after listener modifications.
      • fireRamPowerEvent

        protected int fireRamPowerEvent​(Figure opponent,
                                        int initialRamPower)
        Returns the modified ram power.
        Parameters:
        opponent - The figure being rammed.
        initialRamPower - The figures original ram power.
        Returns:
        The ram damage after listener modifications.
      • fireVisibilityChangesEvent

        protected boolean fireVisibilityChangesEvent​(boolean visible,
                                                     AnimationInfo animation)
        Returns true, if NO listener cancels the action.
        Parameters:
        visible - True, if the figure becomes visible, false if invisible.
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireColorEnterEvent

        protected boolean fireColorEnterEvent​(int c,
                                              AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        c - The color entered.
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireColorStayEvent

        protected boolean fireColorStayEvent​(int c,
                                             AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        c - The color stayed on.
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireDieEvent

        protected boolean fireDieEvent​(Thing source,
                                       DieReason reason,
                                       AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        source - The source that makes this figure explode.
        reason - The reason.
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • fireKillsEnemy

        protected void fireKillsEnemy​(Figure enemy,
                                      DieReason reason,
                                      AnimationInfo animation)
        Fires the enemyKilled event
        Parameters:
        enemy - The killed enemy.
        reason - The reason.
        animation - The AnimationInfo.
      • fireMoveEvent

        protected boolean fireMoveEvent​(Point p,
                                        Point newP,
                                        AnimationInfo animation)
        Returns true, if NO listener cancels the action
        Parameters:
        p - The source point.
        newP - The target point.
        animation - The AnimationInfo.
        Returns:
        false, if the action is cancelled by one of the listeners, true otherwise.
      • setSpeed

        public void setSpeed​(int speed)
        Sets this figures normal speed.
        Parameters:
        speed - The speed.
      • getSpeed

        public int getSpeed()
        Gets this figures normal speed.
        Returns:
        The speed.
      • getIq

        public int getIq()
        Gets the IQ of this figure. The figures original iq is reduced by 20 for easy game and increased by 20 for hard game.
        Returns:
        The IQ.
      • setIq

        public void setIq​(int iq)
        Sets the IQ of this figure (the real iq is modified by the difficulty level).
        Parameters:
        iq - The IQ.
      • removeMoney

        public void removeMoney​(int price)
        Removes a certain amount of money.
        Parameters:
        price - The money to remove.
      • getInvisibilityRounds

        public int getInvisibilityRounds()
        Gets the number of rounds, the figure will be invisible.
        Returns:
        Number of invisible rounds.
      • isDummy

        public boolean isDummy()
        Checks, if this figure is a dummy.
        Returns:
        true, if figure is a dummy.
      • isApplyingLevelInfoSpeed

        public boolean isApplyingLevelInfoSpeed()
        Checks, if the figures speed should be adjusted according to the levels settings.
        Returns:
        true, if level setting for enemy speed should be applied.
      • hasMoved

        public boolean hasMoved()
        Checks, if this figure has moved on the last round.
        Returns:
        true, if the figure has moved in the last round.
      • isApplyingLevelInfoIQ

        public boolean isApplyingLevelInfoIQ()
        Checks, if the levels enemy iq settings should be applied to this figure.
        Returns:
        true, if level settings should be applied.
      • getFreeSlots

        public int getFreeSlots()
        Returns the number of free slots.
        Returns:
        Number of free slots.