Update *.sh and *.java files to use Unix line endings

This commit is contained in:
arcox 2020-07-09 13:07:26 -04:00
parent a6d03c925f
commit 9c7982e8f6
273 changed files with 26704 additions and 26704 deletions

View file

@ -1,165 +1,165 @@
package mage.abilities.effects.common.continuous;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
/**
* @author jeffwadsworth
*/
public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends ContinuousEffectImpl {
public enum LoseType {
NONE, ALL, ALL_BUT_COLOR, ABILITIES, ABILITIES_SUBTYPE_AND_PT
}
protected Token token;
protected String type;
protected LoseType loseType; // what attributes are lost
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration) {
this(token, text, duration, LoseType.NONE);
}
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration, LoseType loseType) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.BecomeCreature);
this.token = token;
this.loseType = loseType;
staticText = text;
}
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(final BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect effect) {
super(effect);
this.token = effect.token.copy();
this.type = effect.type;
this.loseType = effect.loseType;
}
@Override
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect copy() {
return new BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Permanent attachedPermanent = game.getPermanent(source.getSourceId());
if (attachedPermanent != null) {
Permanent permanentAttachedTo = game.getPermanent(attachedPermanent.getAttachedTo());
if (permanentAttachedTo != null) {
affectedObjectList.add(new MageObjectReference(permanentAttachedTo, game));
}
}
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
boolean attachedExists = false;
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
for (MageObjectReference mageObjectReference : affectedObjectList) {
Permanent permanentAttachedTo = mageObjectReference.getPermanent(game);
if (permanentAttachedTo != null) {
attachedExists = true;
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
for (SuperType superType : token.getSuperType()) {
permanentAttachedTo.addSuperType(superType);
}
// card type
switch (loseType) {
case ALL:
case ALL_BUT_COLOR:
permanentAttachedTo.getCardType().clear();
break;
}
for (CardType cardType : token.getCardType()) {
permanentAttachedTo.addCardType(cardType);
}
// sub type
switch (loseType) {
case ALL:
case ALL_BUT_COLOR:
case ABILITIES_SUBTYPE_AND_PT:
permanentAttachedTo.getSubtype(game).retainAll(SubType.getLandTypes());
break;
}
for (SubType subType : token.getSubtype(game)) {
if (!permanentAttachedTo.hasSubtype(subType, game)) {
permanentAttachedTo.getSubtype(game).add(subType);
}
}
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
if (loseType == LoseType.ALL) {
permanentAttachedTo.getColor(game).setBlack(false);
permanentAttachedTo.getColor(game).setGreen(false);
permanentAttachedTo.getColor(game).setBlue(false);
permanentAttachedTo.getColor(game).setWhite(false);
permanentAttachedTo.getColor(game).setRed(false);
}
if (token.getColor(game).hasColor()) {
permanentAttachedTo.getColor(game).setColor(token.getColor(game));
}
}
break;
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
switch (loseType) {
case ALL:
case ALL_BUT_COLOR:
case ABILITIES:
case ABILITIES_SUBTYPE_AND_PT:
permanentAttachedTo.removeAllAbilities(source.getSourceId(), game);
break;
}
for (Ability ability : token.getAbilities()) {
permanentAttachedTo.addAbility(ability, source.getSourceId(), game);
}
}
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
permanentAttachedTo.getPower().setValue(token.getPower().getValue());
permanentAttachedTo.getToughness().setValue(token.getToughness().getValue());
}
break;
}
}
if (!attachedExists) {
discard();
}
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.PTChangingEffects_7
|| layer == Layer.AbilityAddingRemovingEffects_6
|| layer == Layer.ColorChangingEffects_5
|| layer == Layer.TypeChangingEffects_4;
}
}
package mage.abilities.effects.common.continuous;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
/**
* @author jeffwadsworth
*/
public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends ContinuousEffectImpl {
public enum LoseType {
NONE, ALL, ALL_BUT_COLOR, ABILITIES, ABILITIES_SUBTYPE_AND_PT
}
protected Token token;
protected String type;
protected LoseType loseType; // what attributes are lost
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration) {
this(token, text, duration, LoseType.NONE);
}
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration, LoseType loseType) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.BecomeCreature);
this.token = token;
this.loseType = loseType;
staticText = text;
}
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(final BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect effect) {
super(effect);
this.token = effect.token.copy();
this.type = effect.type;
this.loseType = effect.loseType;
}
@Override
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect copy() {
return new BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Permanent attachedPermanent = game.getPermanent(source.getSourceId());
if (attachedPermanent != null) {
Permanent permanentAttachedTo = game.getPermanent(attachedPermanent.getAttachedTo());
if (permanentAttachedTo != null) {
affectedObjectList.add(new MageObjectReference(permanentAttachedTo, game));
}
}
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
boolean attachedExists = false;
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
for (MageObjectReference mageObjectReference : affectedObjectList) {
Permanent permanentAttachedTo = mageObjectReference.getPermanent(game);
if (permanentAttachedTo != null) {
attachedExists = true;
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
for (SuperType superType : token.getSuperType()) {
permanentAttachedTo.addSuperType(superType);
}
// card type
switch (loseType) {
case ALL:
case ALL_BUT_COLOR:
permanentAttachedTo.getCardType().clear();
break;
}
for (CardType cardType : token.getCardType()) {
permanentAttachedTo.addCardType(cardType);
}
// sub type
switch (loseType) {
case ALL:
case ALL_BUT_COLOR:
case ABILITIES_SUBTYPE_AND_PT:
permanentAttachedTo.getSubtype(game).retainAll(SubType.getLandTypes());
break;
}
for (SubType subType : token.getSubtype(game)) {
if (!permanentAttachedTo.hasSubtype(subType, game)) {
permanentAttachedTo.getSubtype(game).add(subType);
}
}
}
break;
case ColorChangingEffects_5:
if (sublayer == SubLayer.NA) {
if (loseType == LoseType.ALL) {
permanentAttachedTo.getColor(game).setBlack(false);
permanentAttachedTo.getColor(game).setGreen(false);
permanentAttachedTo.getColor(game).setBlue(false);
permanentAttachedTo.getColor(game).setWhite(false);
permanentAttachedTo.getColor(game).setRed(false);
}
if (token.getColor(game).hasColor()) {
permanentAttachedTo.getColor(game).setColor(token.getColor(game));
}
}
break;
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
switch (loseType) {
case ALL:
case ALL_BUT_COLOR:
case ABILITIES:
case ABILITIES_SUBTYPE_AND_PT:
permanentAttachedTo.removeAllAbilities(source.getSourceId(), game);
break;
}
for (Ability ability : token.getAbilities()) {
permanentAttachedTo.addAbility(ability, source.getSourceId(), game);
}
}
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
permanentAttachedTo.getPower().setValue(token.getPower().getValue());
permanentAttachedTo.getToughness().setValue(token.getToughness().getValue());
}
break;
}
}
if (!attachedExists) {
discard();
}
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.PTChangingEffects_7
|| layer == Layer.AbilityAddingRemovingEffects_6
|| layer == Layer.ColorChangingEffects_5
|| layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -1,79 +1,79 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continuous;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author jeffwadsworth
*/
public class BecomesEnchantmentSourceEffect extends ContinuousEffectImpl implements SourceEffect {
public BecomesEnchantmentSourceEffect() {
super(Duration.Custom, Outcome.AddAbility);
staticText = "{this} becomes an Enchantment";
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
}
public BecomesEnchantmentSourceEffect(final BecomesEnchantmentSourceEffect effect) {
super(effect);
}
@Override
public BecomesEnchantmentSourceEffect copy() {
return new BecomesEnchantmentSourceEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
if (permanent != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
permanent.getCardType().clear();
permanent.getSubtype(game).clear();
if (!permanent.getCardType().contains(CardType.ENCHANTMENT)) {
permanent.getCardType().add(CardType.ENCHANTMENT);
}
}
break;
}
return true;
}
this.discard();
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return Layer.TypeChangingEffects_4 == layer;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continuous;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author jeffwadsworth
*/
public class BecomesEnchantmentSourceEffect extends ContinuousEffectImpl implements SourceEffect {
public BecomesEnchantmentSourceEffect() {
super(Duration.Custom, Outcome.AddAbility);
staticText = "{this} becomes an Enchantment";
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
}
public BecomesEnchantmentSourceEffect(final BecomesEnchantmentSourceEffect effect) {
super(effect);
}
@Override
public BecomesEnchantmentSourceEffect copy() {
return new BecomesEnchantmentSourceEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
if (permanent != null) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
permanent.getCardType().clear();
permanent.getSubtype(game).clear();
if (!permanent.getCardType().contains(CardType.ENCHANTMENT)) {
permanent.getCardType().add(CardType.ENCHANTMENT);
}
}
break;
}
return true;
}
this.discard();
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return Layer.TypeChangingEffects_4 == layer;
}
}

View file

@ -1,51 +1,51 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class GainAbilityAllOfChosenSubtypeEffect extends GainAbilityAllEffect {
SubType subtype = null;
public GainAbilityAllOfChosenSubtypeEffect(Ability ability, Duration duration, FilterPermanent filter) {
super(ability, duration, filter);
}
public GainAbilityAllOfChosenSubtypeEffect(final GainAbilityAllOfChosenSubtypeEffect effect) {
super(effect);
this.subtype = effect.subtype;
}
@Override
public GainAbilityAllOfChosenSubtypeEffect copy() {
return new GainAbilityAllOfChosenSubtypeEffect(this);
}
@Override
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
if (subtype != null) {
return permanent.hasSubtype(subtype, game);
}
return false;
}
@Override
protected void setRuntimeData(Ability source, Game game) {
subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class GainAbilityAllOfChosenSubtypeEffect extends GainAbilityAllEffect {
SubType subtype = null;
public GainAbilityAllOfChosenSubtypeEffect(Ability ability, Duration duration, FilterPermanent filter) {
super(ability, duration, filter);
}
public GainAbilityAllOfChosenSubtypeEffect(final GainAbilityAllOfChosenSubtypeEffect effect) {
super(effect);
this.subtype = effect.subtype;
}
@Override
public GainAbilityAllOfChosenSubtypeEffect copy() {
return new GainAbilityAllOfChosenSubtypeEffect(this);
}
@Override
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
if (subtype != null) {
return permanent.hasSubtype(subtype, game);
}
return false;
}
@Override
protected void setRuntimeData(Ability source, Game game) {
subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
}
}

View file

@ -1,83 +1,83 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
/**
* @author Styxo
*/
public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
private final Ability ability;
private final FilterCard filter;
public GainAbilityControlledSpellsEffect(Ability ability, FilterCard filter) {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.ability = ability;
this.filter = filter;
staticText = filter.getMessage() + " you cast have " + ability.getRule() + '.';
}
public GainAbilityControlledSpellsEffect(final GainAbilityControlledSpellsEffect effect) {
super(effect);
this.ability = effect.ability;
this.filter = effect.filter;
}
@Override
public GainAbilityControlledSpellsEffect copy() {
return new GainAbilityControlledSpellsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
for (Card card : game.getExile().getAllCards(game)) {
if (card.isOwnedBy(source.getControllerId()) && filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getLibrary().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getHand().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getGraveyard().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (StackObject stackObject : game.getStack()) {
// only spells cast, so no copies of spells
if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) {
Card card = game.getCard(stackObject.getSourceId());
if (card != null && filter.match(card, game)) {
if (!card.hasAbility(ability, game)) {
game.getState().addOtherAbility(card, ability);
}
}
}
}
return true;
}
return false;
}
}
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
/**
* @author Styxo
*/
public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
private final Ability ability;
private final FilterCard filter;
public GainAbilityControlledSpellsEffect(Ability ability, FilterCard filter) {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.ability = ability;
this.filter = filter;
staticText = filter.getMessage() + " you cast have " + ability.getRule() + '.';
}
public GainAbilityControlledSpellsEffect(final GainAbilityControlledSpellsEffect effect) {
super(effect);
this.ability = effect.ability;
this.filter = effect.filter;
}
@Override
public GainAbilityControlledSpellsEffect copy() {
return new GainAbilityControlledSpellsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
for (Card card : game.getExile().getAllCards(game)) {
if (card.isOwnedBy(source.getControllerId()) && filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getLibrary().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getHand().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (Card card : player.getGraveyard().getCards(game)) {
if (filter.match(card, game)) {
game.getState().addOtherAbility(card, ability);
}
}
for (StackObject stackObject : game.getStack()) {
// only spells cast, so no copies of spells
if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) {
Card card = game.getCard(stackObject.getSourceId());
if (card != null && filter.match(card, game)) {
if (!card.hasAbility(ability, game)) {
game.getState().addOtherAbility(card, ability);
}
}
}
}
return true;
}
return false;
}
}

View file

@ -1,57 +1,57 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class SetPowerToughnessEnchantedEffect extends ContinuousEffectImpl {
private final int power;
private final int toughness;
public SetPowerToughnessEnchantedEffect() {
this(0, 2);
}
public SetPowerToughnessEnchantedEffect(int power, int toughness) {
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
staticText = "Enchanted creature has base power and toughness " + power + "/" + toughness;
this.power = power;
this.toughness = toughness;
}
public SetPowerToughnessEnchantedEffect(final SetPowerToughnessEnchantedEffect effect) {
super(effect);
this.power = effect.power;
this.toughness = effect.toughness;
}
@Override
public SetPowerToughnessEnchantedEffect copy() {
return new SetPowerToughnessEnchantedEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if (enchanted != null) {
enchanted.getPower().setValue(power);
enchanted.getToughness().setValue(toughness);
}
return true;
}
return false;
}
}
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class SetPowerToughnessEnchantedEffect extends ContinuousEffectImpl {
private final int power;
private final int toughness;
public SetPowerToughnessEnchantedEffect() {
this(0, 2);
}
public SetPowerToughnessEnchantedEffect(int power, int toughness) {
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
staticText = "Enchanted creature has base power and toughness " + power + "/" + toughness;
this.power = power;
this.toughness = toughness;
}
public SetPowerToughnessEnchantedEffect(final SetPowerToughnessEnchantedEffect effect) {
super(effect);
this.power = effect.power;
this.toughness = effect.toughness;
}
@Override
public SetPowerToughnessEnchantedEffect copy() {
return new SetPowerToughnessEnchantedEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if (enchanted != null) {
enchanted.getPower().setValue(power);
enchanted.getToughness().setValue(toughness);
}
return true;
}
return false;
}
}