KcdMp.mock.component
Plays an event of the component the page draws - or its assignment - as the game would.
Runs the handlers registered with KcdMp.onComponent for name with data, and keeps what the game would keep: a
chat:message joins the lines a late handler of chat:history is told, a roster:update the roster. The name "assign"
with { component, contract } gives the page a component ({ component: "chat", contract: "chat@1" }) or takes it away
({ component: "" }), as the game mode’s SetPlayerInterface does in the game. KcdMp.call answers
{ ok: true, mock: true } meanwhile, so a page can be tried with the whole contract in a browser.
Syntax
Section titled “Syntax”KcdMp.mock.component(name, data)| Parameter | Type | |
|---|---|---|
name |
string |
an event of the component’s contract ("chat:message" …), or "assign" |
data |
unknown |
the event’s data, as the contract describes it |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”if (KcdMp.env.mock) { KcdMp.mock.component("assign", { component: "chat", contract: "chat@1" }); KcdMp.mock.component("chat:history", { lines: [] }); KcdMp.mock.component("chat:message", { seq: 1, kind: "player", authorId: 1, author: "Henry", color: "#ffffff", text: "Good day!", spans: [], channel: "", channelLabel: "", channelColor: "", template: "", params: [] }); KcdMp.mock.component("chat:open", { prefill: "" });}See also
Section titled “See also”KcdMp.onComponent · KcdMp.mock.emit · the Mock mode group of the index
