Prepare game updates and single-process PM2 deployment
This commit is contained in:
@@ -44,7 +44,7 @@ export function createMatchController(config: ControllerConfig) {
|
||||
if (state.phase === 'countdown' && clock.now() >= state.startsAt) engine.beginTurn(state.startsAt);
|
||||
else if (state.phase === 'revealing' && clock.now() >= state.reveal!.revealEndsAt) engine.beginTurn(state.reveal!.revealEndsAt);
|
||||
state = engine.view();
|
||||
if (state.phase === 'selecting' && clock.now() >= state.deadline) engine.resolve([state.ownAction, engine.botAction()]);
|
||||
if (state.phase === 'selecting' && (state.ownAction || clock.now() >= state.deadline)) engine.resolve([state.ownAction, engine.botAction()]);
|
||||
publish(); state = engine.view();
|
||||
if (state.phase === 'finished') { void record(); return; }
|
||||
const next = state.phase === 'countdown' ? state.startsAt : state.phase === 'selecting' ? state.deadline : state.reveal!.revealEndsAt;
|
||||
@@ -69,7 +69,12 @@ export function createMatchController(config: ControllerConfig) {
|
||||
if (!saved) engine.start();
|
||||
tick();
|
||||
},
|
||||
async submitAction(action: ActionId) { if (friend?.recovering) return false; const accepted = engine.lockAction(action); if (accepted) publish(); return accepted; },
|
||||
async submitAction(action: ActionId) {
|
||||
if (friend?.recovering) return false;
|
||||
const accepted = engine.lockAction(action);
|
||||
if (accepted) { if (friend) { publish(); friend.submitAction(); } else tick(); }
|
||||
return accepted;
|
||||
},
|
||||
async leave() {
|
||||
if (friend) { await friend.leave(); await record(); return; }
|
||||
clock.clearTimeout(timer);
|
||||
|
||||
Reference in New Issue
Block a user