I am developing a small-scale TB/RT Strategy hybrid, not unlike the Total War series. It's in the classic medieval setting, with only melee infantry combat currently implemented for testing. Units are fighting in small squads, but the egagements are individual (for example: 1v1, 1v2, 1v4 etc, but not 2v2, 2v3, 3v5, etc) and are taking place on whats usually considered an RPG level of detail (stats, items, scripts...).
The current rules use Java, with class Engagement implements Runnable
and its run()
method simply alternating the attack phases of two units until one of them is incapacitated. That was usefull for ATT/DEF equation balancing, but I'm not sure how to model the following:
- unit's attack, block, parry/conterattack phases during the engagement (deciding when to block, for additional DEF - one simple loop or a separate thread?)
- multiple units engaging one unit (for, say, caster/leadership takedown), where the outnumbered unit has to choose which attacker to repel/conterattack (loop or a check within aforementioned decision thread?)
Is real-time usually modelled as just a really quick loop, or a thread with interrupt
and sleep
/wait
/join
?
If needed, I can add the relevant code, but I think of this as a purely design, flow-modelling problem; simply put: What are the classes/interfaces (and their traits) I should rely on while resolving this problem?
Runnable
will cause much more problems than solve - from your description you are not using it because you need threads but rather for saving objects state in thread's context. All the synchronization and mess for something that can be done by bool flag/enum just as good doesn't seem to be a good trade-off. \$\endgroup\$ – wondra Nov 26 '15 at 20:08