From d75012f6275e913997d82712fcfa74a59143e6bc Mon Sep 17 00:00:00 2001 From: Brad Van Vugt <1531419+bvanvugt@users.noreply.github.com> Date: Tue, 31 Dec 2019 20:43:05 -0800 Subject: [PATCH] Create models.go --- models.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 models.go diff --git a/models.go b/models.go new file mode 100644 index 0000000..c3d395b --- /dev/null +++ b/models.go @@ -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) +}