Merge origin/master

This commit is contained in:
fireshoes 2016-09-22 10:57:53 -05:00
commit 49932a455b
12 changed files with 235 additions and 58 deletions

View file

@ -28,8 +28,6 @@
package mage.sets.championsofkamigawa;
import java.util.UUID;
import mage.constants.*;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
@ -40,15 +38,17 @@ import mage.abilities.condition.common.SourceHasCounterCondition;
import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.PutOntoBattlefieldTargetEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.other.OwnerPredicate;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import mage.watchers.common.CastFromHandWatcher;
@ -57,12 +57,6 @@ import mage.watchers.common.CastFromHandWatcher;
*/
public class MyojinOfLifesWeb extends CardImpl {
private static final FilterCard filter = new FilterCard("any number of creature cards from your hand");
static {
filter.add(new CardTypePredicate(CardType.CREATURE));
filter.add(new OwnerPredicate(TargetController.YOU));
}
public MyojinOfLifesWeb(UUID ownerId) {
super(ownerId, 229, "Myojin of Life's Web", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{6}{G}{G}{G}");
this.expansionSetCode = "CHK";
@ -79,10 +73,10 @@ public class MyojinOfLifesWeb extends CardImpl {
// Myojin of Life's Web is indestructible as long as it has a divinity counter on it.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield),
new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it")));
new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it")));
// Remove a divinity counter from Myojin of Life's Web: Put any number of creature cards from your hand onto the battlefield.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutOntoBattlefieldTargetEffect(false), new RemoveCountersSourceCost(CounterType.DIVINITY.createInstance()));
ability.addTarget(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MyojinOfLifesWebPutCreatureOnBattlefieldEffect(), new RemoveCountersSourceCost(CounterType.DIVINITY.createInstance()));
this.addAbility(ability);
}
@ -95,3 +89,35 @@ public class MyojinOfLifesWeb extends CardImpl {
return new MyojinOfLifesWeb(this);
}
}
class MyojinOfLifesWebPutCreatureOnBattlefieldEffect extends OneShotEffect {
public MyojinOfLifesWebPutCreatureOnBattlefieldEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Put any number of creature cards from your hand onto the battlefield";
}
public MyojinOfLifesWebPutCreatureOnBattlefieldEffect(final MyojinOfLifesWebPutCreatureOnBattlefieldEffect effect) {
super(effect);
}
@Override
public MyojinOfLifesWebPutCreatureOnBattlefieldEffect copy() {
return new MyojinOfLifesWebPutCreatureOnBattlefieldEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your hand to put onto the battlefield"));
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game),
Zone.BATTLEFIELD, source, game, false, false, false, null);
}
return false;
}
}

View file

@ -33,13 +33,13 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectSourcePlayer;
@ -48,7 +48,6 @@ import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -56,8 +55,8 @@ import mage.target.targetpointer.FixedTarget;
*/
public class SelvalaHeartOfTheWilds extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
static {
filter.add(new AnotherPredicate());
filter.add(new GreatestPowerPredicate());
@ -75,12 +74,14 @@ public class SelvalaHeartOfTheWilds extends CardImpl {
this.toughness = new MageInt(3);
// Whenever another creature enters the battlefield, its controller may draw a card if its power is greater than each other creature's power.
this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new SelvalaHeartOfTheWildsEffect(), filter, false, SetTargetPointer.PERMANENT, rule));
// {G}, {T}: Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control.
this.addAbility(new DynamicManaAbility(new Mana(0,0,0,0,0,0,1, 0), new GreatestPowerYouControlValue(), new TapSourceCost(),
"Add X mana in any combination of colors to your mana pool, where X is the number of creatures with defender you control."));
Ability ability = new DynamicManaAbility(new Mana(0, 0, 0, 0, 0, 0, 1, 0), new GreatestPowerYouControlValue(), new ManaCostsImpl<>("{G}"),
"Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control.");
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}
public SelvalaHeartOfTheWilds(final SelvalaHeartOfTheWilds card) {
@ -112,12 +113,12 @@ class SelvalaHeartOfTheWildsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if(permanent == null){
permanent = (Permanent)game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
}
if (permanent != null) {
Player cardowner = game.getPlayer(permanent.getControllerId());
if(cardowner.chooseUse(Outcome.DrawCard, "Would you like to draw a card?", source, game)){
if (cardowner.chooseUse(Outcome.DrawCard, "Would you like to draw a card?", source, game)) {
cardowner.drawCards(1, game);
}
}
@ -125,18 +126,17 @@ class SelvalaHeartOfTheWildsEffect extends OneShotEffect {
}
}
class GreatestPowerPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Permanent>> {
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
int pow = input.getObject().getPower().getValue();
for (UUID id :game.getPlayerList()){
for (UUID id : game.getPlayerList()) {
Player player = game.getPlayer(id);
if (player != null) {
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), id, game)) {
if(p.getPower().getValue() >= pow && !p.equals(input.getObject())){
if (p.getPower().getValue() >= pow && !p.equals(input.getObject())) {
return false; //we found something with equal/more power
}
}
@ -144,6 +144,7 @@ class GreatestPowerPredicate implements ObjectSourcePlayerPredicate<ObjectSource
}
return true;
}
@Override
public String toString() {
return "Greatest Power";

View file

@ -80,7 +80,7 @@ class ReconnaissanceRemoveFromCombatEffect extends OneShotEffect {
public ReconnaissanceRemoveFromCombatEffect() {
super(Outcome.Benefit);
this.staticText = "Remove target attacking creature from combat and untap it";
this.staticText = "Remove target attacking creature you control from combat and untap it";
}
public ReconnaissanceRemoveFromCombatEffect(final ReconnaissanceRemoveFromCombatEffect effect) {

View file

@ -53,7 +53,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
*/
public class EraOfInnovation extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("an artifact or creature");
private static final FilterControlledPermanent filter = new FilterControlledPermanent("an artifact or Artificer");
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT),
@ -64,7 +64,7 @@ public class EraOfInnovation extends CardImpl {
super(ownerId, 45, "Era of Innovation", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.expansionSetCode = "KLD";
// Whenever an artifact or creature enters the battlefield under you control, you may pay {1}. If you do, you get {E}{E}.
// Whenever an artifact or Artificer enters the battlefield under you control, you may pay {1}. If you do, you get {E}{E}.
Effect effect = new DoIfCostPaid(new GetEnergyCountersControllerEffect(2), new GenericManaCost(1));
this.addAbility(new EntersBattlefieldAllTriggeredAbility(effect, filter,
"Whenever an artifact or Artificer enters the battlefield under you control, you may pay {1}. If you do, you get {E}{E}."));

View file

@ -187,10 +187,10 @@ class MultiformWonder2Effect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
target.addPower(power);
target.addToughness(toughness);
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (sourceObject != null) {
sourceObject.addPower(power);
sourceObject.addToughness(toughness);
return true;
}
return false;

View file

@ -33,15 +33,18 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.PutOnLibraryTargetEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveControllerEffect;
import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterArtifactCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
/**
@ -61,10 +64,7 @@ public class SequesteredStash extends CardImpl {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutTopCardOfLibraryIntoGraveControllerEffect(5), new GenericManaCost(4));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
Effect effect = new PutOnLibraryTargetEffect(true);
effect.setText("Then you may put an artifact card from your graveyard on top of your library");
ability.addEffect(effect);
ability.addTarget(new TargetCardInYourGraveyard(new FilterArtifactCard("artifact card from your graveyard")));
ability.addEffect(new SequesteredStashEffect());
this.addAbility(ability);
}
@ -78,3 +78,39 @@ public class SequesteredStash extends CardImpl {
return new SequesteredStash(this);
}
}
class SequesteredStashEffect extends OneShotEffect {
public SequesteredStashEffect() {
super(Outcome.Benefit);
this.staticText = "Then you may put an artifact card from your graveyard on top of your library";
}
public SequesteredStashEffect(final SequesteredStashEffect effect) {
super(effect);
}
@Override
public SequesteredStashEffect copy() {
return new SequesteredStashEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(new FilterArtifactCard("artifact card from your graveyard"));
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
&& controller.chooseUse(outcome, "Put an artifact card from your graveyard to library?", source, game)
&& controller.choose(outcome, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.LIBRARY, source, game);
}
}
return true;
}
}

View file

@ -29,15 +29,18 @@ package mage.sets.legions;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SetTargetPointer;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.token.SliverToken;
import mage.players.Player;
/**
*
@ -54,10 +57,8 @@ public class BroodSliver extends CardImpl {
this.toughness = new MageInt(3);
// Whenever a Sliver deals combat damage to a player, its controller may put a 1/1 colorless Sliver creature token onto the battlefield.
Effect effect = new CreateTokenTargetEffect(new SliverToken());
effect.setText("its controller may put a 1/1 colorless Sliver creature token onto the battlefield");
this.addAbility(new DealsDamageToAPlayerAllTriggeredAbility(effect,
new FilterCreaturePermanent("Sliver", "a Sliver"), true, SetTargetPointer.PLAYER, true));
this.addAbility(new DealsDamageToAPlayerAllTriggeredAbility(new BroodSliverEffect(),
new FilterCreaturePermanent("Sliver", "a Sliver"), false, SetTargetPointer.PLAYER, true));
}
public BroodSliver(final BroodSliver card) {
@ -69,3 +70,32 @@ public class BroodSliver extends CardImpl {
return new BroodSliver(this);
}
}
class BroodSliverEffect extends OneShotEffect {
public BroodSliverEffect() {
super(Outcome.PutCardInPlay);
this.staticText = "its controller may put a 1/1 colorless Sliver creature token onto the battlefield";
}
public BroodSliverEffect(final BroodSliverEffect effect) {
super(effect);
}
@Override
public BroodSliverEffect copy() {
return new BroodSliverEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player permanentController = game.getPlayer(getTargetPointer().getFirst(game, source));
if (permanentController != null) {
if (permanentController.chooseUse(outcome, "put a 1/1 colorless Sliver creature token onto the battlefield", source, game)) {
return new SliverToken().putOntoBattlefield(1, game, source.getSourceId(), permanentController.getId());
}
return true;
}
return false;
}
}

View file

@ -0,0 +1,84 @@
/*
* 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.lorwyn;
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.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author Styxo
*/
public class SilvergillDouser extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Merfolk and/or Faeries you control");
static {
filter.add(Predicates.or(new SubtypePredicate("Merfolk"), new SubtypePredicate("Faerie")));
}
public SilvergillDouser(UUID ownerId) {
super(ownerId, 87, "Silvergill Douser", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.expansionSetCode = "LRW";
this.subtype.add("Merfolk");
this.subtype.add("Wizard");
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// {tap}: Target creature gets -X/-0 until end of turn, where X is the number of Merfolk and/or Faeries you control.
DynamicValue number = new PermanentsOnBattlefieldCount(new FilterControlledCreaturePermanent(filter), -1);
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(number, new StaticValue(0), Duration.EndOfTurn, true), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
public SilvergillDouser(final SilvergillDouser card) {
super(card);
}
@Override
public SilvergillDouser copy() {
return new SilvergillDouser(this);
}
}

View file

@ -52,7 +52,6 @@ public class LightmineField extends CardImpl {
super(ownerId, 32, "Lightmine Field", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}");
this.expansionSetCode = "ROE";
// Whenever one or more creatures attack, Lightmine Field deals damage to each of those creatures equal to the number of attacking creatures.
this.addAbility(new LightmineFieldTriggeredAbility());
}
@ -122,7 +121,7 @@ class LightmineFieldEffect extends OneShotEffect {
for (UUID attacker : attackers) {
Permanent creature = game.getPermanent(attacker);
if (creature != null) {
creature.damage(damage, source.getSourceId(), game, false, false);
creature.damage(damage, source.getSourceId(), game, false, true);
}
}
return true;

View file

@ -15,24 +15,23 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public class BroodSliverTest extends CardTestPlayerBase {
/*
Reported bug: It lets the controller of Brood Sliver choose whether or not the token is created, instead of the attacking Sliver's controller.
*/
*/
@Test
public void testTokenCreatedBySliverController() {
// Brood Sliver {4}{G} 3/3 Sliver
// Whenever a Sliver deals combat damage to a player, its controller may put a 1/1 colorless Sliver creature token onto the battlefield.
addCard(Zone.BATTLEFIELD, playerB, "Brood Sliver");
addCard(Zone.BATTLEFIELD, playerA, "Venom Sliver"); // 1/1 deathtouch granting sliver
attack(1, playerA, "Venom Sliver");
setChoice(playerA, "Yes"); // controller of Venom Sliver dealing damage should get the choice to create token
setChoice(playerB, "No"); // Brood Sliver controller should not be given choice in the first place
setStopAt(1, PhaseStep.END_COMBAT);
execute();
assertLife(playerB, 19);
assertPermanentCount(playerA, "Sliver", 1);
assertPermanentCount(playerB, "Sliver", 0);

View file

@ -73,12 +73,11 @@ public class DealsDamageToAPlayerAllTriggeredAbility extends TriggeredAbilityImp
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
public boolean checkTrigger(GameEvent event, Game game) {
if (!onlyCombat || ((DamagedPlayerEvent) event).isCombatDamage()) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent != null) {
controllerId = permanent.getControllerId();
if (filter.match(permanent, sourceId, controllerId, game)) {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (!setTargetPointer.equals(SetTargetPointer.NONE)) {
for (Effect effect : this.getEffects()) {
effect.setValue("damage", event.getAmount());

View file

@ -122,7 +122,10 @@ class CrewCost extends CostImpl {
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
int sumPower = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controllerId, game)) {
sumPower += permanent.getPower().getValue();
int powerToAdd = permanent.getPower().getValue();
if (powerToAdd > 0) {
sumPower += powerToAdd;
}
if (sumPower >= value) {
return true;
}