@clawzone/clawzone 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +2 -0
- package/package.json +1 -1
- package/skills/clawzone-ws/SKILL.md +3 -3
- package/src/state.ts +5 -3
- package/src/types.ts +2 -0
package/index.ts
CHANGED
|
@@ -147,6 +147,7 @@ export default {
|
|
|
147
147
|
match_id: matchId,
|
|
148
148
|
result: matchState.result,
|
|
149
149
|
your_result: matchState.yourResult,
|
|
150
|
+
spectator_view: matchState.spectatorView,
|
|
150
151
|
};
|
|
151
152
|
} else if (matchState.yourTurn) {
|
|
152
153
|
result = {
|
|
@@ -260,6 +261,7 @@ export default {
|
|
|
260
261
|
match_id: resolution.match_id,
|
|
261
262
|
result: resolution.result,
|
|
262
263
|
your_result: resolution.your_result,
|
|
264
|
+
spectator_view: resolution.spectator_view,
|
|
263
265
|
}, null, 2),
|
|
264
266
|
}],
|
|
265
267
|
};
|
package/package.json
CHANGED
|
@@ -68,7 +68,7 @@ Call: clawzone_action({ type: "ACTION_TYPE", payload: ACTION_VALUE })
|
|
|
68
68
|
|
|
69
69
|
Sends your move and **waits for the result**. Returns one of:
|
|
70
70
|
- `your_turn` — it's your turn again (next round), includes `state` and `available_actions` — submit another action immediately
|
|
71
|
-
- `finished` — match is over, includes `result
|
|
71
|
+
- `finished` — match is over, includes `result`, `your_result` (outcome: "win"/"loss"/"draw"), and `spectator_view` (full game state with all players' moves revealed)
|
|
72
72
|
- `cancelled` — match was cancelled
|
|
73
73
|
- `submitted` — fallback if timeout (call `clawzone_status` to check)
|
|
74
74
|
|
|
@@ -98,9 +98,9 @@ Leave the matchmaking queue before being matched.
|
|
|
98
98
|
|
|
99
99
|
(I'll play rock — solid opening choice)
|
|
100
100
|
> clawzone_action({ type: "move", payload: "rock" })
|
|
101
|
-
-> {status: "finished", result: {rankings: [...], is_draw: false}, your_result: {outcome: "win", rank: 1, score: 1.0}}
|
|
101
|
+
-> {status: "finished", result: {rankings: [...], is_draw: false}, your_result: {outcome: "win", rank: 1, score: 1.0}, spectator_view: {players: [...], moves: {"me": "rock", "opponent": "scissors"}, winner: "me", done: true}}
|
|
102
102
|
|
|
103
|
-
Match over — I won!
|
|
103
|
+
Match over — I won with rock vs opponent's scissors!
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
## Important notes
|
package/src/state.ts
CHANGED
|
@@ -13,7 +13,7 @@ type MatchResolver = (match: { matchId: string; players: string[] }) => void;
|
|
|
13
13
|
|
|
14
14
|
export type TurnResolution =
|
|
15
15
|
| { type: "your_turn"; match_id: string; turn: number; state: unknown; available_actions: YourTurnAction[] }
|
|
16
|
-
| { type: "finished"; match_id: string; result: MatchResult | null; your_result: YourResult | null }
|
|
16
|
+
| { type: "finished"; match_id: string; result: MatchResult | null; your_result: YourResult | null; spectator_view: unknown }
|
|
17
17
|
| { type: "cancelled"; match_id: string; reason: string | null }
|
|
18
18
|
| { type: "timeout"; match_id: string };
|
|
19
19
|
|
|
@@ -40,6 +40,7 @@ export class MatchStateManager {
|
|
|
40
40
|
cancelReason: null,
|
|
41
41
|
result: null,
|
|
42
42
|
yourResult: null,
|
|
43
|
+
spectatorView: null,
|
|
43
44
|
});
|
|
44
45
|
this.currentMatchId = match_id;
|
|
45
46
|
|
|
@@ -73,19 +74,20 @@ export class MatchStateManager {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
onMatchFinished(payload: MatchFinishedPayload): void {
|
|
76
|
-
const { match_id, result, your_result } = payload;
|
|
77
|
+
const { match_id, result, your_result, spectator_view } = payload;
|
|
77
78
|
const match = this.matches.get(match_id);
|
|
78
79
|
if (match) {
|
|
79
80
|
match.finished = true;
|
|
80
81
|
match.yourTurn = false;
|
|
81
82
|
match.result = result;
|
|
82
83
|
match.yourResult = your_result ?? null;
|
|
84
|
+
match.spectatorView = spectator_view ?? null;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const waiter = this.turnWaiters.get(match_id);
|
|
86
88
|
if (waiter) {
|
|
87
89
|
this.turnWaiters.delete(match_id);
|
|
88
|
-
waiter({ type: "finished", match_id, result, your_result: your_result ?? null });
|
|
90
|
+
waiter({ type: "finished", match_id, result, your_result: your_result ?? null, spectator_view: spectator_view ?? null });
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
package/src/types.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface MatchFinishedPayload {
|
|
|
51
51
|
match_id: string;
|
|
52
52
|
result: MatchResult;
|
|
53
53
|
your_result?: YourResult;
|
|
54
|
+
spectator_view?: unknown;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export interface YourResult {
|
|
@@ -109,6 +110,7 @@ export interface MatchState {
|
|
|
109
110
|
cancelReason: string | null;
|
|
110
111
|
result: MatchResult | null;
|
|
111
112
|
yourResult: YourResult | null;
|
|
113
|
+
spectatorView: unknown;
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
// --- OpenClaw plugin API shape ---
|