ruby on rails - How to have an "action" go off in the future in RoR? -


OK, this is a design question which is nothing. I'm making a text based game using Ruby on Rail 3, and I'm not the best way to make sure what I want to do. In the game, the user gets a bunch of Goblins, and can tell what they have to do with Gubblons. One of the available actions is attack , which you can assume, that means the attacks of your tribe are anything else, whether it is an anti-tribal or NPC settlement.

If you choose to attack an anti-tribe, then going to attack your goblins is a definite point when the war will start (we say, in the future, 10 minutes). Here's the question, What's the best way to implement simulation for war in the right 10 (or X) minutes in the future? Because if the simulation is too quick or too late, then the whole

(I know that it is a bit unclear, but for those who have played, the result of the whole war will change If simulation can be played by one another, it is too soon or delayed.)

I was looking at ways to apply some walking in the future (and two previous) , But it seems that something needed for it Run accurately on time. I also looked at Ruby timer, but do not seem compatible, as if it is in Java, nor do they keep the data continuously. I was also hoping for lower coupling, maybe the supervisor was using the pattern.

So there you have it if I send my assault, or I want to do anything in the future time X , in the train on Ruby What is the best way to do this?

simple answer: do not

give you time (now + 10 minutes) You should save the database and then run the cronchob every minute (or whatever you prefer). After this, all those fights should be evaluated which should be fought at that time. For best practices in this behavior, see

You can also add an inquiry that if you can fight on every request. In this way you will get a little bit more randomness when the fight will start at the very beginning and depending on the traffic of your site, it can be like every other, depending on the quantity of your calculations, to evaluate the fight Remember to start a thread for. Otherwise some users may experience long-term on a large scale.

Comments