chaitu236 / TakWeb

Javascript based Tak client
https://www.playtak.com
GNU General Public License v2.0
39 stars 18 forks source link

Don't jump forward to latest move while reviewing a watched game #27

Closed njx closed 8 years ago

njx commented 8 years ago

When I start watching a game, I like to jump back to the beginning and step through the previous moves. When one of the players moves, though, the client automatically jumps to their new move, and I have to go back to where I was. It would be nice to have it not auto-jump forward, at least while watching.

(A simple fix for this might be to just save the current move number at the beginning of serverPMove and serverMMove, then just jump back to it after fast-forwarding and applying the latest move.)

chaitu236 commented 8 years ago

Thanks for the suggestion. Will implement when I get some time.

TreffnonX commented 8 years ago

I believe this can be done simpler than jumping back. The jumping ahead can be conditional on whether or not a player is currently at the last entry of the ptn (or in other words up-to-date). This is a client side thing, and if you want, I can take care of it chaitu...

chaitu236 commented 8 years ago

Don't forget that server moves modify the current board position. So the most recent position has to be shown on board for them to work correctly.

I'm sure we can do it without jumping forward by modifying the board history, but I'd prefer it to be implemented by jumping back simply because implementing separate function for this is wasteful when we already have code which does that (albeit not very efficiently).

chaitu236 commented 8 years ago

Oh, and you can implement this with jumping back method if you want.

TreffnonX commented 8 years ago

I have to take a closer look, but I was under the impression, that server messages which change the game state first and foremost modify the game history. But I need to see how it is to see what can be done. If server moves can be separated from the board position, it would be the (in my opinion) more proper solution. I will however have to get a picture of the code at that position first, which is later today, as now i have to work.

njx commented 8 years ago

Yeah, when I was skimming through the code, it looked like the the model update was closely coupled to the view update - i.e., you can't just tell the board to add a new move and calculate the new full board position to store in history without actually seeking the view forward as well. I didn't look closely to see if those could be easily separated, but if not, you could maybe hack around that by adding a "suppress redraw" flag or something during the operation if you know you're going to jump back at the end.

chaitu236 commented 8 years ago

Fixed in e2ff692f0f14d20f0cbcc6cd699718235f050bfa by fast forwarding and reverting back