reference counterType and amount from closure
parent
cd11dca989
commit
55fbb02f5b
|
@ -10,32 +10,28 @@ public class MagicRemoveCounterEvent extends MagicEvent {
|
|||
public MagicRemoveCounterEvent(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
|
||||
super(
|
||||
permanent,
|
||||
new Object[]{counterType,amount},
|
||||
EVENT_ACTION,
|
||||
new MagicEventAction() {
|
||||
@Override
|
||||
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
|
||||
game.doAction(new MagicChangeCountersAction(
|
||||
event.getPermanent(),
|
||||
counterType,
|
||||
-amount,
|
||||
true
|
||||
));
|
||||
}
|
||||
},
|
||||
genDescription(permanent,counterType,amount)
|
||||
);
|
||||
}
|
||||
|
||||
private static final MagicEventAction EVENT_ACTION=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],
|
||||
-amount,
|
||||
true
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
private static String genDescription(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
|
||||
final StringBuilder description=new StringBuilder("Remove ");
|
||||
if (amount==1) {
|
||||
description.append("a ").append(counterType.getName()).append(" counter");
|
||||
} else {
|
||||
description.append(amount).append(' ').append(counterType.getName()).append(" counters");
|
||||
}
|
||||
}
|
||||
description.append(" from ").append(permanent.getName()).append('.');
|
||||
return description.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue