Add RulesetError test case.
Remove old comments.
This commit is contained in:
parent
2cbf8884bf
commit
accb598e29
4 changed files with 41 additions and 36 deletions
30
ruleset.go
30
ruleset.go
|
|
@ -1,10 +1,36 @@
|
|||
package rules
|
||||
|
||||
type RulesetError string
|
||||
|
||||
func (err RulesetError) Error() string { return string(err) }
|
||||
|
||||
const (
|
||||
MoveUp = "up"
|
||||
MoveDown = "down"
|
||||
MoveRight = "right"
|
||||
MoveLeft = "left"
|
||||
|
||||
BoardSizeSmall = 7
|
||||
BoardSizeMedium = 11
|
||||
BoardSizeLarge = 19
|
||||
|
||||
SnakeMaxHealth = 100
|
||||
SnakeStartSize = 3
|
||||
|
||||
// bvanvugt - TODO: Just return formatted strings instead of codes?
|
||||
NotEliminated = ""
|
||||
EliminatedByCollision = "snake-collision"
|
||||
EliminatedBySelfCollision = "snake-self-collision"
|
||||
EliminatedByOutOfHealth = "out-of-health"
|
||||
EliminatedByHeadToHeadCollision = "head-collision"
|
||||
EliminatedByOutOfBounds = "wall-collision"
|
||||
|
||||
// TODO - Error consts
|
||||
ErrorTooManySnakes = RulesetError("too many snakes for fixed start positions")
|
||||
ErrorNoRoomForSnake = RulesetError("not enough space to place snake")
|
||||
ErrorNoRoomForFood = RulesetError("not enough space to place food")
|
||||
ErrorNoMoveFound = RulesetError("move not provided for snake")
|
||||
ErrorZeroLengthSnake = RulesetError("snake is length zero")
|
||||
)
|
||||
|
||||
type Point struct {
|
||||
|
|
@ -37,7 +63,3 @@ type Ruleset interface {
|
|||
CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
|
||||
IsGameOver(state *BoardState) (bool, error)
|
||||
}
|
||||
|
||||
type RulesetError string
|
||||
|
||||
func (err RulesetError) Error() string { return string(err) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue