Byte-snake-engine/solo.go
Torben 397d925110
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.
2022-03-16 16:58:05 -07:00

20 lines
470 B
Go

package rules
type SoloRuleset struct {
StandardRuleset
}
func (r *SoloRuleset) Name() string { return GameTypeSolo }
func (r *SoloRuleset) IsGameOver(b *BoardState) (bool, error) {
return r.callStageFunc(GameOverSolo, b, []SnakeMove{})
}
func GameOverSolo(b *BoardState, settings Settings, moves []SnakeMove) (bool, error) {
for i := 0; i < len(b.Snakes); i++ {
if b.Snakes[i].EliminatedCause == NotEliminated {
return false, nil
}
}
return true, nil
}