Sharpee
Chord / Standard Library / Death / kill the player

kill the player

kill the player (statement, peer to win and lose) has the forms kill the player, kill the player <phrase-key>, and an optional when <condition> suffix; it is legal anywhere statements go: on and after clauses (entity or trait), on every turn [while …] daemons, define action bodies, and inside select and each blocks. The phrase key is the death text (define it like any phrase) and doubles as the recorded cause; a bare kill the player records the cause killed and shows only the platform's ending text.

The machinery, in order: the death text speaks, the platform's player-died event fires, and at end of turn the engine re-checks the player's actual life state; that re-check, not the event, is the final word. A story policy that revives the player during the turn (Dungeo's death-penalty machinery works this way) vetoes the ending; otherwise the game ends in defeat (game-lost, the death and endgame channels). Because the decision waits for end of turn, statements after the kill in the same body still run. There is no built-in "restart or undo?" prompt; that is client/story territory.

The author writes:

create the Generator Room
  a room

  Pipes and cables hum along every wall.

create the bare wire
  aka wire
  scenery
  in the Generator Room
  states: live, dead

  A stripped cable sags from the ceiling conduit.

  on the player touching
    kill the player shock-death when the bare wire is live
    phrase wire-cold when the bare wire is dead
  end on

create the breaker lever
  aka lever, breaker
  scenery
  pullable
  in the Generator Room

  A heavy knife-switch bolted beside the door.

  on the player pulling
    change the bare wire to dead
    phrase breaker-thrown
  end on

create Alex
  a person
  playable
  starts in the Generator Room

define phrases en-US
  shock-death:
    The current takes you before you can let go.
  wire-cold:
    Cold and inert. The breaker did its job.
  breaker-thrown:
    The breaker slams over and the hum dies with it.

before the game starts
  change the player to Alex
end before

The player who touches the wire straight away sees the death text and nothing after it; the game has ended in defeat:

> touch the wire
The current takes you before you can let go.

The player who throws the breaker first (a fresh game) lives:

> pull the lever
The breaker slams over and the hum dies with it.

> touch the wire
Cold and inert. The breaker did its job.

The when suffix is the whole gate: with a live wire, the kill fires; with a dead wire, it is skipped. Note the second when on phrase wire-cold: statements after a kill still run, so follow-up text must gate itself off the fatal case.