draft/mlp/i8pcube_test.go

73 lines
2.2 KiB
Go

package mlp_test
import (
"testing"
"git.fromouter.space/mcg/draft"
"git.fromouter.space/mcg/draft/mlp"
)
// TestDraftI8PCube sets up a I8PCube and drafts 3 packs from it
func TestDraftI8PCube(t *testing.T) {
pool := mlp.I8PPool{
mlp.I8PTypeBlue: mockCards("b1", "b2", "b3"),
mlp.I8PTypeOrange: mockCards("o1", "o2", "o3"),
mlp.I8PTypePink: mockCards("p1", "p2", "p3"),
mlp.I8PTypePurple: mockCards("u1", "u2", "u3"),
mlp.I8PTypeWhite: mockCards("w1", "w2", "w3"),
mlp.I8PTypeYellow: mockCards("y1", "y2", "y3"),
mlp.I8PTypeNone: mockCards("n1", "n2", "n3"),
mlp.I8PTypeMulti: mockCards("m1", "m2", "m3", "m4", "m5"),
mlp.I8PTypeEntry: mockCards("e1", "e2", "e3", "e4", "e5"),
mlp.I8PTypeProblem: mockCards("P1", "P2"),
}
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema())
pack1 := draft.MakePack(cube.Main)
pack2 := draft.MakePack(cube.Main)
pack3 := draft.MakePack(cube.Problems)
if len(pack1) != 12 {
t.Errorf("Expected 12 cards in pack 1 but got %d", len(pack1))
}
if len(pack2) != 12 {
t.Errorf("Expected 12 cards in pack 2 but got %d", len(pack2))
}
if len(pack3) != 2 {
t.Errorf("Expected 2 cards in pack 3 but got %d", len(pack3))
}
t.Logf("Cards in pack1: %s\n", pack1)
t.Logf("Cards in pack2: %s\n", pack2)
t.Logf("Cards in pack3: %s\n", pack3)
}
// TestDryCube tries drying up the cube to make the "OtherProvider" not able to pick a card
// Expected behavior is to have a 11 card pack generate and not crash.
// This should **never** happen! If it does, please go fix your cube!
func TestDryCube(t *testing.T) {
pool := mlp.I8PPool{
mlp.I8PTypeBlue: mockCards("b1"),
mlp.I8PTypeOrange: mockCards("o1"),
mlp.I8PTypePink: mockCards("p1"),
mlp.I8PTypePurple: mockCards("u1"),
mlp.I8PTypeWhite: mockCards("w1"),
mlp.I8PTypeYellow: mockCards("y1"),
mlp.I8PTypeNone: mockCards("n1"),
mlp.I8PTypeMulti: mockCards("m1", "m4"),
mlp.I8PTypeEntry: mockCards("e1", "e4"),
}
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema())
pack := draft.MakePack(cube.Main)
if len(pack) != 11 {
t.Errorf("Expected 11 cards in pack but got %d", len(pack))
}
}
func mockCards(ids ...string) []mlp.Card {
out := make([]mlp.Card, len(ids))
for i, id := range ids {
out[i] = mlp.Card{ID: id}
}
return out
}