feat(currency_wars): complete systems, settlement Rank SS, damage report, camera and recovery fixes
This commit is contained in:
1 parent
c008243f11
commit
0995055296
78 files changed
+33840
-9525
No files matched your search
@@ -0,0 +1,97 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type CurrencyWarsTrailblazeGood struct {
|
||||
ID uint32 `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
Cost uint32 `json:"cost"`
|
||||
Father uint32 `json:"father"`
|
||||
Params []uint32 `json:"params"`
|
||||
}
|
||||
|
||||
type CurrencyWarsTrailblazeCatalog struct {
|
||||
Goods map[uint32]CurrencyWarsTrailblazeGood
|
||||
GoodsList []CurrencyWarsTrailblazeGood
|
||||
LayerParams map[uint32][]uint32
|
||||
PomThreshold uint32
|
||||
InitialGoodID uint32
|
||||
RefreshGoodID uint32
|
||||
PomGoodID uint32
|
||||
}
|
||||
|
||||
func LoadCurrencyWarsTrailblaze() (*CurrencyWarsTrailblazeCatalog, error) {
|
||||
raw, err := ReadResourceFile("resources/CurrencyWarsTrailblaze.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var r struct {
|
||||
Goods []CurrencyWarsTrailblazeGood `json:"goods"`
|
||||
LayerParams map[string][]uint32 `json:"layer_params"`
|
||||
PomThreshold uint32 `json:"pom_threshold"`
|
||||
InitialGood uint32 `json:"initial_goods_id"`
|
||||
RefreshGood uint32 `json:"refresh_goods_id"`
|
||||
PomGood uint32 `json:"pom_goods_id"`
|
||||
}
|
||||
if err = json.Unmarshal(raw, &r); err != nil {
|
||||
return nil, fmt.Errorf("unmarshal CurrencyWarsTrailblaze: %w", err)
|
||||
}
|
||||
|
||||
cat := &CurrencyWarsTrailblazeCatalog{
|
||||
Goods: make(map[uint32]CurrencyWarsTrailblazeGood, len(r.Goods)),
|
||||
GoodsList: r.Goods,
|
||||
LayerParams: make(map[uint32][]uint32, len(r.LayerParams)),
|
||||
PomThreshold: r.PomThreshold,
|
||||
InitialGoodID: r.InitialGood,
|
||||
RefreshGoodID: r.RefreshGood,
|
||||
PomGoodID: r.PomGood,
|
||||
}
|
||||
if cat.InitialGoodID == 0 {
|
||||
cat.InitialGoodID = 101
|
||||
}
|
||||
if cat.RefreshGoodID == 0 {
|
||||
cat.RefreshGoodID = 999
|
||||
}
|
||||
if cat.PomGoodID == 0 {
|
||||
cat.PomGoodID = 507
|
||||
}
|
||||
if cat.PomThreshold == 0 {
|
||||
cat.PomThreshold = 300
|
||||
}
|
||||
|
||||
for _, g := range r.Goods {
|
||||
cat.Goods[g.ID] = g
|
||||
}
|
||||
|
||||
for k, v := range r.LayerParams {
|
||||
layer, err := strconv.ParseUint(k, 10, 32)
|
||||
if err == nil {
|
||||
cat.LayerParams[uint32(layer)] = v
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(cat.GoodsList, func(i, j int) bool {
|
||||
return cat.GoodsList[i].ID < cat.GoodsList[j].ID
|
||||
})
|
||||
|
||||
return cat, nil
|
||||
}
|
||||
|
||||
func (c *CurrencyWarsTrailblazeCatalog) Tier(layer uint32) uint32 {
|
||||
if params, ok := c.LayerParams[layer]; ok && len(params) > 0 {
|
||||
return params[0]
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
func (c *CurrencyWarsTrailblazeCatalog) Income(layer uint32) uint32 {
|
||||
if params, ok := c.LayerParams[layer]; ok && len(params) > 1 {
|
||||
return params[1]
|
||||
}
|
||||
return 0
|
||||
}
|
||||
Reference in new issue
Block a user