Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • A nice and clean way for me would be to be able to access the owner of a monster from the monster's data. If you have some map where you use the monster id (or index) for key and the player that owns it, or even a monster object that has the owning player as a property, then you would not even pass the player in the action. Commented May 19, 2014 at 10:17
  • Why would you like to refer to "the other player"? Don't! Imagine, you want somewhat later to implement that the monster of a player can attack another monster of the same player. Refering to the other player is useless in this case. So the monster needs some kind of controller. It then tells to its controller "I got attacked and took 2000 damage points" or something like that. The controller then knows both players and knows what monster belongs to which player so it can handle all the stuff that has to be done next. Commented May 19, 2014 at 15:43
  • @valenterry The concrete action does not depend on "the other player", it only needs two players and two monster indices as input and will do whatever you ask it to do. I do however, from within the GUI for example, need to determine whom is the opponent in regular play. Commented May 19, 2014 at 15:44
  • I also see some drawbacks with the GameState solution from @GrahamA. It seems nice first, but it makes it for example harder to test, because an AttackMonsterAction does not have to know for example how many turns have been made - so you should not bother it with information from a GameState that it does not need or care of. Commented May 19, 2014 at 15:45
  • @valenterry I see where the confusion came from on AttackMonsterAction, I updated it to reflect my current version where it does include the targetPlayer. Commented May 19, 2014 at 15:46