tavern-harness 0.1.6 → 0.1.7
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/package.json +1 -1
- package/src/core/gameplay.ts +23 -10
package/package.json
CHANGED
package/src/core/gameplay.ts
CHANGED
|
@@ -371,18 +371,21 @@ export async function importGameplay(payload: unknown): Promise<ImportGameplayRe
|
|
|
371
371
|
// 创建对话的同时预建其专属工作目录
|
|
372
372
|
await ensureSessionWorkspaceDir(workspaceDir);
|
|
373
373
|
|
|
374
|
-
// ---- 5. 参与者(玩家恒定 -1;NPC participantId = 新 npc id
|
|
374
|
+
// ---- 5. 参与者(玩家恒定 -1;NPC participantId = 新 npc id,保留源座位顺序) ----
|
|
375
375
|
const participants: ChatParticipant[] = [];
|
|
376
|
-
participants.push({
|
|
377
|
-
sessionId,
|
|
378
|
-
participantId: -1,
|
|
379
|
-
kind: 'PLAYER',
|
|
380
|
-
npcId: null,
|
|
381
|
-
displayName: '用户',
|
|
382
|
-
seatOrder: 0,
|
|
383
|
-
});
|
|
384
376
|
const sortedSrcParticipants = [...data.sessionParticipants].sort((a, b) => a.seatOrder - b.seatOrder);
|
|
385
377
|
for (const sp of sortedSrcParticipants) {
|
|
378
|
+
if (sp.kind === 'PLAYER') {
|
|
379
|
+
participants.push({
|
|
380
|
+
sessionId,
|
|
381
|
+
participantId: -1,
|
|
382
|
+
kind: 'PLAYER',
|
|
383
|
+
npcId: null,
|
|
384
|
+
displayName: sp.displayName || '用户',
|
|
385
|
+
seatOrder: sp.seatOrder,
|
|
386
|
+
});
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
386
389
|
if (sp.kind !== 'NPC' || sp.npcId == null) continue;
|
|
387
390
|
const newNpcId = sourceNpcIdToNew.get(sp.npcId) ?? null;
|
|
388
391
|
if (newNpcId == null) continue;
|
|
@@ -392,7 +395,17 @@ export async function importGameplay(payload: unknown): Promise<ImportGameplayRe
|
|
|
392
395
|
kind: 'NPC',
|
|
393
396
|
npcId: newNpcId,
|
|
394
397
|
displayName: sp.displayName || '',
|
|
395
|
-
seatOrder:
|
|
398
|
+
seatOrder: sp.seatOrder,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
if (!participants.some((p) => p.kind === 'PLAYER')) {
|
|
402
|
+
participants.push({
|
|
403
|
+
sessionId,
|
|
404
|
+
participantId: -1,
|
|
405
|
+
kind: 'PLAYER',
|
|
406
|
+
npcId: null,
|
|
407
|
+
displayName: '用户',
|
|
408
|
+
seatOrder: 0,
|
|
396
409
|
});
|
|
397
410
|
}
|
|
398
411
|
await db.participants.bulkAdd(participants);
|