mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Fixed some problems with abilities that let permanents become artifact creatures but only added creature card type instead of artifact and creature card type (fixes #4290).
This commit is contained in:
parent
6a23a0f707
commit
519eae42fc
24 changed files with 225 additions and 177 deletions
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -38,8 +37,9 @@ import mage.game.permanent.Permanent;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class AddCardTypeAttachedEffect extends ContinuousEffectImpl {
|
||||
private CardType addedCardType;
|
||||
private AttachmentType attachmentType;
|
||||
|
||||
private final CardType addedCardType;
|
||||
private final AttachmentType attachmentType;
|
||||
|
||||
public AddCardTypeAttachedEffect(CardType addedCardType, Duration duration, AttachmentType attachmentType) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
|
||||
|
|
@ -59,8 +59,9 @@ public class AddCardTypeAttachedEffect extends ContinuousEffectImpl {
|
|||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
Permanent target = game.getPermanent(equipment.getAttachedTo());
|
||||
if (target != null && !target.getCardType().contains(addedCardType))
|
||||
if (target != null && !target.getCardType().contains(addedCardType)) {
|
||||
target.addCardType(addedCardType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,90 +1,112 @@
|
|||
/*
|
||||
* 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.effects.common.continuous;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author emerald000
|
||||
*/
|
||||
public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final CardType addedCardType;
|
||||
|
||||
public AddCardTypeSourceEffect(CardType addedCardType, Duration duration) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
|
||||
this.addedCardType = addedCardType;
|
||||
if (addedCardType == CardType.ENCHANTMENT) {
|
||||
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
|
||||
}
|
||||
}
|
||||
|
||||
public AddCardTypeSourceEffect(final AddCardTypeSourceEffect effect) {
|
||||
super(effect);
|
||||
this.addedCardType = effect.addedCardType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && affectedObjectList.contains(new MageObjectReference(permanent, game))) {
|
||||
permanent.addCardType(addedCardType);
|
||||
return true;
|
||||
} else if (this.getDuration() == Duration.Custom) {
|
||||
this.discard();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddCardTypeSourceEffect copy() {
|
||||
return new AddCardTypeSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{this} becomes ").append(addedCardType.toString()).append(" in addition to its other types " + this.getDuration().toString());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.effects.common.continuous;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author emerald000
|
||||
*/
|
||||
public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final ArrayList<CardType> addedCardTypes = new ArrayList<>();
|
||||
|
||||
public AddCardTypeSourceEffect(Duration duration, CardType... addedCardType) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
|
||||
for (CardType cardType : addedCardType) {
|
||||
this.addedCardTypes.add(cardType);
|
||||
if (cardType == CardType.ENCHANTMENT) {
|
||||
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
|
||||
} else if (cardType == CardType.ARTIFACT) {
|
||||
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AddCardTypeSourceEffect(final AddCardTypeSourceEffect effect) {
|
||||
super(effect);
|
||||
this.addedCardTypes.addAll(effect.addedCardTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && affectedObjectList.contains(new MageObjectReference(permanent, game))) {
|
||||
for (CardType cardType : addedCardTypes) {
|
||||
if (!permanent.getCardType().contains(cardType)) {
|
||||
permanent.addCardType(cardType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (this.getDuration() == Duration.Custom) {
|
||||
this.discard();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddCardTypeSourceEffect copy() {
|
||||
return new AddCardTypeSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{this} becomes ");
|
||||
boolean article = false;
|
||||
for (CardType cardType : addedCardTypes) {
|
||||
if (!article) {
|
||||
if (cardType.toString().startsWith("A") || cardType.toString().startsWith("E")) {
|
||||
sb.append("an ");
|
||||
} else {
|
||||
sb.append("a ");
|
||||
}
|
||||
article = true;
|
||||
}
|
||||
sb.append(cardType.toString().toLowerCase()).append(" ");
|
||||
}
|
||||
sb.append(" in addition to its other types ").append(this.getDuration().toString());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
|
|
@ -45,21 +46,24 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final CardType addedCardType;
|
||||
private final ArrayList<CardType> addedCardTypes = new ArrayList<>();
|
||||
|
||||
public AddCardTypeTargetEffect(CardType addedCardType, Duration duration) {
|
||||
public AddCardTypeTargetEffect(Duration duration, CardType... addedCardType) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
|
||||
this.addedCardType = addedCardType;
|
||||
if (addedCardType == CardType.ENCHANTMENT) {
|
||||
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
|
||||
} else if (addedCardType == CardType.ARTIFACT) {
|
||||
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
|
||||
for (CardType cardType : addedCardType) {
|
||||
this.addedCardTypes.add(cardType);
|
||||
if (cardType == CardType.ENCHANTMENT) {
|
||||
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
|
||||
} else if (cardType == CardType.ARTIFACT) {
|
||||
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AddCardTypeTargetEffect(final AddCardTypeTargetEffect effect) {
|
||||
super(effect);
|
||||
this.addedCardType = effect.addedCardType;
|
||||
this.addedCardTypes.addAll(effect.addedCardTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -68,8 +72,10 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
|
|||
for (UUID targetId : targetPointer.getTargets(game, source)) {
|
||||
Permanent target = game.getPermanent(targetId);
|
||||
if (target != null) {
|
||||
if (!target.getCardType().contains(addedCardType)) {
|
||||
target.addCardType(addedCardType);
|
||||
for (CardType cardType : addedCardTypes) {
|
||||
if (!target.getCardType().contains(cardType)) {
|
||||
target.addCardType(cardType);
|
||||
}
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
|
|
@ -93,7 +99,23 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
|
|||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Target ").append(mode.getTargets().get(0).getTargetName()).append(" becomes ").append(addedCardType.toString()).append(" in addition to its other types until end of turn");
|
||||
sb.append("Target ").append(mode.getTargets().get(0).getTargetName()).append(" becomes ");
|
||||
boolean article = false;
|
||||
for (CardType cardType : addedCardTypes) {
|
||||
if (!article) {
|
||||
if (cardType.toString().startsWith("A") || cardType.toString().startsWith("E")) {
|
||||
sb.append("an ");
|
||||
} else {
|
||||
sb.append("a ");
|
||||
}
|
||||
article = true;
|
||||
}
|
||||
sb.append(cardType.toString().toLowerCase()).append(" ");
|
||||
}
|
||||
sb.append("in addition to its other types");
|
||||
if (getDuration().equals(Duration.EndOfTurn)) {
|
||||
sb.append(" until end of turn");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ public class CrewAbility extends SimpleActivatedAbility {
|
|||
private final int value;
|
||||
|
||||
public CrewAbility(int value) {
|
||||
super(Zone.BATTLEFIELD, new AddCardTypeSourceEffect(CardType.ARTIFACT, Duration.EndOfTurn), new CrewCost(value));
|
||||
this.addEffect(new AddCardTypeSourceEffect(CardType.CREATURE, Duration.EndOfTurn));
|
||||
super(Zone.BATTLEFIELD, new AddCardTypeSourceEffect(Duration.EndOfTurn, CardType.ARTIFACT), new CrewCost(value));
|
||||
this.addEffect(new AddCardTypeSourceEffect(Duration.EndOfTurn, CardType.ARTIFACT, CardType.CREATURE));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledArtifactPermanent;
|
||||
import static mage.filter.StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
|
|
@ -49,13 +49,13 @@ public class TezzeretTheSchemerEmblem extends Emblem {
|
|||
public TezzeretTheSchemerEmblem() {
|
||||
this.setName("Emblem Tezzeret");
|
||||
|
||||
Effect effect = new AddCardTypeTargetEffect(CardType.CREATURE, Duration.EndOfGame);
|
||||
Effect effect = new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.ARTIFACT, CardType.CREATURE);
|
||||
effect.setText("target artifact you control becomes an artifact creature");
|
||||
Ability ability = new BeginningOfCombatTriggeredAbility(Zone.COMMAND, effect, TargetController.YOU, false, true);
|
||||
effect = new SetPowerToughnessTargetEffect(5, 5, Duration.EndOfGame);
|
||||
effect.setText("with base power and toughness 5/5");
|
||||
ability.addEffect(effect);
|
||||
ability.addTarget(new TargetPermanent(new FilterControlledArtifactPermanent()));
|
||||
ability.addTarget(new TargetPermanent(FILTER_CONTROLLED_PERMANENT_ARTIFACT));
|
||||
this.getAbilities().add(ability);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue