DEV-765 pipeline refactor (#64)

Refactor rulesets into smaller composable operations

In order to mix up the functionality from different rulesets like Solo, Royale, etc. the code in these classes needs to be broken up into small functions that can be composed in a pipeline to make a custom game mode.
This commit is contained in:
Torben 2022-03-16 16:58:05 -07:00 committed by GitHub
parent 5e629e9e93
commit 397d925110
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1475 additions and 222 deletions

View file

@ -3,6 +3,7 @@ package rules
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -247,6 +248,20 @@ func TestEdgeCrossingEating(t *testing.T) {
}
}
func TestWrap(t *testing.T) {
// no wrap
assert.Equal(t, int32(0), wrap(0, 0, 0))
assert.Equal(t, int32(0), wrap(0, 1, 0))
assert.Equal(t, int32(0), wrap(0, 0, 1))
assert.Equal(t, int32(1), wrap(1, 0, 1))
// wrap to min
assert.Equal(t, int32(0), wrap(2, 0, 1))
// wrap to max
assert.Equal(t, int32(1), wrap(-1, 0, 1))
}
// Checks that snakes moving out of bounds get wrapped to the other side.
var wrappedCaseMoveAndWrap = gameTestCase{
"Wrapped Case Move and Wrap",