Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
Hamcha | 198f1a6704 | |
Hamcha | 69f54c08cc | |
Hamcha | 0e2c613375 | |
Hamcha | e9e5ffdada | |
Hamcha | 3184ce476a | |
Hamcha | d2a2e4526b |
11
mlp/card.go
11
mlp/card.go
|
@ -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 {
|
||||
|
|
17
mlp/mlp.go
17
mlp/mlp.go
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
}
|
11
mlp/set.go
11
mlp/set.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue