model view controller - Where does game logic go in Rails apps? -


(disclosure: I am very new to rail)

I try to make a risk I am in the style board-game rail, although this question can apply for any MVC-style structure.

I have players and games where players can join the game until the game is complete. Trying to join the full game (or two games), an error indicates, Yada Yada.

Three pieces of game logic are given below, where I do not know where the place is, or at least where they are usually kept.

  1. If a game is full, then it should start and do things related to it (i.e., messaging all players starting the game, spreading forces on random maps Ones). / P>

  2. When a player executes moves during his turn, it seems that the argument in the controller is logical. What happens when its turn ends and the time for giving the message to the next player? Do this code as the same controller

  3. Assume that a player will change his turn if he does not end in 24 hours. From time to time I should see all the games in my app and see if a player had started a turn 24 hours ago. Where would this logic go?

    My question is: Where does the logic argument for items like the above in the railway / MVC app come from?

    In the same sense, I can do everything except the 3 << code>. For the last-action-action in the controllers, for example, I 1. I can argue in the player-add-game controller method for (check that if the player is finished after joining each player, if it is, then 1 <. Code> related logic ) It seems that this may be the wrong place, but it can be done generally how it is done.

    Rail 'conference is "fat model, thin controller". That's why I can suggest that the game model should be organized by the game model.

    You have zero or more games in the webpage, and each game has 1 or more players.

    "Full" or "game start" conditions are the qualities of the game, and should be organized by that model. Therefore 1) When the last player (or perhaps, all the current players will vote to start the game), the game state (a property of the game) will be set to "start", activate current The player holds the property which will be set, and one player will be queued for the message

    For 2, the game controller in the game has a "execution" method that will check Driver walker Neither player, so it will have to run against the game model. The game model will know internally that the trick is correct, what is the result, and what will be the next step again, it will use something like a delayed job to deliver the message to the next player.

    For # 3, again, a delayed job can be set to execute the timeline. I am not 100% to determine delayed jobs or if there is another gem / plugin that will work better but, at the right time, to check the position of the game, a game on the game controller will say the method. If the player has not moved, then execute your virtual logic, which again, there will be a way in the game model.

    The status of each player can be discussed in the player model or in the game model, I think, depending on the game, and the player model.

    In the case of risk sports, I think the player model will be rather slim, as more about the state board the player is the owner of the country, and how many armies there are - the more games Position, then the status of each person's player. I expect the player model to be more oriented towards the real player about the Mayaadata in the risk game - username, win / loss, skill level, etc.

    In a game like domination, where the player has resources, Nikes etc., then there is more data to store in Player Model.

Comments