Documentation
¶
Overview ¶
Package status holds the timed effects that sit on a unit: damage over time, stat debuffs, control, buffs and shields.
This is where duration lives, so anything that should wear off is modelled as a status rather than growing its own bookkeeping. Block charges are a shield status whose stack count is the charge count, which is how they gained an expiry without a second mechanism.
Three decisions shape the rest.
Duration is counted in the holder's own turns and a status ticks at the start of one. That makes the total damage of a damage-over-time independent of speed: a fast victim takes its three ticks sooner, not more often. Counting in rounds instead would punish a unit for being hasted, which would put speed at war with itself.
Every stack keeps its own snapshotted tick damage, taken when it was applied. The unit that applied it may be dead by the time it resolves, and two different attackers may stack the same poison on one target, so a single number per status could not stay honest. At a cap of three stacks the cost of keeping them separately is nothing.
Stacks are a discrete resource, so they are bounded by a hard cap rather than the saturation the engine uses for continuous values. Ticks themselves are not rolled: a status that has landed cannot be dodged or blocked, which is the whole role damage over time plays against those two defences. Cleanse is what answers it.
Index ¶
- Constants
- type Book
- type Category
- type Group
- type Kind
- type Set
- func (s *Set) Active() []string
- func (s *Set) Apply(kind Kind, tickAmount int64) (added, wasted bool)
- func (s *Set) Cleanse(categories []Category, count int) int
- func (s *Set) Consume(id string) (stacks int, damage int64)
- func (s *Set) CountIn(category Category) int
- func (s *Set) Has(id string) bool
- func (s *Set) HealShare() int
- func (s *Set) Hold(kind Kind, amount int64, stacks int) int
- func (s *Set) Modifiers() modifier.Set
- func (s *Set) Pending() int64
- func (s *Set) PendingIn(category Category) int64
- func (s *Set) PermanentPoolIn(category Category) int64
- func (s *Set) PierceShare() int
- func (s *Set) PoolIn(category Category) int64
- func (s *Set) Release(id string) int
- func (s *Set) Remaining(id string) int
- func (s *Set) Remove(id string, count int) (removed int, damage int64)
- func (s *Set) Snapshot() []Snapshot
- func (s *Set) SpendPool(category Category, amount int64) (spent int64)
- func (s *Set) Stacks(id string) int
- func (s *Set) Tick() (damage, healing int64, expired []string)
- func (s *Set) TickAmount(id string) int64
- func (s *Set) Timed() bool
- func (s *Set) TimedIn(categories []Category) bool
- func (s *Set) WardShare() int
- func (s *Set) With(kind Kind, tickAmount int64, stacks int) Set
- func (s *Set) Without(categories []Category, count int) Set
- type Snapshot
- type Stack
Constants ¶
const CategoryCount = int(HealMend) + 1
CategoryCount is the number of categories.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
// MaxStacks and MaxDuration bound every declared kind, so one status cannot
// be authored far outside the range the rest are balanced against.
MaxStacks int
MaxDuration int
// MaxCounterStacks bounds a counter — see Category.Counter — instead of
// MaxStacks, and is a separate number because it is bounding a different
// thing.
//
// MaxStacks bounds an *effect*: five stacks of a debuff at 300 per mille each
// is a figure the stat budget was reasoned against, so the cap and the
// budget are one argument. A charge multiplies nothing and ticks for nothing
// — what a pile of it is worth is entirely a property of the skill that
// spends it — so bounding it at five would be a number with no argument
// behind it, borrowed from a category it has nothing in common with.
//
// It is still a bound rather than no bound: a battle is finite, the shape a
// consumer buys is capped by the pattern book's own max_targets, and a
// ceiling nobody reaches in practice is what says out loud that reaching it
// was never the plan.
MaxCounterStacks int
// contains filtered or unexported fields
}
Book is the declared statuses plus the limits they obey.
func ParseBook ¶
ParseBook reads a status declaration. It never touches the filesystem.
⚠️ **A field this book does not know is refused, not ignored**, which is the one thing that separates it from the way a book is usually read. It was authored the other way round and cost a debugging session: a status written with `"name"` and `"flavour"` beside its numbers — exactly as a skill and a trait carry them — parsed clean, the two fields went nowhere, and the id reached the battle log bare. Nothing on the way said so. A silent drop of a field an author deliberately wrote is the worst answer available, because the file looks like it worked; a sentence naming the field is the cheapest.
It does not reach inside a modifier, and it does not have to: a custom unmarshaller is where DisallowUnknownFields stops, so `modifier.Modifier` closed that level itself. The type is shared with the skill and passive books, which is why the fix belongs to it rather than to any one of its three readers — and why those two books now set this flag at their own level too, leaving one rule rather than a status that refuses a typo beside a skill that swallows it.
func (*Book) Grouped ¶
Grouped files the declared statuses under their categories.
It exists because a cleanse names a category rather than a status — rapid_spin strips a stat_debuff and a dot — so a reader who cannot see which statuses those are cannot tell what the skill removes. Every front-end that lists the statuses needs the same grouping, and a grouping worked out twice is two answers to "which category is this in" waiting to disagree.
Category order is the enum's, kind order is the book's, and a category nothing is declared in is left out rather than printed empty: an empty heading reads as a listing that failed to load its rows.
type Category ¶
type Category uint8
Category groups statuses so a cleanse can name what it removes without listing every kind, and so a cleanse aimed at debuffs cannot strip the holder's own buffs.
const ( // Dot deals its snapshotted damage at the start of the holder's turn. Dot Category = iota // StatDebuff carries modifier terms applied while it lasts. StatDebuff // Control prevents or restricts the holder's action. Control // Buff is a beneficial timed effect. Buff // Shield absorbs incoming damage; its stack count is the charge count. Shield // Regen restores its snapshotted amount at the start of the holder's turn. // It is Dot with the sign the other way, and it shares the machinery: the // amount is frozen when the stack is applied, so two casters stacking one // regeneration each contribute what their own attack was worth. Regen // Taunt takes the holder's choice of enemy rather than its turn. // // Its own category rather than a second Control, because the two do opposite // things to a turn: a stunned unit does not act, and a taunted one acts and // is simply not allowed to pick. A category exists so a cleanse can name a // class without listing its members, and "strips a control" that took a // taunt off along with a stun would be a cleanse nobody could aim. // // Declared last on purpose. The value serialises by name like every other // enum here, so appending cannot reinterpret a saved book or log — but // CategoryCount and the order the grouped reference prints in are built from // the declaration order, and slotting one in beside Control would move every // table below it for no rule. Taunt // HealCut takes a share off the healing its holder *receives*, and is the // answer to a unit that out-heals what can be put on it. // // Its own category rather than a StatDebuff carrying no modifier, and the // reason is that the two descriptions would both be wrong. Lang's own // describeStatusEffect is a switch on the category plus a loop over the // modifier terms, and StatDebuff has no case at all — so a stat_debuff with // no term would describe itself as *nothing*. Worse, the statuses reference // prints a category as a predicate: stat_debuff reads "lowers a stat", which // is a lie on screen for something that lowers no stat. That is the class of // bug the taunt entry above paid for. // // It is HARMFUL — a heal-block is obviously something its holder wants gone, // so a cleanse may strip it and a trait may resist it — and it does NOT // outlast a shield: it is something done to a unit rather than something left // on it, so read OutlastsAShield's own comment before reaching for it here. // // Declared last for the reason Taunt was, which is now the rule rather than // one entry's note: appending cannot reinterpret a saved book or log, while // slotting one in moves CategoryCount and every table built from declaration // order, the grouped reference's print order included. HealCut // Charge is a counter that does nothing at all on its own and exists to be // spent by a skill that names it. // // Every other category answers "what does holding this do to me". This one // answers "what may somebody now do to me that they could not before", and // the two are different enough that folding it in would be wrong in both // directions. A Buff carrying no modifier would describe itself as nothing — // the trap Taunt and HealCut each paid for above — and a Shield is the // nearest relative but the wrong one: a shield spends itself, automatically, // against whatever arrives, while a charge sits there until somebody chooses // to cash it. Nothing on the holder's side ever reads it. // // ⚠️ **It is the one category the book's stack cap does not bound**, and that // is the whole reason it is a category rather than a flag. Every other cap // bounds an *effect* — five stacks of a debuff at 300 per mille each is a // number the stat budget was reasoned about. A charge multiplies nothing, so // the figure that bounds it is the one on the skill that spends it, and // max_counter_stacks in the book is where that is said out loud. A category // carrying a modifier or a tick is refused at parse for exactly this reason. // // It is HARMFUL: it goes on an enemy, and what it buys is bought by whoever // put it there, so a cleanse may take it off and a trait may refuse it. And it // DOES outlast a shield — a counter is nothing but something left on a target, // which is the exact sentence that predicate is written on. // // Declared last, which is now the rule rather than one entry's note. Charge // Absorb is a pool of damage its holder does not take, and it is the second // shape a guard comes in rather than a smoother Shield. // // ⚠️ **The difference from Shield is the whole reason it exists.** A block // charge cancels a *strike*, whole, however big it was — which is what makes // a wall the answer to one heavy blow and multi-strike the answer to a wall, // and that trade is `warden`'s identity. A pool eats *damage*, so it is // indifferent to how the damage arrives: many small blows drain it exactly as // one big one does, and a blow larger than what is left spills the remainder // through. The two are opposite shapes, not two sizes of one, and a game with // only one of them has only one kind of wall. // // Two consequences follow and both are load-bearing: // // - **A strike a pool ate still connected.** The blow arrived and was paid // for; only its damage went somewhere else. So the riders it carries land, // its drains drain what actually reached health, and Count(attempts, // Struck) counts it — none of which is true of a blocked strike, which // never happened at all. That is the complement of OutlastsAShield rather // than a case of it. // - **It is the one category whose per-stack amount MOVES.** Every other // frozen figure in this package is snapshotted at application and read for // the rest of the stack's life; a pool is spent. It therefore lives in its // own field rather than in TickAmount — see Stack.Pool — because the two // are read by different machinery and folding them together would have // Tick charging a holder for its own shield. // // It is NOT harmful: it is something its holder wants, so a cleanse aimed at // debuffs may not take it and a dispel aimed at an enemy may. // // Declared last, which is the rule. Absorb // Reserve is a counter its holder builds up on itself and spends on its own // skills, and it is Charge read from the other side of the board. // // ⚠️ **The difference from Charge is who it belongs to, and that is not a // detail of targeting.** A charge is laid on an ENEMY and cashed by hitting // them: whoever put it there paid a turn for it, so it is HARMFUL, a cleanse // takes it off, and its whole cost is that the victim's own side can wash it // away. A reserve sits on its holder and buys its holder's own skills, so it // is the opposite in every one of those: it is NOT harmful, a cleanse aimed // at debuffs may not touch it, and what takes it off is an enemy's dispel. // // Folding the two into one category was tried on paper and is wrong in a way // that shows immediately: `rinse` is a cleanse a squad points at its own ally // naming dot, stat_debuff and charge, and a fuel gauge in that list is a heal // that empties the tank it was meant to help. // // It is a counter, so everything Charge's comment says about a counter is // true here too: it changes no stat, ticks for nothing, does nothing at all // until a skill names it, and it is bounded by max_counter_stacks rather than // by the stack cap that bounds an effect. A modifier or a tick on one is // refused at parse for exactly that reason. // // It does NOT outlast a shield. The half of that predicate a counter earns is // "a charge is nothing but something left on the target", and it is earned by // a RIDER — a charge goes on because a blow arrived. Nothing puts a reserve on // a unit by hitting it: it is granted to its own side, where no shield stands // between the caster and the grant, so the question the predicate answers is // one nobody asks about it. // // Declared last, which is the rule. Reserve // HealMend raises the healing its holder RECEIVES, and is HealCut read the // other way up. // // ⚠️ **The arithmetic was already there and only the parser said no.** // battle.healingFor computes `scale.Base + share` and clamps the result at // nought, so a positive share has always raised a heal correctly — what did // not exist was a category allowed to carry one. That is why this is a // category and not a relaxation of HealCut's bound: a category prints as a // PREDICATE on the statuses reference, `heal_cut` reads "lowers the healing // its holder receives", and a status that raised healing under that heading // would be a lie on screen. Taunt and HealCut each paid for that lesson // already. // // It is NOT harmful — it is something its holder wants — so a cleanse aimed // at debuffs may not take it and a dispel aimed at an enemy may, which is the // Absorb reading rather than the HealCut one. // // It does NOT outlast a shield. Nothing puts one on by hitting: it is granted // to its own side, so the question that predicate answers is one nobody asks // about it. // // ⚠️ **Bounded at a doubling.** HealCut is bounded at total negation because // that is where the arithmetic stops meaning anything; the mirror of "takes // all of it" is "adds all of it again", and a share above that is a heal // multiplier with no argument behind it. One stack may promise a doubling and // the stack cap is what decides the rest. // // Declared last, which is the rule. HealMend )
func Categories ¶
func Categories() []Category
Categories returns every category in declaration order.
func ParseCategory ¶
ParseCategory resolves a category name as written in the data files.
func (Category) Counter ¶
Counter reports whether the category is a bare tally — something that changes nothing on its holder and exists to be spent by a skill that names it.
It is what the two counters share and it is the whole of what they share: the cap that bounds them is max_counter_stacks rather than the one that bounds an effect, and a modifier on either is refused. Which side of the board each belongs to is the thing they do NOT share, and that lives in Harmful.
A predicate rather than two names spelled out at each site, because there are three sites and a list written three times is a list that will disagree with itself the next time somebody appends.
func (Category) Harmful ¶
Harmful reports whether the category is something the holder wants removed. It is what separates a cleanse from a dispel.
func (Category) OutlastsAShield ¶
OutlastsAShield reports whether a rider of this category still lands when the strike carrying it was eaten by a shield.
The reading is one sentence: **a shield stops the blow and the wear, but not the contamination.** Fire still burns you through a shield and poison still gets on you, because both are something left on the target rather than something done to it. A stat the blow never bent and a turn it never took are stopped with the strike — there is nothing left over for them to be about.
⚠️ A **missed** strike is a different question and this is not asked about one. A block means the blow arrived and was stopped; a miss means nothing touched the target, so a miss delivers nothing, this category included. That distinction is the whole justification for the rule and collapsing the two deletes it.
⚠️ **It is one case on purpose.** HealCut was refused entry on the reading rather than on a measurement: cut healing is a share taken off a number some *later* effect produces, so a strike that was stopped leaves nothing on the target for it to have been about — the same sentence as a stat the blow never bent. Letting StatDebuff through was measured and rejected outright.
⚠️ With mire unstoppable — 25% off speed a stack, two stacks — pokemon.squirtle against itself stops resolving: 0 of 20 duels finished inside spar's 4000-turn limit (Endless 40 of 40 across both arrangements) against 20 of 20 finishing with a kill today, mire applications went 373 → 12875, and nothing was anywhere near dying — every unit sat at 45% health or better when the limit was hit and the lowest any was driven to at any point was 29%. That breaks TestABothWaysMirrorIsExactlyEven, which is a **fairness invariant** — a character duelling an identical copy of itself comes to exactly 500‰ — rather than a balance number. So do not "complete" this predicate by adding a second case, and do not fold it into Harmful, which is Dot|StatDebuff|Control|Taunt and answers what a cleanse may strip.
⚠️ **Charge is the second case, and it is the one the rule was already written for.** A counter is *nothing but* something left on a target — it changes no stat, takes no turn, and does nothing at all until somebody chooses to spend it — so "the shield stops the blow and the wear, but not the contamination" is a sentence about it more exactly than about the poison it was written for. It is also the case the mire experiment above cannot be read as a warning against: what broke there was a *stat* the wall could no longer be rid of, and a charge carries no stat to break anything with.
The half that stays: a shield still denies the charging when it eats the blow **that is the charge**, because the charge going ON is a rider and the charge going OFF is not. Read together, a guard is worth exactly one thing against a conduit — it stops the skill's own damage — which is the trade the whole playstyle rests on.
type Kind ¶
type Kind struct {
ID string
Category Category
// Name is what the status is called in the language the data is written in,
// and it is optional: a kind that declares none falls back to the compiled
// table in internal/i18n, which is where the names of the statuses that
// shipped before this field existed still live.
//
// It exists because the two books next door already had it. A skill and a
// trait each carry their own name, so an author moving to this one wrote
// `"name"` beside the numbers, the field went nowhere, and the status
// reached the log as a bare id — the file gave no sign, because nothing
// refused it. Both halves of that are fixed here: the field is real, and
// ParseBook refuses a field it does not know.
//
// The thirty-four shipped names are NOT migrated into the data, for the
// reason skillGloss was not: moving them would edit thirty-four lines of a
// balance file to change nothing anybody can observe, and the reasoning for
// half of those words — why a block charge and a barrier are different words
// — is written in Go comments that JSON has nowhere to put. So the table is
// the frozen fallback and this field is what a status authored from here on
// carries. An authored name WINS over a table entry for the same id.
Name string
// MaxStacks is how many times the status can be layered on one unit.
MaxStacks int
// Duration is how many of the holder's turns a freshly applied stack lasts.
// A permanent status declares none.
Duration int
// Permanent means a stack never counts down and never expires, which is what
// a passive's granted status needs: a passive is what a unit *is* rather than
// something that happened to it.
//
// It is a flag rather than a duration of nought, because nought would make an
// absent or mistyped duration silently permanent — and the fields around it
// already refuse their own zero for that reason. A permanent status is
// therefore two declarations that have to agree, and ParseBook checks they
// do.
Permanent bool
// TickPower is what one stack deals per tick, in parts per thousand of the
// applier's scaling stat, run through the usual damage formula at the moment
// it is applied.
//
// It belongs to the status rather than to the skill for the same reason the
// modifier terms do: poison should tick for the same thing however it was
// inflicted. What the skill contributes is the attack behind it, which is
// why two attackers stacking one poison produce stacks of different weight.
TickPower int
// parts per thousand, and it is negative: -400 means a stack takes 40% off
// every heal aimed at the unit.
//
// Negative rather than a positive "reduction" figure so that the sign says
// which way the number points, the way every other share on this type and on
// modifier.Modifier does. It composes by addition per stack (Set.HealShare),
// and the engine floors the result at total negation, so no amount of
// stacking can turn a heal into damage.
//
// It belongs to the status rather than to the skill for the reason TickPower
// and Modifiers do: every skill inflicting one status should inflict the same
// thing. ParseBook requires it on a HealCut and refuses it on anything else,
// exactly as it does TickPower on the two ticking categories — a category
// whose one job is a number cannot ship without it.
HealShare int
// PoolPower is how big an Absorb's pool is, in parts per thousand of the
// caster's scaling stat — the same shape TickPower has for a regeneration,
// and it goes through the same rules expression, so a barrier put up by a
// heavy hitter really is a heavier barrier.
//
// Its own field rather than TickPower, for the reason Stack.Pool is its own
// field: the validation two hundred lines below refuses a tick_power on
// anything that does not tick, and an absorb does not tick. Sharing the name
// would mean relaxing that check for one category and losing the guarantee
// for every other.
PoolPower int
// blows ignore, in parts per thousand, ADDED to whatever the skill already
// pierces.
//
// ⚠️ **Added rather than substituted, and a skill that pierces nothing is
// still raised.** A share that only applied to skills already piercing would
// be a bonus a kit either has or cannot use, which is a different design and a
// narrower one; this is the author's call, recorded here because the two read
// the same in a data file and not at all the same on a board.
//
// It is a field here rather than a modifier.Target for the reason Pierce is a
// field on a skill rather than a stat: `modifier.Target` maps onto
// progression's stat line, `Battle.Stats` returns that line, and a term nothing
// in progression names would be a value the stat machinery carries and never
// applies. Pierce is a property of a BLOW, and the blow is where it is read.
//
// Refused on a counter, exactly as Modifiers are and for the same reason: a
// counter is bounded by max_counter_stacks, which bounds a tally rather than an
// effect, so an effect on one is a number the stat budget never answered.
PierceShare int
// stack refuses, in parts per thousand.
//
// ⚠️ **Blanket, where a trait's resistance names a status.**
// passive.Resistance carries a Status and an Amount, so a trait says "I refuse
// poison"; there is no way to spell "I refuse a share of whatever is thrown at
// me", and a data file listing every status in the book would be a rule nobody
// could read or keep current. The two are different claims rather than one at
// two grains, which is why this is its own field and not a Resistance with an
// empty name — an empty name in that type would be a value every reader of it
// has to learn about.
//
// It composes the way a trait's does, by multiplying what each source lets
// through, so two sources of six hundred leave sixteen per cent rather than
// none and stacking diminishes for free.
//
// Positive only. A negative here would be a blanket vulnerability, which is a
// real design and a different one: `bare` exists and is granted by a trait that
// names what it gives up, where a status that quietly invited everything would
// be a cost no screen accounts for. Refused at parse rather than left to an
// author.
//
// Refused on a counter for the reason Modifiers and PierceShare are.
WardShare int
// Modifiers are the stat terms one stack contributes while it lasts.
//
// They belong to the status rather than to the skill that applies it, so
// that every skill inflicting the same debuff inflicts the same thing. A
// skill carrying its own terms would let two skills apply a status called
// "weaken" that weakened by different amounts, which is a bug nobody would
// see until they were compared.
Modifiers []modifier.Modifier
}
Kind is a declared status type.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is the statuses active on one unit. The zero value is a clean unit.
Entries are held in a slice in order of first application rather than a map, because a tick has to resolve in the same order every time for a battle to replay from its seed.
func (*Set) Active ¶
Active returns the ids of every status on the unit, in the order they were applied.
func (*Set) Apply ¶
Apply layers one stack of a status onto the unit and refreshes the duration of every stack already there, which is what makes sustained pressure worth more than a single application.
It reports whether a stack was added and, when the status was already at its cap, that the application was wasted. A caller that wants to tell the player its effect did nothing needs that distinction; silently succeeding would hide it.
func (*Set) Cleanse ¶
Cleanse removes up to count stacks from the given categories, working through the statuses in the order they were applied. It returns how many stacks went.
Taking categories rather than ids is what keeps a cleanse from stripping the holder's own buffs, and what lets one effect answer a whole class of statuses without naming each one.
func (*Set) Consume ¶
Consume removes every stack of a status and reports what it was worth over the turns it had left. It is what a skill that detonates a status calls, so the burst can be priced off the damage it gave up.
func (*Set) HealShare ¶
HealShare is what every active stack does to the healing this unit receives, accumulated: parts per thousand, negative, and nought on a clean unit.
Stacks contribute their share once each, mirroring Modifiers exactly — three stacks of a heal-cut are three times the term — which is what makes stacking it worth doing. Like Modifiers it accumulates and does not bound: the total is a share of a healing amount rather than a stat, so the bound belongs where the amount is (floored at total negation, so a heal can never become damage) and not here, where a second bound would be a second answer.
func (*Set) Hold ¶
Hold puts a permanent status on the unit, and is one half of the door a passive's gate needs.
Apply would do the same thing, and that is exactly why this exists: Remove refuses a permanent status so that nothing in the game can dispel a trait, and a gated trait has to be able to take its own grant back. A pair that only works on permanent statuses says which door is which — Apply/Remove is what the game does to a unit, Hold/Release is what a unit's own traits do to themselves, and a cleanse reaching the second would be a bug that reads as a typo rather than as a rule being broken.
It refuses a timed status for the same reason Remove refuses a permanent one: a trait that granted a timed status would wear off on its holder's own turns with nothing to put it back, and the parse layer already says so. Both halves of the pair refusing the other's kind is what keeps either from becoming a second Apply.
Stacks below one are nothing to hold. It reports how many stacks went on, which is nought when the status is timed or already at its cap.
func (*Set) Modifiers ¶
Modifiers returns the stat terms every active stack contributes, accumulated.
Stacks contribute their terms once each, so three stacks of a debuff are three times the term before the modifier package saturates the total. That is what makes stacking a debuff worth doing and still bounded.
func (*Set) Pending ¶
Pending is what every ticking stack in this set still owes over the turns it has left: the frozen tick amount times the remaining duration, per stack.
Per stack rather than per status, because TickAmount totals a status's stacks while Remaining reports the longest of them — multiplying those two would charge every stack for the longest one's duration. A cleanse is priced by this figure, and a price that over-counted would have the opponent cleansing ahead of finishing a unit off.
func (*Set) PendingIn ¶
PendingIn is Pending restricted to one category: what the ticking stacks of that category still owe over the turns they have left.
It exists because Pending totals every ticking stack without asking which way the sign points, and a caller that wants only the healing cannot subtract the harm out of it — the same reason undone has to refuse a strip that names anything harmful rather than reading the difference. Written beside PoolIn and CountIn, which restrict the other two per-stack figures the same way.
func (*Set) PermanentPoolIn ¶ added in v0.2.0
PoolIn returns what an absorbing guard still has left across every stack of every kind in a category.
A total rather than a per-kind figure, because damage does not choose which barrier it runs into: two kinds of absorb on one unit are one pool as far as an arriving blow is concerned, and SpendPool drains them in the order they were applied. PermanentPoolIn is the part of a category's pool held by permanent stacks, which is the part a battle can be rid of for good.
The distinction is not cosmetic and it is the whole reason this exists beside PoolIn. A timed guard is spent and then cast again — taking a bite out of one buys the turn it takes to come back and nothing else — while a permanent guard is granted once, is refused a second stack by Apply, and is never seen again once it is empty. Only the second is progress that keeps, and only a caller that can tell them apart may price one.
func (*Set) PierceShare ¶ added in v0.2.0
PierceShare is what every active stack lets its holder's blows ignore of a target's defence, accumulated and bounded at the base.
It composes by addition per stack, the way HealShare does, and is capped at total piercing because combat.Pierced treats anything at or past the base as "resolve against no defence at all" — so a stack beyond that buys nothing and a cap here says so once rather than leaving every reader to notice.
func (*Set) Release ¶
Release takes a permanent status back off, every stack of it, and is the other half of the door.
Every stack rather than a count, because a grant is a fact about the unit rather than an accumulation: a trait that granted three stacks and gave back one would leave two stacks of a trait that is no longer in force. It reports how many went, which is nought when the status is timed or absent.
A timed status is refused here so that this cannot be used as a cleanse that ignores a resistance. Remove is the way to take a timed status off, and it is the way that reports the damage that stopped.
func (*Set) Remove ¶
Remove takes up to count stacks off one status and reports what went, both as a stack count and as the damage those stacks still owed: each one's frozen tick times the turns it had left, which is the same figure Pending prices a whole set at.
The turns left rather than one tick of them. A stack is not worth a tick, it is worth every tick it was still going to take, and a detonate that reported the smaller number said a burn with two turns on it cost half what it did — which is exactly backwards for the decision the figure exists to inform, because the longer a status has left the *less* a consume is worth taking.
The heaviest stacks go first. A cleanse that removed the weakest would leave a player worse off than not cleansing at all in the case they care about, and picking by application order would make the outcome depend on bookkeeping nobody can see. Heaviest is measured by the same worth that is reported, so the two cannot disagree: today every stack of one status carries the same duration, because Apply refreshes all of them, so this orders exactly as the tick alone did — and it keeps ordering by what a stack is worth if that ever stops being true.
func (*Set) SpendPool ¶
SpendPool takes damage out of an absorbing guard and returns what it actually ate, which is the amount or the whole pool, whichever is smaller.
⚠️ **Oldest stack first, and the order is the replay contract rather than a preference.** Entries sit in a slice in order of first application and stacks within an entry in the order they were added, so draining walks them the same way on every machine — the same reason a tick resolves in application order. A map here, or a "drain the smallest first" rule, would be a battle that stops reproducing from its seed.
A stack drained to nothing is dropped immediately rather than left at zero: a spent barrier is not a barrier, and leaving it would have Stacks() report a guard that stops nothing.
func (*Set) Stacks ¶
Stacks returns how many stacks of a status the unit carries. It is what a skill's condition is tested against.
func (*Set) Tick ¶
Tick resolves the start of the holder's turn: it totals what every ticking stack owes, then spends one turn of every stack's duration and drops whatever ran out.
Damage and healing come back as two unsigned totals rather than one signed one, and that is deliberate. The caller subtracts damage through the same path that kills a unit at zero, so a negative arriving there would subtract a negative and could bring a corpse back — the one bug this shape makes impossible to write.
Totals are taken before durations are spent, so a status with one turn left still ticks a final time. It returns the ids of statuses that ran out entirely, in the order they were applied.
func (*Set) TickAmount ¶
TickAmount returns what the status currently deals per tick.
func (*Set) Timed ¶
Timed reports whether the unit holds anything that will change on its own: a stack with a duration still to spend. A permanent status does not count, because nothing about one is ever spent — Tick skips the whole entry.
It is the question a caller asks before deciding a battle can no longer change. Snapshot could be read for the same answer, but only by re-deriving which kinds are permanent, and a caller deriving that would be a second copy of the rule Tick already enforces.
func (*Set) TimedIn ¶
TimedIn is Timed narrowed to a set of categories: does the unit hold a stack with a duration still to spend, in one of these kinds of effect.
It exists because "will anything change on its own" and "can anything change how this battle *ends*" are different questions, and a deadlock predicate wants the second. A regeneration ticking away on a unit nobody can reach changes a number for ever and changes nothing else; a poison on the same unit will kill it, which empties a side.
Categories rather than ids, and a list rather than one, because that is how Cleanse already asks the same shape of question — a caller naming ids would be naming today's data instead of the rule.
func (*Set) WardShare ¶ added in v0.2.0
WardShare is what every active stack refuses of an application aimed at its holder, accumulated the way a trait's resistances are.
⚠️ **Sources MULTIPLY what they let through rather than adding what they refuse**, which is the reading battle.resist already gives a trait's shares: two stacks of six hundred leave sixteen per cent rather than nothing, so stacking diminishes for free and no saturation helper is needed. Adding the shares would make two stacks of six hundred a total refusal, and a status that cannot be landed at all is the one thing this share is not allowed to be — a single declared full thousand still reaches it, which is the author's door and never a stack's.
func (*Set) With ¶
With is a copy of this set with one application layered on, for a caller that wants to know what a status would do before anything does it.
It exists for Suggest, which may not mutate: the rating prices a buff, a guard or a regeneration by building the unit that would hold it and reading the numbers off that, so it needs the set the application *would* produce. The application itself goes through Apply, so the cap, the duration refresh and the wasted-stack rule are the ones that resolve for real rather than a second reading of them.
⚠️ The copy is deep, and it has to be. A Set holds its entries in a slice and each entry holds its stacks in another, so a value copy shares both arrays -- and Apply writes *through* them, refreshing every existing stack's Remaining. A shallow copy here would therefore have Suggest quietly refresh the real unit's durations every time it rated a status, which is a mutation in the one function that promises not to, and no existing test would have failed.
func (*Set) Without ¶
Without is With pointed the other way: a copy of this set with stacks taken off, which is what prices a cleanse.
Same deep copy and the same reason, and the removal goes through Cleanse so the stacks it takes are the ones a cleanse would actually take -- a price that chose its own stacks could name a figure the skill never delivers.
type Snapshot ¶
type Snapshot struct {
ID string
Category Category
Stacks int
TickAmount int64
// Pool is what an Absorb still has left across its stacks, and nought for
// every other category. A renderer drawing a guard needs the figure rather
// than the stack count: two stacks of a barrier that has eaten most of itself
// stop far less than two fresh ones, and a screen showing only "x2" would be
// telling a player something untrue at exactly the moment it matters.
Pool int64
// Remaining is the longest turn count left across the stacks, and it is
// meaningless when Permanent is set: a permanent status carries no duration,
// so a renderer reading Remaining alone would draw "0 turns left" beside
// something that never runs out.
Remaining int
Permanent bool
}
Snapshot is a readable view of one status, for logs and reports.
type Stack ¶
type Stack struct {
// TickAmount is what this stack ticks for, snapshotted when it
// was applied. It is zero for a status that does not deal damage.
TickAmount int64
// Pool is what an Absorb stack still has left to eat, and it is the only
// figure in this package that goes *down* over a stack's life.
//
// ⚠️ It is not TickAmount under another name, and the two may not be folded
// together. TickAmount is frozen at application and multiplied by the turns
// a stack has left — that is what Tick charges for and what Pending totals —
// while a pool is spent against arriving damage and is worth exactly itself
// however many turns are left. Sharing one field would have a barrier tick
// its holder for its own strength, and Pending price a guard as though every
// point of it were owed once per turn.
//
// It is zero for every category but Absorb, which is why nothing else in
// this file has to mention it.
Pool int64
// Remaining is how many of the holder's turns are left.
Remaining int
}
Stack is one application of a status.