Skip to main content

std-score

Level: Atom | Entity: ScoreEntry | Persistence: runtime

1 states, 5 events, 5 transitions

Live Preview

orbital ScoreEntryOrbital {
entity ScoreEntry [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
total : number
combo : number
points : number
multiplier : number
}
trait ScoreEntryScore -> ScoreEntry [interaction] {
state idle {
INIT -> idle
(fetch ScoreEntry)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "score-board", score: ["object/get", ["array/first", "@entity"], "total"], highScore: 0, combo: ["object/get", ["array/first", "@entity"], "combo"], multiplier: 1, level: 1 }, { type: "animated-counter", value: ["object/get", ["array/first", "@entity"], "total"], prefix: "Score: ", duration: 300 }, { type: "trend-indicator", value: ["object/get", ["array/first", "@entity"], "points"], showValue: true }, { type: "spacer", size: "md" }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Add", event: "ADD", variant: "primary", icon: "plus" }, { type: "button", label: "Subtract", event: "SUBTRACT", variant: "secondary", icon: "minus" }, { type: "button", label: "Combo", event: "COMBO", variant: "secondary", icon: "zap" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
ADD -> idle
(set @entity.points @payload.points)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "score-board", score: ["object/get", ["array/first", "@entity"], "total"], highScore: 0, combo: ["object/get", ["array/first", "@entity"], "combo"], multiplier: 1, level: 1 }, { type: "animated-counter", value: ["object/get", ["array/first", "@entity"], "total"], prefix: "Score: ", duration: 300 }, { type: "trend-indicator", value: ["object/get", ["array/first", "@entity"], "points"], showValue: true }, { type: "spacer", size: "md" }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Add", event: "ADD", variant: "primary", icon: "plus" }, { type: "button", label: "Subtract", event: "SUBTRACT", variant: "secondary", icon: "minus" }, { type: "button", label: "Combo", event: "COMBO", variant: "secondary", icon: "zap" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
SUBTRACT -> idle
(set @entity.points @payload.points)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "score-board", score: ["object/get", ["array/first", "@entity"], "total"], highScore: 0, combo: ["object/get", ["array/first", "@entity"], "combo"], multiplier: 1, level: 1 }, { type: "animated-counter", value: ["object/get", ["array/first", "@entity"], "total"], prefix: "Score: ", duration: 300 }, { type: "trend-indicator", value: ["object/get", ["array/first", "@entity"], "points"], showValue: true }, { type: "spacer", size: "md" }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Add", event: "ADD", variant: "primary", icon: "plus" }, { type: "button", label: "Subtract", event: "SUBTRACT", variant: "secondary", icon: "minus" }, { type: "button", label: "Combo", event: "COMBO", variant: "secondary", icon: "zap" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
COMBO -> idle
(set @entity.multiplier @payload.multiplier)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "confetti-effect", trigger: true }, { type: "score-board", score: ["object/get", ["array/first", "@entity"], "total"], highScore: 0, combo: ["object/get", ["array/first", "@entity"], "combo"], multiplier: 1, level: 1 }, { type: "animated-counter", value: ["object/get", ["array/first", "@entity"], "total"], prefix: "Score: ", duration: 300 }, { type: "trend-indicator", value: ["object/get", ["array/first", "@entity"], "points"], showValue: true }, { type: "spacer", size: "md" }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Add", event: "ADD", variant: "primary", icon: "plus" }, { type: "button", label: "Subtract", event: "SUBTRACT", variant: "secondary", icon: "minus" }, { type: "button", label: "Combo", event: "COMBO", variant: "secondary", icon: "zap" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
RESET -> idle
(set @entity.total 0)
(set @entity.combo 1)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "score-board", score: ["object/get", ["array/first", "@entity"], "total"], highScore: 0, combo: ["object/get", ["array/first", "@entity"], "combo"], multiplier: 1, level: 1 }, { type: "animated-counter", value: ["object/get", ["array/first", "@entity"], "total"], prefix: "Score: ", duration: 300 }, { type: "trend-indicator", value: ["object/get", ["array/first", "@entity"], "points"], showValue: true }, { type: "spacer", size: "md" }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Add", event: "ADD", variant: "primary", icon: "plus" }, { type: "button", label: "Subtract", event: "SUBTRACT", variant: "secondary", icon: "minus" }, { type: "button", label: "Combo", event: "COMBO", variant: "secondary", icon: "zap" }, { type: "button", label: "Reset", event: "RESET", variant: "ghost", icon: "rotate-ccw" }] }] })
}
}
page "/scoreentrys/score" -> ScoreEntryScore
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-
totalnumber0
combonumber1
pointsnumber0
multipliernumber1

States

StateType
idleInitial

Events

EventPayload
INIT-
ADDpoints: number
SUBTRACTpoints: number
RESET-
COMBOmultiplier: number

Transitions

FromEventToEffects
idleINITidle2 effects
idleADDidle2 effects
idleSUBTRACTidle2 effects
idleCOMBOidle2 effects
idleRESETidle3 effects