Class CreatureServerSide

java.lang.Object
net.sf.colossus.game.Creature
net.sf.colossus.server.CreatureServerSide
All Implemented Interfaces:
BattleCritter

public class CreatureServerSide extends Creature implements BattleCritter
Class Critter represents an individual Titan Character. TODO this duplicates functionality from the CreatureType class, mostly due to the fact that the latter doesn't handle the Titans properly TODO a lot of the code in here is about the battle rules, often implemented in combination with the Battle class. It would be much easier if this class was just a dumb critter and the rules of battles are all in the Battle class.
Author:
David Ripton, Romain Dolbeau
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • battle

      private BattleServerSide battle
    • game

      private final GameServerSide game
      The game this creature belongs to. Never null.
    • tag

      private final int tag
      Unique identifier for each critter.
    • tagCounter

      private static int tagCounter
      Counter used to assign unique tags.
    • penaltyOptions

      private final SortedSet<PenaltyOption> penaltyOptions
    • carryPossible

      private boolean carryPossible
  • Constructor Details

  • Method Details

    • setBattleInfo

      void setBattleInfo(BattleHex currentHex, BattleHex startingHex, BattleServerSide battle)
    • setLegion

      void setLegion(LegionServerSide legion)
    • getGame

      public Game getGame()
    • getTag

      public int getTag()
      Specified by:
      getTag in interface BattleCritter
    • isDefender

      public boolean isDefender()
      Specified by:
      isDefender in interface BattleCritter
    • undoMove

      void undoMove()
    • canStrike

      boolean canStrike(Creature target)
    • strike

      void strike(CreatureServerSide target)
      Calculate number of dice and strike number needed to hit target, and whether any carries and strike penalties are possible. The actual striking is now deferred to strike2().
    • assignStrikePenalty

      void assignStrikePenalty(String prompt)
      Side effects.
    • matchingPenaltyOption

      private PenaltyOption matchingPenaltyOption(String prompt)
      Return true if the passed prompt matches one of the stored penalty options.
    • findCarries

      void findCarries(CreatureServerSide target)
      Side effects on penaltyOptions, Battle.carryTargets
    • possibleCarryToDir

      private boolean possibleCarryToDir(BattleHex targetHex, int dir)
      Return true if carries are possible to the hex in direction dir, considering only terrain.
    • findCarry

      private void findCarry(CreatureServerSide target, BattleHex neighbor)
      For a strike on target, find any carries (including those only allowed via strike penalty) to the creature in neighbor Side effects on penaltyOptions, Battle.carryTargets
    • strike2

      private void strike2(CreatureServerSide target, int dice, int strikeNumber)
      Called after strike penalties are chosen. Roll the dice and apply damage. Highlight legal carry targets.
    • getPenaltyOptions

      Set<PenaltyOption> getPenaltyOptions()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object