This commit is contained in:
@@ -390,16 +390,12 @@ async function main() {
|
||||
// Run ticks until game ends
|
||||
let maxTicks = 100;
|
||||
while (maxTicks-- > 0) {
|
||||
const result = await ticker();
|
||||
if (!result || result.length === 0) {
|
||||
// Check if game ended
|
||||
const events = await store.queryByKind('werewolf.game-end', { limit: 1 });
|
||||
if (events.length > 0) {
|
||||
console.log('\n🎮 游戏结束!');
|
||||
break;
|
||||
}
|
||||
// Might be waiting, tick again
|
||||
continue;
|
||||
await ticker();
|
||||
// Check if game ended
|
||||
const endEvents = await store.queryByKind('werewolf.game-end', { limit: 1 });
|
||||
if (endEvents.length > 0) {
|
||||
console.log('\n🎮 游戏结束!');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ describe('werewolf WorkflowType', () => {
|
||||
if (tmpDir) rmSync(tmpDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
function trigger(topicId: string) {
|
||||
const hash = store.putObject('werewolf game start');
|
||||
store.appendEvent({
|
||||
async function trigger(topicId: string) {
|
||||
const hash = await store.putObject('werewolf game start');
|
||||
await store.appendEvent({
|
||||
occurredAt: Date.now(),
|
||||
kind: 'werewolf.__start__',
|
||||
key: topicId,
|
||||
@@ -62,7 +62,7 @@ describe('werewolf WorkflowType', () => {
|
||||
try {
|
||||
const wf = createWerewolfWorkflow();
|
||||
const rule = createWorkflowRule(wf, store);
|
||||
trigger('g1');
|
||||
await trigger('g1');
|
||||
|
||||
const order: string[] = [];
|
||||
// Max 200 ticks to allow the game to finish
|
||||
|
||||
Reference in New Issue
Block a user