Feat: Add top commander pages

This commit is contained in:
zuma 2025-04-16 20:05:54 +02:00
parent d64b20c44b
commit 899bdd4714
6 changed files with 157 additions and 67 deletions

View file

@ -123,6 +123,8 @@ func GenerateCache(pb core.App) {
totalSize += int64(unsafe.Sizeof(cacheCardsSearch))
pb.Store().Set("searchData", cacheCardsSearch)
cacheColorCommanderTop := map[string][]CacheCarteListItem{}
cacheBrawlsetList := []CacheBrawlsetListItem{}
for _, v := range brawlsets {
setIconList := []string{}
@ -190,6 +192,14 @@ func GenerateCache(pb core.App) {
if c.CanBeCommander {
obj.NumberOfDecks = numberOfDecksPerCard[fmt.Sprintf("c-%s",c.ID)]
obj.Url = fmt.Sprintf("/commander/%s-%s", c.SetCode,c.SanitizedName)
colorIdentity := ""
if len(c.ColorIdentity) == 0 {
colorIdentity = "colorless"
} else {
colorIdentity = strings.Join(c.ColorIdentity, "")
}
cacheColorCommanderTop[colorIdentity] = append(cacheColorCommanderTop[colorIdentity], obj)
cacheColorCommanderTop["all"] = append(cacheColorCommanderTop["all"], obj)
cacheBrawlsetData.Cards["commander"] = append(cacheBrawlsetData.Cards["commander"], obj)
detailsObj := CacheCarteListItemWithSynergy{
@ -245,6 +255,12 @@ func GenerateCache(pb core.App) {
pb.Store().Set("json/brawlset/" + v.SanitizedName, cacheBrawlsetData)
}
totalSize += int64(unsafe.Sizeof(cacheColorCommanderTop))
for k := range cacheColorCommanderTop {
sort.Slice(cacheColorCommanderTop[k], func(i, j int) bool { return cacheColorCommanderTop[k][i].NumberOfDecks > cacheColorCommanderTop[k][j].NumberOfDecks})
pb.Store().Set(fmt.Sprintf("json/top/commander/%s", k),cacheColorCommanderTop[k])
}
totalSize += int64(unsafe.Sizeof(cacheBrawlsetList))
pb.Store().Set("json/misc/brawlsets", cacheBrawlsetList)

Binary file not shown.