@clawlabz/clawarena 0.2.8 → 0.2.10
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 +8 -8
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare function setTimeout(fn: () => void, ms: number): unknown
|
|
|
5
5
|
declare function clearTimeout(id: unknown): void
|
|
6
6
|
declare function fetch(url: string, init?: Record<string, unknown>): Promise<{ status: number; text: () => Promise<string>; headers: Headers }>
|
|
7
7
|
|
|
8
|
-
const VERSION = '0.2.
|
|
8
|
+
const VERSION = '0.2.10'
|
|
9
9
|
const PLUGIN_ID = 'clawarena'
|
|
10
10
|
const DEFAULT_BASE_URL = 'https://arena.clawlabz.xyz'
|
|
11
11
|
const DEFAULT_HEARTBEAT_SECONDS = 20
|
|
@@ -421,12 +421,12 @@ class ArenaRunner {
|
|
|
421
421
|
|
|
422
422
|
// ── Action Logic ──
|
|
423
423
|
|
|
424
|
-
private pickAliveTarget(players: unknown[]): string | null {
|
|
424
|
+
private pickAliveTarget(players: unknown[]): { id: string; name: string } | null {
|
|
425
425
|
for (const player of players) {
|
|
426
426
|
if (!isObject(player)) continue
|
|
427
427
|
if (!player.alive) continue
|
|
428
428
|
if (player.id === this.agentId) continue
|
|
429
|
-
return String(player.id)
|
|
429
|
+
return { id: String(player.id), name: String(player.name || player.id) }
|
|
430
430
|
}
|
|
431
431
|
return null
|
|
432
432
|
}
|
|
@@ -444,21 +444,21 @@ class ArenaRunner {
|
|
|
444
444
|
const round = Number(state.round || 1)
|
|
445
445
|
const players = Array.isArray(state.players) ? state.players : []
|
|
446
446
|
const target = this.pickAliveTarget(players)
|
|
447
|
-
const targetName = target ? String((players.find(p => isObject(p) && p.id === target) as Record<string, unknown>)?.name || target) : 'someone'
|
|
448
447
|
|
|
449
448
|
if (phase === 'day') {
|
|
449
|
+
const targetName = target?.name || 'someone'
|
|
450
450
|
const pool = forceFallback ? SPEECH_POOL_FALLBACK : SPEECH_POOL_NORMAL
|
|
451
451
|
const text = this.pickSpeech(pool, round, targetName)
|
|
452
452
|
return { actions: [{ action: 'speak', text }], markSubmittedOnExhausted: false }
|
|
453
453
|
}
|
|
454
454
|
if (phase === 'vote' && target) {
|
|
455
|
-
return { actions: [{ action: 'vote', target }], markSubmittedOnExhausted: false }
|
|
455
|
+
return { actions: [{ action: 'vote', target: target.id }], markSubmittedOnExhausted: false }
|
|
456
456
|
}
|
|
457
457
|
if (phase === 'night' && target) {
|
|
458
|
-
if (this.tribunalRole === 'traitor') return { actions: [{ action: 'kill', target }], markSubmittedOnExhausted: false }
|
|
459
|
-
if (this.tribunalRole === 'detective') return { actions: [{ action: 'investigate', target }], markSubmittedOnExhausted: false }
|
|
458
|
+
if (this.tribunalRole === 'traitor') return { actions: [{ action: 'kill', target: target.id }], markSubmittedOnExhausted: false }
|
|
459
|
+
if (this.tribunalRole === 'detective') return { actions: [{ action: 'investigate', target: target.id }], markSubmittedOnExhausted: false }
|
|
460
460
|
if (this.tribunalRole === 'citizen') return null
|
|
461
|
-
return { actions: [{ action: 'investigate', target }, { action: 'kill', target }], markSubmittedOnExhausted: true }
|
|
461
|
+
return { actions: [{ action: 'investigate', target: target.id }, { action: 'kill', target: target.id }], markSubmittedOnExhausted: true }
|
|
462
462
|
}
|
|
463
463
|
return null
|
|
464
464
|
}
|
package/openclaw.plugin.json
CHANGED