Skip to main content
10 events
when toggle format what by license comment
May 19, 2014 at 15:50 comment added valenterry So why does it not include the "actionSourcePlayer" who started or performs the action but only the targetPlayer as a private member??
May 19, 2014 at 15:46 comment added skiwi @valenterry I see where the confusion came from on AttackMonsterAction, I updated it to reflect my current version where it does include the targetPlayer.
May 19, 2014 at 15:46 history edited skiwi CC BY-SA 3.0
added 43 characters in body
May 19, 2014 at 15:45 comment added valenterry 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.
May 19, 2014 at 15:44 comment added skiwi @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.
May 19, 2014 at 15:43 comment added valenterry 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.
May 19, 2014 at 13:14 history tweeted twitter.com/#!/StackProgrammer/status/468379077095993344
May 19, 2014 at 10:17 comment added Ivaylo Slavov 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.
May 19, 2014 at 10:16 answer added GrahamA timeline score: 4
May 19, 2014 at 9:34 history asked skiwi CC BY-SA 3.0