Create models.go

This commit is contained in:
Brad Van Vugt 2019-12-31 20:43:05 -08:00 committed by GitHub
parent b4ef73f378
commit d75012f627
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

43
models.go Normal file
View file

@ -0,0 +1,43 @@
package rulesets
// NOTE: IMMUTABLE THINGS HERE //
const MOVE_UP = "up"
const MOVE_DOWN = "down"
const MOVE_RIGHT = "right"
const MOVE_LEFT = "left"
type Game struct {
Height int32
Width int32
}
type SnakeMove struct {
Snake *Snake
Move string
}
// NOTE: MUTABLE THINGS HERE //
type Point struct {
X int32
Y int32
}
type Snake struct {
ID string
Body []*Point
Health int32
EliminatedCause string
}
type GameState struct {
Food []*Point
Snakes []*Snake
}
// RULESET API //
type Ruleset interface {
ResolveMoves(*Game, *GameState, []*SnakeMove) (*GameState, error)
}