feat(currency_wars): complete systems, settlement Rank SS, damage report, camera and recovery fixes

This commit is contained in:
CAtlas0784 committed 2026-10-31 20:47:36 +07:00
1 parent c008243f11
commit 0995055296
78 files changed
+33840 -9525

No files matched your search

+71 -27
View File
@@ -14,7 +14,7 @@ import (
func apiCurrencyWarsCommand(w http.ResponseWriter, command string) {
fail := func(err error) { writeJSON(w, map[string]any{"success": false, "output": err.Error()}) }
parts := strings.Fields(command)
usage := "Usage: /cw status | /cw list role|equip|orb|consumable|forge | /cw gold <total> | /cw hp <total> | /cw exp <gain> | /cw equip|orb|consumable|forge <itemID> [count] | /cw role <roleID> <star> [count]. Changes apply in CW Preparation."
usage := "Usage: /cw status | /cw list role|equip|orb|consumable|forge | /cw gold <total> | /cw hp <total> | /cw exp <gain> | /cw tbpower <total> [costed] | /cw equip|orb|consumable|forge <itemID> [count] (for orb: <itemID> or 'random') | /cw role <roleID> <star> [count]. Changes apply in CW Preparation."
if len(parts) < 2 {
fail(fmt.Errorf("%s", usage))
return
@@ -132,18 +132,38 @@ func apiCurrencyWarsCommand(w http.ResponseWriter, command string) {
return
}
field := strings.ToLower(parts[1])
if field == "tb" || field == "trailblaze" {
field = "tbpower"
}
if field == "status" && len(parts) == 2 {
writeJSON(w, map[string]any{"success": true, "output": fmt.Sprintf("CW run=%d revision=%d gold=%d hp=%d/%d level=%d", run.UniqueId, snapshot.Revision, player.Gold, player.GridFightLineupHp, player.PPKKHHNEOHB, player.EHNJDIDABHD)})
tbPower := uint32(0)
if snapshot.Runtime != nil && snapshot.Runtime.Rules != nil {
tbPower = snapshot.Runtime.Rules["TbPower"]
}
writeJSON(w, map[string]any{"success": true, "output": fmt.Sprintf("CW run=%d revision=%d gold=%d tbpower=%d hp=%d/%d level=%d", run.UniqueId, snapshot.Revision, player.Gold, tbPower, player.GridFightLineupHp, player.PPKKHHNEOHB, player.EHNJDIDABHD)})
return
}
if len(parts) < 3 || len(parts) > 5 || (field != "gold" && field != "hp" && field != "exp" && field != "equip" && field != "role" && field != "orb" && field != "consumable" && field != "forge") {
isRandomOrb := false
if field == "orb" {
if len(parts) == 2 {
isRandomOrb = true
} else if len(parts) >= 3 && (strings.EqualFold(parts[2], "random") || strings.EqualFold(parts[2], "rand")) {
isRandomOrb = true
}
}
if (!isRandomOrb && (len(parts) < 3 || len(parts) > 5)) || (isRandomOrb && len(parts) > 4) || (field != "gold" && field != "hp" && field != "exp" && field != "equip" && field != "role" && field != "orb" && field != "consumable" && field != "forge" && field != "tbpower") {
fail(fmt.Errorf("%s", usage))
return
}
value, err := strconv.ParseUint(parts[2], 10, 32)
if err != nil {
fail(fmt.Errorf("value must be a nonnegative uint32"))
return
var value uint64
if isRandomOrb {
value = 0
} else {
value, err = strconv.ParseUint(parts[2], 10, 32)
if err != nil {
fail(fmt.Errorf("value must be a nonnegative uint32"))
return
}
}
if field == "hp" && (value == 0 || value > uint64(player.PPKKHHNEOHB)) {
fail(fmt.Errorf("HP must be 1..%d", player.PPKKHHNEOHB))
@@ -171,31 +191,51 @@ func apiCurrencyWarsCommand(w http.ResponseWriter, command string) {
_, err = catalog.CapturedRoleVariant(uint32(value), star)
}
case "orb", "consumable", "forge":
if isRandomOrb {
if len(parts) == 4 {
quantity, err = parse(parts[3])
}
} else {
if len(parts) > 4 {
fail(fmt.Errorf("%s", usage))
return
}
if len(parts) == 4 {
quantity, err = parse(parts[3])
}
if err == nil {
var rows *common.CurrencyWarsRewards
rows, err = common.LoadCurrencyWarsRewards(catalog)
if err == nil {
if field == "forge" {
if _, ok := rows.Forges[uint32(value)]; !ok {
err = fmt.Errorf("unknown forge %d", value)
}
} else if field == "orb" {
if _, ok := rows.Orbs[uint32(value)]; !ok {
err = fmt.Errorf("unknown Orb %d", value)
}
} else {
if _, ok := rows.Consumables[uint32(value)]; !ok {
err = fmt.Errorf("unknown consumable %d", value)
}
}
}
}
}
case "tbpower":
if len(parts) > 4 {
fail(fmt.Errorf("%s", usage))
return
}
if len(parts) == 4 {
quantity, err = parse(parts[3])
}
if err == nil {
var rows *common.CurrencyWarsRewards
rows, err = common.LoadCurrencyWarsRewards(catalog)
if err == nil {
if field == "forge" {
if _, ok := rows.Forges[uint32(value)]; !ok {
err = fmt.Errorf("unknown forge %d", value)
}
} else if field == "orb" {
if _, ok := rows.Orbs[uint32(value)]; !ok {
err = fmt.Errorf("unknown Orb %d", value)
}
} else {
if _, ok := rows.Consumables[uint32(value)]; !ok {
err = fmt.Errorf("unknown consumable %d", value)
}
}
var costed uint64
costed, err = strconv.ParseUint(parts[3], 10, 32)
if err != nil {
fail(fmt.Errorf("costed must be a nonnegative uint32"))
return
}
star = uint32(costed) + 1
}
case "equip":
if len(parts) > 4 {
@@ -229,5 +269,9 @@ func apiCurrencyWarsCommand(w http.ResponseWriter, command string) {
fail(err)
return
}
writeJSON(w, map[string]any{"success": true, "state": "queued", "request_id": id, "output": fmt.Sprintf("Queued CW %s=%d star=%d count=%d for run %d. Applies at the next heartbeat in Preparation; check CW_GM log for the applied result.", field, value, star, quantity, run.UniqueId)})
valDesc := fmt.Sprintf("%d", value)
if isRandomOrb {
valDesc = "random"
}
writeJSON(w, map[string]any{"success": true, "state": "queued", "request_id": id, "output": fmt.Sprintf("Queued CW %s=%s star=%d count=%d for run %d. Applies at the next heartbeat in Preparation; check CW_GM log for the applied result.", field, valDesc, star, quantity, run.UniqueId)})
}