Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions calc-sidecar/src/backends/rocalc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,28 @@ export function createShim(): ShimSession {
throwing_mastery: [
{ driver: "skill_slot", rocalcId: 393, level: "buffLevel" },
],
// Alchemist / Creator (m_JobBuff[19] == m_JobBuff[33] == [537,59,68,241];
// identical, no trans gating). Pure-data, skill_slot only. crazy_uproar (68)
// is already bound (inherited Merchant). Excluded: 537 (Enlarge Weight Limit
// R, universal carry-weight) and 59 (Enlarge Weight Limit / MC_INCCARRY,
// Merchant carry-weight). axe_mastery is axe-gated in rocalc (+ATK with axes
// only; non-axe weapons see no change), and the bonus is combat-sim mastery
// ATK -- it moves damage.ave, not derived atk.base. See alchemist_buffs.test.ts.
axe_mastery: [{ driver: "skill_slot", rocalcId: 241, level: "buffLevel" }],
// Soul Linker (m_JobBuff[43] = [537,340,341,329,338,342,380,372,379]). Pure-data,
// skill_slot only. spurt (329+379) is already bound (inherited TaeKwon). kaina is
// SL-specific and scored (+maxSp). The 4 TaeKwon skills (tumbling/peaceful_break/
// happy_break/kihop) are shared across the TaeKwon branch (also in m_JobBuff[41]
// and [42]) and wired-but-inert per bind-every-control. taekwon_ranker is NOT here
// (TaeKwon-Kid-only). Excluded: 537 (carry-weight); 380 (Kihop party-count
// sub-param). See soul_linker_buffs.test.ts.
kaina: [{ driver: "skill_slot", rocalcId: 372, level: "buffLevel" }],
tumbling: [{ driver: "skill_slot", rocalcId: 338, level: "buffLevel" }],
peaceful_break: [
{ driver: "skill_slot", rocalcId: 340, level: "buffLevel" },
],
happy_break: [{ driver: "skill_slot", rocalcId: 341, level: "buffLevel" }],
kihop: [{ driver: "skill_slot", rocalcId: 342, level: "buffLevel" }],
};

// A_Weapon_element option values (empirically probed; value 0 = "(unchanged)"
Expand Down
117 changes: 117 additions & 0 deletions calc-sidecar/test/backends/rocalc/alchemist_buffs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { createShim } from "../../../src/shim.ts";

// Alchemist/Creator self-buffs ride the rocalc job-buff bank (m_JobBuff[19] ==
// m_JobBuff[33] == [537,59,68,241]); axe_mastery uses the skill_slot driver. It
// is AXE-GATED: it raises damage.ave only with an axe, and is inert with any
// non-axe weapon (the load-bearing negatives below lock that). The bonus is
// combat-sim mastery ATK, so reset() is verified via damage.ave (not atk.base,
// which the buff never moves). Buffs apply before the enemy (production order).
// axe_mastery (2H axe) -> readCombatResults().damage.ave (+30 at lv10)
// axe_mastery (dagger / mace) -> inert

const AXE_2H = 1360; // Two-Handed Axe (W_2HAXE)
const DAGGER = 1207; // Main Gauche (W_DAGGER) -- non-axe negative
const MACE = 1501; // Club (W_MACE) -- non-axe negative

function alShim(weaponId: number, className = "alchemist") {
const s = createShim();
s.setClass(className);
s.setLevel({ base: 99, job: 70 });
s.setStats({ str: 90, agi: 40, vit: 40, int: 40, dex: 90, luk: 20 });
s.equip("weapon", { id: weaponId });
return s;
}

const ENEMY = {
hp: 50000,
atk_min: 1500,
atk_max: 2000,
def: 20,
mdef: 10,
race: "RC_Brute",
element: "Ele_Neutral",
element_lv: 1,
size: "Size_Medium",
level: 90,
};

type Buff = { name: string; level: number };

function aveWith(
weaponId: number,
buffs: Buff[],
className = "alchemist",
): number {
const s = alShim(weaponId, className);
if (buffs.length) s.setBuffs(buffs);
s.setEnemyInline(ENEMY);
const ave = s.readCombatResults().damage.ave;
assert.ok(ave != null, "damage.ave must be numeric");
return ave as number;
}

test("axe_mastery raises damage.ave at lv10 (2H axe)", () => {
const base = aveWith(AXE_2H, []);
const got = aveWith(AXE_2H, [{ name: "axe_mastery", level: 10 }]);
assert.ok(
got > base,
`axe_mastery lv10 should raise damage.ave on an axe (${base} -> ${got})`,
);
});

test("axe_mastery scales with level (lv1 < lv10)", () => {
const lo = aveWith(AXE_2H, [{ name: "axe_mastery", level: 1 }]);
const hi = aveWith(AXE_2H, [{ name: "axe_mastery", level: 10 }]);
assert.ok(hi > lo, `axe_mastery lv10 should exceed lv1 (${lo} -> ${hi})`);
});

test("axe_mastery is inert on a dagger (axe-gated)", () => {
const base = aveWith(DAGGER, []);
const got = aveWith(DAGGER, [{ name: "axe_mastery", level: 10 }]);
assert.equal(
got,
base,
"axe_mastery must not move damage.ave on a non-axe weapon (dagger)",
);
});

test("axe_mastery is inert on a mace (axe-gated)", () => {
const base = aveWith(MACE, []);
const got = aveWith(MACE, [{ name: "axe_mastery", level: 10 }]);
assert.equal(
got,
base,
"axe_mastery must not move damage.ave on a non-axe weapon (mace)",
);
});

test("axe_mastery raises damage.ave for Creator too (identical bank)", () => {
const base = aveWith(AXE_2H, [], "creator");
const got = aveWith(AXE_2H, [{ name: "axe_mastery", level: 10 }], "creator");
assert.ok(
got > base,
`axe_mastery lv10 should raise Creator damage.ave (${base} -> ${got})`,
);
});

test("reset() clears axe_mastery (no damage.ave leak)", () => {
const plain = aveWith(AXE_2H, []);
const s = alShim(AXE_2H);
s.setBuffs([{ name: "axe_mastery", level: 10 }]);
s.setEnemyInline(ENEMY);
s.readCombatResults();
s.reset();
s.setClass("alchemist");
s.setLevel({ base: 99, job: 70 });
s.setStats({ str: 90, agi: 40, vit: 40, int: 40, dex: 90, luk: 20 });
s.equip("weapon", { id: AXE_2H });
s.setEnemyInline(ENEMY);
const after = s.readCombatResults().damage.ave;
assert.equal(
after,
plain,
"reset must clear axe_mastery (no damage.ave leak)",
);
});
92 changes: 92 additions & 0 deletions calc-sidecar/test/backends/rocalc/soul_linker_buffs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { createShim } from "../../../src/shim.ts";

// Soul Linker self-buffs ride the rocalc job-buff bank (m_JobBuff[43]); all use
// the skill_slot driver. kaina is the only scored buff -- it raises maxSp
// (readDerivedStats().maxSp), +30/level. The 4 shared TaeKwon skills
// (tumbling/peaceful_break/happy_break/kihop) are wired-but-inert: they move no
// scored field. Reset is verified via maxSp (the field kaina moves). Buffs apply
// before the enemy (production order).

const ROD = 1601; // Rod (W_ROD)

function slShim() {
const s = createShim();
s.setClass("soul_linker");
s.setLevel({ base: 99, job: 70 });
s.setStats({ str: 40, agi: 50, vit: 50, int: 80, dex: 70, luk: 30 });
s.equip("weapon", { id: ROD });
return s;
}

const ENEMY = {
hp: 50000,
atk_min: 1500,
atk_max: 2000,
def: 20,
mdef: 10,
race: "RC_Brute",
element: "Ele_Neutral",
element_lv: 1,
size: "Size_Medium",
level: 90,
};

type Buff = { name: string; level: number };

function read(buffs: Buff[]): { maxSp: number; ave: number } {
const s = slShim();
if (buffs.length) s.setBuffs(buffs);
s.setEnemyInline(ENEMY);
const maxSp = s.readDerivedStats().maxSp;
const ave = s.readCombatResults().damage.ave;
assert.ok(maxSp != null && ave != null, "maxSp and ave must be numeric");
return { maxSp: maxSp as number, ave: ave as number };
}

test("kaina raises maxSp at lv7", () => {
const base = read([]);
const got = read([{ name: "kaina", level: 7 }]);
assert.ok(
got.maxSp > base.maxSp,
`kaina lv7 should raise maxSp (${base.maxSp} -> ${got.maxSp})`,
);
});

test("kaina scales with level (lv1 < lv7)", () => {
const lo = read([{ name: "kaina", level: 1 }]);
const hi = read([{ name: "kaina", level: 7 }]);
assert.ok(
hi.maxSp > lo.maxSp,
`kaina lv7 should exceed lv1 (${lo.maxSp} -> ${hi.maxSp})`,
);
});

for (const [name, level] of [
["tumbling", 1],
["peaceful_break", 10],
["happy_break", 10],
["kihop", 5],
] as [string, number][]) {
test(`${name} is wired but inert`, () => {
const base = read([]);
const got = read([{ name, level }]);
assert.equal(got.maxSp, base.maxSp, `${name} must not move maxSp`);
assert.equal(got.ave, base.ave, `${name} must not move damage.ave`);
});
}

test("reset() clears kaina (no maxSp leak)", () => {
const baseMaxSp = read([]).maxSp;
const s = slShim();
s.setBuffs([{ name: "kaina", level: 7 }]);
s.readDerivedStats();
s.reset();
s.setClass("soul_linker");
s.setLevel({ base: 99, job: 70 });
s.setStats({ str: 40, agi: 50, vit: 50, int: 80, dex: 70, luk: 30 });
s.equip("weapon", { id: ROD });
const after = s.readDerivedStats().maxSp;
assert.equal(after, baseMaxSp, "reset must clear kaina (no maxSp leak)");
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { createShim } from "../../../src/shim.ts";

// Star Gladiator self-buffs ride the rocalc job-buff bank (m_JobBuff[42]); all ten
// use the skill_slot driver. The SG_ skills tested here are class-exclusive; the 3
// TK-inherited buffs (mild_wind / spurt / taekwon_ranker) are covered elsewhere.
// TK-inherited buffs (mild_wind / spurt) are covered elsewhere. taekwon_ranker is
// TaeKwon-Kid-only and no longer surfaces for Star Gladiator.
// The build is barehanded -- the authentic SG auto-attack. Buffs are applied
// BEFORE the enemy is set (production order); union and solar_protection read inert
// otherwise. The three Wrath skills are enemy size+maxHP gated INSIDE rocalc:
Expand Down
29 changes: 29 additions & 0 deletions cmd/build-catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,34 @@ func loadJobMaxLevels(herculesPath, repoRoot string) ([]data.JobMaxLevels, error
return data.LoadJobMaxLevels(full, data.PreRenewal)
}

// usabilityExclusions removes skills that Hercules's skill_tree.conf carries as
// allocated (inherited) for a class but which the class cannot actually USE. A
// Soul Linker / Star Gladiator was a TaeKwon Kid, so the flattened tree carries
// every TK skill, but only a usable subset remains. Taekwon Ranker (TK_MISSION)
// is TaeKwon-Kid-only (rocalc models it solely in m_JobBuff[41]); without this it
// would wrongly surface as a self-buff for both 2nd classes. Keyed by shim-style
// class name -> set of aegis names to drop.
var usabilityExclusions = map[string]map[string]bool{
"soul_linker": {"TK_MISSION": true},
"star_gladiator": {"TK_MISSION": true},
}

// filterSkills returns skills with any entry whose AegisName is in drop removed.
// A nil/empty drop is a no-op (returns skills unchanged).
func filterSkills(skills []data.ClassSkillEntry, drop map[string]bool) []data.ClassSkillEntry {
if len(drop) == 0 {
return skills
}
out := make([]data.ClassSkillEntry, 0, len(skills))
for _, e := range skills {
if drop[e.AegisName] {
continue
}
out = append(out, e)
}
return out
}

// buildClassMap reads Hercules's skill_tree.conf, flattens inherits so
// every class's Skills slice carries its full allocatable set, and
// keys the result by shim-style class names ("taekwon", "high_wizard",
Expand All @@ -710,6 +738,7 @@ func buildClassMap(herculesPath, repoRoot string) (map[string]data.ClassSkillTre
for _, c := range raw {
flat := flattenSkills(c, out)
key := classKeyFromHerculesName(c.Name)
flat = filterSkills(flat, usabilityExclusions[key])
out[key] = data.ClassSkillTree{
Name: c.Name,
Inherit: c.Inherit,
Expand Down
36 changes: 36 additions & 0 deletions cmd/build-catalog/usability_exclusions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"testing"

"github.com/levonn-dev/ro-builder/internal/data"
)

// filterSkills drops allocated-but-unusable inherited skills (e.g. TK_MISSION for
// the TaeKwon 2nd classes).
func TestFilterSkills_DropsExcludedAegisNames(t *testing.T) {
skills := []data.ClassSkillEntry{
{AegisName: "TK_MISSION"},
{AegisName: "TK_SEVENWIND"},
{AegisName: "SL_KAINA"},
}
out := filterSkills(skills, map[string]bool{"TK_MISSION": true})
if len(out) != 2 {
t.Fatalf("filterSkills: got %d skills, want 2", len(out))
}
for _, e := range out {
if e.AegisName == "TK_MISSION" {
t.Fatalf("TK_MISSION should have been dropped: %+v", out)
}
}
}

func TestFilterSkills_NilOrEmptyDropIsNoop(t *testing.T) {
skills := []data.ClassSkillEntry{{AegisName: "TK_MISSION"}, {AegisName: "SL_KAINA"}}
if got := filterSkills(skills, nil); len(got) != 2 {
t.Fatalf("nil drop should be a no-op, got %d", len(got))
}
if got := filterSkills(skills, map[string]bool{}); len(got) != 2 {
t.Fatalf("empty drop should be a no-op, got %d", len(got))
}
}
Loading
Loading