mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
LoseAllAbilitiesTargetEffect. Updated BecomesCreatureSourceEffect and BecomesCreatureTargetEffect to clear previous subtypes if needed.
This commit is contained in:
parent
8eb5ce8012
commit
8018ccf953
4 changed files with 106 additions and 7 deletions
|
@ -303,6 +303,7 @@ public final class Constants {
|
||||||
BoostCreature(true),
|
BoostCreature(true),
|
||||||
UnboostCreature(false),
|
UnboostCreature(false),
|
||||||
AddAbility(true),
|
AddAbility(true),
|
||||||
|
LoseAbility(false),
|
||||||
GainLife(true),
|
GainLife(true),
|
||||||
ExtraTurn(true),
|
ExtraTurn(true),
|
||||||
BecomeCreature(true),
|
BecomeCreature(true),
|
||||||
|
|
|
@ -74,13 +74,19 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl<BecomesCre
|
||||||
switch (layer) {
|
switch (layer) {
|
||||||
case TypeChangingEffects_4:
|
case TypeChangingEffects_4:
|
||||||
if (sublayer == SubLayer.NA) {
|
if (sublayer == SubLayer.NA) {
|
||||||
if (token.getCardType().size() > 0)
|
if (token.getCardType().size() > 0) {
|
||||||
for (Constants.CardType t : token.getCardType()) {
|
for (Constants.CardType t : token.getCardType()) {
|
||||||
if (!permanent.getCardType().contains(t))
|
if (!permanent.getCardType().contains(t)) {
|
||||||
permanent.getCardType().add(t);
|
permanent.getCardType().add(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (token.getSubtype().size() > 0)
|
}
|
||||||
|
if (type == null) {
|
||||||
|
permanent.getSubtype().clear();
|
||||||
|
}
|
||||||
|
if (token.getSubtype().size() > 0) {
|
||||||
permanent.getSubtype().addAll(token.getSubtype());
|
permanent.getSubtype().addAll(token.getSubtype());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ColorChangingEffects_5:
|
case ColorChangingEffects_5:
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities.effects.common.continious;
|
package mage.abilities.effects.common.continious;
|
||||||
|
|
||||||
|
import mage.Constants;
|
||||||
import mage.Constants.Duration;
|
import mage.Constants.Duration;
|
||||||
import mage.Constants.Layer;
|
import mage.Constants.Layer;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
|
@ -72,10 +73,19 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl<BecomesCre
|
||||||
switch (layer) {
|
switch (layer) {
|
||||||
case TypeChangingEffects_4:
|
case TypeChangingEffects_4:
|
||||||
if (sublayer == SubLayer.NA) {
|
if (sublayer == SubLayer.NA) {
|
||||||
if (token.getCardType().size() > 0)
|
if (token.getCardType().size() > 0) {
|
||||||
permanent.getCardType().addAll(token.getCardType());
|
for (Constants.CardType t : token.getCardType()) {
|
||||||
if (token.getSubtype().size() > 0)
|
if (!permanent.getCardType().contains(t)) {
|
||||||
|
permanent.getCardType().add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == null) {
|
||||||
|
permanent.getSubtype().clear();
|
||||||
|
}
|
||||||
|
if (token.getSubtype().size() > 0) {
|
||||||
permanent.getSubtype().addAll(token.getSubtype());
|
permanent.getSubtype().addAll(token.getSubtype());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ColorChangingEffects_5:
|
case ColorChangingEffects_5:
|
||||||
|
@ -120,7 +130,7 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl<BecomesCre
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(duration.toString());
|
sb.append(duration.toString());
|
||||||
sb.append(" target ").append(mode.getTargets().get(0).getTargetName()).append(" becomes a ").append(token.getDescription());
|
sb.append(" target ").append(mode.getTargets().get(0).getTargetName()).append(" becomes a ").append(token.getDescription());
|
||||||
if (type.length() > 0)
|
if (type != null && type.length() > 0)
|
||||||
sb.append(" that's still a ").append(type);
|
sb.append(" that's still a ").append(type);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* 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.continious;
|
||||||
|
|
||||||
|
import mage.Constants.Duration;
|
||||||
|
import mage.Constants.Layer;
|
||||||
|
import mage.Constants.Outcome;
|
||||||
|
import mage.Constants.SubLayer;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.Mode;
|
||||||
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author nantuko
|
||||||
|
*/
|
||||||
|
public class LoseAllAbilitiesTargetEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
|
public LoseAllAbilitiesTargetEffect(Duration duration) {
|
||||||
|
super(duration, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoseAllAbilitiesTargetEffect(final LoseAllAbilitiesTargetEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoseAllAbilitiesTargetEffect copy() {
|
||||||
|
return new LoseAllAbilitiesTargetEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
int affectedTargets = 0;
|
||||||
|
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
|
||||||
|
Permanent permanent = game.getPermanent(permanentId);
|
||||||
|
if (permanent != null) {
|
||||||
|
permanent.getAbilities().clear();
|
||||||
|
affectedTargets++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return affectedTargets > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText(Mode mode) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Target ").append(mode.getTargets().get(0).getTargetName()).append(" loses all abilities").append(duration.toString());
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue