reference counterType and amount from closure

master
melvin 2012-09-23 22:28:53 +08:00
parent cd11dca989
commit 55fbb02f5b
1 changed files with 12 additions and 16 deletions

View File

@ -10,24 +10,20 @@ public class MagicRemoveCounterEvent extends MagicEvent {
public MagicRemoveCounterEvent(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
super(
permanent,
new Object[]{counterType,amount},
EVENT_ACTION,
genDescription(permanent,counterType,amount)
);
}
private static final MagicEventAction EVENT_ACTION=new MagicEventAction() {
new MagicEventAction() {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
final int amount=(Integer)data[1];
game.doAction(new MagicChangeCountersAction(
event.getPermanent(),
(MagicCounterType)data[0],
counterType,
-amount,
true
));
}
};
},
genDescription(permanent,counterType,amount)
);
}
private static String genDescription(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
final StringBuilder description=new StringBuilder("Remove ");