mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-15 03:12:03 +00:00
feat: add casual bot backfill policy
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package domain
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCasualLineupUsesBotsOnlyForMissingSlotsAndRequiresBothTeams(t *testing.T) {
|
||||
lineup, err := BuildCasualLineup([]ConnectParticipant{{PlayerID: "p2", Team: 1}, {PlayerID: "p1", Team: 0}})
|
||||
if err != nil || len(lineup) != 6 || lineup[0].IsBot || lineup[1].IsBot || !lineup[2].IsBot || lineup[2].Team != 0 {
|
||||
t.Fatalf("casual lineup = %+v err=%v", lineup, err)
|
||||
}
|
||||
if _, err := BuildCasualLineup([]ConnectParticipant{{PlayerID: "p1", Team: 0}, {PlayerID: "p2", Team: 0}}); err == nil {
|
||||
t.Fatal("lineup without a human on team 1 was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCasualBackfillIsKickoffOnlyAndUnrated(t *testing.T) {
|
||||
slot := CasualSlot{Slot: 2, Team: 0, PlayerID: "bot-slot-2", IsBot: true}
|
||||
if !CanCasualBackfill(CasualKickoff, slot) || CanCasualBackfill(CasualLive, slot) || CasualBackfillPenalty() != 0 {
|
||||
t.Fatal("casual backfill policy is incorrect")
|
||||
}
|
||||
if CanCasualBackfill(CasualKickoff, CasualSlot{Slot: 2, Team: 0, PlayerID: "human", IsBot: false}) {
|
||||
t.Fatal("human slot was treated as backfillable")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user