DEV 559: Refactor CLI and add customizations (#57)

* move snake API structs into a new client package

* add customizations to snake objects

* refactor and add support for passing snake customizations in games
This commit is contained in:
Rob O'Dwyer 2021-11-25 14:07:56 -08:00 committed by GitHub
parent 6140f232c2
commit 4a9dbbcaef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 665 additions and 197 deletions

View file

@ -4,6 +4,7 @@ import (
"testing"
"github.com/BattlesnakeOfficial/rules"
"github.com/BattlesnakeOfficial/rules/test"
)
func TestGetIndividualBoardStateForSnake(t *testing.T) {
@ -14,8 +15,27 @@ func TestGetIndividualBoardStateForSnake(t *testing.T) {
Width: 11,
Snakes: []rules.Snake{s1, s2},
}
snake := Battlesnake{Name: "one", URL: "", ID: "one"}
requestBody := getIndividualBoardStateForSnake(state, snake, &rules.StandardRuleset{})
s1State := SnakeState{
ID: "one",
Name: "ONE",
URL: "http://example1.com",
Head: "safe",
Tail: "curled",
Color: "#123456",
}
s2State := SnakeState{
ID: "two",
Name: "TWO",
URL: "http://example2.com",
Head: "silly",
Tail: "bolt",
Color: "#654321",
}
snakeStates := map[string]SnakeState{
s1State.ID: s1State,
s2State.ID: s2State,
}
requestBody := getIndividualBoardStateForSnake(state, s1State, snakeStates, &rules.StandardRuleset{})
rules.RequireJSONMatchesFixture(t, "testdata/snake_request_body.json", string(requestBody))
test.RequireJSONMatchesFixture(t, "testdata/snake_request_body.json", string(requestBody))
}