Yesterday (after reading AM's post about a new card game he released) I build the card game SET. I've played this a lot with my son, as its a hugely entertaining (and brainwrecking) game.
Anyway, with this game time is of the essence and thus the matter of 'delayed updated over server' came up. So I started thinking whether there is a way to synchronise either the update or (much easier) the view port of all connected clients.
Example Issue
- one of the clients is the dealer and she clicks on the 'draw cards' macro.
- this macro puts a couple of cards on the map face up.
- issue is that the 'dealer' has the advantage of seeing them first and the other clients after the update. Not a big deal on fast internet, but might be a big deal when the connection is slow.
Possible solution
- as soon as the dealer clicks the 'draw cards' macro her view port is send somewhere else. So same map but lets say the game table is near 0,0 we send the viewport to 10000,10000. The same is done for the other clients
- after the update is done the viewport returns (preferably to its original position but thats currently not possible) to the game table.
Obviously the solution still suffers from the same 'delay' issue.
So I was thinking:
- its possible to get the time for each client
- so if you can get the (near) exact time of all clients then on each client you can run an individual time loop that finishes after a certain time is reached.
Example
For this to work you require a server and two connected clients (the server could be run by one of the clients as a seperate instance of MT)
Lets assume for simplicity sake that both clients have the same time (here's btw where the issue lies what this topic is about).
Now the dealer runs the 'draw cards macro: (sv = server, dl = dealer, cc = connected clients, c1 = client 1)
Code: Select all
dl (draw cards macro)
- broadcast (=remote execute macro) an initiation instruction to sv
- end of macro
sv (initiation macro):
- gets time of all cc (e.g c1: 0:00:00, c2:11:58)
- add (eg) 5 seconds to those times (so 0:00:05 and 2:12:03)
- broadcast a 'screen off' instruction to all cc's
- draw cards
- end of macro
c1 (screen off)
- set viewport to far away
- runs timer loop until its 0:00:05
- returns viewport to gamebord
- end of macro
dito c2
What I'm currently breaking my head over is the fact that when you 'get' the times of the cc that there will be a delay in that as well. Thats the procedure Im bashing my head for against the wall.
One thought I had:
Code: Select all
sv (getCCTime)
- get current time and store on lib
- broadcast 'give me your time' to cc
- end of macro
cc (giveMeYourTime)
- get current time
- broadcast 'heres my time' to sv
- end of macro
sv (heresMyTime)
- get current time
- get time stored on lib
- checks how much time has passed (current - stored) divide by two (assuming that send and recieve over the interweb takes the same amount of time)
<!-- now we know how much delay there is lets say 1 second -->
- adds 1 second to the cc time as the actual cc time is one s later.
- store (earlier stored) sv and cc time on lib e.g. in a json object {c1: 0:00:05, c2: 2:12:03, sv: 13:22:12}
I hope this makes sense. Basically currently I'm just looking for comments, suggestions, better ideas, gaps in the above etc.
thank you.