Package ai.nettogrof.battlesnake.info
Class SnakeInfo
- java.lang.Object
 - 
- ai.nettogrof.battlesnake.info.SnakeInfo
 
 
- 
public class SnakeInfo extends Object
Data related to a Snake in non-squad modes- Version:
 - Spring 2021
 - Author:
 - carl.lajeunesse
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected booleanaliveIf the snake is still aliveprotected booleaneatDoes the snake just eatprotected inthealthCurrent health of the snakeprotected static com.google.common.flogger.FluentLoggerlogLogging objectprotected StringnameName of the snakeprotected gnu.trove.list.array.TIntArrayListsnakeBodyArraylist of the Snake Body.private StringsquadName of the squad of the current snake 
- 
Constructor Summary
Constructors Constructor Description SnakeInfo()Basic constructor with a empty body.SnakeInfo(SnakeInfo snakeInfo)copy constructor .SnakeInfo(SnakeInfo prevSnakeInfo, int moveSquare, boolean eat)Constructor with all informations except hazard ( use in non-royale mode)SnakeInfo(SnakeInfo prevSnakeInfo, int moveSquare, boolean eat, boolean hazard, GameRuleset rules)Constructor with all informationsSnakeInfo(com.fasterxml.jackson.databind.JsonNode snakeInfo)Constructor with the Json field 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddie()Kill the snakebooleanequals(Object obj)Equals methodintgetHead()Get the square of the snake head ( first element of the snakeBody)intgetHealth()Get the health of the snakeStringgetName()Get the snake's namegnu.trove.list.array.TIntArrayListgetSnakeBody()Get the full snake bodiesStringgetSquad()intgetTail()Get the square of the snake head ( last element of the snakeBody)inthashCode()booleanisAlive()Return if the snake is alive or notbooleanisSnake(int pos)Check if there will be a snake on square on next movebooleanisSnake(int pos, String squad)Check if there will be a snake on square on next move 
 - 
 
- 
- 
Field Detail
- 
log
protected static com.google.common.flogger.FluentLogger log
Logging object 
- 
snakeBody
protected final gnu.trove.list.array.TIntArrayList snakeBody
Arraylist of the Snake Body. Starting at the head. This array of Integer of the square (based on square formula) 
- 
name
protected String name
Name of the snake 
- 
health
protected int health
Current health of the snake 
- 
eat
protected boolean eat
Does the snake just eat 
- 
alive
protected boolean alive
If the snake is still alive 
- 
squad
private final String squad
Name of the squad of the current snake 
 - 
 
- 
Constructor Detail
- 
SnakeInfo
public SnakeInfo()
Basic constructor with a empty body. 
- 
SnakeInfo
public SnakeInfo(SnakeInfo snakeInfo)
copy constructor .- Parameters:
 snakeInfo- the snake info to copy
 
- 
SnakeInfo
public SnakeInfo(com.fasterxml.jackson.databind.JsonNode snakeInfo)
Constructor with the Json field- Parameters:
 snakeInfo- Json field
 
- 
SnakeInfo
public SnakeInfo(SnakeInfo prevSnakeInfo, int moveSquare, boolean eat, boolean hazard, GameRuleset rules)
Constructor with all informations- Parameters:
 prevSnakeInfo- Same snake on the previous movemoveSquare- The destination square of the snake moveeat- Is destination square a foodhazard- Is destination square a hazardrules- Game ruleset
 
- 
SnakeInfo
public SnakeInfo(SnakeInfo prevSnakeInfo, int moveSquare, boolean eat)
Constructor with all informations except hazard ( use in non-royale mode)- Parameters:
 prevSnakeInfo- Same snake on the previous movemoveSquare- The destination square of the snake moveeat- Is destination square a food
 
 - 
 
- 
Method Detail
- 
getSquad
public String getSquad()
- Returns:
 - squad
 
 
- 
getSnakeBody
public gnu.trove.list.array.TIntArrayList getSnakeBody()
Get the full snake bodies- Returns:
 - arraylist int of the snake's bodies
 
 
- 
die
public void die()
Kill the snake 
- 
isSnake
public boolean isSnake(int pos)
Check if there will be a snake on square on next move- Parameters:
 pos- int square (based on square formula)- Returns:
 - If there's a snake body
 
 
- 
isSnake
public boolean isSnake(int pos, String squad)Check if there will be a snake on square on next move- Parameters:
 pos- int square (based on square formula)squad- Squad name- Returns:
 - If there's a snake body
 
 
- 
getHead
public int getHead()
Get the square of the snake head ( first element of the snakeBody)- Returns:
 - int square (based on square formula)
 
 
- 
getTail
public int getTail()
Get the square of the snake head ( last element of the snakeBody)- Returns:
 - int square (based on square formula)
 
 
- 
getName
public String getName()
Get the snake's name- Returns:
 - String name
 
 
- 
getHealth
public int getHealth()
Get the health of the snake- Returns:
 - int health
 
 
- 
isAlive
public boolean isAlive()
Return if the snake is alive or not- Returns:
 - boolean
 
 
- 
equals
public boolean equals(Object obj)
Equals method 
 - 
 
 -