mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 11:33:52 +00:00
feat(pipeline): add WRUN (Wowee DK Rune Cost) catalog
62nd open format — replaces RuneCost.dbc plus the DK-specific portions of ChrPowerType. Defines per-spell rune costs (Blood / Frost / Unholy) and runic-power generation / consumption for the Death Knight class. 4 spell tree branches (BloodTree / FrostTree / UnholyTree / Generic) classify which spec uses each rune cost. Each entry binds a spell to its rune cost (how many of each rune kind the spell consumes), an optional anyDeathConvertCost (extra Death-rune-acceptable cost for procced abilities), and a runicPowerCost (negative = generator, positive = spender). Cross-references with prior formats — spellId points at WSPL.spellId (the spell that uses this rune cost). CLI: --gen-rune (3 baseline DK abilities — Death Strike 1F+1U + 20RP gen, Frost Strike pure 40 RP spender, Heart Strike 1B + 10RP gen), --gen-rune-blood (4 blood-tree DK abilities — Heart Strike, Death and Decay AoE, Vampiric Blood tank cooldown, Rune Tap self-heal), --gen-rune-frost (4 frost-tree — Frost Strike, Howling Blast AoE, Obliterate finisher, Icy Touch ranged opener applying Frost Fever), --info-wrun, --validate-wrun with --json variants. Validator catches id+name+spellId required, branch 0..3, no rune cost > 2 (DK only has 2 of each rune type so a higher cost can never be paid), runicPowerCost > 100 (DK RP cap), no-cost warning (spell consumes nothing — verify it's a passive/stance/form), and high-RP-generator warning (> 25 RP per cast is unusual). Format graph: 61 → 62 binary formats. CLI flag count: 840 → 847.
This commit is contained in:
parent
2a31eeb2fe
commit
ad603c0c44
10 changed files with 635 additions and 0 deletions
264
tools/editor/cli_runes_catalog.cpp
Normal file
264
tools/editor/cli_runes_catalog.cpp
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
#include "cli_runes_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_runes.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string stripWrunExt(std::string base) {
|
||||
stripExt(base, ".wrun");
|
||||
return base;
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeRuneCost& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeRuneCostLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wrun\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeRuneCost& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wrun\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" costs : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenStarter(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "StarterRuneCosts";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWrunExt(base);
|
||||
auto c = wowee::pipeline::WoweeRuneCostLoader::makeStarter(name);
|
||||
if (!saveOrError(c, base, "gen-rune")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenBlood(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "BloodTreeRuneCosts";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWrunExt(base);
|
||||
auto c = wowee::pipeline::WoweeRuneCostLoader::makeBlood(name);
|
||||
if (!saveOrError(c, base, "gen-rune-blood")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenFrost(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "FrostTreeRuneCosts";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWrunExt(base);
|
||||
auto c = wowee::pipeline::WoweeRuneCostLoader::makeFrost(name);
|
||||
if (!saveOrError(c, base, "gen-rune-frost")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleInfo(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
||||
base = stripWrunExt(base);
|
||||
if (!wowee::pipeline::WoweeRuneCostLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WRUN not found: %s.wrun\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeRuneCostLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wrun"] = base + ".wrun";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
arr.push_back({
|
||||
{"runeCostId", e.runeCostId},
|
||||
{"spellId", e.spellId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"bloodCost", e.bloodCost},
|
||||
{"frostCost", e.frostCost},
|
||||
{"unholyCost", e.unholyCost},
|
||||
{"anyDeathConvertCost", e.anyDeathConvertCost},
|
||||
{"runicPowerCost", e.runicPowerCost},
|
||||
{"spellTreeBranch", e.spellTreeBranch},
|
||||
{"spellTreeBranchName", wowee::pipeline::WoweeRuneCost::spellTreeBranchName(e.spellTreeBranch)},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WRUN: %s.wrun\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" costs : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id spell B F U Any RP branch name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
const char* rpKind = e.runicPowerCost == 0
|
||||
? " "
|
||||
: (e.runicPowerCost > 0 ? "→" : "←");
|
||||
std::printf(" %4u %5u %u %u %u %u %s%4d %-8s %s\n",
|
||||
e.runeCostId, e.spellId,
|
||||
e.bloodCost, e.frostCost, e.unholyCost,
|
||||
e.anyDeathConvertCost,
|
||||
rpKind, e.runicPowerCost,
|
||||
wowee::pipeline::WoweeRuneCost::spellTreeBranchName(e.spellTreeBranch),
|
||||
e.name.c_str());
|
||||
}
|
||||
std::printf(" legend: B/F/U/Any = blood/frost/unholy/death-convertible costs; "
|
||||
"RP arrow shows generator (←) vs spender (→)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleValidate(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
||||
base = stripWrunExt(base);
|
||||
if (!wowee::pipeline::WoweeRuneCostLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wrun: WRUN not found: %s.wrun\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeRuneCostLoader::load(base);
|
||||
std::vector<std::string> errors;
|
||||
std::vector<std::string> warnings;
|
||||
if (c.entries.empty()) {
|
||||
warnings.push_back("catalog has zero entries");
|
||||
}
|
||||
std::vector<uint32_t> idsSeen;
|
||||
for (size_t k = 0; k < c.entries.size(); ++k) {
|
||||
const auto& e = c.entries[k];
|
||||
std::string ctx = "entry " + std::to_string(k) +
|
||||
" (id=" + std::to_string(e.runeCostId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.runeCostId == 0)
|
||||
errors.push_back(ctx + ": runeCostId is 0");
|
||||
if (e.name.empty())
|
||||
errors.push_back(ctx + ": name is empty");
|
||||
if (e.spellId == 0)
|
||||
errors.push_back(ctx +
|
||||
": spellId is 0 (rune cost not bound to a WSPL spell)");
|
||||
if (e.spellTreeBranch > wowee::pipeline::WoweeRuneCost::Generic) {
|
||||
errors.push_back(ctx + ": spellTreeBranch " +
|
||||
std::to_string(e.spellTreeBranch) + " not in 0..3");
|
||||
}
|
||||
// A DK has 6 runes total (2 of each kind) — a single
|
||||
// ability cost shouldn't exceed 2 of any one type
|
||||
// because the system can't satisfy it.
|
||||
if (e.bloodCost > 2)
|
||||
errors.push_back(ctx + ": bloodCost " +
|
||||
std::to_string(e.bloodCost) + " exceeds 2 (DK only "
|
||||
"has 2 blood runes)");
|
||||
if (e.frostCost > 2)
|
||||
errors.push_back(ctx + ": frostCost " +
|
||||
std::to_string(e.frostCost) + " exceeds 2");
|
||||
if (e.unholyCost > 2)
|
||||
errors.push_back(ctx + ": unholyCost " +
|
||||
std::to_string(e.unholyCost) + " exceeds 2");
|
||||
// A spell with no rune cost AND no runic-power cost
|
||||
// is weird — every DK ability either consumes
|
||||
// resources, generates them, or applies a stance.
|
||||
// We don't have stance info here, so warn.
|
||||
bool noResourceCost = e.bloodCost == 0 && e.frostCost == 0 &&
|
||||
e.unholyCost == 0 &&
|
||||
e.anyDeathConvertCost == 0 &&
|
||||
e.runicPowerCost == 0;
|
||||
if (noResourceCost) {
|
||||
warnings.push_back(ctx +
|
||||
": no rune or runic-power cost — verify this is "
|
||||
"intentional (passive / stance / forms only)");
|
||||
}
|
||||
// RP cost > 100 isn't possible — max RP cap is 100.
|
||||
if (e.runicPowerCost > 100) {
|
||||
errors.push_back(ctx +
|
||||
": runicPowerCost " +
|
||||
std::to_string(e.runicPowerCost) +
|
||||
" exceeds 100 (DK runic power max)");
|
||||
}
|
||||
if (e.runicPowerCost < -25) {
|
||||
warnings.push_back(ctx +
|
||||
": runicPowerCost " +
|
||||
std::to_string(e.runicPowerCost) +
|
||||
" generates more than 25 RP per cast — unusual");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.runeCostId) {
|
||||
errors.push_back(ctx + ": duplicate runeCostId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.runeCostId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wrun"] = base + ".wrun";
|
||||
j["ok"] = ok;
|
||||
j["errors"] = errors;
|
||||
j["warnings"] = warnings;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
std::printf("validate-wrun: %s.wrun\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu rune costs, all runeCostIds unique, all costs within DK budget\n",
|
||||
c.entries.size());
|
||||
return 0;
|
||||
}
|
||||
if (!warnings.empty()) {
|
||||
std::printf(" warnings (%zu):\n", warnings.size());
|
||||
for (const auto& w : warnings)
|
||||
std::printf(" - %s\n", w.c_str());
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
std::printf(" ERRORS (%zu):\n", errors.size());
|
||||
for (const auto& e : errors)
|
||||
std::printf(" - %s\n", e.c_str());
|
||||
}
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool handleRunesCatalog(int& i, int argc, char** argv, int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-rune") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenStarter(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-rune-blood") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenBlood(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-rune-frost") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenFrost(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wrun") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wrun") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue