cuttle icon indicating copy to clipboard operation
cuttle copied to clipboard

[Feature]: Enable transition animations for replays

Open itsalaidbacklife opened this issue 5 months ago • 1 comments

Feature Summary

Currently replays 'jump' to the selected gamestate when you step forward and backward without showing the full animations for moves like scuttling, resolving 3's, 4's and 5's. We should adjust the update flow to allow transitions when stepping forward/backward

Detailed Description

Stepping between moves in replays is managed by the PlaybackControls.vue, which makes a call to gameStore.requestGameState() when the user selects a next state.

This gets the new game state from the server, and updates the gameStore with the latest data, but it does so in a way that doesn't properly trigger transitions.

Here's the function:

    requestGameState(gameId, gameStateIndex = -1, route = null) {
      const authStore = useAuthStore();
      return new Promise((resolve, reject) => {
        io.socket.get(`/api/game/${gameId}?gameStateIndex=${gameStateIndex}`, (res, jwres) => {
          switch (jwres.statusCode) {
            case 200:
              this.resetState(); // this clears out old data to ensure we don't keep anything stale
              this.resetPNumIfNullThenUpdateGame(res.game); // this fully updates the game
              return handleInGameEvents(res, route).then(() => { // this should handle transitions
                return resolve(res);
              });
            case 401:
              authStore.mustReauthenticate = true;
              // resolve so we can navigate to gameview & login there
              return resolve(jwres.body.message);
            default:
              return reject(jwres.body.message);
          }
        });
      });
    },

The crux of the issue is that we're calling:

  1. resetState() which fully clears out the game store including game id and myPNum
  2. resetPNumIfNullThenUpdateGame() which fully updates the game without transitions to the new set (this is currently needed after the reset to ensure we get at minimum the correct game id, and myPNum value
  3. Then last we call handleInGameEvents() which would fire the transitions if the game state were the previous one instead of the new one.

We need to sort out this flow so that we properly clear out the stale data at the right time, ensure that the necessary data for the game to load is also set (e.g. id and myPNum) and that the transitions can fire when appropriate.

itsalaidbacklife avatar Jun 27 '25 13:06 itsalaidbacklife

Hi, Can you please assign me this ?

ryuga001 avatar Oct 23 '25 16:10 ryuga001