Class Creature

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Fourmi, Insecte

public abstract class Creature extends ObjetSurCarteAId implements Serializable
The class that extends every living thing on the game.
Most of the common var between Fourmi and Insecte can be found here.
Creature have a lot of interfaces. They can be used to do every action that a creature can do. If a creature can not do an action as lay (pondre) and try to do it, an error message will appear. This actions can all be call by a short cut here (to be able to do creature.action() and not ActionFourmi.action(creature)).
Author:
Hydrolien
See Also:
  • Field Details

    • déplacement

      public Deplacement déplacement
    • chasse

      public Chasse chasse
    • pondre

      public Pondre pondre
    • trophallaxie

      public Trophallaxie trophallaxie
    • evoluer

      public Evoluer evoluer
    • mourir

      public Mourir mourir
    • netoyer

      public Netoyer netoyer
    • tour

      public Tour tour
    • food

      protected int food
    • maxFood

      protected int maxFood
    • givenFood

      protected int givenFood
    • age

      protected int age
    • maxAge

      protected int maxAge
    • isDead

      protected boolean isDead
    • action

      protected byte action
    • maxAction

      protected byte maxAction
    • ph

      protected Pheromone ph
    • health

      protected byte health
    • pheromoneTolerence

      protected byte pheromoneTolerence
    • stade

      protected byte stade
      -3=egg, -2=larva, -1=nymph, 0=imago
    • e

      protected Espece e
    • transported

      protected ObjetSurCarteAId transported
    • lastTurnEnd

      private int lastTurnEnd
  • Constructor Details

    • Creature

      public Creature(CCase ccase, int age, int maxAge, byte maxAction, Pheromone ph, int food, int maxFood)
      Main constructor for Creature.
      All args are Creature var.
    • Creature

      public Creature(CCase ccase, int age, int maxAge, byte maxAction)
      constructor for Creature.
      Here we only know some var, but the main constructor will take care of them.
    • Creature

      public Creature(CCase ccase, int age, int maxAge, int maxAction)
    • Creature

      public Creature(CCase ccase, int age, int maxAge)
      constructor for Creature.
      Here we only know some var, but the main constructor will take care of them.
    • Creature

      public Creature(CCase ccase, int maxAge)
    • Creature

      public Creature(CCase ccase)
    • Creature

      public Creature()
  • Method Details

    • getFood

      public int getFood()
    • getMaxFood

      public int getMaxFood()
    • setFoodMoins1

      public void setFoodMoins1()
    • setFood

      public void setFood(int x)
    • setMaxFood

      public void setMaxFood(int x)
    • ajouteFood

      public void ajouteFood(int x)
    • addFood

      public void addFood(int x)
    • diminuerOuPasFood

      public void diminuerOuPasFood()
    • getGivenFood

      public int getGivenFood()
    • setGivenFood

      public void setGivenFood(int x)
    • getAge

      public int getAge()
    • getMaxAge

      public int getMaxAge()
    • setMaxAge

      public void setMaxAge(int x)
    • setAgePlus1

      public void setAgePlus1()
    • setAge

      public void setAge(int x)
    • ajouteAge

      public void ajouteAge(int x)
    • getAction

      public int getAction()
    • setAction

      private void setAction(byte x)
    • setAction

      public void setAction(int x)
    • setActionMoins

      public void setActionMoins(int x)
    • setActionTo0

      public void setActionTo0()
    • getMaxAction

      public byte getMaxAction()
    • setMaxAction

      public void setMaxAction(byte x)
    • setCCase

      public void setCCase(CCase newCCase)
      Move the Creature from a case to an other.
      It is used by Deplacement interfaces.
      It wil try to remove from old CCase and add to new CCase.
      Overrides:
      setCCase in class ObjetSurCarteAId
    • getPheromone

      public Pheromone getPheromone()
    • getPh

      public Pheromone getPh()
    • setPheromone

      public void setPheromone(Pheromone ph)
    • setPh

      public void setPh(Pheromone ph)
    • setPheromone

      public void setPheromone(byte a, byte b, byte c)
    • setPheromone

      public void setPheromone(int a, int b, int c)
    • getIsDead

      public boolean getIsDead()
    • isDead

      public boolean isDead()
    • setIsDead

      public void setIsDead(boolean b)
    • getHealth

      public byte getHealth()
    • getMaxHealth

      public byte getMaxHealth()
    • setHealth

      public void setHealth(int x)
    • setHealth

      public void setHealth(byte x)
    • getFemelle

      public abstract boolean getFemelle()
    • setFemelle

      public abstract void setFemelle(boolean b)
    • getSex

      public abstract String getSex()
    • getStade

      public byte getStade()
    • setStade

      public void setStade(byte s)
    • setStade

      public void setStade(int x)
    • estFourmi

      public boolean estFourmi()
    • getType

      public abstract byte getType()
    • getPheromoneTolerence

      public byte getPheromoneTolerence()
    • setPheromoneTolerence

      public void setPheromoneTolerence(byte x)
    • getHaveWings

      public abstract boolean getHaveWings()
      return true if Creature have wings.
    • isFlying

      public boolean isFlying()
    • wantFood

      public abstract boolean wantFood()
    • wantClean

      public abstract boolean wantClean()
    • getEspece

      public Espece getEspece()
    • setEspece

      public void setEspece(Espece e)
    • setEspece

      public void setEspece(int e)
    • getName

      public String getName()
    • getLastTurnEnd

      public int getLastTurnEnd()
    • setLastTurnEnd

      public void setLastTurnEnd(int x)
    • isAI

      public boolean isAI()
      Return true if is own by an AI.
    • getIa

      public boolean getIa()
    • getTransported

      public ObjetSurCarteAId getTransported()
    • setTransported

      public void setTransported(ObjetSurCarteAId o)
      Set as transported item o.
      If item is no null it will be remove from the CCase.
      If item is not null & it already have an item it will throw an exception.
    • dropTransported

      public void dropTransported()
      Drop the transported item.
      Transported item is now on the CCase of the Creature & not anymore transported by Creature.
    • getSize

      public int getSize()
    • ceDeplacer

      public void ceDeplacer(boolean bIa)
    • ceDeplacer

      public void ceDeplacer(CCase ccase)
    • ceDeplacer

      public void ceDeplacer(Case ca)
    • ceDeplacer

      public void ceDeplacer(int direction)
    • ceDeplacerPlusieurCase

      public void ceDeplacerPlusieurCase(CCase cc)
    • pondre

      public void pondre()
    • canLay

      public boolean canLay()
    • chasse

      public boolean chasse()
    • chasser

      public boolean chasser(int direction)
    • trophallaxie

      public void trophallaxie(int id, int foodDonnée)
    • trophallaxie

      public void trophallaxie(Creature c, int foodDonnée)
    • trophallaxer

      public void trophallaxer()
    • evoluer

      public void evoluer()
    • mourir

      public void mourir()
    • mourir

      public void mourir(int r)
    • supprimerDeLaCarte

      public void supprimerDeLaCarte()
    • netoyer

      public void netoyer()
    • netoyer

      public void netoyer(Creature c)
    • ceNetoyer

      public void ceNetoyer()
    • netoyerIa

      public boolean netoyerIa()
    • tour

      public void tour()
    • endTurn

      public void endTurn()
    • getStateFood

      public int getStateFood()
      Return the state of the Creature concerning food.
      Returns:
      an int from 0 to 3 (0=OK, 1=medium, 2=bad, 3=critical)
    • getStateAction

      public int getStateAction()
      Return the state of the Creature concerning action.
      Returns:
      an int from 0 to 3 (0=OK, 1=medium, 2=bad, 3=critical)
    • getStateAge

      public int getStateAge()
      Return the state of the Creature concerning age.
      Returns:
      an int from 0 to 3 (0=OK, 1=medium, 2=bad, 3=critical)
    • getStateHealth

      public int getStateHealth()
      Return the state of the Creature concerning health. Creature that don't Override getStateHealth() will always be at 0.
      Returns:
      an int from 0 to 3 (0=OK, 1=medium, 2=bad, 3=critical)
    • getMovingCost

      public int getMovingCost()
    • toString

      public String toString()
      Return a description of the creature.
      Overrides:
      toString in class ObjetAId
    • toStringShort

      public String toStringShort()
      Return a short string that describe this.
      Overrides:
      toStringShort in class ObjetAId
    • getStringStade

      public String getStringStade()
      return stade as a string in the good language.
    • getEstAllié

      public boolean getEstAllié(Creature c)
      Is this consider as an ally of c ?
      Parameters:
      c - A Creature that whant to know if we are ally.
    • getEstEnnemi

      public boolean getEstEnnemi(Creature c)
      Is this consider as an enemy of c ?
      Parameters:
      c - A Creature that whant to know if we are enemy.
    • getIsNeutral

      public boolean getIsNeutral(Creature c)
      Is this consider as neutral for c ?
      Parameters:
      c - A Creature that whant to know if we are neutral.
    • friendlyLevel

      public int friendlyLevel(Creature c)
      Return a friendly level. Higer is more frienly.
      Parameters:
      c - A Creature to test friendly level.
    • getAlliéSurLaCase

      public GCreature getAlliéSurLaCase()
      find all allied Creature on the same Case.
    • getAlliéSurLaCaseSansThis

      public GCreature getAlliéSurLaCaseSansThis()
      find all allied Creature on the same Case and remove this form the GCreature.
    • mourirOuPas

      public void mourirOuPas(int x)
      check if this should died of reason x.
      Parameters:
      x - Reason to died or not.
    • isHungry

      public boolean isHungry(int percentageOfHungryness)
      check if this is hungry.
      Parameters:
      percentageOfHungryness - 0=are you starving to death, 40=are you hungry, 90=can you eat something more.
      return true if actual %age of food is < than percentageOfHungryness.
    • eat

      public void eat(int percentageOfHungryness)
      Eat with the interface Chasse.
      It will stop eating only if action <= 0 or is not hungry or it transport something or chasse have returned false (creature haven't eat the last time he try).
      If transported thing can be eat, it will be done. Else transported thing will be drop at anthill.
    • runAway

      public void runAway()
      Run away if a predator is next to you.
    • preTurn

      public void preTurn()
      Actualise Creature c before the turn.