KcdMp.mock.reply
Sets what KcdMp.post answers for a name.
In mock mode KcdMp.post(name, data) calls fn(data) and resolves to what it returns (or to what a returned promise
resolves to), where in the game a client script’s OnWebEvent would answer. A name without a reply answers
{ ok: true, mock: true }.
Syntax
Section titled “Syntax”KcdMp.mock.reply(name, fn)| Parameter | Type | |
|---|---|---|
name |
string |
the call’s name |
fn |
(data: unknown) => unknown |
answers the call |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”KcdMp.mock.reply("buy", (data) => ({ ok: data.item === "bread" }));const reply = await KcdMp.post("buy", { item: "bread" }); // { ok: true }See also
Section titled “See also”KcdMp.post · KcdMp.mock.emit · the Mock mode group of the index
