mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* SetPowerToughnessSourceEffect - Set the correct sublayer to use (fixes #1354).
This commit is contained in:
parent
af18f95bba
commit
1139495fd7
24 changed files with 238 additions and 121 deletions
|
|
@ -7,6 +7,7 @@ import mage.constants.Zone;
|
|||
* @author Loki
|
||||
*/
|
||||
public class PutIntoGraveFromAnywhereSourceTriggeredAbility extends ZoneChangeTriggeredAbility {
|
||||
|
||||
public PutIntoGraveFromAnywhereSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.GRAVEYARD, effect, "When {this} is put into a graveyard from anywhere, ", optional);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,13 +48,21 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
|
|||
private int toughness;
|
||||
|
||||
public SetPowerToughnessSourceEffect(DynamicValue amount, Duration duration) {
|
||||
super(duration, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
|
||||
this(amount, duration, SubLayer.CharacteristicDefining_7a);
|
||||
}
|
||||
|
||||
public SetPowerToughnessSourceEffect(DynamicValue amount, Duration duration, SubLayer subLayer) {
|
||||
super(duration, Layer.PTChangingEffects_7, subLayer, Outcome.BoostCreature);
|
||||
this.amount = amount;
|
||||
staticText = "{this}'s power and toughness are each equal to the number of " + amount.getMessage();
|
||||
}
|
||||
|
||||
public SetPowerToughnessSourceEffect(int power, int toughness, Duration duration) {
|
||||
super(duration, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
|
||||
this(power, toughness, duration, SubLayer.CharacteristicDefining_7a);
|
||||
}
|
||||
|
||||
public SetPowerToughnessSourceEffect(int power, int toughness, Duration duration, SubLayer subLayer) {
|
||||
super(duration, Layer.PTChangingEffects_7, subLayer, Outcome.BoostCreature);
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
staticText = "{this}'s power and toughness is " + power + "/" + toughness + " " + duration.toString();
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* 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
|
||||
|
|
@ -20,15 +20,15 @@
|
|||
* 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.keyword;
|
||||
|
||||
import mage.constants.Zone;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -39,18 +39,17 @@ import mage.abilities.decorator.ConditionalContinuousEffect;
|
|||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.LevelerCard;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The implementation by BetaSteward was discarded as requires special handling in Mage.Core.
|
||||
* The implementation by BetaSteward was discarded as requires special handling
|
||||
* in Mage.Core.
|
||||
*
|
||||
* Instead it was replaced by conditional continuous effects and builder pattern.
|
||||
* Instead it was replaced by conditional continuous effects and builder
|
||||
* pattern.
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author noxx
|
||||
|
|
@ -82,7 +81,7 @@ public class LevelerCardBuilder {
|
|||
constructed.add(staticAbility);
|
||||
}
|
||||
|
||||
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.WhileOnBattlefield);
|
||||
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.WhileOnBattlefield, SubLayer.SetPT_7b);
|
||||
ConditionalContinuousEffect ptEffect = new ConditionalContinuousEffect(effect, condition, rule);
|
||||
constructed.add(new SimpleStaticAbility(Zone.BATTLEFIELD, ptEffect));
|
||||
|
||||
|
|
@ -212,12 +211,11 @@ public class LevelerCardBuilder {
|
|||
sb.append("<b>Level ").append(level1);
|
||||
if (level2 == -1) {
|
||||
sb.append("+");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sb.append("-").append(level2);
|
||||
}
|
||||
sb.append(":</b> ").append(power).append("/").append(toughness).append(" ");
|
||||
for (String rule: abilities.getRules("{this}")) {
|
||||
for (String rule : abilities.getRules("{this}")) {
|
||||
sb.append(rule).append(" ");
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
|||
|
|
@ -328,8 +328,13 @@ public class Spell extends StackObjImpl implements Card {
|
|||
|
||||
@Override
|
||||
public void counter(UUID sourceId, Game game) {
|
||||
this.counter(sourceId, game, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void counter(UUID sourceId, Game game, boolean moveToGraveyard) {
|
||||
this.countered = true;
|
||||
if (!isCopiedSpell()) {
|
||||
if (!isCopiedSpell() && moveToGraveyard) {
|
||||
Player player = game.getPlayer(getControllerId());
|
||||
if (player != null) {
|
||||
Ability counteringAbility = null;
|
||||
|
|
@ -337,7 +342,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
if (counteringObject instanceof StackObject) {
|
||||
counteringAbility = ((StackObject) counteringObject).getStackAbility();
|
||||
}
|
||||
player.moveCards(card, Zone.STACK, Zone.GRAVEYARD, counteringAbility, game);
|
||||
player.moveCards(card, Zone.GRAVEYARD, counteringAbility, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -662,11 +667,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
if (this.isCopiedSpell() && !zone.equals(Zone.STACK)) {
|
||||
return true;
|
||||
}
|
||||
Card card = game.getCard(getSourceId());
|
||||
if (card != null) {
|
||||
return card.moveToZone(zone, sourceId, game, flag, appliedEffects);
|
||||
}
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
return card.moveToZone(zone, sourceId, game, flag, appliedEffects);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -122,6 +122,11 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
|
||||
@Override
|
||||
public void counter(UUID sourceId, Game game) {
|
||||
this.counter(sourceId, game, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void counter(UUID sourceId, Game game, boolean moveToGraveyard) {
|
||||
//20100716 - 603.8
|
||||
if (ability instanceof StateTriggeredAbility) {
|
||||
((StateTriggeredAbility) ability).counter(game);
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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.game.stack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -38,11 +37,19 @@ import mage.game.Game;
|
|||
public interface StackObject extends MageObject, Controllable {
|
||||
|
||||
boolean resolve(Game game);
|
||||
|
||||
UUID getSourceId();
|
||||
|
||||
void counter(UUID sourceId, Game game);
|
||||
|
||||
void counter(UUID sourceId, Game game, boolean moveToGraveyard);
|
||||
|
||||
Ability getStackAbility();
|
||||
|
||||
int getConvertedManaCost();
|
||||
|
||||
boolean chooseNewTargets(Game game, UUID playerId, boolean forceChange, boolean onlyOneTarget, FilterPermanent filterNewTarget);
|
||||
|
||||
@Override
|
||||
StackObject copy();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue