Move Card LIstener
Posted: 08 Sep 2010, 19:23
Previously I didn't understand why MoveCardListener couldn't be used for move card events, at least it worked for me fine. Until, as you said, I tried undo - e.g. canceling paying manacost - MoveCardListener is not notified when rollback is in action. So I rewrote this part, using your example in ZonePanelImpl (btw, you have redundant code there checking evt.getSource() == getZone() && Zone.CARDS.equals(evt.getPropertyName()) twice).however, since you're talking about GUI, you should probably use a PropertyChangeListener, see here starting at line 161. The reason is that the PCL will also be notified undo. In LM, this happens during the normal flow of the game if you can't pay for an action, for example.
It works except one aspect: MoveCardEvent(from, to) is splitted into 2 property change events: remove(card1, from:Zone.Library) and add(card1, to:Zone.Hand). Unfortunately I need them at the same time. I mean clients need information about source and target zones, smth like move(card, from:Zone.Library, to:Zone.Hand) that is used for animation. I know it is a little bit difficult because of lists separated, but may be still possible. Please advise.
p.s. other option that comes to my mind is to track event pairs on clients: whenever card is removed from anywhere, it should have mirror event that adds it to another zone.