tihawk / project-hiros

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rewrite the way action chains are handled

tihawk opened this issue · comments

Right now walking, attacking and so on are handled by time-interval promises in the server, after which the new state is send to the clients. This looks a lot like promise hell, and it would be beneficial to refactor this in a way where the responsibility for action chains is shared between server and client.

One option would be to aggregate an action chain in the server, and send it to the client. The client then deals with the action chain by animating the creatures, and finishing an item from the chain as an animation ends. Since it hasn't yet received an updated state, it can freely update its own, without it being overwritten by the server
At the time of finishing the chain, it emits a resolution to the server, and the server sends the new state to the client.
If the client fails to handle the chain withing a time-out period, the server can enforce a state update to that client.