package common import "fmt" // IntegerArrayRule returns a copy of a native integer array, without coercing // floats/bools or substituting a default for an absent entry. func (c *CurrencyWarsCatalog) IntegerArrayRule(name string) ([]uint32, error) { rule, found := c.Constants["ConstValueCommonExcelTable"][name] if !found || !rule.IsArray || len(rule.ArrayValue) == 0 { return nil, fmt.Errorf("CW integer array rule missing or mistyped: %s", name) } values := make([]uint32, len(rule.ArrayValue)) for i, item := range rule.ArrayValue { if !item.IsInt || item.IntValue < 0 || uint64(item.IntValue) > uint64(^uint32(0)) { return nil, fmt.Errorf("invalid CW integer array %s index %d", name, i) } values[i] = uint32(item.IntValue) } return values, nil } // BaseSalePrice is the unmodified native star/rarity table price. Run effects, // stolen-role refunds and special-role policies must be applied by the action // processor before crediting gold. This does not sell a role or change state. func (c *CurrencyWarsCatalog) BaseSalePrice(roleID, star uint32) (uint32, error) { role, err := c.CapturedRole(roleID) if err != nil { return 0, err } if star == 0 || star > role.MaxStar || role.Config.Rarity == 0 { return 0, fmt.Errorf("CW role sale star/rarity is invalid") } prices, err := c.IntegerArrayRule(fmt.Sprintf("GridFight_AvatarSnippetSellGoldStar%d", star)) if err != nil { return 0, err } if uint64(role.Config.Rarity) > uint64(len(prices)) { return 0, fmt.Errorf("CW role rarity has no captured sale price") } return prices[role.Config.Rarity-1], nil } // BaseInterest follows native GetWillGainInterest's integer division and cap. // maxInterest must be the current run's resolved cap, including OC/modifiers; // callers must not replace a legitimate zero cap with the normal-mode rule. func (c *CurrencyWarsCatalog) BaseInterest(gold, maxInterest uint32) (uint32, error) { deposit, err := c.IntegerRule("GridFight_DepositPerInterest") if err != nil || deposit <= 0 || uint64(deposit) > uint64(^uint32(0)) { return 0, fmt.Errorf("invalid CW deposit-per-interest rule") } interest := gold / uint32(deposit) if interest > maxInterest { interest = maxInterest } return interest, nil }