fix(server): grant non-stackable chapter rewards and expose all completed packs
This commit is contained in:
@@ -2,13 +2,26 @@ package gamedata
|
||||
|
||||
// LoadQuestCostumes loads only costume rewards referenced by the installed
|
||||
// quest catalog, using the same character and duplicate-copy metadata as gacha.
|
||||
func LoadQuestCostumes(root, version string, packs map[int]map[int]QuestDesign) (*RegularGachaCatalog, error) {
|
||||
func LoadQuestCostumes(root, version string, packs map[int]map[int]QuestDesign, story *StoryCatalog) (*RegularGachaCatalog, error) {
|
||||
db, closeDB, err := openStatDatabase(root, version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer closeDB()
|
||||
catalog := &RegularGachaCatalog{characters: map[uint64]CharacterDesign{}}
|
||||
if story != nil {
|
||||
for _, pack := range story.Packs {
|
||||
for _, reward := range pack.BuyRewards {
|
||||
if reward.Type == 11 {
|
||||
design, err := loadGachaCharacterDesign(db, reward.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
catalog.characters[reward.ID] = design
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, quests := range packs {
|
||||
for _, quest := range quests {
|
||||
for _, slot := range quest.Rewards {
|
||||
|
||||
@@ -111,9 +111,9 @@ func loadStoryCatalog(db *sql.DB) (*StoryCatalog, error) {
|
||||
return nil, fmt.Errorf("gamedata: invalid story pack%d buy rewards", id)
|
||||
}
|
||||
for i, count := range counts {
|
||||
// PackTable may retain a disabled reward slot with a real type/ID
|
||||
// and zero count. It contributes no granted reward.
|
||||
if count == 0 {
|
||||
// Costume/equipment are instance rewards: their count is zero,
|
||||
// just as in QuestTable. Only zero-count stackable slots are empty.
|
||||
if count == 0 && types[i] != 10 && types[i] != 11 {
|
||||
continue
|
||||
}
|
||||
if types[i] == 0 || count > math.MaxInt32 || types[i] > math.MaxInt32 || ids[i] > math.MaxInt32 {
|
||||
|
||||
@@ -26,8 +26,7 @@ func TestStoryCatalogEnumeratesSeparateChainsAndContentTicketRules(t *testing.T)
|
||||
raw = wire.AppendVarint(raw, 8, 1)
|
||||
raw = wire.AppendVarint(raw, 9, 100)
|
||||
raw = wire.AppendVarint(raw, 10, 19)
|
||||
// An official-shaped disabled costume slot must be equivalent
|
||||
// to omitting that slot; type and ID remain populated.
|
||||
// Non-stackable costume instances retain their ID with count zero.
|
||||
raw = wire.AppendVarint(raw, 8, 0)
|
||||
raw = wire.AppendVarint(raw, 9, 200)
|
||||
raw = wire.AppendVarint(raw, 10, 11)
|
||||
@@ -82,7 +81,7 @@ func TestStoryCatalogEnumeratesSeparateChainsAndContentTicketRules(t *testing.T)
|
||||
if d.Packs[1].Quests[1].NextQuestID != 2 || d.Packs[1].Quests[2].PriorQuestID != 1 || d.Packs[1].Quests[3].Type != 1 {
|
||||
t.Fatal("quest edges/type were lost")
|
||||
}
|
||||
if rewards := d.Packs[7].BuyRewards; len(rewards) != 1 || rewards[0].Type != 19 || rewards[0].ID != 100 {
|
||||
if rewards := d.Packs[7].BuyRewards; len(rewards) != 2 || rewards[0].Type != 19 || rewards[0].ID != 100 || rewards[1].Type != 11 || rewards[1].ID != 200 || rewards[1].Count != 0 {
|
||||
t.Fatalf("buy rewards=%+v", rewards)
|
||||
}
|
||||
if len(d.TicketSources[101]) != 2 {
|
||||
|
||||
Reference in New Issue
Block a user