fix: 사령부 모바일 현재 턴과 NPC 대상을 호환
daemon 진행 뒤 국가 명령을 현재 슬롯에 재기준화하고 Ref 명령별 장수 대상 필터를 적용한다. 모바일 고급 편집기 12턴과 500px 8수뇌 행렬을 실제 Chromium 기준으로 복원한다.
This commit is contained in:
@@ -396,6 +396,32 @@ export const setNationTurns = async (
|
||||
return { revision, turns: serializeTurnList(turns) };
|
||||
};
|
||||
|
||||
/**
|
||||
* 국가 턴 입력은 화면을 연 뒤 daemon이 선두 턴을 소비했더라도 사용자가 고른
|
||||
* 슬롯 번호를 현재 큐에 적용한다. 큐 lease가 실제로 잡혀 있는 충돌은 그대로
|
||||
* 거절하고, revision이 앞으로 진행한 경우에만 새 revision으로 재기준화한다.
|
||||
*/
|
||||
export const setNationTurnsAtCurrentPositions = async (
|
||||
db: DatabaseClient,
|
||||
nationId: number,
|
||||
officerLevel: number,
|
||||
updates: readonly ReservedTurnUpdate[],
|
||||
expectedRevision: number
|
||||
): Promise<ReservedTurnSnapshot> => {
|
||||
let revision = expectedRevision;
|
||||
for (let attempt = 0; attempt < 8; attempt += 1) {
|
||||
try {
|
||||
return await setNationTurns(db, nationId, officerLevel, updates, revision);
|
||||
} catch (error) {
|
||||
if (!(error instanceof ReservedTurnRevisionConflictError) || error.currentRevision === revision) {
|
||||
throw error;
|
||||
}
|
||||
revision = error.currentRevision;
|
||||
}
|
||||
}
|
||||
throw new ReservedTurnRevisionConflictError(revision, revision);
|
||||
};
|
||||
|
||||
export const setNationTurn = async (
|
||||
db: DatabaseClient,
|
||||
nationId: number,
|
||||
@@ -407,6 +433,23 @@ export const setNationTurn = async (
|
||||
): Promise<ReservedTurnSnapshot> =>
|
||||
setNationTurns(db, nationId, officerLevel, [{ turnIndices: [turnIndex], action, args }], expectedRevision);
|
||||
|
||||
export const setNationTurnAtCurrentPosition = async (
|
||||
db: DatabaseClient,
|
||||
nationId: number,
|
||||
officerLevel: number,
|
||||
turnIndex: number,
|
||||
action: string,
|
||||
args: unknown,
|
||||
expectedRevision: number
|
||||
): Promise<ReservedTurnSnapshot> =>
|
||||
setNationTurnsAtCurrentPositions(
|
||||
db,
|
||||
nationId,
|
||||
officerLevel,
|
||||
[{ turnIndices: [turnIndex], action, args }],
|
||||
expectedRevision
|
||||
);
|
||||
|
||||
export const shiftNationTurns = async (
|
||||
db: DatabaseClient,
|
||||
nationId: number,
|
||||
|
||||
Reference in New Issue
Block a user