Class Point

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public final class Point
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    The point is the atomic part on the Starpoint field. It has a color, and x and y coordinates on the field. It can have one occupant, which might be any thing, an item, or a figure, but only one at once. In addition to that, a fog can reside on a point. If a point is exploding, the explosionCounter is greater 0 indicating the number of rounds the point will proceed to explode. The explosion power is removed from an occupant as explosion damage each round it stays on the point. Use the explode()-methods to make the point explode immediatly (energy losses to occupants caused by the explosion are handled at the end of the round like all others. Use the explodeDelayed()-method, to cause a delayed explosion of the point after a specified number of rounds. The Effect-class provides convenience methods to make all points in a certain radius explode.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean blueSwirling
      Flag, if the blue swirling efffect is on.
      protected int color
      This points color.
      protected int colorPower
      The power of the new color setter.
      protected Thing colorSrc
      Reference to the last caller of setColor().
      protected int countDown
      Counter for delayed explosions.
      protected Thing delayer
      The source of a delayed explosion.
      protected int delayExplosionLength
      Length of delayed explosions.
      protected int delayExplosionPower
      Explosion power for delayed explosions.
      protected int delayExplosionRadius
      Radius of delayed explosions.
      protected int explosionPower
      The current explosions power.
      protected Thing explosionSource
      The source of an explosion on this point
      protected Field field
      The field this point is on.
      protected Fog fog
      The fog on the point.
      protected Thing grayer
      The source of a gray colouring
      protected Thing heater
      Last thing responsible for heat change.
      protected int heatLevel
      Heat value for occupants.
      protected int newColor
      The new color to set.
      protected Thing swirler
      The source of a swirling effect
      protected int swirling
      Counter for swirling effect.
      int x
      The x coordinate of this point.
      int y
      The y coordinate of this point.
    • Constructor Summary

      Constructors 
      Constructor Description
      Point​(Field f, int x, int y, int color)
      Creates a new point on the field f at the coordinates (x,y).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PointState createState​(java.util.Map<java.lang.Integer,​FigureState> figs, AnimationInfo animation)
      Creates a state object for this point.
      void drawAsTarget()
      After calling this method, the point will be drawn with a target cross this round.
      boolean equals​(java.lang.Object o)
      Checks, if the other Object is a thing with the same id.
      void explode​(int length, int power, Thing source)
      Lets the point explode for the number of length rounds with an explosion power of power.
      void explode​(Thing source)
      Lets this point explode for 3 rounds with the fields default energy loss.
      void explodeDelayed​(int delay, int power, int radius, int rounds, Thing source)
      Lets the point explode after the given delay with the given explosion power for the given number of rounds with the given radius.
      int getColor()
      Returns the points color.
      int getDotColor()
      Gets the color of a dot to display on the point.
      Thing getEnergyLossSource()
      Gets the source of enrgy losses on this point
      int getExplosionCounter()
      Returns the explosion counter that indicates how many rounds this point will explode.
      int getExplosionPower()
      Gets the explosion power of this point.
      Field getField()
      Gets the field this point belongs to.
      Fog getFog()
      Gets the fog on the point.
      Thing getHeater()
      Gets the thing that is responsible for the points heat.
      int getHeatLevel()
      Gets the heat level of this point.
      int getID()  
      static int getNextID()
      Gets the next possible ID for a figure.
      Thing getOccupant()
      Returns this points opponent
      Thing getOldOccupant()
      Gets the last occupant.
      int getX()
      Gets the x coordinate of the point.
      int getY()
      Gets the y coordinate of the point.
      int hashCode()
      Returns the id.
      boolean isBlueSwirling()
      Checks, if this point is blue swirling.
      boolean isExploding()
      Checks, if this point is exploding.
      boolean isOccupied()
      Checks, if the point is occupied.
      boolean isRandomPoint()
      Checks, if this is a randomly colored point.
      boolean isSwirling()
      Checks, if this point is swirling.
      boolean isTarget()
      Checks, if targetcross to display on the point.
      void occupy​(Thing newOccupant, boolean performEnterEffect, AnimationInfo animation)
      Occupies this point with the thing newOccupant performs the point enter effect.
      void setColor​(int newColor, Thing source, AnimationInfo animation)
      Sets the new color of the point.
      void setDotColor​(int col)
      Sets a color for a dot in the middle of the point.
      void setExplosionCounter​(int explosionCounter)
      Sets the explosion counter that indicates how many rounds this point will explode.
      void setFog​(Fog fog)
      Sets the fog on this point.
      void setHeatLevel​(int heat, Thing heater)
      Sets the heat level of this point.
      void setID​(int iD)  
      void stopExplosion()
      Stops an explosion on the point.
      void stopSwirling()
      Stops the swirling color effect for this point.
      void swirlBlue​(int rounds, Thing source)
      Starts the swirling color effect for the given number of rounds.
      void swirlColors​(int rounds, Thing source)
      Starts the swirling color effect for the given number of rounds.
      java.lang.String toLongString()
      Returns a String represantation for this point containing this points coordinates, occupant info etc.
      java.lang.String toString()
      Returns a String represantation for this point containing this points coordinates
      protected void updateOccupant​(AnimationInfo animation)
      Updates the points occupant.
      protected void updatePoint​(AnimationInfo animation)
      Update routine which is called once after each round in a game. - It fires OccupantEvents if a thing stays on a field or left it this round. - If this point is currently exploding, the explosion pointer is increased, and the status set back to normal, if the explosion length is reached, otherwise any opponent is hit with the explosion power.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x

        public int x
        The x coordinate of this point.
      • y

        public int y
        The y coordinate of this point.
      • swirling

        protected int swirling
        Counter for swirling effect.
      • heatLevel

        protected int heatLevel
        Heat value for occupants.
      • heater

        protected Thing heater
        Last thing responsible for heat change.
      • blueSwirling

        protected boolean blueSwirling
        Flag, if the blue swirling efffect is on.
      • field

        protected Field field
        The field this point is on.
      • color

        protected int color
        This points color.
      • explosionSource

        protected Thing explosionSource
        The source of an explosion on this point
      • swirler

        protected Thing swirler
        The source of a swirling effect
      • grayer

        protected Thing grayer
        The source of a gray colouring
      • fog

        protected Fog fog
        The fog on the point.
      • delayer

        protected Thing delayer
        The source of a delayed explosion.
      • countDown

        protected int countDown
        Counter for delayed explosions.
      • delayExplosionPower

        protected int delayExplosionPower
        Explosion power for delayed explosions.
      • delayExplosionRadius

        protected int delayExplosionRadius
        Radius of delayed explosions.
      • delayExplosionLength

        protected int delayExplosionLength
        Length of delayed explosions.
      • explosionPower

        protected int explosionPower
        The current explosions power.
      • colorPower

        protected int colorPower
        The power of the new color setter.
      • newColor

        protected int newColor
        The new color to set.
      • colorSrc

        protected Thing colorSrc
        Reference to the last caller of setColor().
    • Constructor Detail

      • Point

        public Point​(Field f,
                     int x,
                     int y,
                     int color)
        Creates a new point on the field f at the coordinates (x,y).
        Parameters:
        f - The Field to create the point on.
        x - The x coordinate of this point.
        y - The y coordinate of this point.
        color - The color of this point.
    • Method Detail

      • getColor

        public int getColor()
        Returns the points color.
        Returns:
        The color of this point
      • drawAsTarget

        public void drawAsTarget()
        After calling this method, the point will be drawn with a target cross this round.
      • getHeatLevel

        public int getHeatLevel()
        Gets the heat level of this point.
        Returns:
        The heat level
      • setHeatLevel

        public void setHeatLevel​(int heat,
                                 Thing heater)
        Sets the heat level of this point.
        Parameters:
        heat - The heat level
        heater - The responsible thing
      • explode

        public void explode​(Thing source)
        Lets this point explode for 3 rounds with the fields default energy loss.
        Parameters:
        source - The explosion source.
      • explode

        public void explode​(int length,
                            int power,
                            Thing source)
        Lets the point explode for the number of length rounds with an explosion power of power. If the point is currently exploding, the new explosions power is added to the current power.
        Parameters:
        length - The length of the explosion.
        power - The explosion power.
        source - The explosion source.
      • getEnergyLossSource

        public Thing getEnergyLossSource()
        Gets the source of enrgy losses on this point
        Returns:
        A thing that originated the explosion, the gray color, or the swirling state of this point.
      • updatePoint

        protected void updatePoint​(AnimationInfo animation)
        Update routine which is called once after each round in a game. - It fires OccupantEvents if a thing stays on a field or left it this round. - If this point is currently exploding, the explosion pointer is increased, and the status set back to normal, if the explosion length is reached, otherwise any opponent is hit with the explosion power.
        Parameters:
        animation - The AnimationInfo
      • updateOccupant

        protected void updateOccupant​(AnimationInfo animation)
        Updates the points occupant. If an opponent is destroyed, he is removed from the field.
        Parameters:
        animation - The AnimationInfo.
      • occupy

        public void occupy​(Thing newOccupant,
                           boolean performEnterEffect,
                           AnimationInfo animation)
        Occupies this point with the thing newOccupant performs the point enter effect. The things coordinates are set to this points coordinates.
        Parameters:
        newOccupant - The new occupant for this point. (The old occupant is remembered until the update routine in this.oldOccupant.)
        performEnterEffect - Flag, if enter effect should be performed.
        animation - The AnimationInfo.
      • isExploding

        public boolean isExploding()
        Checks, if this point is exploding.
        Returns:
        true, if this points explosionCounter is greater 0.
      • isSwirling

        public boolean isSwirling()
        Checks, if this point is swirling.
        Returns:
        true, if this point is swirling.
      • isBlueSwirling

        public boolean isBlueSwirling()
        Checks, if this point is blue swirling.
        Returns:
        true, if this point is blue swirling.
      • swirlColors

        public void swirlColors​(int rounds,
                                Thing source)
        Starts the swirling color effect for the given number of rounds.
        Parameters:
        rounds - The number of rounds the effect should last.
        source - The source.
      • swirlBlue

        public void swirlBlue​(int rounds,
                              Thing source)
        Starts the swirling color effect for the given number of rounds.
        Parameters:
        rounds - The number of rounds the effect should last.
        source - The source.
      • stopSwirling

        public void stopSwirling()
        Stops the swirling color effect for this point.
      • explodeDelayed

        public void explodeDelayed​(int delay,
                                   int power,
                                   int radius,
                                   int rounds,
                                   Thing source)
        Lets the point explode after the given delay with the given explosion power for the given number of rounds with the given radius. Optionally, a currently blue point can take is blue level into account and explode even bigger. In this case, the color of the point will be switched from verydarkblue to darkblue, from darkblue to blue, from blue to lightblue, or to the specified color, if the point is lightblue.
        Parameters:
        delay - The number of rounds, the explosion will be delayed
        power - The explosion power per round
        radius - The explosion radius.
        rounds - The number of rounds the explosion will last
        source - The source.
      • getOccupant

        public Thing getOccupant()
        Returns this points opponent
        Returns:
        The Thing on the point.
      • getFog

        public Fog getFog()
        Gets the fog on the point.
        Returns:
        The fog.
      • setFog

        public void setFog​(Fog fog)
        Sets the fog on this point.
        Parameters:
        fog - The new fog
      • setDotColor

        public void setDotColor​(int col)
        Sets a color for a dot in the middle of the point. Set to null for no dot.
        Parameters:
        col - The color.
      • setColor

        public void setColor​(int newColor,
                             Thing source,
                             AnimationInfo animation)
        Sets the new color of the point. If the points color was already set in the same round, this method only has an effect, if the sources energy is higher than the former source. If the sources energy is the same, it is randomly chosen, if the coloring takes place. If the source is null, the energy is checked against 0.
        Parameters:
        newColor - The new color to set.
        source - The source
        animation - The AnimationInfo
      • getExplosionPower

        public int getExplosionPower()
        Gets the explosion power of this point.
        Returns:
        The explosion power or 0, if not exploding.
      • toString

        public java.lang.String toString()
        Returns a String represantation for this point containing this points coordinates
        Overrides:
        toString in class java.lang.Object
        Returns:
        A String
      • toLongString

        public java.lang.String toLongString()
        Returns a String represantation for this point containing this points coordinates, occupant info etc.
        Returns:
        A String
      • getDotColor

        public int getDotColor()
        Gets the color of a dot to display on the point.
        Returns:
        The dot color
      • isTarget

        public boolean isTarget()
        Checks, if targetcross to display on the point.
        Returns:
        true, if target cross should be draw
      • getExplosionCounter

        public int getExplosionCounter()
        Returns the explosion counter that indicates how many rounds this point will explode.
        Returns:
        The explosion counter.
      • setExplosionCounter

        public void setExplosionCounter​(int explosionCounter)
        Sets the explosion counter that indicates how many rounds this point will explode.
        Parameters:
        explosionCounter - The explosion counter.
      • getX

        public int getX()
        Gets the x coordinate of the point.
        Returns:
        The x coordinate.
      • getY

        public int getY()
        Gets the y coordinate of the point.
        Returns:
        The y coordinate.
      • getID

        public int getID()
        Returns:
        the iD
      • setID

        public void setID​(int iD)
        Parameters:
        iD - the iD to set
      • stopExplosion

        public void stopExplosion()
        Stops an explosion on the point.
      • getOldOccupant

        public Thing getOldOccupant()
        Gets the last occupant.
        Returns:
        the oldOccupant
      • getField

        public Field getField()
        Gets the field this point belongs to.
        Returns:
        The field.
      • isOccupied

        public boolean isOccupied()
        Checks, if the point is occupied.
        Returns:
        true, if point is occupied by item or figure.
      • getHeater

        public Thing getHeater()
        Gets the thing that is responsible for the points heat.
        Returns:
        The heater.
      • equals

        public boolean equals​(java.lang.Object o)
        Checks, if the other Object is a thing with the same id.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - The object to compare.
        Returns:
        true, if o is a point with same id.
      • isRandomPoint

        public boolean isRandomPoint()
        Checks, if this is a randomly colored point.
        Returns:
        true, random point.
      • hashCode

        public int hashCode()
        Returns the id.
        Overrides:
        hashCode in class java.lang.Object
      • getNextID

        public static int getNextID()
        Gets the next possible ID for a figure. Calling this method is valid Integer.MAXINT times
        Returns:
        a unique integer ID.
      • createState

        public PointState createState​(java.util.Map<java.lang.Integer,​FigureState> figs,
                                      AnimationInfo animation)
        Creates a state object for this point.
        Parameters:
        figs - The map of figure states.
        animation - The AnimationInfo.
        Returns:
        The point state.