I’m making a turn-based RPG game, and my method that sorts all “Actor” objects in the order in which they all attack sorts them completely randomly. I, however, want to improve this method so that an “agility” stat that every actor has is able to improve their roll. I’ve looked at several methods in the Collections class, and Arrays as well, but didn’t seem to find anything that does what I want.
Right now, I’m thinking about getting a random int between 1 and 100, and having the agility score improve the odds. I tried separate ArrayLists for the Integers and a HashMap… but a no go on those.
My method as it is now:
// getFriendlies(), getHostiles(), and attack_order are all ArrayLists
public void calculateAttackOrder() {
attack_order.addAll(getFriendlies());
attack_order.addAll(getHostiles());
Collections.shuffle(attack_order);
}
I appreciate the help!
Then you can call