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,74 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type CurrencyWarsTrait struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Thresholds []uint32 `json:"thresholds"`
|
||||
ActivationType uint32 `json:"activation_type"`
|
||||
TraitType uint32 `json:"trait_type"`
|
||||
SeasonID uint32 `json:"season_id"`
|
||||
}
|
||||
|
||||
type CurrencyWarsTraitsCatalog struct {
|
||||
FormatVersion uint32 `json:"format_version"`
|
||||
TargetClientVersion string `json:"target_client_version"`
|
||||
TargetAssemblySHA256 string `json:"target_assembly_sha256"`
|
||||
Traits []CurrencyWarsTrait `json:"traits"`
|
||||
Effects map[string]int32 `json:"effects"`
|
||||
Constants map[string]interface{} `json:"constants"`
|
||||
|
||||
byID map[uint32]CurrencyWarsTrait
|
||||
}
|
||||
|
||||
func LoadCurrencyWarsTraits(catalog *CurrencyWarsCatalog) (*CurrencyWarsTraitsCatalog, error) {
|
||||
raw, err := ReadResourceFile("resources/CurrencyWarsTraits.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out CurrencyWarsTraitsCatalog
|
||||
if err = json.Unmarshal(raw, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if catalog != nil {
|
||||
if out.FormatVersion != 1 || out.TargetClientVersion != catalog.ClientVersion || out.TargetAssemblySHA256 != catalog.Provenance.GameAssemblySHA256 {
|
||||
return nil, fmt.Errorf("CW traits revision differs from catalog")
|
||||
}
|
||||
}
|
||||
out.byID = make(map[uint32]CurrencyWarsTrait, len(out.Traits))
|
||||
for _, t := range out.Traits {
|
||||
out.byID[t.ID] = t
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (c *CurrencyWarsTraitsCatalog) Trait(id uint32) (CurrencyWarsTrait, bool) {
|
||||
if c == nil || c.byID == nil {
|
||||
return CurrencyWarsTrait{}, false
|
||||
}
|
||||
t, ok := c.byID[id]
|
||||
return t, ok
|
||||
}
|
||||
|
||||
func (c *CurrencyWarsTraitsCatalog) ActiveLayer(traitID, count uint32) uint32 {
|
||||
t, ok := c.Trait(traitID)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
exact := t.ActivationType == 3
|
||||
var layer uint32
|
||||
for _, need := range t.Thresholds {
|
||||
valid := count >= need
|
||||
if exact {
|
||||
valid = count == need
|
||||
}
|
||||
if valid && need > layer {
|
||||
layer = need
|
||||
}
|
||||
}
|
||||
return layer
|
||||
}
|
||||
Reference in new issue
Block a user