Entry 524
Boss split, step two: the BossClass trait and its one dispatch, Patterns with BaseActs in place of corbenik::Host
24mbattle
Filescrates/piney-battle/src/boss.rsboss/docs/engine/boss.mdboss-innis.mdplans/rust-cleanup.md
The second step of section 2's boss split (plans/rust-cleanup.md,
after worklog 523's Boss { base, class }). A class's Main and
Affect are now a trait's, reached through one match, and the base's
pattern code calls back into a class through a second trait that took
the place of Corbenik's Host. The 288 pinned probe answers are byte for
byte the same.
The dispatch
BossClass(boss/class.rs):main,affectandeffects_passon(&mut self, b: &mut BossBase, cx).- The defaults are what
Boss::mainandBoss::affectdid for a class with no arm:ccBoss01's frame and affect, no effect pass. - Every class implements it, the parts too. Corbenik's eyes and roots keep the defaults, as they did.
- The defaults are what
Class::with_rulesis the onematch: an arm a class, handing&mut dyn BossClassto a closure.Boss::main,Boss::affectandBoss::effects_passeach go through it; their three matches are gone. Skeith and a bareccBossare the zero-sizedSkeith.- Two affects that took the whole boss now take its two halves:
- the Kyvia core's (
kyvia::core::affect); - a Gorre brother's (
affect_alone). It puts the brother's base and members into Gorre'sbrothersfor the report and takes them back, as the old swap of the wholeBossdid. - So
gorre::brother_affectand Gorre's emptyaffectare gone (the empty one is the trait method, with its note).
- the Kyvia core's (
The patterns
Patterns: the class'sChangeAction(the base's by default),ExecPatternIndex(the base's by default) andExecPattern(a one-word table), with aconst ACTS: BaseActs.base_exec_pattern_indexis Corbenik's one generic copy, now over anyPatterns.- The wrappers that fed it (
first's andsecond'sBaseHost,ThirdHost, the killer eye'sKillerHost) and the forms' freeexec_patterns are gone. - Each form implements
Patterns; the third form keeps its ownChangeAction.
- The wrappers that fed it (
- The killer eye's patterns read only what the body tells it. So its
PatternsisKillerRules(&KillerView), and itsexec_patternno longer takes the eye's members. BaseActsholds what really differs between the classes' ports ofccBoss::ExecPatternIndex, found by diffing the six copies:- the neutral's forbid on a word the base does not know: 1 for Skeith, Magus and Corbenik, 3 for Fidchell, Macha and Tarvos;
- the dash offset's w lane: 0 for Skeith and Magus, 1 for the rest.
- So Corbenik's forms are
{ other_forbid: 1, dash_w: 1 }; the other classes take theirs as their copies move onto the trait. - The act ids are not among them: every class's copy sets
ccBoss's numbers (neutral 0, epitaph 12, escape 16, return 17, chase 18, dash 7, wander 8). So the base reads Skeith'sactmodule, which isccBoss's numbering.
- The M2 helpers:
target_okisCx::target_ok, andselectisBossBase::select.wordis one function beside the trait. Corbenik's copies are gone; the other classes' go in the next step, where their pattern code moves onto the trait.
Checks
- The pin: the 288 recorded
battle_probecalls replayed against the rebuilt probe, every answer byte for byte the same. - The tests of piney-battle, piney-world, piney-effect and piney-event, and piney-game's full suite (the boss session tests in it), release.
- clippy with all features, fmt,
cairns check,tools/docs.py check. too_many_arguments: 152 before, 152 after.
Still unknown: nothing