I want to make a system, so that there are certain tasks. For example, let's talk about a game. I want to make it so there are 100+ tasks doing different things, but when the player's magic level is 5, it will do the magic task, if the player's fighting skill is level 5, it will fight. I have that already, however here is the catch. I want to make it so once the task executes, it will have an 'ending'. So, it will do something before it finally gets killed.
My code so far:
for (GameTask a : s.gameTasks) {
if (a != null) {
if (a.validate()) {
a.execute();
}
}
}
It will loop all the tasks and execute them, however how can I implement an 'ending' to it, so that it will get ready for the next task? I hope I have written it clearly as English is not my first language.
tl;dr, I want to add an 'end' to each task so that it can be killed and can be ready for next task.