Compare commits

..

6 Commits

Author SHA1 Message Date
Hamcha 198f1a6704 Add boosted cards
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details
2019-08-27 12:00:12 +02:00
Hamcha 69f54c08cc Add promo as set
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2019-08-26 16:00:59 +02:00
Hamcha 0e2c613375 Add support for MLP promo cards
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2019-08-23 16:57:53 +02:00
Hamcha e9e5ffdada Allow problem packs to have arbitrary sizes
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details
2019-07-01 14:43:25 +02:00
Hamcha 3184ce476a
We don't need this as a global
continuous-integration/drone/push Build is passing Details
2019-06-28 22:45:39 +02:00
Hamcha d2a2e4526b
Add LoadAllSets
continuous-integration/drone/tag Build is passing Details
2019-06-28 22:35:47 +02:00
5 changed files with 51 additions and 3 deletions

View File

@ -24,6 +24,7 @@ type Card struct {
ProblemBonus *int `json:",omitempty"`
ProblemOpponentPower int `json:",omitempty"`
ProblemRequirement PowerRequirement `json:",omitempty"`
Boosted *Card `json:",omitempty"`
}
// ToDraftCard converts cards to draft.Card
@ -50,9 +51,19 @@ func LoadCardList(list []string, fetch bool) (out []Card, err error) {
err = ErrInvalidCardID
return
}
// Get Set ID
setid := SetID(strings.ToUpper(card[:2]))
// Check for promo card
for _, promoid := range promoIDs {
if strings.ToLower(card) == promoid {
card = strings.ToLower(card)
setid = SetPromo
break
}
}
// Get set
var set *Set
if fetch {

View File

@ -30,6 +30,7 @@ const (
SetDefendersOfEquestria SetID = "DE"
SetSeaquestriaBeyond SetID = "SB"
SetFriendsForever SetID = "FF"
SetPromo SetID = "Promo"
)
// BlockID denotes a certain block
@ -41,3 +42,19 @@ const (
BlockOdyssey BlockID = "EO" // Odyssey block - EO/HM/MT
BlockDefenders BlockID = "DE" // Defenders block - DE/SB/FF
)
var allSets = []SetID{
SetPremiere,
SetCanterlotNights,
SetRockNRave,
SetCelestialSolstice,
SetCrystalGames,
SetAbsoluteDiscord,
SetEquestrialOdysseys,
SetHighMagic,
SetMarksInTime,
SetDefendersOfEquestria,
SetSeaquestriaBeyond,
SetFriendsForever,
SetPromo,
}

5
mlp/promo.go Normal file
View File

@ -0,0 +1,5 @@
package mlp
var promoIDs = []string{
"prpf1", "prpf2", "prpf3", "prpf4", "prpf6", "cnpf3", "cnpf5", "cnpf7", "cnpf9", "cnpf11", "cnpf13", "cgpf4", "cgpf6", "cgpf8", "cgpf11", "cgpf12", "cgpf14", "gf1", "gf4", "gf5", "gf7", "gf9",
}

View File

@ -120,3 +120,14 @@ func LoadSetHTTP(id SetID) (*Set, error) {
return LoadSetBytes(id, data)
}
// LoadAllSets just loads all sets from the web
func LoadAllSets() error {
for _, set := range allSets {
_, err := LoadSetHTTP(set)
if err != nil {
return err
}
}
return nil
}

View File

@ -75,6 +75,12 @@ func TestAllLoads(t *testing.T) {
if err != nil {
t.Fatalf("[LoadSetMemory] Could not load set: %s", err.Error())
}
// Load all remaining sets
err = mlp.LoadAllSets()
if err != nil {
t.Fatalf("[LoadAllSets] Could not load remaining sets: %s", err.Error())
}
}
// TestNotLoadedErr tests that LoadSetMemory fails if set is not cached
@ -166,10 +172,8 @@ func TestMalformedJSONLoad(t *testing.T) {
}
}
var testServer *httptest.Server
func TestMain(m *testing.M) {
testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
switch req.URL.Path {
case "/nopenope.json":
// 404