Scoring
Scoring is opt-in. A story turns it on with a use scoring line in its
header. After that, a score <name> worth N line declares a scoring
identity, and award <name> grants it. Without use scoring, a score
or award line anywhere in the story is a compile error. This is
deliberate. A game with no score should say so rather than answer SCORE
with a number.
score and award are legal under four owners: the story header, a
create block, a define trait, and a define action. This section
shows all four in one story, because where a score lives is a real design
choice.
The story header owns scores that belong to the whole game:
story "Scoring" by "Sharpee Docs"
id: chord-ref-scoring
version: 0.0.1
use scoring
score green-thumb worth 5
A trait owns a score every entity composed with it can grant, without the trait knowing which entities those are:
define trait prunable
score tidy-secateurs worth 5
phrases en-US
pruned:
You snip away the dead wood.
on pruning it
award tidy-secateurs
phrase pruned
end on
end trait
A create block owns a score specific to that one entity, and here is
the payoff of owner-scoping. The damask rose and the moss rose both
declare score deadheaded worth 5, and those are two different
scores, one per rose, because each is owned by its own entity:
create the damask rose
aka damask
prunable
in the Rose Border
score deadheaded worth 5
A crimson damask, badly overgrown.
after pruning it
award deadheaded
award green-thumb
end after
The damask's after clause awards its own deadheaded, and also the
story-wide green-thumb. award <name> resolves owner-first: it looks
for a score of that name on the enclosing owner, then falls back to the
story header. So the same word deadheaded under the damask means the
damask's score, and under the moss rose means the moss rose's: no
collision, no prefixing.
An action owns a score granted whenever the action succeeds:
define action composting
grammar
compost the stuff
score turned-the-heap worth 10
award turned-the-heap
phrase composted
phrases en-US
composted:
Straight onto the heap with it.
Two properties fall out of this model. First, the maximum score is the
sum of every declared worth, computed at load time. Second, awards
dedupe by identity (ADR-129): awarding the same score twice grants it
once, so award is idempotent and the explicit , once modifier
is never needed for correctness; it
only documents intent.
This is why the pattern is "declare the score on the owner, award it in
an after clause" rather than guarding awards behind first-time checks.
Ranks
use scoring can take an indented body of ranks. A rank names a threshold
in absolute points, and SCORE reports the rung the player has reached:
use scoring, announce all
rank "Curious Visitor" at 0
rank "Attentive Guest" at 40 says settled-in
rank "Master of the Folly" at 120
The threshold is absolute points, never a percentage of the maximum. A
story that raises its ceiling mid-game would otherwise demote players who
had earned nothing and lost nothing. says <key> names a phrase from your
own phrases block, spoken on the turn the rung is crossed. A rung with no
says speaks an overridable platform line, and announce silent turns
announcements off.
The announce mode sets how a single award that crosses several rungs at
once reads. all reports each crossing in order, collapsed reports only
the top rung, combined speaks one line for the whole span, and silent
says nothing while the crossing still happens.