amZotti/mudConnector — pull request #10 by amZotti (2014-08-18 19:31:14+00:00)
Title: Interactive combat, map, and square description display

My actual branch name for this is "combat", which is very deceiving. The actual purpose of this branch is to set up websockets to display combat and map features in real time.

I have set up this using the websocket rails gem. Information is routed through mapped events to controllers. Controllers pass control to the models like normal, but instead of information being passed back to controllers, server output should be passed to Message.rb model. This model acts as the central output hub in the server for all websockets data. All HTTP data is handled through dashboards controller.

My view and JS was assembled in such a way whereby it can handle both HTTP data and websockets data simultaneously. Although, the only HTTP use case is during the initial page load for login or page refreshes.

Although the combat system is not fully implemented yet, it WILL use multithreading. However, I designed it very thoughtfully to minimize dependence on them. In actuality, the only thing threads will do in this game is activate the sleep command. Here is an overview of combat with threading:
1)User initiate attack
2) Warning message is sent to target. Target has 5 seconds to 'deflect' (implemented with NPCs right now, not players yet)
3) New thread activates, waits 5 seconds.
4) Once sleeper is over, thread jumps to check if the bot or player inputted deflection command. and registers a hit or fail
5) thread collapses.