draft/mlp/booster_test.go

118 lines
2.6 KiB
Go
Raw Normal View History

2019-05-31 13:13:13 +00:00
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!
// This test *requires* an internet connection!
func TestAlternates(t *testing.T) {
// Load Premiere/CN as they have their own UR ratios
prSet, err := mlp.LoadSetHTTP(mlp.SetPremiere)
if err != nil {
2019-06-17 20:56:05 +00:00
t.Fatalf("Could not fetch set data: %s", err.Error())
2019-05-31 13:13:13 +00:00
}
cnSet, err := mlp.LoadSetHTTP(mlp.SetCanterlotNights)
if err != nil {
2019-06-17 20:56:05 +00:00
t.Fatalf("Could not fetch set data: %s", err.Error())
2019-05-31 13:13:13 +00:00
}
// Load set with Royal rares
eoSet, err := mlp.LoadSetHTTP(mlp.SetEquestrialOdysseys)
if err != nil {
2019-06-17 20:56:05 +00:00
t.Fatalf("Could not fetch set data: %s", err.Error())
2019-05-31 13:13:13 +00:00
}
// Find all Premiere URs
prURs := []string{}
2019-06-26 09:05:49 +00:00
for _, card := range prSet.CardData {
2019-05-31 13:13:13 +00:00
if card.Rarity == mlp.RarityUltraRare {
prURs = append(prURs, card.ID)
}
}
// Find all CN URs
cnURs := []string{}
2019-06-26 09:05:49 +00:00
for _, card := range cnSet.CardData {
2019-05-31 13:13:13 +00:00
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 {
2019-06-12 13:40:21 +00:00
t.Logf("PR Ultra Rare found after %d packs\n", i)
2019-05-31 13:13:13 +00:00
break
}
}
if !prurfound {
2019-06-17 20:56:05 +00:00
t.Fatalf("No PR UR found after 1000 packs")
2019-05-31 13:13:13 +00:00
}
// 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 {
2019-06-12 13:40:21 +00:00
t.Logf("CN Ultra Rare found after %d packs\n", i)
2019-05-31 13:13:13 +00:00
break
}
}
if !cnurfound {
2019-06-17 20:56:05 +00:00
t.Fatalf("No CN UR found after 1000 packs")
2019-05-31 13:13:13 +00:00
}
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" {
2019-06-12 13:40:21 +00:00
t.Logf("EO Royal Rare found after %d packs\n", i)
2019-05-31 13:13:13 +00:00
eorrfound = true
break
}
}
if !eorrfound {
2019-06-17 20:56:05 +00:00
t.Fatalf("No EO RR found after 100k packs")
2019-05-31 13:13:13 +00:00
}
}
// TestPackFixedSets tries to get packs a set that isn't a true set
// This should result in empty packs
func TestPackFixedSets(t *testing.T) {
2019-06-17 20:56:05 +00:00
set, err := mlp.LoadSetBytes(mlp.SetRockNRave, []byte("{}"))
2019-05-31 13:13:13 +00:00
if err != nil {
2019-06-17 20:56:05 +00:00
t.Fatalf("Could not load set: %s", err.Error())
2019-05-31 13:13:13 +00:00
}
pack := draft.MakePack(set)
if len(pack) != 0 {
2019-06-17 20:56:05 +00:00
t.Fatalf("Expected an empty pack but got %d cards", len(pack))
2019-05-31 13:13:13 +00:00
}
}