remove kicker from MagicPermanent, convert multikicker to use MagicMultikickerCost

master
melvin 2013-06-18 22:05:40 +08:00
parent 16b1c2925e
commit 07f3648c49
12 changed files with 57 additions and 62 deletions

View File

@ -8,5 +8,5 @@ subtype=Vampire,Shaman
cost={2}{B} cost={2}{B}
pt=2/2 pt=2/2
timing=main timing=main
ability=multikicker {B} target opponent discards a card for each time it was kicked ability=multikicker {B}
requires_groovy_code requires_groovy_code

View File

@ -8,5 +8,5 @@ subtype=Ogre,Shaman
cost={4}{R} cost={4}{R}
pt=4/3 pt=4/3
timing=main timing=main
ability=multikicker {R} it deals damage to target player equal to twice the number of times it was kicked ability=multikicker {R}
requires_groovy_code requires_groovy_code

View File

@ -7,6 +7,6 @@ type=Creature
subtype=Angel subtype=Angel
cost={3}{W} cost={3}{W}
pt=2/4 pt=2/4
ability=flying,multikicker {W} you gain 2 life for each time it was kicked ability=flying,multikicker {W}
timing=main timing=main
requires_groovy_code requires_groovy_code

View File

@ -8,5 +8,5 @@ subtype=Elemental
cost={2}{G}{G} cost={2}{G}{G}
pt=4/4 pt=4/4
timing=main timing=main
ability=multikicker {G} put a 2/2 green Wolf creature token onto the battlefield for each time it was kicked ability=multikicker {G}
requires_groovy_code requires_groovy_code

View File

@ -19,6 +19,7 @@ import magic.model.event.MagicPermanentActivation;
import magic.model.event.MagicCyclingActivation; import magic.model.event.MagicCyclingActivation;
import magic.model.event.MagicReinforceActivation; import magic.model.event.MagicReinforceActivation;
import magic.model.event.MagicKickerCost; import magic.model.event.MagicKickerCost;
import magic.model.event.MagicMultikickerCost;
import magic.model.mstatic.MagicCDA; import magic.model.mstatic.MagicCDA;
import magic.model.mstatic.MagicStatic; import magic.model.mstatic.MagicStatic;
import magic.model.trigger.MagicAllyGrowTrigger; import magic.model.trigger.MagicAllyGrowTrigger;
@ -685,11 +686,8 @@ public enum MagicAbility {
}, },
Multikicker("multikicker", 0) { Multikicker("multikicker", 0) {
public void addAbilityImpl(final MagicCardDefinition card, final String arg) { public void addAbilityImpl(final MagicCardDefinition card, final String arg) {
final int idx = arg.indexOf(' '); final MagicManaCost cost = MagicManaCost.create(arg);
final String[] token = {arg.substring(0,idx), arg.substring(idx+1)}; card.add(new MagicMultikickerCost(cost));
final MagicManaCost cost = MagicManaCost.create(token[0]);
final String desc = token[1];
card.add(MagicPlayCardEvent.createKicker(cost, true, desc));
} }
}, },
EntersWithX("enters with x", 0) { EntersWithX("enters with x", 0) {

View File

@ -57,7 +57,6 @@ public class MagicPermanent implements MagicSource,MagicTarget,Comparable<MagicP
private int abilityPlayedThisTurn; private int abilityPlayedThisTurn;
private int damage; private int damage;
private int preventDamage; private int preventDamage;
private int kicker;
private int fixedScore; private int fixedScore;
private int score; private int score;
@ -108,7 +107,6 @@ public class MagicPermanent implements MagicSource,MagicTarget,Comparable<MagicP
chosenTarget = copyMap.copy(sourcePermanent.chosenTarget); chosenTarget = copyMap.copy(sourcePermanent.chosenTarget);
damage=sourcePermanent.damage; damage=sourcePermanent.damage;
preventDamage=sourcePermanent.preventDamage; preventDamage=sourcePermanent.preventDamage;
kicker=sourcePermanent.kicker;
fixedScore=sourcePermanent.fixedScore; fixedScore=sourcePermanent.fixedScore;
score=sourcePermanent.score; score=sourcePermanent.score;
stateId=sourcePermanent.stateId; stateId=sourcePermanent.stateId;
@ -150,7 +148,6 @@ public class MagicPermanent implements MagicSource,MagicTarget,Comparable<MagicP
stateFlags, stateFlags,
damage, damage,
preventDamage, preventDamage,
kicker,
equippedCreature.getStateId(), equippedCreature.getStateId(),
enchantedCreature.getStateId(), enchantedCreature.getStateId(),
blockedCreature.getStateId(), blockedCreature.getStateId(),
@ -488,16 +485,12 @@ public class MagicPermanent implements MagicSource,MagicTarget,Comparable<MagicP
preventDamage=amount; preventDamage=amount;
} }
public void setKicker(final int aKicker) {
kicker = aKicker;
}
public int getKicker() { public int getKicker() {
return kicker; return card.getKicker();
} }
public boolean isKicked() { public boolean isKicked() {
return kicker > 0 || card.isKicked(); return card.isKicked();
} }
public int getLethalDamage(final int toughness) { public int getLethalDamage(final int toughness) {

View File

@ -27,8 +27,6 @@ public class MagicPlayCardFromStackAction extends MagicPutIntoPlayAction {
@Override @Override
protected MagicPermanent createPermanent(final MagicGame game) { protected MagicPermanent createPermanent(final MagicGame game) {
cardOnStack.setMoveLocation(MagicLocationType.Play); cardOnStack.setMoveLocation(MagicLocationType.Play);
final MagicPermanent permanent=game.createPermanent(cardOnStack.getCard(),cardOnStack.getController()); return game.createPermanent(cardOnStack.getCard(),cardOnStack.getController());
permanent.setKicker(kicker);
return permanent;
} }
} }

View File

@ -24,43 +24,33 @@ public class MagicKickerChoice extends MagicChoice {
private final MagicChoice otherChoice; private final MagicChoice otherChoice;
private final MagicManaCost cost; private final MagicManaCost cost;
private final boolean multi;
private final String name; private final String name;
public static MagicKickerChoice Replicate(final MagicChoice otherChoice, final MagicManaCost cost) { public static MagicKickerChoice Replicate(final MagicChoice otherChoice, final MagicManaCost cost) {
return new MagicKickerChoice(otherChoice, cost, true, "replicate"); return new MagicKickerChoice(otherChoice, cost, "replicate");
} }
public static MagicKickerChoice Replicate(final MagicManaCost cost) { public static MagicKickerChoice Replicate(final MagicManaCost cost) {
return new MagicKickerChoice(cost, true, "replicate"); return new MagicKickerChoice(cost, "replicate");
} }
public MagicKickerChoice(final MagicChoice otherChoice, final MagicManaCost cost,final boolean multi,final String name) { public MagicKickerChoice(final MagicChoice otherChoice, final MagicManaCost cost,final String name) {
super("Choose how many times to pay the " + name + " cost."); super("Choose how many times to pay the " + name + " cost.");
this.otherChoice=otherChoice; this.otherChoice=otherChoice;
this.cost=cost; this.cost=cost;
this.multi=multi;
this.name = name; this.name = name;
} }
public MagicKickerChoice(final MagicChoice otherChoice,final MagicManaCost cost,final boolean multi) {
this(otherChoice, cost, multi, "kicker");
}
public MagicKickerChoice(final MagicChoice otherChoice,final MagicManaCost cost) { public MagicKickerChoice(final MagicChoice otherChoice,final MagicManaCost cost) {
this(otherChoice, cost, false, "kicker"); this(otherChoice, cost, "kicker");
} }
public MagicKickerChoice(final MagicManaCost cost,final boolean multi, final String name) { public MagicKickerChoice(final MagicManaCost cost, final String name) {
this(MagicChoice.NONE, cost, multi, name); this(MagicChoice.NONE, cost, name);
}
public MagicKickerChoice(final MagicManaCost cost,final boolean multi) {
this(MagicChoice.NONE, cost, multi, "kicker");
} }
public MagicKickerChoice(final MagicManaCost cost) { public MagicKickerChoice(final MagicManaCost cost) {
this(MagicChoice.NONE, cost, false, "kicker"); this(MagicChoice.NONE, cost, "kicker");
} }
@Override @Override
@ -94,9 +84,6 @@ public class MagicKickerChoice extends MagicChoice {
if (!new MagicPayManaCostResultBuilder(game,player,builderCost).hasResults()) { if (!new MagicPayManaCostResultBuilder(game,player,builderCost).hasResults()) {
return index-1; return index-1;
} }
if (multi==false) {
return 1;
}
} }
} }

View File

@ -27,7 +27,7 @@ public class MagicKickerCost extends MagicAdditionalCost implements MagicEventAc
new MagicPayManaCostChoice(manaCost) new MagicPayManaCostChoice(manaCost)
), ),
this, this,
"PN may$$ pay " + manaCost.getText() + "$." "PN may$ pay " + manaCost.getText() + "$."
); );
} }

View File

@ -0,0 +1,37 @@
package magic.model.event;
import magic.model.MagicManaCost;
import magic.model.MagicSource;
import magic.model.MagicGame;
import magic.model.choice.MagicKickerChoice;
import magic.model.action.MagicSetKickerAction;
public class MagicMultikickerCost extends MagicAdditionalCost implements MagicEventAction {
final MagicManaCost manaCost;
public MagicMultikickerCost(final MagicManaCost aManaCost) {
manaCost = aManaCost;
}
public MagicMultikickerCost(final String cost) {
manaCost = MagicManaCost.create(cost);
}
public MagicEvent getEvent(final MagicSource source) {
return new MagicEvent(
source,
new MagicKickerChoice(manaCost),
this,
"PN may pay " + manaCost.getText() + " any number of times$$."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
event.payManaCost(game,event.getPlayer());
if (event.isKicked()) {
game.doAction(new MagicSetKickerAction(event.getCard(), event.getKickerCount()));
}
}
}

View File

@ -30,24 +30,6 @@ public class MagicPlayCardEvent {
} }
}; };
public static MagicSpellCardEvent createKicker(final MagicManaCost kickerCost, final boolean multi, final String desc) {
return new MagicSpellCardEvent() {
@Override
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent(
cardOnStack,
new MagicKickerChoice(kickerCost,multi),
this,
"$Play SN. If SN was kicked$, " + desc + "."
);
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicPlayCardFromStackAction(event.getCardOnStack(), event.getKickerCount()));
}
};
}
public static MagicSpellCardEvent createX(final String desc) { public static MagicSpellCardEvent createX(final String desc) {
return new MagicSpellCardEvent() { return new MagicSpellCardEvent() {
@Override @Override

View File

@ -22,7 +22,7 @@ public class MagicPlayMulticounterEvent extends MagicSpellCardEvent {
public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) { public MagicEvent getEvent(final MagicCardOnStack cardOnStack,final MagicPayedCost payedCost) {
return new MagicEvent( return new MagicEvent(
cardOnStack, cardOnStack,
new MagicKickerChoice(cost,true), new MagicKickerChoice(cost),
this, this,
"$Play SN. SN enters the battlefield " + "$Play SN. SN enters the battlefield " +
"with a +1/+1 counter on it for each time it was kicked$" "with a +1/+1 counter on it for each time it was kicked$"