Merge pull request #1134 from Simown/master

Missing "Domain" cards and Matca Rioters fix.
This commit is contained in:
LevelX2 2015-07-22 00:32:28 +02:00
commit c312160d81
5 changed files with 449 additions and 3 deletions

View file

@ -33,7 +33,7 @@ import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
@ -56,9 +56,9 @@ public class MatcaRioters extends CardImpl {
this.toughness = new MageInt(0);
// Domain - Matca Rioters's power and toughness are each equal to the number of basic land types among lands you control.
Effect effect = new BoostSourceEffect(new DomainValue(), new DomainValue(), Duration.EndOfGame);
Effect effect = new SetPowerToughnessSourceEffect(new DomainValue(), Duration.EndOfGame);
effect.setText("Domain - {this}'s power and toughness are each equal to the number of basic land types among lands you control.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(Zone.ALL, effect));
}
public MatcaRioters(final MatcaRioters card) {

View file

@ -0,0 +1,151 @@
/*
* 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.ftvdragons;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
* @author Simown
*/
public class Draco extends CardImpl {
public Draco(UUID ownerId) {
super(ownerId, 3, "Draco", Rarity.RARE, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{16}");
this.expansionSetCode = "FVD";
this.subtype.add("Dragon");
this.power = new MageInt(9);
this.toughness = new MageInt(9);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Domain - Draco costs {2} less to cast for each basic land type among lands you control.
this.addAbility(new SimpleStaticAbility(Zone.STACK, new DracoCostReductionEffect()));
// Domain - At the beginning of your upkeep, sacrifice Draco unless you pay {10}. This cost is reduced by {2} for each basic land type among lands you control.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DracoSacrificeUnlessPaysEffect(), TargetController.YOU, false));
}
public Draco(final Draco card) {
super(card);
}
@Override
public Draco copy() {
return new Draco(this);
}
}
class DracoCostReductionEffect extends CostModificationEffectImpl {
public DracoCostReductionEffect() {
super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = "<i>Domain</i> - {this} costs {2} less to cast for each basic land type among lands you control.";
}
protected DracoCostReductionEffect(final DracoCostReductionEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
CardUtil.reduceCost(abilityToModify, new DomainValue(2).calculate(game, source, this));
return true;
}
public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getSourceId().equals(source.getSourceId());
}
@Override
public DracoCostReductionEffect copy() {
return new DracoCostReductionEffect(this);
}
}
class DracoSacrificeUnlessPaysEffect extends OneShotEffect {
public static final int MAX_DOMAIN_VALUE = 10;
public DracoSacrificeUnlessPaysEffect () {
super(Outcome.Sacrifice);
staticText = "sacrifice {this} unless you pay {10}. This cost is reduced by {2} for each basic land type among lands you control.";
}
public DracoSacrificeUnlessPaysEffect (final DracoSacrificeUnlessPaysEffect 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) {
// The cost is reduced by {2} for each basic land type.
int domainValueReduction = new DomainValue(2).calculate(game, source, this);
// Nothing to pay
if (domainValueReduction >= MAX_DOMAIN_VALUE) {
return true;
}
int count = (MAX_DOMAIN_VALUE-domainValueReduction );
if (player.chooseUse(Outcome.Benefit, "Pay {" + count + "}? Or " + permanent.getName() + " will be sacrificed.", source, game)) {
GenericManaCost cost = new GenericManaCost(count);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
return true;
}
}
permanent.sacrifice(source.getSourceId(), game);
return true;
}
return false;
}
@Override
public DracoSacrificeUnlessPaysEffect copy() {
return new DracoSacrificeUnlessPaysEffect (this);
}
}

View file

@ -0,0 +1,100 @@
/*
* 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.invasion;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostImpl;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.PayCostToAttackBlockEffectImpl;
import mage.abilities.effects.common.combat.CantAttackYouUnlessPayManaAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterEnchantmentPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author Simown
*/
public class CollectiveRestraint extends CardImpl {
public CollectiveRestraint(UUID ownerId) {
super(ownerId, 49, "Collective Restraint", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
this.expansionSetCode = "INV";
// Domain - Creatures can't attack you unless their controller pays {X} for each creature he or she controls that's attacking you, where X is the number of basic land types you control.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CollectiveRestraintPayManaToAttackAllEffect()));
}
public CollectiveRestraint(final CollectiveRestraint card) {
super(card);
}
@Override
public CollectiveRestraint copy() {
return new CollectiveRestraint(this);
}
}
class CollectiveRestraintPayManaToAttackAllEffect extends CantAttackYouUnlessPayManaAllEffect {
CollectiveRestraintPayManaToAttackAllEffect() {
super(null, true);
staticText = "Creatures can't attack you unless their controller pays {X} for each creature he or she controls that's attacking you, where X is the number of basic land types you control.";
}
CollectiveRestraintPayManaToAttackAllEffect(CollectiveRestraintPayManaToAttackAllEffect effect) {
super(effect);
}
@Override
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
int domainValue = new DomainValue().calculate(game, source, this);
if (domainValue > 0) {
return new ManaCostsImpl<>("{" + domainValue + "}");
}
return null;
}
@Override
public CollectiveRestraintPayManaToAttackAllEffect copy() {
return new CollectiveRestraintPayManaToAttackAllEffect(this);
}
}

View file

@ -0,0 +1,52 @@
/*
* 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.planeshift;
import java.util.UUID;
/**
*
* @author Simown
*/
public class Draco extends mage.sets.ftvdragons.Draco {
public Draco(UUID ownerId) {
super(ownerId);
this.cardNumber = 131;
this.expansionSetCode = "PLS";
}
public Draco(final Draco card) {
super(card);
}
@Override
public Draco copy() {
return new Draco(this);
}
}

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.planeshift;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.DomainValue;
import mage.abilities.effects.PreventionEffectImpl;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author Simown
*/
public class SamitePilgrim extends CardImpl {
public SamitePilgrim(UUID ownerId) {
super(ownerId, 15, "Samite Pilgrim", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{W}");
this.expansionSetCode = "PLS";
this.subtype.add("Human");
this.subtype.add("Cleric");
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// Domain - {tap}: Prevent the next X damage that would be dealt to target creature this turn, where X is the number of basic land types among lands you control.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SamitePilgrimPreventDamageToTargetEffect(), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
public SamitePilgrim(final SamitePilgrim card) {
super(card);
}
@Override
public SamitePilgrim copy() {
return new SamitePilgrim(this);
}
}
class SamitePilgrimPreventDamageToTargetEffect extends PreventionEffectImpl {
protected int amount = 0;
public SamitePilgrimPreventDamageToTargetEffect() {
super(Duration.EndOfTurn);
staticText = "Prevent the next X damage that would be dealt to target creature this turn, where X is the number of basic land types among lands you control.";
}
public SamitePilgrimPreventDamageToTargetEffect(final SamitePilgrimPreventDamageToTargetEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public SamitePilgrimPreventDamageToTargetEffect copy() {
return new SamitePilgrimPreventDamageToTargetEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
amount = new DomainValue().calculate(game, source, this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
boolean result = false;
int toPrevent = amount;
if (event.getAmount() < this.amount) {
toPrevent = event.getAmount();
amount -= event.getAmount();
} else {
amount = 0;
}
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent, false);
if (!game.replaceEvent(preventEvent)) {
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null) {
if (amount == 0) {
this.used = true;
this.discard();
}
if (event.getAmount() >= toPrevent) {
event.setAmount(event.getAmount() - toPrevent);
} else {
event.setAmount(0);
result = true;
}
if (toPrevent > 0) {
game.informPlayers(new StringBuilder("Samite Pilgrim ").append("prevented ").append(toPrevent).append(" to ").append(targetCreature.getName()).toString());
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
}
}
}
return result;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return !this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getFirstTarget());
}
}