Compare commits

...

5 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
6 changed files with 26 additions and 10 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

@ -57,10 +57,10 @@ const (
type I8PPool map[I8PType][]Card
// MakeI8PCube takes an organized set of cards and sorts them into a draftable I8PCube
func MakeI8PCube(cards I8PPool, schema I8PSchema) *I8PCube {
func MakeI8PCube(cards I8PPool, schema I8PSchema, problemPackSize int) *I8PCube {
return &I8PCube{
Main: makeMainSet(cards, schema),
Problems: makeProblemSet(cards),
Problems: makeProblemSet(cards, problemPackSize),
}
}
@ -102,7 +102,7 @@ func makeMainSet(cards I8PPool, schema I8PSchema) (set *I8PSet) {
return
}
func makeProblemSet(cards I8PPool) (set *I8PSet) {
func makeProblemSet(cards I8PPool, problemPackSize int) (set *I8PSet) {
set = &I8PSet{
Cards: I8PPool{
I8PTypeProblem: cards[I8PTypeProblem],
@ -111,7 +111,7 @@ func makeProblemSet(cards I8PPool) (set *I8PSet) {
set.Schema = draft.PackSchema{
Slots: []draft.PackSlot{
{
Amount: 12,
Amount: problemPackSize,
Provider: set.ProviderByType(I8PTypeProblem),
},
},

View File

@ -21,7 +21,7 @@ func TestDraftI8PCube(t *testing.T) {
mlp.I8PTypeEntry: mockCards("e1", "e2", "e3", "e4", "e5"),
mlp.I8PTypeProblem: mockCards("P1", "P2"),
}
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema())
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema(), 12)
pack1 := draft.MakePack(cube.Main)
pack2 := draft.MakePack(cube.Main)
@ -57,7 +57,7 @@ func TestDryCube(t *testing.T) {
mlp.I8PTypeMulti: mockCards("m1", "m4"),
mlp.I8PTypeEntry: mockCards("e1", "e4"),
}
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema())
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema(), 12)
pack := draft.MakePack(cube.Main)
if len(pack) != 11 {
t.Fatalf("Expected 11 cards in pack but got %d", len(pack))
@ -93,7 +93,7 @@ func TestPodI8PCube(t *testing.T) {
"Q9", "Q10", "Q11", "Q12",
),
}
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema())
cube := mlp.MakeI8PCube(pool, mlp.DefaultI8PSchema(), 12)
remainingStart := i8pCountRemaining(cube)

View File

@ -30,6 +30,7 @@ const (
SetDefendersOfEquestria SetID = "DE"
SetSeaquestriaBeyond SetID = "SB"
SetFriendsForever SetID = "FF"
SetPromo SetID = "Promo"
)
// BlockID denotes a certain block
@ -55,4 +56,5 @@ var allSets = []SetID{
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

@ -172,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