Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Hamcha | 198f1a6704 | |
Hamcha | 69f54c08cc | |
Hamcha | 0e2c613375 | |
Hamcha | e9e5ffdada | |
Hamcha | 3184ce476a |
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 {
|
||||
|
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue