In turn-based games, actors (player, enemies, everything that moves or acts) often differ by their speed. However, since the game happens in turns,
the speed is more accurately described as a frequency in which turns happen for a particular actor. ROT.Scheduler
is a simple tool designed to
simplify the task of selecting proper actor for a turn, based on the abstract speed of all actors.
First, you need to fill the scheduler instance with actors. There are very few requirements on actors: they need to be JS objects with method getSpeed()
,
which returns a number. An actor with speed=100 will get twice as many turns as actor with speed=50.
You can then repeatedly call the scheduler's next()
method: it returns the actor whose turn should start.