preview
The on-screen attack preview of forecastKit. `Preview.show(preview, opts)` draws the result of `Odds.compute` over the target in one of four layouts (`big`, `duel`, `tooltip`, `minimal`) and five themes (`clean`, `scifi`, `fantasy`, `pixel`, `cartoon`), with hit, damage, crit, gr…
preview
The on-screen attack preview of forecastKit. Preview.show(preview, opts) draws the result of Odds.compute over the target in one of four layouts (big, duel, tooltip, minimal) and five themes (clean, scifi, fantasy, pixel, cartoon), with hit, damage, crit, graze and kill chance, follows the target's world position every frame, and scales to phone screens. Preview.showResult(result) shows HIT / CRIT / GRAZE / MISS / HEAL at the target in one of four result styles (stamp, burst, ticker, banner) and clears it. Preview.setStyle / Preview.setTheme / Preview.setResultStyle switch the look everywhere; Preview.catalog() lists every option.
Called by a game's targeting code (on hover / on confirm) or through the OddsPreview component. Uses the engine UI (screens forecastKit.preview, forecastKit.preview.result), worldToScreen and ui.fromViewport.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
now( ) → number
isStyle(s: string?) → boolean
| arg | type | description |
|---|---|---|
| s | string? |
setStyle(name: string) → void
Set the global default layout ("big", "duel", "tooltip" or "minimal"). Re-renders a preview on screen.
| arg | type | description |
|---|---|---|
| name | string |
setTheme(name: string) → void
Set the global default theme ("clean", "scifi", "fantasy", "pixel" or "cartoon"). Re-renders a preview on screen.
| arg | type | description |
|---|---|---|
| name | string |
style( ) → string
The current global default layout.
setResultStyle(name: string) → void
Set the global default result style ("stamp", "burst", "ticker" or "banner"): how Preview.showResult draws HIT / CRIT / GRAZE / MISS / HEAL. The one-change switch for the result look.
| arg | type | description |
|---|---|---|
| name | string |
resultStyle( ) → string
The current global default result style.
theme( ) → string
The current global default theme.
isShown( ) → boolean
True while a preview is shown.
toVec(a: any) → Vec
| arg | type | description |
|---|---|---|
| a | any |
project(anchor: any, lift: number) → void
| arg | type | description |
|---|---|---|
| anchor | any | |
| lift | number |
screen( ) → void
r(n: number) → number
| arg | type | description |
|---|---|---|
| n | number |
col(style: { [string]: any }?, children: { any }?, id: string?) → Node
| arg | type | description |
|---|---|---|
| style | { [string]: any }? | |
| children | { any }? | |
| id | string? |
row(style: { [string]: any }?, children: { any }?, id: string?) → Node
| arg | type | description |
|---|---|---|
| style | { [string]: any }? | |
| children | { any }? | |
| id | string? |
dmgText(d: Odds.Range) → string
| arg | type | description |
|---|---|---|
| d | Odds.Range |
signed(v: number) → string
| arg | type | description |
|---|---|---|
| v | number |
chip(th: Themes.Theme, k: number, label: string, value: string, color: string) → Node
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| k | number | |
| label | string | |
| value | string | |
| color | string |
pulse(dur: number) → any
| arg | type | description |
|---|---|---|
| dur | number |
bar(th: Themes.Theme, k: number, width: number, segs: { { [string]: any } }, id: string?) → Node
A bar: { { frac, color, pulse?, stripes? } } left to right.
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| k | number | |
| width | number | |
| segs | { { [string]: any } } | |
| id | string? |
hpSegments(th: Themes.Theme, who: Who, p: Odds.Preview?, isTarget: boolean) → void
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| who | Who | |
| p | Odds.Preview? | |
| isTarget | boolean |
panel(th: Themes.Theme, k: number, w: number, h: number?, style: { [string]: any }?, children: { any }, id: string?, delay: number?) → Node
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| k | number | |
| w | number | |
| h | number? | |
| style | { [string]: any }? | |
| children | { any } | |
| id | string? | |
| delay | number? |
anchored(x: number, y: number, w: number, h: number, align: string, child: Node, id: string) → Node
An anchored wrapper: a transparent fixed box centred (x) / bottom-aligned (y) on the anchor, so content of any size sits over the point.
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| w | number | |
| h | number | |
| align | string | |
| child | Node | |
| id | string |
headline(p: Odds.Preview) → string
| arg | type | description |
|---|---|---|
| p | Odds.Preview |
buildBig(th: Themes.Theme, p: Odds.Preview, o: ShowOpts, k: number, gid: string) → void
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| p | Odds.Preview | |
| o | ShowOpts | |
| k | number | |
| gid | string |
buildMinimal(th: Themes.Theme, p: Odds.Preview, _o: ShowOpts, k: number, gid: string) → Node
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| p | Odds.Preview | |
| _o | ShowOpts | |
| k | number | |
| gid | string |
breakdownRows(th: Themes.Theme, p: Odds.Preview, k: number, size: number) → void
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| p | Odds.Preview | |
| k | number | |
| size | number |
divider(th: Themes.Theme, k: number) → Node
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| k | number |
statRow(th: Themes.Theme, k: number, label: string, value: string, color: string) → Node
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| k | number | |
| label | string | |
| value | string | |
| color | string |
buildTooltip(th: Themes.Theme, p: Odds.Preview, o: ShowOpts, k: number, gid: string) → void
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| p | Odds.Preview | |
| o | ShowOpts | |
| k | number | |
| gid | string |
sideBlock(th: Themes.Theme, k: number, who: Who, p: Odds.Preview, isTarget: boolean, width: number) → Node
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| k | number | |
| who | Who | |
| p | Odds.Preview | |
| isTarget | boolean | |
| width | number |
buildDuel(th: Themes.Theme, p: Odds.Preview, o: ShowOpts, sw: number, k: number, gid: string) → void
| arg | type | description |
|---|---|---|
| th | Themes.Theme | |
| p | Odds.Preview | |
| o | ShowOpts | |
| sw | number | |
| k | number | |
| gid | string |
render(force: boolean?) → void
| arg | type | description |
|---|---|---|
| force | boolean? |
free(px: number, py: number) → boolean
| arg | type | description |
|---|---|---|
| px | number | |
| py | number |
startLoop( ) → void
show(preview: Odds.Preview, opts: ShowOpts?) → void
Show the preview for `preview` (from Odds.compute). `opts.anchor` is the target's world position (vector, {x,y,z}, an entity, or a function returning one); `opts.lift` raises the anchor in world units; `attacker`/`target` = { name, hp, maxHp, side?, color? }; `title` = ability name; `style`/`theme` override the global default for this call.
| arg | type | description |
|---|---|---|
| preview | Odds.Preview | |
| opts | ShowOpts? |
hide( ) → void
Hide the preview (the result stamp, if any, keeps playing out).
update(_dt: number?) → void
Re-project the anchor and re-render when it moved. Called every frame by the OddsPreview component and by an internal follow loop; safe to call more often.
| arg | type | description |
|---|---|---|
| _dt | number? |
showResult(result: Odds.Result, opts: ShowOpts?) → void
Show the outcome of Odds.resolve at the anchor in the current result style (Preview.setResultStyle) and theme: HIT / CRIT / GRAZE / MISS / HEAL. It plays and clears by itself in 1.2 to 1.7 s. `opts` takes anchor, lift, theme like show (defaults to the last shown preview's), `resultStyle` to override the style for this call, `preview` (the Odds preview, so the ticker and banner can show the roll against the chance; defaults to the shown one) and `keepPreview`.
| arg | type | description |
|---|---|---|
| result | Odds.Result | |
| opts | ShowOpts? |
catalog( ) → void
Every preview style, theme and result style with { kind = "style"|"theme"|"resultStyle", id, name, tags, description }.
Who = { name: string?, hp: number?, maxHp: number?, side: string?, color: string? }ShowOpts = {Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.