Announce equipment uses in game chat
This commit is contained in:
parent
0907ad6b7b
commit
1eb7b7e409
5 changed files with 24 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fuji-engine",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"files": [
|
||||
|
|
|
|||
|
|
@ -1529,3 +1529,15 @@ test("teammate changes renew confirmation credit while manual undo does not", as
|
|||
assert.equal(timeIncrements(s)[0], confirmed + 2);
|
||||
assert.throws(() => applyMove(s, { action: "give", id: "machete", target: 0 }, 2));
|
||||
});
|
||||
|
||||
test("equipment use produces one public chat message and drains once", async () => {
|
||||
const wrapper = await import("../wrapper.js");
|
||||
let s = withPhase();
|
||||
s.players[0]!.name = "Climber";
|
||||
s = equip(s, 0, "flare");
|
||||
assert.deepEqual(s.chatMessages, ["Climber used Flare gun."]);
|
||||
assert.equal("chatMessages" in stripSecret(s, 1), false);
|
||||
const drained = wrapper.messages(s);
|
||||
assert.deepEqual(drained.messages, s.chatMessages);
|
||||
assert.deepEqual(wrapper.messages(drained.data).messages, []);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -553,6 +553,7 @@ function useEquipment(s: State, seat: number, m: Move) {
|
|||
p.cards = p.cards.filter((c) => c !== card);
|
||||
s.discard.push(card.id);
|
||||
}
|
||||
(s.chatMessages ??= []).push(`${p.name} used ${equipment(card.id).name}${id !== card.id ? ` as ${info.name}` : ""}.`);
|
||||
resetReady(s);
|
||||
if (id !== "rope")
|
||||
event(
|
||||
|
|
@ -1132,6 +1133,7 @@ export function stripSecret(s: State, seat?: number): View {
|
|||
liveUpdate: _____,
|
||||
planningSnapshot: ______,
|
||||
turns: _______,
|
||||
chatMessages: ________,
|
||||
...publicState
|
||||
} = structuredClone(s);
|
||||
const revealed = s.phase === "movement" || s.phase === "eruption" || s.phase === "ended";
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ export interface PlanningSnapshot {
|
|||
revision: number;
|
||||
}
|
||||
export interface State {
|
||||
chatMessages?: string[];
|
||||
turns?: TurnProgress[];
|
||||
skillChoices?: number[];
|
||||
liveUpdate?: boolean;
|
||||
|
|
@ -119,7 +120,7 @@ export interface State {
|
|||
}
|
||||
export interface View extends Omit<
|
||||
State,
|
||||
"seed" | "counter" | "deck" | "history" | "initOptions" | "liveUpdate" | "planningSnapshot" | "turns"
|
||||
"seed" | "counter" | "deck" | "history" | "initOptions" | "liveUpdate" | "planningSnapshot" | "turns" | "chatMessages"
|
||||
> {
|
||||
deckCount: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,3 +46,10 @@ export function setPlayerMetaData(s: State, seat: number, meta: { name: string }
|
|||
return setPlayerName(s, seat, meta.name);
|
||||
}
|
||||
export const dropPlayer = dropGamePlayer;
|
||||
|
||||
export function messages(data: State): { messages: string[]; data: State } {
|
||||
const messages = data.chatMessages ?? [];
|
||||
const next = { ...data };
|
||||
delete next.chatMessages;
|
||||
return { messages, data: next };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue