Background:
For the past few months, I've been working on a turn-based RPG in my free time in Java. I have only been programming for around a year, so my expertise is mostly limited to command line applications and object-oriented programming principles that I learned in elementary CS classes.
Development was going swimmingly up until I started to adapt the game from taking input from the command line to using a custom-made UI that I started building using Swing. This is largely because command line-based input lets me stop everything that I'm doing and wait for input from a scanner or something in that vein, but judging from threads that I've read on here (Waiting for multiple button inputs in Java Swing, Waiting till button is pressed), Swing's event-driven nature doesn't really allow you to wait for anything without interrupting the EDT and freezing the GUI, which is a bad thing for my purposes.
The Problem:
While Swing is quite novel to me, I've got it working on the main menu and see how it could readily be applied to games where data is relatively centralized between a few objects that utilize simple commands from the user to move or attack or what have you. My problem is that my RPG has anywhere between 2 and 16 active characters in a battle scenario, which can be user-controlled or AI controlled, can use any number of different commands (including something like 16 different skills) and player characters have to be able to access an inventory common between all of them. Suffice to say, my game is heavily menu-driven. For example, I'll post a method called from the loop that I run during a battle:
//initializes a turn; written as a function to cut down on duplicate code
public battleData initializeTurn(battleData toInitialize){
if(toInitialize.initializeSkill()) {
if(toInitialize.initializeTarget(playerParty, playerMinions, 1) == 0)
return initializeTurn(toInitialize); //recursive call if the user cancelled
} //the skill they selected.
else {
if(toInitialize.initializeTarget(enemyParty, enemyMinions, -1) == 0)
return initializeTurn(toInitialize); //see above
}
return toInitialize;
}
This method calls two functions written in the gameCharacter class, initializeTarget and initializeSkill to choose a target from two arrays of passed targets and one skill out of the character's two skill lists. Derived from the gameCharacter class are the playerCharacter and Monster classes, which calculate the return values of the methods from user input and a rudimentary AI, respectively. Since I have a lot of data about skills and items stored across different classes and user input behaves differently depending on which character is getting input, whether they're choosing a target or selecting a skill at the moment and where they are in the scope of the skill selection menu, I'm finding it very difficult to formulate an algorithm that lets me make the entire thing event-driven, since events can mean so many different things depending on what part of the menu is being looked at presently.
Solutions:
I've read about things like swingworkers being used to handle background tasks, states being used to feed input to different places and timers being used to regularly update graphical components, but I'm not familiar enough with Swing to really know what the best route is to take at this point. I'm more looking for a general algorithm to implement than a magical solution that will let me solve my problem without changing much of my code. I'm more than willing to reshape quite a bit of what I've written so far, so don't be afraid to tell me that I'll have to redo quite a bit if you think that it will make the program better.
Thanks for bearing with me; if you need more context, I'd be happy to explain or post more code. I would have posted more to start with, but most of the menus that I mentioned are 1-200 lines and are more easily explained than actually copied.