[AVR] 3 cards

This commit is contained in:
magenoxx 2012-05-22 19:21:17 +04:00
parent 082a1fcb64
commit 2f202424a8
3 changed files with 361 additions and 0 deletions

View file

@ -0,0 +1,128 @@
/*
* 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.avacynrestored;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
* @author noxx
*/
public class TyrantOfDiscord extends CardImpl<TyrantOfDiscord> {
public TyrantOfDiscord(UUID ownerId) {
super(ownerId, 162, "Tyrant of Discord", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{R}{R}{R}");
this.expansionSetCode = "AVR";
this.subtype.add("Elemental");
this.color.setRed(true);
this.power = new MageInt(7);
this.toughness = new MageInt(7);
// When Tyrant of Discord enters the battlefield, target opponent chooses a permanent he or she controls at random and sacrifices it. If a nonland permanent is sacrificed this way, repeat this process.
Ability ability = new EntersBattlefieldTriggeredAbility(new TyrantOfDiscordEffect());
ability.addTarget(new TargetOpponent(true));
this.addAbility(ability);
}
public TyrantOfDiscord(final TyrantOfDiscord card) {
super(card);
}
@Override
public TyrantOfDiscord copy() {
return new TyrantOfDiscord(this);
}
}
class TyrantOfDiscordEffect extends OneShotEffect<TyrantOfDiscordEffect> {
public TyrantOfDiscordEffect() {
super(Constants.Outcome.Benefit);
this.staticText = "target opponent chooses a permanent he or she controls at random and sacrifices it. If a nonland permanent is sacrificed this way, repeat this process";
}
public TyrantOfDiscordEffect(final TyrantOfDiscordEffect effect) {
super(effect);
}
@Override
public TyrantOfDiscordEffect copy() {
return new TyrantOfDiscordEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
UUID target = source.getFirstTarget();
Player opponent = game.getPlayer(target);
if (opponent != null) {
boolean stop = false;
while (!stop) {
int count = game.getBattlefield().countAll(new FilterPermanent(), opponent.getId());
if (count > 0) {
int random = (int)(Math.random()*count);
int index = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponent.getId())) {
if (index == random) {
if (permanent.sacrifice(source.getSourceId(), game)) {
if (permanent.getCardType().contains(CardType.LAND)) {
stop = true;
game.informPlayers("Land permanent has been sacrificed: " + permanent.getName() + ". Stopping process.");
} else {
game.informPlayers("Nonland permanent has been sacrificed: " + permanent.getName() + ". Repeating process.");
}
} else {
game.informPlayers("Couldn't sacrifice a permanent. Stopping the process.");
stop = true;
}
break;
}
index++;
}
} else {
game.informPlayers("There is no permanent to sacrifice");
stop = true;
}
}
}
return true;
}
}

View file

@ -0,0 +1,120 @@
/*
* 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.avacynrestored;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.Set;
import java.util.UUID;
/**
*
* @author noxx
*/
public class VexingDevil extends CardImpl<VexingDevil> {
public VexingDevil(UUID ownerId) {
super(ownerId, 164, "Vexing Devil", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{R}");
this.expansionSetCode = "AVR";
this.subtype.add("Devil");
this.color.setRed(true);
this.power = new MageInt(4);
this.toughness = new MageInt(3);
// When Vexing Devil enters the battlefield, any opponent may have it deal 4 damage to him or her. If a player does, sacrifice Vexing Devil.
this.addAbility(new EntersBattlefieldTriggeredAbility(new VexingDevilEffect(), false));
}
public VexingDevil(final VexingDevil card) {
super(card);
}
@Override
public VexingDevil copy() {
return new VexingDevil(this);
}
}
class VexingDevilEffect extends OneShotEffect<VexingDevilEffect> {
public VexingDevilEffect() {
super(Constants.Outcome.Neutral);
staticText = "any opponent may have it deal 4 damage to him or her. If a player does, sacrifice Vexing Devil";
}
VexingDevilEffect(final VexingDevilEffect effect) {
super(effect);
}
@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) {
StringBuilder sb = new StringBuilder();
sb.append("Make ").append(permanent.getName()).append(" deal 4 damage to you?");
Set<UUID> opponents = game.getOpponents(source.getControllerId());
for (UUID opponentUuid : opponents) {
Player opponent = game.getPlayer(opponentUuid);
if (opponent != null && opponent.chooseUse(Constants.Outcome.LoseLife, sb.toString(), game)) {
game.informPlayers(opponent.getName() + " has chosen to receive 4 damage from " + permanent.getName());
int dealt = opponent.damage(4, permanent.getId(), game, false, true);
if (dealt == 4) {
game.informPlayers(opponent.getName() + " was dealt 4 damage so " + permanent.getName() + " will be sacrificed.");
permanent.sacrifice(source.getId(), game);
return true;
} else {
game.informPlayers("4 damage wasn't dealt so " + permanent.getName() + " won't be sacrificed.");
}
}
}
return true;
}
return false;
}
@Override
public VexingDevilEffect copy() {
return new VexingDevilEffect(this);
}
}

View file

@ -0,0 +1,113 @@
/*
* 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.avacynrestored;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* @author noxx
*/
public class WildDefiance extends CardImpl<WildDefiance> {
public WildDefiance(UUID ownerId) {
super(ownerId, 203, "Wild Defiance", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}");
this.expansionSetCode = "AVR";
this.color.setGreen(true);
// Whenever a creature you control becomes the target of an instant or sorcery spell, that creature gets +3/+3 until end of turn.
this.addAbility(new CreaturesYouControlBecomesTargetTriggeredAbility(new BoostTargetEffect(3, 3, Constants.Duration.EndOfTurn)));
}
public WildDefiance(final WildDefiance card) {
super(card);
}
@Override
public WildDefiance copy() {
return new WildDefiance(this);
}
}
class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityImpl<CreaturesYouControlBecomesTargetTriggeredAbility> {
public CreaturesYouControlBecomesTargetTriggeredAbility(Effect effect) {
super(Constants.Zone.BATTLEFIELD, effect);
}
public CreaturesYouControlBecomesTargetTriggeredAbility(final CreaturesYouControlBecomesTargetTriggeredAbility ability) {
super(ability);
}
@Override
public CreaturesYouControlBecomesTargetTriggeredAbility copy() {
return new CreaturesYouControlBecomesTargetTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.TARGETED) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getControllerId().equals(this.controllerId)) {
MageObject object = game.getObject(event.getSourceId());
if (object != null && object instanceof Spell) {
Card c = (Spell)object;
if (c.getCardType().contains(CardType.INSTANT) || c.getCardType().contains(CardType.SORCERY)) {
if (getTargets().size() == 0) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
}
}
return true;
}
}
}
}
return false;
}
@Override
public String getRule() {
return "Whenever a creature you control becomes the target of an instant or sorcery spell, that creature gets +3/+3 until end of turn";
}
}