draft/mlp/booster_test.go

117 lines
2.5 KiB
Go

package mlp_test
import (
"testing"
"git.fromouter.space/mcg/draft"
"git.fromouter.space/mcg/draft/mlp"
)
// TestAlternates tries to get alternates (SR/UR/RR)
// This might require a while since it needs to generate MANY packs!
func TestAlternates(t *testing.T) {
// Load Premiere/CN as they have their own UR ratios
prSet, err := mlp.LoadSetHTTP(mlp.SetPremiere)
if err != nil {
t.Fatalf("Could not fetch set data: %s", err.Error())
}
cnSet, err := mlp.LoadSetHTTP(mlp.SetCanterlotNights)
if err != nil {
t.Fatalf("Could not fetch set data: %s", err.Error())
}
// Load set with Royal rares
eoSet, err := mlp.LoadSetHTTP(mlp.SetEquestrialOdysseys)
if err != nil {
t.Fatalf("Could not fetch set data: %s", err.Error())
}
// Find all Premiere URs
prURs := []string{}
for _, card := range prSet.CardData {
if card.Rarity == mlp.RarityUltraRare {
prURs = append(prURs, card.ID)
}
}
// Find all CN URs
cnURs := []string{}
for _, card := range cnSet.CardData {
if card.Rarity == mlp.RarityUltraRare {
cnURs = append(cnURs, card.ID)
}
}
// Get some PR packs and search for URs
prurfound := false
for i := 0; i < 1000; i++ {
pack := draft.MakePack(prSet)
// Check for ultra rares
for _, id := range prURs {
if pack[7].ID == id {
prurfound = true
break
}
}
if prurfound {
t.Logf("PR Ultra Rare found after %d packs\n", i)
break
}
}
if !prurfound {
t.Fatalf("No PR UR found after 1000 packs")
}
// Get some CN packs and search for URs
cnurfound := false
for i := 0; i < 1000; i++ {
pack := draft.MakePack(cnSet)
// Check for ultra rares
for _, id := range cnURs {
if pack[7].ID == id {
cnurfound = true
break
}
}
if cnurfound {
t.Logf("CN Ultra Rare found after %d packs\n", i)
break
}
}
if !cnurfound {
t.Fatalf("No CN UR found after 1000 packs")
}
eorrfound := false
for i := 0; i < 100000; i++ {
pack := draft.MakePack(eoSet)
// Check for royal rares
if pack[6].ID == "eo207/rr1" || pack[6].ID == "eo208/rr2" {
t.Logf("EO Royal Rare found after %d packs\n", i)
eorrfound = true
break
}
}
if !eorrfound {
t.Fatalf("No EO RR found after 100k packs")
}
}
// TestPackFixedSets tries to get packs a set that isn't a true set
// This should result in empty packs
func TestPackFixedSets(t *testing.T) {
set, err := mlp.LoadSetBytes(mlp.SetRockNRave, []byte("{}"))
if err != nil {
t.Fatalf("Could not load set: %s", err.Error())
}
pack := draft.MakePack(set)
if len(pack) != 0 {
t.Fatalf("Expected an empty pack but got %d cards", len(pack))
}
}