← 前端阅读目录

chunks/B_cV99S-.mjs

伪代码
源文件超过50行,已替换为不超过50行的伪代码。辅助函数为逻辑抽象,不直接执行。
1async function rollDice({ target, condition, amount, currency }) {2  // 先创建零金额记录;响应到达后才用返回金额更新。3  const identifier = ledger.create({ amount: 0, currency });45  try {6    const response = await gameClient.post("dice/roll", {7      target, condition, identifier, amount, currency8    });9    const bet = response.diceRoll;1011    await waitForMinimumRevealTime();12    ledger.applyResponse({13      identifier,14      amount: bet.amount,15      payout: bet.payout,16      currency: bet.currency17    });18    resultState.set(bet);19    return { ...bet, identifier };20  } catch (error) {21    ledger.rollback(identifier);22    throw error;23  }24}2526function finishPresentation(identifier) {27  ledger.markGameFinished(identifier);28  // 真实余额推送与本局状态满足同步条件后再清理记录。29  ledger.clearIfSynchronized(identifier);30}
已确认说明