fix(battle): show and debit confirmed backup vehicles
Use the signed i64 profile encoding identified in PR #13. Make attached backups selectable in LocalMP after the daily quota, and debit backups only after the engine confirms the selected slot entered play. Record the stock daily allowance once per room and slot. Settle owned backups using the confirmed spawn facts and keep repeat settlement from charging the same battle again. Verified server and launcher types, MSVC compilation, three client builds for patch and Quirrel checks, and a temporary 2.61.0.58 build. In-game acceptance is pending. Co-authored-by: duduyagame <[email protected]>
This commit is contained in:
1 parent
6d0abf9caf
commit
3282320fb7
34 files changed
+402
-46
No files matched your search
@@ -6,6 +6,7 @@
|
||||
import type { BattleSettlementContext } from '@wto/mods';
|
||||
import type { AccountStore } from '../../accounts/account-store.ts';
|
||||
import { parseBattleReport } from '../../battle/battle-report.ts';
|
||||
import { hasBattleResultLog } from '../../battle/battle-result-log.ts';
|
||||
import type { BattleSessionStore } from '../../battle/battle-session-store.ts';
|
||||
import { settleBattle, type BattleSettlementDeps } from '../../battle/battle-settlement.ts';
|
||||
import type { BattleEconomy } from '../../battle/battle-economy.ts';
|
||||
@@ -62,15 +63,19 @@ export function finishBattleAction(ctx: FinishBattleContext, battle: BattleActio
|
||||
if (session.settled) {
|
||||
return { kind: 'data', blk: clientProfile(ctx.profiles.profileOf(account.userId), account) };
|
||||
}
|
||||
const updated = ctx.profiles.update(account.userId, (profile) => {
|
||||
const updated = ctx.profiles.updateWhen(account.userId, (profile) => {
|
||||
// The result log and expenses are written together. A retry can arrive after the profile
|
||||
// was saved but before the session was marked settled.
|
||||
if (hasBattleResultLog(profile, session.roomId)) return false;
|
||||
settleBattle(profile, report, session, settlementDeps);
|
||||
battle.onAfterSettle?.({
|
||||
userId: account.userId,
|
||||
roomId: session.sessionId,
|
||||
summary: { profile, report, session },
|
||||
});
|
||||
return true;
|
||||
});
|
||||
battle.sessions.markSettled(session.sessionId);
|
||||
return { kind: 'data', blk: clientProfile(updated, account) };
|
||||
return { kind: 'data', blk: clientProfile(updated ?? ctx.profiles.profileOf(account.userId), account) };
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user