Turn based combat turn order

I’m working on a project for my class at a tech center, and am making a turn-based rpg in Java. Currently I’m looking at using either a priority queue or a linked list to store the order of the characters in battle each round. Which should I be using? Or is there a better way I could be doing it?

You could do that, but unless you need some advanced properties that I didn’t get a whiff of, you could more simply use a ArrayList and sort it via Collections.sort().
99% of the time you don’t need a data structure more complicated than a List/array type.

Well, we plan to add features after getting a basic system working, including things such as the ability to cast a haste or slow spell in order to change a character’s speed.

I’m assuming your system works something like each character has a “cooldown” or a count down till next action?



// in BattleHandler or something

updateAllEntities(); // decrements Entity.cooldown for each, plus whatever logic

for(Entity character : yourParty) {
    if(character.cooldown <= 0) {
        character.performAction();
        character.resetCooldown();
    }
}

// then to "slow down" an opponent, all you do is add to their cooldown:

public void stun(Entity target, int timeToSlow) {
    target.cooldown += timeToSlow;
}

This is just a simple method I came up with, and is based off of game ticks, but you could also use actual time if game-tick based logic is undesirable (despite it’s nice determinism).

You could also store priorities in the entities and just sort the list every frame, and unless you have hundreds of entities, it won’t really matter.

Awesome, thanks! We’ve been thinking about storing the priorities for each character, but doing it with ticks is also a pretty good idea. Thanks for the help!