Documentation
¶
Overview ¶
Package passive declares what a character *has* rather than what it uses.
Every skill is spent on a turn. A passive is not: it is in force from the moment a unit is enlisted, and nothing the unit or its opponents do turns it off. That is the whole distinction, and it is why a passive is declared here rather than as a skill with a flag on it — a skill book full of entries that can never be chosen is a book that lies about what a unit can do.
Nothing here is a new rule. A passive grants statuses, and a status already knows how to change a stat: the terms belong to the status, the saturation belongs to modifier.Set, and both are inherited rather than reimplemented. A passive that composed with temporary buffs instead of saturating alongside them would be the one place in this game where stacking explodes, and reusing the status is what makes that unwritable.
It computes nothing and reads no filesystem. Turning a declaration into an effect is the battle layer's job, because only the battle knows which unit is holding it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Amplification ¶
type Amplification struct {
Status string
// Effect is the share added to a damage-over-time tick, in parts per
// thousand. Only a ticking status has one.
Effect int
// Chance is the share added to the application's chance, in parts per
// thousand.
Chance int
}
Amplification is a status the trait's holder is better at inflicting.
Why two shares rather than two features with one share each ¶
"Makes my poison better" is two different things and they land in two different places: a **stronger tick**, which folds into the one multiplication battle freezes on the stack, and a **better chance**, which lands at the site a resistance already bites. They read differently in play — a tick is worth more the longer a stack lives, a chance the more often the skill is cast — so a trait must be able to want either alone, and either share may be left out.
One entry per status rather than two lists, because two lists would let the same status be named in both and there would be nothing to say which entry was the real one. Leaving a share at nought is how a trait says it does not touch that half.
Why this one is not restricted to harmful statuses ¶
Resistance is, and the asymmetry is the point rather than an oversight: refusing a status the holder's own side puts on it is nonsense, while making one *better* is exactly as sensible for a shield as for a poison. What is refused instead is narrower and more useful — an Effect on a status with no tick to raise, which is a trait that cannot do the thing it says.
Why the shares compose by multiplying, and what that costs ¶
The same arithmetic a resistance composes with, read in the other direction: a chance is multiplied by everything raising it and everything lowering it, so the order they are applied in cannot matter and neither side has to know the other exists. The cost is that resistances stacking *diminish* for free while amplifiers stacking *compound* — two shares of three hundred are 69 percent rather than 60. The guard is the per-trait bound plus the fact that a unit holds a handful of traits and cannot restack them the way it can restack a buff; if that ever stops being true, scale.Saturate is where this goes.
type Book ¶
type Book struct {
// contains filtered or unexported fields
}
Book is the declared passives, in the order they were written.
func ParseBook ¶
ParseBook reads a passive declaration. It never touches the filesystem; the caller supplies the bytes.
⚠️ **A field this book does not know is refused, not ignored**, the same rule the status book states for itself and for the same reason: a silent drop of a field an author deliberately wrote is the worst answer available, because the file looks like it worked. Leaving it open here after closing it there would have been a new asymmetry in place of the one that was closed — a misspelt field on a status refused while the same typo on a trait went nowhere.
Measured before it was turned on: the shipped book decodes strictly as it stands, so this refuses nothing that exists today.
type Condition ¶
type Condition struct {
// BelowHealth is the share of its maximum health the holder must be at or
// under, in parts per thousand. A third is 333.
BelowHealth int
// AboveHealth is the share of its maximum health the holder must be at or
// over, in parts per thousand. Nine tenths is 900.
AboveHealth int
}
Condition is when a trait is in force.
Why this is not skill.Condition ¶
Reusing the existing vocabulary was the plan, and it does not fit. A skill's condition asks what the *target* is carrying — a status, a stack count, and whether to spend it — because it exists to pay a skill off for arriving after a debuff. What a trait wants to ask is about its *holder*, and the question it wants most is one no status can answer: how hurt am I. Bending skill.Condition to carry a health share would give one type two unrelated jobs, and the note that said to reuse it also said this term was the work.
Two terms, one of which a condition holds: the bottom of the health bar and the top of it. Each is a share rather than a number of points, because a threshold in points would mean a different fraction of the bar at every level, so a trait authored for a level-eight unit would be permanently on at sixty.
⚠️ **Exactly one of the two, never both.** A condition holding both ends is a *band*, and a band is two rules wearing one clause — every screen in the game words a gate as a single sentence, so a trait in force between a fifth and a half would either print two clauses that read as contradicting each other or print one that is false. ParseBook refuses the pair, and refuses a clause holding neither. The zero value of each field is therefore "not this end" rather than a share of nought, which is the same spelling skill.Condition uses for the same reason: a bound written as "below n" or "above n" has no meaningful zero, so nought can mean unasked without a pointer or a flag.
The two ends are not the same trait with a sign flipped, and that is the whole point of having the second. A trait behind BelowHealth *arrives* as its holder is worn down; one behind AboveHealth *leaves* then — so it costs a great deal in a battle that goes long and nothing at all in one that is over while its holder is still healthy. That is a duration rather than a stat, and no other dial a trait offers can say it.
func (*Condition) AtTop ¶ added in v0.2.0
AtTop reports whether the gate is written at the top of the health bar.
It exists so a caller that has to word or render the gate asks one question instead of comparing two fields, and so the answer is derived in one place: a second reading of "which end is this" is how a screen comes to say "under" about a gate the engine reads as "over".
func (*Condition) Holds ¶
Holds reports whether the condition is met by a unit at the given health.
At or under and at or over, never strictly either: a threshold of a third means a third counts at both ends. That is what makes a pair of traits either side of one number cover the whole bar — see scale.AtOrAboveShare for the overlap and why it is deliberate. Maximum health of nought answers no rather than dividing by it, at either end — a unit with no maximum is neither hurt nor fresh.
func (*Condition) Threshold ¶ added in v0.2.0
Threshold is the share the gate is written against, whichever end it is at, and nought when there is no condition at all.
Every caller that renders a gate wants the figure and the end separately — the figure to print as a percentage, the end to choose the wording — and a caller reading BelowHealth directly prints a nought for every gate at the top of the bar.
type Deps ¶
Deps are the books a passive's declarations are checked against. Validating here rather than at use is the whole point: a passive naming a status that does not exist is a data error, and a data error should stop the load.
type Grant ¶
type Grant struct {
Status string
Stacks int
// Power is how big the granted status is, in parts per thousand of the stat
// Scaling names, and it is read only by a grant whose status carries a
// quantity — which today is an absorbing guard and nothing else.
//
// # Why a grant needed a number at all
//
// Every grant before this one was a *switch*: `toughened` is a status whose
// modifiers say what it does, so granting it needs nothing but its name.
// A barrier is not a switch — it is a pool, and how deep the pool is is the
// whole of what the trait says. Set.Hold applied a nought amount for exactly
// this reason ("a permanent status can be neither a damage-over-time nor a
// regeneration, so there is nothing here to snapshot"), and a barrier granted
// that way would have been a guard that stops nothing at all.
//
// ⚠️ It is read against the holder's **base** line rather than its buffed
// one, and that is a determinism rule rather than a preference. Grants go on
// at enlistment, one trait after another, so a grant reading buffed stats
// would depend on which traits happened to be applied first — a unit with
// `endurance` and a defence-scaled barrier would get a bigger barrier in one
// declaration order than another, and nothing on either trait would say so.
Power int
// Scaling is which of the holder's stats Power is a share of. Absent is
// refused where Power is required, because the zero value is health and a
// guard scaled off health is a different design question.
Scaling progression.Kind
// While gates this grant alone, or nil when the trait's own gate — or
// nothing at all — decides when it is carried.
//
// # Why a gate on the grant as well as on the trait
//
// Passive.While gates the *whole* trait, so the most it can say is one tier:
// "+Z while above Y, nothing below". The shape an author wants is two —
// "+X always, +Z instead while above Y" — which is an ungated grant carrying
// X and a gated one carrying the difference, on **one** trait. Splitting the
// two tiers across two traits is not the answer, because a character has
// trait slots and one idea may not cost two of them.
//
// ⚠️ **A grant is behind one gate or the other, never both.** ParseBook
// refuses a grant carrying this on a trait that is itself gated: two clauses
// over one grant is what a band already is, and every screen words a gate as
// one sentence. Passive.GateOver is the single reading of *which* gate
// applies, and every refusal, every renderer and the battle itself ask it
// rather than either field — a caller reading this field alone would let a
// grant under a trait-level gate through the two refusals below.
//
// The refusals a gate owns come down here with it: a health term and an
// absorbing pool are rules about the *grant*, so they are refused wherever
// the gate over that grant comes from.
//
// The first subject is `pristine`, and it is what the field was built for: a
// thin plating that never lapses beside the shipped `fortified` behind a gate
// at the top of the bar. Measured, the gate is the only dial in the game that
// separates two matchups a magnitude cannot — the same tier ungated is worth
// 248 and 216 parts per thousand against two opponents, and behind the gate
// 222 and 38. → README.md § *What a guard that holds while its holder is
// fresh is worth*.
While *Condition
}
Grant is a status a passive puts on its holder, and how many stacks of it.
There is no chance here and there is not going to be one. A passive is a fact about a unit rather than an event that happened to it, so a grant that sometimes failed would make two units built from the same character different in a way nothing on screen could explain.
type Passive ¶
type Passive struct {
ID string
// Name is the authored display name, and this package knows nothing about it
// beyond that it is text — the same arrangement skill.Name has, and for the
// same reason: a trait and the name it is called by are authored in one
// sitting, and a separate translations file is a second thing to keep in
// step. Absent is a real answer; a passive with no name renders as its id.
Name string
// Flavour is the authored clause a description opens with, and it is the one
// thing about a trait that is written rather than derived.
//
// It sits beside Name for the same reason skill.Flavour does: both are the
// words a trait is read in, and a name alone was never enough. A trait's
// sentences are one per declared field — "always carries cứng đòn", "refuses
// bỏng outright" — and they say what it does without ever saying what it is,
// so a reader meets the mechanism with nothing to hang it on. The clause is
// where "máu nó là nọc" is allowed to be said, because nothing derives that
// from a resistance and a reply.
//
// It is safe for exactly one reason: it may carry **no figure**, which
// ParseBook enforces. A clause with no number in it cannot be made wrong by
// changing a number, which is what lets prose sit beside derived sentences
// without the drift that Archetype.Demands was made derived to avoid.
//
// ⚠️ And it may name **no body**, which is a rule the seed tests hold rather
// than this package. A skill free for anybody to carry may not say "mai" and
// a restricted one may, because its restriction guarantees the body — a trait
// has **no restriction mechanism at all**, so for a trait the ban is
// unconditional. Nothing here can be authored its way out of.
//
// Absent is a real answer, the way it is for a skill: a trait with no clause
// opens on its derived sentences, which is what every one of them read like
// before this existed.
Flavour string
// Grants are the statuses the holder carries while the trait is in force,
// which is the whole battle unless a gate says otherwise — the trait's own
// While, or one written on the grant itself.
//
// Every one of them must be a permanent status, which ParseBook enforces.
// That is not about how long the trait lasts — a gated one comes and goes —
// but about who decides: a permanent status is one nothing in the game can
// dispel, so the only thing that can take a grant off is the gate that put it
// on. A timed status here would wear off on the holder's own turns with
// nothing to put it back, which is a trait that quietly stopped being true.
Grants []Grant
// Applies are the statuses the holder adds to what its own damaging skills
// inflict, on top of whatever those skills declare.
//
// skill.Application is reused rather than copied: "this inflicts that, at a
// fixed chance" is a shape that already exists, and a second one beside it is
// how the two drift apart. So a trait contributes to the list a skill's own
// applications are drawn from, which is a change in battle rather than a new
// rule.
//
// It rides on a skill that **deals damage** and on no other. A support skill
// aimed at an ally would otherwise carry a hostile rider to the ally:
// resolveAgainst deliberately never asks which side a target is on, so
// "already hurting whatever it hits" is the available way to say "hostile",
// and it is the honest one — a damaging skill aimed across the midline is
// already an attack on whoever is standing there.
Applies []skill.Application
// Renews are the statuses the holder puts back on itself at the start of
// every turn of its own.
//
// ⚠️ **It is the answer to the rule above rather than a hole in it.** Grants
// take permanent statuses only, because a timed one would wear off on the
// holder's own turns with nothing to put it back. This field is the nothing
// to put it back: a trait that renews says so once and the turn does the
// rest, so a timed status is exactly what belongs here and a permanent one is
// refused as a grant written in the wrong place.
//
// They land on the holder, which is why a permanent status here would be a
// grant and not a renewal, and they land after the tick that spends
// durations -- ahead of it the buff would lose its first turn to the very
// tick that was meant to leave it standing.
Renews []skill.Application
// Replies is what the trait costs an attacker, or nil when it answers
// nothing.
Replies *Reply
// While gates the trait, or nil when it is always in force.
//
// It gates the *whole* trait: the grants, the resistances and the
// applications all come and go together. That is still the shape for a trait
// that is one idea with a condition on it, and it is the only shape anything
// shipped uses.
//
// ⚠️ **A grant may now carry a gate of its own, and the two do not
// combine.** Grant.While is what writes the two-tier shape — an ungated
// grant carrying X beside a gated one carrying the difference — and a grant
// carrying one on a trait that is *also* gated is refused at parse, because
// two clauses over one grant is what a band already is. So a trait is either
// gated as a whole or has gates on its grants, never both, and
// Passive.GateOver is the one place that says which.
While *Condition
// Resists is the share of an incoming application's chance the holder
// refuses, per status.
//
// It is the one thing a passive does that had no home already: nothing in the
// engine could refuse a status before this. A stat change reuses
// status.Kind.Modifiers, so a trait grants and the existing code does the
// rest; there was no equivalent field for "this unit says no", and the roll
// that decides an application belonged entirely to the skill making it.
Resists []Resistance
// Drains is the share of the damage its holder deals that comes back as
// health, in parts per thousand, and nought is "does not drain".
//
// # Why a trait may hold one when a skill already can
//
// A skill's drain belongs to the skill: leech_seed takes six hundred because
// that is what leech_seed is, and a unit carrying it drains only on the turns
// it casts it. A trait's belongs to the unit, so everything it does drains —
// which is the difference between a skill that heals and a build that
// sustains, and there was no way to write the second.
//
// It is a **share** rather than a granted status, and that is the cheaper of
// the two things to gate: a share is read fresh on every strike, so a gate on
// this needs nothing but the reading. A grant needed a door — Hold and
// Release, an event each way and a retune — because the status it puts on is
// permanent and nothing else in the game may take one off. Both work now;
// this one always did.
Drains int
// Converts is the share of every blow its holder throws that meets no defence
// at all, in parts per thousand.
//
// # Why it is here rather than on a skill
//
// skill.Pierce already lets a *skill* ignore armour, and this is the other
// half of the same sentence: piercing belongs to razor_leaf because that is
// what razor_leaf is, so every carrier gets the same ratio. Converting
// belongs to whoever is swinging — "part of everything I throw goes straight
// through" is a fact about a unit and applies to its whole kit — and there
// was no way to write it. It is Drains' neighbour for exactly that reason:
// that field exists because a skill's drain belongs to the skill and a
// trait's belongs to the unit.
//
// ⚠️ **It is not a bigger pierce.** Piercing lowers the divisor, so a heavy
// enough armour still eats most of what is left; converting splits the blow
// and the converted share is divided by nothing, so it arrives whole however
// deep the armour is. One is the answer to armour in general and this is the
// answer to a wall — which is what makes it the damage dealer's tool against
// a tank rather than a second helping of the same thing.
//
// Read fresh on every strike like Drains, so a gate on it works as written.
Converts int
// Spares is the share of a skill's health cost its holder does not pay, in
// parts per thousand.
//
// # Why a share rather than a flag
//
// "Pays nothing" is the whole of what the first trait wanting this does, and a
// bool would have said it — but a cost is a quantity and the interesting
// designs are the partial ones: a trait that halves the price is a different
// unit from one that removes it, and neither is expressible if the field can
// only be on. Resists is the same shape for the same reason, and the base
// means immunity in both.
//
// # What it does NOT spare
//
// Only skill.Cost — the health a caster hands over up front, whether or not
// anything lands. It is not damage resistance, not a heal, and not a refusal
// of a status; a trait that should blunt a poison tick says so with Resists.
// The separation matters because the two read at opposite ends of a turn: a
// cost is paid before a strike is rolled and a tick lands on somebody else's.
//
// ⚠️ **It has to be read where the RATING prices a cost as well as where the
// battle charges it.** Battle.spendHealth is what a caster pays and
// pricing.spentHealth is what Suggest thinks it will pay; a trait applied to
// only the first makes a unit that never casts the skill it holds the trait
// for, because the rating still sees the full price and declines.
Spares int
// Amplifies is what the holder is better at inflicting, which is the one
// field here that reads the *other* unit's side of an application: every
// other job a trait has is about its holder, and this one is about what its
// holder does to somebody else.
Amplifies []Amplification
}
Passive is one declared trait.
func (Passive) Boosts ¶
Boosts is the shares the passive adds to one status's tick and to its chance, or nought for either it says nothing about.
Both at once rather than one call each, because the two are one entry: asking twice would look up the same row twice and would let a caller read one half and forget the other, which is exactly the half that does not reach the log.
func (Passive) GateOver ¶ added in v0.2.0
GateOver is the condition in force over one of the trait's grants: the grant's own where it carries one, the trait's otherwise, and nil when the grant is behind no gate at all.
Why every caller asks this instead of reading a field ¶
A grant is gated if the **trait** is gated or the **grant** is, and the two refusals a gate owns — a health term, an absorbing pool — are about the grant rather than about where the clause was written. A caller reading Grant.While alone waves through every health-raising grant and every pool sitting under a trait-level gate, which is exactly the pair of cases those refusals exist for; a caller reading Passive.While alone never sees a per-grant gate at all and leaves it stuck in whatever state enlistment put it in. One question, one answer, one place.
The two cannot both be set — ParseBook refuses a gated grant on a gated trait — so which wins is a fact about a hand-built Passive only. The grant's own is the answer there, because a clause written on the grant is the more specific of the two.
func (Passive) Gated ¶ added in v0.2.0
Gated reports whether anything the trait grants comes and goes with its holder's health.
It is the cheap question asked before walking the grants: a trait that gates nothing never has to be re-read when health moves. ⚠️ It is not `While != nil` — a trait with no gate of its own and one gated grant answers yes, and the early return that reads only the trait's own field is what makes a per-grant gate parse, render and never fire.
type Reply ¶
type Reply struct {
// Power is the share of the stat below that the reply deals, in parts per
// thousand. Nought is a reply that only applies statuses.
Power int
// Scaling is which of the holder's stats the reply is priced against, and
// whether it reads the base line or the modified one. Attack unless the
// trait says otherwise, which is what every damaging thing in this game
// scales off by default.
//
// It is authored because a reply is the one damaging thing whose owner is
// not choosing to use it. A trait that answers whoever hit it belongs to a
// unit built to be hit, and such a unit is armoured rather than sharp -- so
// pricing every reply off attack made thorns worth least to exactly the
// character thorns are for. Blastoise carries 640 defence and 460 attack;
// the same share off the wrong stat is a third less.
Scaling skill.Scaling
// Applies are the statuses the reply puts on the attacker. Timed only, for
// the same reason a rider is: a permanent one would be an effect on somebody
// else that nothing in the game could ever take off.
Applies []skill.Application
}
Reply is what a trait costs whoever attacked its holder.
It is the one thing a passive does that fires on somebody else's turn, from a unit that is not acting. `Applies` is the mirror of it and is not it: that one rides on the holder's own attack, at a moment the battle is already resolving a skill the holder chose.
What it is not allowed to be ¶
It is not a second damage path. The battle prices it through `combat.Rules` like everything else and writes it to the log as damage, so a replay reads it as events and `--verify` re-runs it from the seed. Anything that could only be seen by reading `*Battle` would be a rule the renderer and the verifier could not agree on.
The two numbers, and what is deliberately missing ¶
Power is a share of the holder's attack, in parts per thousand, exactly as a skill's is — so a reply is read against the same scale as the attacks around it, and nought is the honest way to write a trait that answers with a status and no damage.
There is no element and no accuracy, and both absences are the same decision: a reply is not an attack the holder chose to make. The elemental chart prices what one creature threw at another, and a trait reading it would make a fire creature's blood weak to water for a reason written nowhere on the trait; an accuracy roll asks whether contact was made, and contact is the thing that has already happened. So a reply is neutral, and it lands.
type Resistance ¶
type Resistance struct {
Status string
// Amount is the share refused, in parts per thousand. Negative is a
// vulnerability; the full base is declared immunity; nought is refused.
Amount int
}
Resistance is how much of one status's application chance its holder refuses, in parts per thousand.
Why a status rather than a category ¶
A category would read as the tidier choice — Cleanse takes categories, and for good reason — but it cannot say the thing that is actually wanted. "Immune to poison" as a category is "immune to every damage-over-time", which hands the holder immunity to burn as well; there is no way to be exact. An id can always name a class by listing it, while a category can never name one member of one.
So the cost of ids is verbosity on a trait meaning to cover a whole class, and the cost of categories is being unable to express the case that motivated the feature. A category resistance can be added beside this later if a class is ever wanted; adding it the other way round would mean shipping something wrong first.
Why a ratio, and what a full thousand means ¶
A ratio because refusing outright is a hard cap on a continuous quantity, and this engine has chosen against that everywhere: buffs saturate, piercing is a share, dodge approaches a floor it never reaches. A declared full thousand is then the explicit way to write true immunity — exactly as a skill declaring full accuracy is the explicit way to write an effect that must land. The absolute is available to whoever authors it and never falls out of stacking.
A negative share is a vulnerability ¶
Amount may be negative, and then the status lands **more** easily on the holder. That is a whole feature reusing the arithmetic rather than a second field: the chance is multiplied by what the resistance lets through, so a share of -300 lets 1300 through and a trait that says "no guard at all" costs what it says. Nought is refused in both directions — a share of nothing is a status the trait does not touch, and the way to write that is to leave the entry out.
It inherits the harmful-only rule for free, and that is the right answer rather than a happy accident: refusing a status the holder's own side puts on it is nonsense, and so is *inviting* one. A vulnerability is about being easier to hurt.
⚠️ It composes with a resistance to the same status through the same multiply, so the two do not cancel to nothing — a -500 and a +500 leave 1500*500/1000 = 750, three quarters, not the full chance. Anybody expecting them to annihilate is reading it as addition, which is what shares do and chances do not.