Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.farafin.snEADy.world
Class C_Snake

    java.lang.Object
      de.farafin.snEADy.world.C_GameObject
          de.farafin.snEADy.world.C_Snake

All Implemented Interfaces:
  I_Constants, I_PlayFieldConstants

    public final class C_Snake

extends C_GameObject
implements I_Constants

this is the snake.. the body of the player controlled objects

Version:
  $Revision: 1.51 $
Author:
  roland

Field Summary
`protected int` | `length` the length of the snake
`protected float` | `lengthRateStatus` Every LENGTH_RATE's killed segment, the snake gets one segment longer, so here is the status stored..
`protected long` | `nextAutoGrow` reallize the autoGrow
`protected long` | `nextAutoSlow` for realizing autoslow..
`protected D_PlayerData` | `pilot` the "pilot" of the snake. the controlling element.
`private long` | `pilotDelay` for checking if something changed
`private int` | `pilotLength` for checking if something changed
`protected int` | `status` status of the snake
`protected int` | `survivalBonus` the survival bonus a snake gets if it reaches the exit

Fields inherited from class de.farafin.snEADy.world.C_GameObject
`faceDirection, headPosition, nextUpdateTime, objPositions, ownChar, parameter, waitCycles`

Fields inherited from interface de.farafin.snEADy.communication.I_Constants
`analyse_ms, auto_grow_delay, auto_slowdown_delay, closemonitor, commandConstants, damage_length_grow, damage_points_radius, DEBUG, delplayer, easy_points, emergencyPause, exit_time, FACE_EAST, FACE_NORTH, FACE_SOUTH, FACE_WEST, goody_length_occ, goody_length_value, goody_points_occ, goody_points_value, goody_shorter_occ, goody_shorter_value, goody_slowdown_occ, goody_speed_occ, IN_ACTION, IN_ERROR_EXC, IN_ERROR_INIT, IN_ERROR_SPACE, IN_ERROR_TIME, IN_EXIT, IN_HEAVEN, init_length, init_move_delay, kill, kill_point_goodies, kill_points_radius, loadhuman, loadlevel, loadplayer, logging, max_goody_occ_delay, MAX_HUMAN_PLAYERS, max_mem_check_delay, max_move_delay, max_player_mem, MAX_PLAYERS, max_thinking_ms, min_cycle_ms, min_move_delay, openmonitor, overalldelay, pause, print_calc_ms, print_parameter, print_player_mem, print_playfield, quit, run, show_subcycles, start, stop, suddend_time, survival_points, timeout_ms, TURN_LEFT, TURN_NONE, TURN_RIGHT`

Fields inherited from interface de.farafin.snEADy.communication.I_PlayFieldConstants
`EXIT, FIELD_B, FIELD_C, FIELD_D, FIELD_E, FIELD_F, FIELD_G, FIELD_H, FIELD_I, FIELD_J, FIELD_K, FIELD_L, FIELD_M, FIELD_N, FIELD_O, FIELD_P, FIELD_Q, FIELD_R, FIELD_S, FIELD_T, FIELD_U, FIELD_V, FIELD_W, FIELD_X, FIELD_Y, FIELD_Z, FREE, GOODY_f, GOODY_g, GOODY_h, GOODY_i, GOODY_j, GOODY_k, GOODY_l, GOODY_m, GOODY_n, GOODY_o, GOODY_p, GOODY_q, GOODY_r, GOODY_s, GOODY_t, GOODY_u, GOODY_v, GOODY_w, GOODY_x, GOODY_y, GOODY_z, LENGTH, PLAYER_0, PLAYER_1, PLAYER_2, PLAYER_3, PLAYER_4, PLAYER_5, PLAYER_6, PLAYER_7, PLAYER_8, PLAYER_9, POINTS, SHORT, SLOW, SPEED, WALL`

Constructor Summary
`protected` | `C_Snake()` default constructor
`protected` | `C_Snake(D_PlayerData playerData, GameParameter parameter)`
`protected` | `C_Snake(D_Vec2D headPosition, int faceDirection, char ownChar, D_PlayerData pilot, long waitCycles, GameParameter parameter)` constructor
`protected` | `C_Snake(D_Vec2D headPosition, int faceDirection, char ownChar, int length, D_PlayerData pilot, long waitCycles, GameParameter parameter)` constructor
`protected` | `C_Snake(D_Vec2D headPosition, int faceDirection, RingVector objPositions, char ownChar, int length, D_PlayerData pilot, long waitCycles, GameParameter parameter)` smart Constructor
`protected` | `C_Snake(D_Vec2D headPosition, int faceDirection, RingVector objPositions, char ownChar, int status, int length, D_PlayerData pilot, long waitCycles, GameParameter parameter)` create Constructor

Method Summary
`private void` | `actualizateSnakeLength(C_Arena arena, D_Vec2D lastPos)`
`protected java.lang.Object` | `clone()`
`private void` | `computeKillPoints(C_Arena arena, C_Snake snake, boolean died)` computes the kill points for other snakes if this one looses a segment or is killed
`private void` | `die(C_Arena arena, C_Snake killer)` kills the snake
`protected D_Vec2D[]` | `getAllPosSorted(int sort)`
`private char` | `getCharDirHead(C_Arena arena, int direction)` checs which char is in direction of `direction<\code>.`
`protected D_PlayerData` | `getPilot()`
`private boolean` | `isBlocked(char c)`
`protected void` | `jumpTo(D_Vec2D pos, C_Arena arena)` turns the head of the object to `left_right`
`protected void` | `moveToFace(C_Arena arena)` let the object move one field to the direction of its head it is necessary, that there it is computed here what happands if the object runns into a wall..
`private D_Vec2D` | `removeLastSegments(C_Arena arena, int n)`
`java.lang.String` | `toString()`
`private void` | `turnHead(C_Arena arena)` turns the head to the direction pilot
`private void` | `turnHeadBack()` turns the head to the opposide direction of what pilot sais pilot
`protected void` | `update(C_Arena arena)` the update call meens that the object should do what ever it does usually
`private void` | `updateLengthState()` if the length state is bigger than one, the snake gets longer..
`protected void` | `updatePilot()` updates the own informations with the snake infos
`private void` | `updateSpeedState()` if speed State is more than one, the snake gets slower

Methods inherited from class de.farafin.snEADy.world.C_GameObject
`getAllPosArray, getAllPosList, getFaceDirection, getHeadPosition, getNextPosInFaceDirection, getNextUpdateTime, getOwnChar, jumpHeadPos, setFaceDirection, setHeadPosition`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### status

    protected int status

  status of the snake

  See Also:
    `I_Constants.IN_ACTION`, `I_Constants.IN_HEAVEN`, `I_Constants.IN_EXIT`, `I_Constants.IN_ERROR_TIME`, `I_Constants.IN_ERROR_SPACE`, `I_Constants.IN_ERROR_INIT`, `I_Constants.IN_ERROR_EXC`

### length

    protected int length

  the length of the snake

### lengthRateStatus

    protected float lengthRateStatus

  Every LENGTH_RATE's killed segment, the snake gets one segment longer, so here is the status stored..

### nextAutoGrow

    protected long nextAutoGrow

  reallize the autoGrow

### nextAutoSlow

    protected long nextAutoSlow

  for realizing autoslow..

### pilot

    protected D_PlayerData pilot

  the "pilot" of the snake. the controlling element.

### pilotLength

    private int pilotLength

  for checking if something changed

### pilotDelay

    private long pilotDelay

  for checking if something changed

### survivalBonus

    protected int survivalBonus

  the survival bonus a snake gets if it reaches the exit

Constructor Detail

### C_Snake

    protected C_Snake()

  default constructor

### C_Snake

    protected C_Snake(D_Vec2D headPosition,
                      int faceDirection,
                      RingVector objPositions,
                      char ownChar,
                      int status,
                      int length,
                      D_PlayerData pilot,
                      long waitCycles,
                      GameParameter parameter)

  create Constructor

  Parameters:
    `headPosition` -
    `faceDirection` -
    `objPositions` -
    `ownChar` -
    `status` -
    `length` -
    `pilot` -
    `waitCycles` -
    `parameter` -

### C_Snake

    protected C_Snake(D_Vec2D headPosition,
                      int faceDirection,
                      char ownChar,
                      int length,
                      D_PlayerData pilot,
                      long waitCycles,
                      GameParameter parameter)

  constructor

  Parameters:
    `headPosition` -
    `faceDirection` -
    `ownChar` -
    `length` -
    `pilot` -
    `waitCycles` -
    `parameter` -

### C_Snake

    protected C_Snake(D_Vec2D headPosition,
                      int faceDirection,
                      char ownChar,
                      D_PlayerData pilot,
                      long waitCycles,
                      GameParameter parameter)

  constructor

  Parameters:
    `headPosition` -
    `faceDirection` -
    `ownChar` -
    `pilot` -
    `waitCycles` -
    `parameter` -

### C_Snake

    protected C_Snake(D_Vec2D headPosition,
                      int faceDirection,
                      RingVector objPositions,
                      char ownChar,
                      int length,
                      D_PlayerData pilot,
                      long waitCycles,
                      GameParameter parameter)

  smart Constructor

  Parameters:
    `headPosition` -
    `faceDirection` -
    `objPositions` -
    `ownChar` -
    `length` -
    `pilot` -
    `waitCycles` -
    `parameter` -

### C_Snake

    protected C_Snake(D_PlayerData playerData,
                      GameParameter parameter)

Parameters:
  `playerData` -
  `parameter` -

Method Detail

### computeKillPoints

    private void computeKillPoints(C_Arena arena,
                                   C_Snake snake,
                                   boolean died)

  computes the kill points for other snakes if this one looses a segment or is killed

  Parameters:
    `arena` -
    `snake` -
    `died` -

### removeLastSegments

    private D_Vec2D removeLastSegments(C_Arena arena,
                                       int n)

  Parameters:
    `arena` -
    `n` - the number of segmnets that should removed
  Returns:
    the last deleted vector

### actualizateSnakeLength

    private void actualizateSnakeLength(C_Arena arena,
                                        D_Vec2D lastPos)

  Parameters:
    `arena` -
    `lastPos` -

### die

    private void die(C_Arena arena,
                     C_Snake killer)

  kills the snake

  Parameters:
    `arena` - the arena the snake is living in
    `killer` - if the snake was killed by an other snake, this is it. otherwise killer is null

### moveToFace

    protected void moveToFace(C_Arena arena)

  let the object move one field to the direction of its head it is necessary, that there it is computed here what happands if the object runns into a wall..

  Parameters:
    `arena` -

### updateLengthState

    private void updateLengthState()

  if the length state is bigger than one, the snake gets longer..

### updateSpeedState

    private void updateSpeedState()

  if speed State is more than one, the snake gets slower

### updatePilot

    protected void updatePilot()

  updates the own informations with the snake infos

### turnHead

    private void turnHead(C_Arena arena)

  turns the head to the direction pilot

### turnHeadBack

    private void turnHeadBack()

  turns the head to the opposide direction of what pilot sais pilot

### update

    protected void update(C_Arena arena)

  Description copied from class: `C_GameObject`
  the update call meens that the object should do what ever it does usually

  Specified by:
    `update` in class `C_GameObject`
  Parameters:
    `arena` - the arena the object is living in

### getCharDirHead

    private char getCharDirHead(C_Arena arena,
                                int direction)

  checs which char is in direction of `direction<\code>.

  `
  Parameters:
    `arena` -
    `direction` -
  Returns:
    the field at arena

### isBlocked

    private boolean isBlocked(char c)

  Parameters:
    `c` -
  Returns:
    if its locked or not

### jumpTo

    protected void jumpTo(D_Vec2D pos,
                          C_Arena arena)

  turns the head of the object to `left_right`

  Specified by:
    `jumpTo` in class `C_GameObject`
  Parameters:
    `arena` -
    `left_right` - turn direction
  See Also:
    `I_Constants`

### getAllPosSorted

    protected D_Vec2D[] getAllPosSorted(int sort)

  Specified by:
    `getAllPosSorted` in class `C_GameObject`
  Parameters:
    `sort` - maybe there are more than one way to sort the object positions, this parameter specifies the kind of sort.
  Returns:
    an sorted array of all posistions of the object.

### clone

    protected java.lang.Object clone()

  Specified by:
    `clone` in class `C_GameObject`

### toString

    public java.lang.String toString()

  Specified by:
    `toString` in class `C_GameObject`

### getPilot

    protected D_PlayerData getPilot()

  Returns:
    Returns the pilot.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD