forked from External/mage
Changes to kicker and multikicker, showing in log if spell was cast with kicker. Changed some effects and abilities to implement some cards.
This commit is contained in:
parent
c18345ef85
commit
c8d9006740
12 changed files with 272 additions and 29 deletions
|
|
@ -41,6 +41,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.mana.KickerManaCost;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -76,6 +77,10 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
rules.add(ability.getRule());
|
||||
}
|
||||
if (ability instanceof SpellAbility) {
|
||||
String kickerRule = getKickerRule(ability);
|
||||
if (!kickerRule.isEmpty()) {
|
||||
rules.add(kickerRule);
|
||||
}
|
||||
if (ability.getAlternativeCosts().size() > 0) {
|
||||
StringBuilder sbRule = new StringBuilder();
|
||||
for (AlternativeCost cost: ability.getAlternativeCosts()) {
|
||||
|
|
@ -113,6 +118,25 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
return rules;
|
||||
}
|
||||
|
||||
private String getKickerRule(Ability ability) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int numberKicker = 0;
|
||||
for (Object cost : ability.getOptionalCosts()) {
|
||||
if (cost instanceof KickerManaCost) {
|
||||
if (numberKicker == 0) {
|
||||
sb.append(((KickerManaCost)cost).getText(true));
|
||||
} else {
|
||||
sb.append(" and/or ").append(((KickerManaCost)cost).getText(true));
|
||||
}
|
||||
++numberKicker;
|
||||
}
|
||||
}
|
||||
if (numberKicker > 0) {
|
||||
return "Kicker " + sb.toString() + " <i>(You may pay an additional " + sb.toString() + " as you cast this spell.)</i>";
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Abilities<ActivatedAbility> getActivatedAbilities(Zone zone) {
|
||||
Abilities<ActivatedAbility> zonedAbilities = new AbilitiesImpl<ActivatedAbility>();
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ import mage.game.stack.StackAbility;
|
|||
import mage.target.Target;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.mana.KickerManaCost;
|
||||
import mage.abilities.keyword.MultikickerAbility;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
/**
|
||||
|
|
@ -172,8 +175,9 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
|
||||
@Override
|
||||
public String getActivatedMessage(Game game) {
|
||||
if (game.isSimulation())
|
||||
if (game.isSimulation()) {
|
||||
return "";
|
||||
}
|
||||
return " activates ability from " + getMessageText(game);
|
||||
}
|
||||
|
||||
|
|
@ -196,6 +200,7 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
if (spell.getFromZone() == Zone.GRAVEYARD) {
|
||||
sb.append(" from graveyard");
|
||||
}
|
||||
sb.append(getKickerText(game, spell));
|
||||
} else {
|
||||
sb.append(object.getName());
|
||||
}
|
||||
|
|
@ -212,4 +217,37 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
String getKickerText(Game game, Spell spell) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int numberPaid = 0;
|
||||
for (Object cost : spell.getSpellAbility().getOptionalCosts()) {
|
||||
if (cost instanceof KickerManaCost) {
|
||||
if (((KickerManaCost) cost).isPaid()) {
|
||||
if (numberPaid == 0) {
|
||||
sb.append(" with ").append(((KickerManaCost)cost).getText(true));
|
||||
} else {
|
||||
sb.append(" and ").append(((KickerManaCost)cost).getText(true));
|
||||
}
|
||||
++numberPaid;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (numberPaid > 0) {
|
||||
sb.append(" kicker");
|
||||
}
|
||||
// Multikicker
|
||||
int multikickerCount = 0;
|
||||
Card card = game.getCard(this.getSourceId());
|
||||
if (card != null) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof MultikickerAbility) {
|
||||
multikickerCount = ((MultikickerAbility)ability).getActivateCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (multikickerCount > 0) {
|
||||
sb.append(" with ").append(multikickerCount).append(multikickerCount > 1? " times":" time").append(" multikicker");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.abilities.common;
|
|||
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.EntersBattlefieldEffect;
|
||||
|
||||
|
|
@ -38,27 +39,43 @@ import mage.abilities.effects.EntersBattlefieldEffect;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class EntersBattlefieldAbility extends StaticAbility<EntersBattlefieldAbility> {
|
||||
|
||||
protected Boolean generateRule;
|
||||
|
||||
protected String abilityRule;
|
||||
protected Boolean showRule;
|
||||
|
||||
public EntersBattlefieldAbility(Effect effect) {
|
||||
this(new EntersBattlefieldEffect(effect), true);
|
||||
}
|
||||
|
||||
public EntersBattlefieldAbility(Effect effect, Boolean generateRule) {
|
||||
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect));
|
||||
this.generateRule = generateRule;
|
||||
/**
|
||||
*
|
||||
* @param effect effect that happens when the permanent enters the battlefield
|
||||
* @param showRule show a rule for this ability
|
||||
*/
|
||||
public EntersBattlefieldAbility(Effect effect, Boolean showRule) {
|
||||
this(effect, null, showRule, null, null);
|
||||
}
|
||||
|
||||
public EntersBattlefieldAbility(Effect effect, String rule) {
|
||||
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect, rule));
|
||||
this.generateRule = true;
|
||||
public EntersBattlefieldAbility(Effect effect, String effectText) {
|
||||
this(effect, null, true, null, effectText);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param effect effect that happens when the permanent enters the battlefield
|
||||
* @param condition only if this condition is true, the effect will happen
|
||||
* @param showRule show a rule for this ability
|
||||
* @param abilityRule rule for this ability (no text from effects will be added)
|
||||
* @param effectText this text will be used for the EnterBattlefieldEffect
|
||||
*/
|
||||
public EntersBattlefieldAbility(Effect effect, Condition condition, Boolean showRule, String abilityRule, String effectText) {
|
||||
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect, condition, effectText));
|
||||
this.showRule = true;
|
||||
this.abilityRule = abilityRule;
|
||||
}
|
||||
|
||||
|
||||
public EntersBattlefieldAbility(EntersBattlefieldAbility ability) {
|
||||
super(ability);
|
||||
this.generateRule = ability.generateRule;
|
||||
this.showRule = ability.showRule;
|
||||
this.abilityRule = ability.abilityRule;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -68,10 +85,11 @@ public class EntersBattlefieldAbility extends StaticAbility<EntersBattlefieldAbi
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
if (generateRule != null) {
|
||||
if (!generateRule) {
|
||||
if (showRule != null && !showRule) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
if (abilityRule != null && !abilityRule.isEmpty()) {
|
||||
return abilityRule;
|
||||
}
|
||||
return "{this} enters the battlefield " + super.getRule();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.mana.KickerManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* Describes condition when specific KickerCosts were paid.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class KickedCostCondition implements Condition {
|
||||
|
||||
protected KickerManaCost kickerManaCost;
|
||||
|
||||
public KickedCostCondition(KickerManaCost kickerManaCost) {
|
||||
this.kickerManaCost = kickerManaCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card p = game.getCard(source.getSourceId());
|
||||
|
||||
boolean kicked = false;
|
||||
if (p != null) {
|
||||
for (Object cost : p.getSpellAbility().getOptionalCosts()) {
|
||||
if (cost.equals(kickerManaCost)) {
|
||||
if (((KickerManaCost) cost).isPaid()) {
|
||||
kicked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return kicked;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,15 @@ public class KickerManaCost extends ManaCostsImpl {
|
|||
return new KickerManaCost(this);
|
||||
}
|
||||
|
||||
|
||||
public String getText(boolean onlyMana) {
|
||||
if (onlyMana) {
|
||||
return super.getText();
|
||||
} else {
|
||||
return this.getText();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Kicker - " + super.getText();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.keyword.MultikickerAbility;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class MultikickerCount implements DynamicValue {
|
||||
|
||||
public MultikickerCount() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
for (Ability ability : permanent.getAbilities()) {
|
||||
if (ability instanceof MultikickerAbility) {
|
||||
return ((MultikickerAbility)ability).getActivateCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue clone() {
|
||||
return new MultikickerCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "a";
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "time it was kicked";
|
||||
};
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ public class SacrificeCostCreaturesToughness implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
return "X";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ package mage.abilities.effects;
|
|||
import mage.Constants.Duration;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
|
@ -44,6 +45,7 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlef
|
|||
|
||||
protected Effects baseEffects = new Effects();
|
||||
protected String text;
|
||||
protected Condition condition;
|
||||
|
||||
public static final String SOURCE_CAST_SPELL_ABILITY = "sourceCastSpellAbility";
|
||||
|
||||
|
|
@ -57,10 +59,18 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlef
|
|||
this.text = text;
|
||||
}
|
||||
|
||||
public EntersBattlefieldEffect(Effect baseEffect, Condition condition, String text) {
|
||||
super(Duration.OneUse, baseEffect.getOutcome());
|
||||
this.baseEffects.add(baseEffect);
|
||||
this.text = text;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public EntersBattlefieldEffect(EntersBattlefieldEffect effect) {
|
||||
super(effect);
|
||||
this.baseEffects = effect.baseEffects.copy();
|
||||
this.text = effect.text;
|
||||
this.condition = effect.condition;
|
||||
}
|
||||
|
||||
public void addEffect(Effect effect) {
|
||||
|
|
@ -71,7 +81,9 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlef
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
return true;
|
||||
if (condition == null || condition.apply(game, source)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -37,7 +38,6 @@ import mage.cards.Card;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -87,6 +87,9 @@ public class ReturnToHandTargetEffect extends OneShotEffect<ReturnToHandTargetEf
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (mode.getTargets().size() < 1) {
|
||||
return "";
|
||||
}
|
||||
if (mode.getTargets().get(0).getNumberOfTargets() == 0 && mode.getTargets().get(0).getMaxNumberOfTargets() > 0) {
|
||||
return "Return up to " + mode.getTargets().get(0).getMaxNumberOfTargets() +" target " + mode.getTargets().get(0).getTargetName() + " to their owners' hand";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ package mage.abilities.effects.common.counter;
|
|||
|
||||
import mage.Constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.Counter;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -44,15 +45,27 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
|
|||
|
||||
private Counter counter;
|
||||
protected boolean informPlayers;
|
||||
protected DynamicValue amount;
|
||||
|
||||
public AddCountersSourceEffect(Counter counter) {
|
||||
this(counter, false);
|
||||
}
|
||||
|
||||
public AddCountersSourceEffect(Counter counter, boolean informPlayers) {
|
||||
this(counter, new StaticValue(0), informPlayers);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param counter
|
||||
* @param amount this amount will be added to the counter instances
|
||||
* @param informPlayers
|
||||
*/
|
||||
public AddCountersSourceEffect(Counter counter, DynamicValue amount, boolean informPlayers) {
|
||||
super(Outcome.Benefit);
|
||||
this.counter = counter.copy();
|
||||
this.informPlayers = informPlayers;
|
||||
this.amount = amount;
|
||||
setText();
|
||||
}
|
||||
|
||||
|
|
@ -62,6 +75,7 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
|
|||
this.counter = effect.counter.copy();
|
||||
}
|
||||
this.informPlayers = effect.informPlayers;
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -69,11 +83,13 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
|
|||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (counter != null) {
|
||||
Counter newCounter = counter.copy();
|
||||
newCounter.add(amount.calculate(game, source));
|
||||
permanent.addCounters(counter.copy(), game);
|
||||
if (informPlayers) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
game.informPlayers(player.getName()+ " puts " + counter.getCount() + " " + counter.getName() + " counter on " + permanent.getName());
|
||||
game.informPlayers(player.getName()+ " puts " + newCounter.getCount() + " " + newCounter.getName() + " counter on " + permanent.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class KickerAbility extends StaticAbility<KickerAbility> {
|
|||
public boolean activate(Game game, boolean noMana) {
|
||||
Player player = game.getPlayer(this.getControllerId());
|
||||
|
||||
String message = "Use kicker - " + getRule() + "?";
|
||||
String message = getKickerText(false) + "?";
|
||||
Card card = game.getCard(sourceId);
|
||||
// replace by card name or just plain "this"
|
||||
String text = card == null ? "this" : card.getName();
|
||||
|
|
@ -94,8 +94,12 @@ public class KickerAbility extends StaticAbility<KickerAbility> {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return getKickerText(true);
|
||||
}
|
||||
|
||||
public String getKickerText(boolean withRemainder) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Kicker");
|
||||
sb.append("Kicker - ");
|
||||
if (manaCosts.size() > 0) {
|
||||
sb.append(manaCosts.getText());
|
||||
if (costs.size() > 0)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.common.EmptyEffect;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
|
||||
|
|
@ -43,6 +45,11 @@ public class MultikickerAbility extends KickerAbility {
|
|||
super(effect, replaces);
|
||||
}
|
||||
|
||||
public MultikickerAbility(ManaCosts manaCosts) {
|
||||
super(new EmptyEffect(""), false);
|
||||
this.addManaCost(manaCosts);
|
||||
}
|
||||
|
||||
public MultikickerAbility(final MultikickerAbility ability) {
|
||||
super(ability);
|
||||
this.activateCount = ability.activateCount;
|
||||
|
|
@ -77,19 +84,21 @@ public class MultikickerAbility extends KickerAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
public String getKickerText(boolean withRemainder) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Multikicker");
|
||||
sb.append("Multikicker ");
|
||||
if (manaCosts.size() > 0) {
|
||||
sb.append(manaCosts.getText());
|
||||
if (costs.size() > 0)
|
||||
if (costs.size() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
if (costs.size() > 0)
|
||||
if (costs.size() > 0) {
|
||||
sb.append(costs.getText());
|
||||
sb.append(":").append(modes.getText());
|
||||
if (replaces)
|
||||
sb.append(" instead");
|
||||
}
|
||||
if (withRemainder) {
|
||||
sb.append(" (You may pay an additional ").append(manaCosts.getText()).append(" any number of times as you cast this spell.)");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue