Add Scuttlemutt and BecomesColorOrColorsTargetEffect

This commit is contained in:
User 2015-02-20 16:24:00 -05:00
parent 38f47b1f1e
commit ea69376943
2 changed files with 269 additions and 0 deletions

View file

@ -0,0 +1,143 @@
/*
* 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.sets.shadowmoor;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.mana.AnyColorManaAbility;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.constants.Zone;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continious.BecomesColorOrColorsTargetEffect;
import mage.choices.ChoiceColor;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author philvt101
*/
public class Scuttlemutt extends CardImpl {
public Scuttlemutt(UUID ownerId) {
super(ownerId, 263, "Scuttlemutt", Rarity.COMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}");
this.expansionSetCode = "SHM";
this.subtype.add("Scarecrow");
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// {tap}: Add one mana of any color to your mana pool.
this.addAbility(new AnyColorManaAbility());
// {tap}: Target creature becomes the color or colors of your choice until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ChangeColorsTargetEffect(), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
public Scuttlemutt(final Scuttlemutt card) {
super(card);
}
@Override
public Scuttlemutt copy() {
return new Scuttlemutt(this);
}
}
class ChangeColorsTargetEffect extends OneShotEffect {
public ChangeColorsTargetEffect() {
super(Outcome.Neutral);
staticText = "target creature becomes the color or colors of your choice until end of turn";
}
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Permanent target = game.getPermanent(source.getFirstTarget());
List<ObjectColor> chosenColors = new ArrayList<>();
if (you != null && target != null) {
for (int i = 0; i < 5; i++) {
if (!you.chooseUse(Outcome.Neutral, "Do you wish to choose another color?", game)) {
break;
}
ChoiceColor choiceColor = new ChoiceColor();
you.choose(Outcome.Benefit, choiceColor, game);
if (!you.isInGame()) {
return false;
}
game.informPlayers(target.getName() + ": " + you.getName() + " has chosen " + choiceColor.getChoice());
if (choiceColor.getColor().isBlack()) {
chosenColors.add(ObjectColor.BLACK);
} else if (choiceColor.getColor().isBlue()) {
chosenColors.add(ObjectColor.BLUE);
} else if (choiceColor.getColor().isRed()) {
chosenColors.add(ObjectColor.RED);
} else if (choiceColor.getColor().isGreen()) {
chosenColors.add(ObjectColor.GREEN);
} else if (choiceColor.getColor().isWhite()) {
chosenColors.add(ObjectColor.WHITE);
}
}
ContinuousEffect effect = new BecomesColorOrColorsTargetEffect(chosenColors, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
game.addEffect(effect, source);
return true;
}
return false;
}
public ChangeColorsTargetEffect(final ChangeColorsTargetEffect effect) {
super(effect);
}
@Override
public ChangeColorsTargetEffect copy() {
return new ChangeColorsTargetEffect(this);
}
}

View file

@ -0,0 +1,126 @@
/*
*
* 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 java.util.UUID;
import mage.MageObject;
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;
import mage.game.stack.StackObject;
import mage.players.Player;
import java.util.List;
import mage.ObjectColor;
/**
*
* @author philvt101
*/
public class BecomesColorOrColorsTargetEffect extends ContinuousEffectImpl {
private final List<ObjectColor> colors;
/**
* Set the color or colors of a spell or permanent
*
* @param duration
* @param colors
*/
public BecomesColorOrColorsTargetEffect(List<ObjectColor> colors, Duration duration) {
super(duration, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Benefit);
this.colors=colors;
}
@Override
public boolean apply(Game game, Ability source){
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
boolean result = false;
for (UUID targetId :targetPointer.getTargets(game, source)) {
MageObject o = game.getObject(targetId);
if(o != null){
if(o instanceof Permanent || o instanceof StackObject);{
if(!colors.isEmpty()){
/**As target may become a single color other than its original color,
* all colors must be initialized to false before applying chosen color/colors
*/
o.getColor().setWhite(false);
o.getColor().setBlue(false);
o.getColor().setBlack(false);
o.getColor().setRed(false);
o.getColor().setGreen(false);
for (ObjectColor color : colors) {
if (color.isWhite()) {
o.getColor().setWhite(true);
} else if (color.isBlue()) {
o.getColor().setBlue(true);
} else if (color.isBlack()) {
o.getColor().setBlack(true);
} else if (color.isRed()) {
o.getColor().setRed(true);
} else if (color.isGreen()) {
o.getColor().setGreen(true);
}
}
}
}
}
}
if (!result) {
if (this.getDuration().equals(Duration.Custom)) {
this.discard();
}
}
return result;
}
public BecomesColorOrColorsTargetEffect(final BecomesColorOrColorsTargetEffect effect) {
super(effect);
this.colors = effect.colors;
}
@Override
public BecomesColorOrColorsTargetEffect copy() {
return new BecomesColorOrColorsTargetEffect(this);
}
}