generated from nhcarrigan/template
fix: sync game state before auto-boss challenge (#102)
Auto-boss was calling the boss API directly without first flushing pending game state to the server. This inlines a saveGame call (using refs, matching the existing auto-save pattern) before the challenge so the server sees up-to-date state, consistent with the manual challenge flow.
This commit is contained in:
@@ -1281,7 +1281,26 @@ export const GameProvider = ({
|
||||
if (availableBoss !== undefined) {
|
||||
const { id: bossId, name: bossName } = availableBoss;
|
||||
isAutoBossingReference.current = true;
|
||||
void challengeBossApi({ bossId }).
|
||||
const syncBeforeBoss
|
||||
= stateReference.current !== null && !isSyncingReference.current
|
||||
? saveGame({
|
||||
state: stateReference.current,
|
||||
...signatureReference.current === null
|
||||
? {}
|
||||
: { signature: signatureReference.current },
|
||||
}).then((response) => {
|
||||
if (response.signature !== undefined) {
|
||||
signatureReference.current = response.signature;
|
||||
localStorage.setItem(
|
||||
"elysium_save_signature",
|
||||
response.signature,
|
||||
);
|
||||
}
|
||||
})
|
||||
: Promise.resolve();
|
||||
void syncBeforeBoss.then(async() => {
|
||||
return await challengeBossApi({ bossId });
|
||||
}).
|
||||
then((result) => {
|
||||
setState((previous) => {
|
||||
if (previous === null) {
|
||||
|
||||
Reference in New Issue
Block a user