admin管理员组文章数量:1389783
As a university software engineering project, my group has to make a videogame out of the board game Galaxy Truckers (rules summary, if it helps), using the MVC pattern (we're using Java as a language, but this is a conceptual question).
The game has several actions that require a decision from the player to resolve, for example, in some cases, a player can choose to activate a cannon. Because, in the MVC pattern, the Model is passive and can't directly ask for input, our solution is to use an FSM, so that the Controller can monitor the Model's state and prompt the user for input based on the state. This is how we imagine the FSM, based on the various phases of the game: The problem is that we can't figure out who should be responsible for handling state transitions:
- Controller handles transitions: the Model simply contains the states and executes each state's code. The Controller reacts to inputs from the View and decides state transitions based on these inputs, forwarding inputs to the model when needed.
- Model handles trsnsitions: the Models performs state transitions, notifying the Controller when it does. Whenever the Model needs an input, it moves to some
InputRequest
state, which the Controller sees and prompts the View for an input. - Controller handles everything: the Model contains the states, but the Controller handles state transitions as well as instructing the Model on what to do based on the state.
Perhaps the third approach would actually make more sense if the FSM was actually in the Controller rather than the Model.
I hope the question is clear, thanks in advance for your help!
本文标签: model view controllerHandling input requests in MVC pattern with an FSMStack Overflow
版权声明:本文标题:model view controller - Handling input requests in MVC pattern with an FSM - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744610693a2615636.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论