GameChallenge
Methods
- .effectCallback({ challenge, formatScoreSignal })
- .define(tag, registry)
- .subscribe(context, callback)
CSS Custom Properties
| Property | Default | Description |
|---|---|---|
--game-result-gradient-from | #6ee7b7 | Start color of the score gradient |
--game-result-gradient-to | #3b82f6 | End color of the score gradient |
Shadow DOM Parts
| Part | Description |
|---|---|
label | The "Their score" heading |
score | The opponent's formatted score |
taunt | The randomly selected taunt text |
Shows the opponent's score in challenge/group play. Hidden by default — only becomes visible when the challenge signal has a value (i.e. the player arrived via a shared result link). Displays the opponent's score and a randomly selected taunt to motivate the player.
Behavior
When a challenge is active the component:
- Adds the
:state(active)CSS state viaElementInternals(switches fromdisplay: nonetodisplay: block). - Renders the opponent's score in a large gradient display.
- Picks a random taunt message (e.g. "No mercy.", "Prove them wrong.").
- Changes the start button text in the parent overlay to "Challenge accepted".
Properties
- .formatScore
-
set(function) — Override for formatting the opponent's score. Receives the full challenge object. If not set, the component uses the shell'sformatScoreSignal(i.e.shell.formatScore) withchallenge.score, which is sufficient for most cases.Only set this if you need the full challenge object rather than just
challenge.score:const challenge = document.querySelector("game-challenge"); challenge.formatScore = (c) => `${c.score}ms and ${c.rounds} rounds`;
Signal Access
| Signal | Usage |
|---|---|
| Shell signals | Reads the challenge and formatScore signals |
Usage
<div when-some-scene="intro" data-overlay>
<game-challenge></game-challenge>
<h1>Reaction Time</h1>
<button commandfor="game" command="--start">Play</button>
</div>