-1
\$\begingroup\$

I'd like to make a 2D game in Java using the Model-View-Controller (MVC) pattern, but I have some issues concerning the battles.

There are two groups of characters in each battle: heroes and monsters. The player controls the heroes. My game is turn-based: I'd like to select one character at a time, ask the player the action to use, its target, and finally execute the action. However I can't seem to adjust this sequence of commands with the MVC pattern.

Could anyone help me?

\$\endgroup\$
3
  • 4
    \$\begingroup\$ Yep, someone can help you. But you'll have to make it clearer what you're asking. What have you tried? Why is it failing? \$\endgroup\$ Commented Apr 30, 2013 at 15:30
  • \$\begingroup\$ My problem is the turn-based battle implementation. I created a Battle object in my model. This Battle object knows the two groups. It is able to run a turn at a time as well. In my point of view, it should also be able to run the battle in its entirety : each character attacks and it goes on until the death of one of the groups. But between every attack, for the heroes, I need the commands of the player, which will be received by the GUI, and given to the controller. So, I'd like to know if it's correct or which path should i take to resolve this little problem... Thx ! \$\endgroup\$ Commented May 1, 2013 at 8:52
  • \$\begingroup\$ Edit : I've implemented what I just said. The battle object is able to manage turns : I invoke a new turn after each attack. Therefore, the entirety of the battle is managed by the view, and it doesn't seem normal to me. That's my problem and what I'd like to do. Sorry for not being clear... And thanks. \$\endgroup\$ Commented May 1, 2013 at 9:10

1 Answer 1

3
\$\begingroup\$

You can solve this by implementing the controller as a state machine with four states:

  • select character
  • select action
  • select target
  • wait for animation to finish

In each of these state different GUI elements are shown/hidden and the inputs of the user are interpreted differently.

Instead of implementing it as a state machine, you could also implement it with four individual controller classes, one for each state.

\$\endgroup\$
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.