Merge pull request #9 from magefree/master

merge
This commit is contained in:
theelk801 2017-07-31 16:09:27 -04:00 committed by GitHub
commit c310bcd053
7 changed files with 100 additions and 88 deletions

View file

@ -48,7 +48,7 @@ import mage.players.Player;
public class AvatarOfWill extends CardImpl { public class AvatarOfWill extends CardImpl {
public AvatarOfWill(UUID ownerId, CardSetInfo setInfo) { public AvatarOfWill(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{6}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{6}{U}{U}");
this.subtype.add(SubType.AVATAR); this.subtype.add(SubType.AVATAR);
this.power = new MageInt(5); this.power = new MageInt(5);
this.toughness = new MageInt(6); this.toughness = new MageInt(6);
@ -99,10 +99,12 @@ class AvatarOfWillCostReductionEffect extends CostModificationEffectImpl {
@Override @Override
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
for (UUID playerId : game.getOpponents(source.getControllerId())) { if (abilityToModify.getSourceId().equals(source.getSourceId())) {
Player opponent = game.getPlayer(playerId); for (UUID playerId : game.getOpponents(source.getControllerId())) {
if (opponent != null && opponent.getHand().isEmpty()) { Player opponent = game.getPlayer(playerId);
return true; if (opponent != null && opponent.getHand().isEmpty()) {
return true;
}
} }
} }
return false; return false;

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -34,13 +35,12 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/** /**
* *
* @author ciaccona007 * @author ciaccona007
@ -49,7 +49,6 @@ public class CinderCloud extends CardImpl {
public CinderCloud(UUID ownerId, CardSetInfo setInfo) { public CinderCloud(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{R}{R}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{R}{R}");
// Destroy target creature. If a white creature dies this way, Cinder Cloud deals damage to that creature's controller equal to the creature's power. // Destroy target creature. If a white creature dies this way, Cinder Cloud deals damage to that creature's controller equal to the creature's power.
this.getSpellAbility().addEffect(new CinderCloudEffect()); this.getSpellAbility().addEffect(new CinderCloudEffect());
@ -85,13 +84,19 @@ class CinderCloudEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if(permanent != null && permanent.destroy(source.getSourceId(), game, false) && permanent.getColor(game).equals(ObjectColor.WHITE)) { if (permanent != null && permanent.destroy(source.getSourceId(), game, false) && permanent.getColor(game).equals(ObjectColor.WHITE)) {
int damage = permanent.getPower().getValue(); game.applyEffects();
Player player = game.getPlayer(permanent.getControllerId()); if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
if(player != null) { && !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
player.damage(damage, source.getSourceId(), game, false, true); // A replacement effect has moved the card to another zone as grvayard
return true;
}
Player permanentController = game.getPlayer(permanent.getControllerId());
if (permanentController != null) {
int damage = permanent.getPower().getValue();
permanentController.damage(damage, source.getSourceId(), game, false, true);
} }
} }
return false; return true;
} }
} }

View file

@ -44,7 +44,6 @@ import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.constants.WatcherScope; import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.filter.common.FilterInstantOrSorceryCard; import mage.filter.common.FilterInstantOrSorceryCard;
import mage.game.ExileZone; import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
@ -117,7 +116,8 @@ class JelevaNephaliasScourgeEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
player.moveCards(player.getLibrary().getTopCards(game, xValue), Zone.EXILED, source, game); //
player.moveCardsToExile(player.getLibrary().getTopCards(game, xValue), source, game, true, CardUtil.getCardExileZoneId(game, source), sourceObject.getIdName());
} }
} }
} }

View file

@ -327,20 +327,20 @@ public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase {
assertLife(playerA, 20); assertLife(playerA, 20);
assertLife(playerB, 20); assertLife(playerB, 20);
} }
@Test @Test
public void testJelevaCastingSavageBeatingFromExile() { public void testJelevaCastingSavageBeatingFromExile() {
/* /*
Jeleva, Nephalia's Scourge {1}{U}{B}{R} Jeleva, Nephalia's Scourge {1}{U}{B}{R}
Legendary Creature - Vampire Wizard 1/3 Legendary Creature - Vampire Wizard 1/3
Flying Flying
When Jeleva, Nephalia's Scourge enters the battlefield, each player exiles the top X cards of his or her library, where X is the amount of mana spent to cast Jeleva. When Jeleva, Nephalia's Scourge enters the battlefield, each player exiles the top X cards of his or her library, where X is the amount of mana spent to cast Jeleva.
Whenever Jeleva attacks, you may cast an instant or sorcery card exiled with it without paying its mana cost. Whenever Jeleva attacks, you may cast an instant or sorcery card exiled with it without paying its mana cost.
*/ */
String jeleva = "Jeleva, Nephalia's Scourge"; String jeleva = "Jeleva, Nephalia's Scourge";
/* /*
Savage Beating {3}{R}{R} Savage Beating {3}{R}{R}
Instant Instant
Cast Savage Beating only during your turn and only during combat. Cast Savage Beating only during your turn and only during combat.
@ -348,30 +348,31 @@ public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase {
- Creatures you control gain double strike until end of turn. - Creatures you control gain double strike until end of turn.
- Untap all creatures you control. After this phase, there is an additional combat phase. - Untap all creatures you control. After this phase, there is an additional combat phase.
Entwine {1}{R} (Choose both if you pay the entwine cost.) Entwine {1}{R} (Choose both if you pay the entwine cost.)
*/ */
String savageBeating = "Savage Beating"; String savageBeating = "Savage Beating";
skipInitShuffling(); skipInitShuffling();
addCard(Zone.LIBRARY, playerA, savageBeating); addCard(Zone.LIBRARY, playerA, savageBeating, 2);
addCard(Zone.HAND, playerA, jeleva); addCard(Zone.HAND, playerA, jeleva);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3); addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
addCard(Zone.BATTLEFIELD, playerA, "Island", 3); addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, jeleva); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, jeleva);
attack(3, playerA, jeleva); attack(3, playerA, jeleva);
setChoice(playerA, "Yes"); // opt to use Jeleva ability setChoice(playerA, "Yes"); // opt to use Jeleva ability
setChoice(playerA, savageBeating); // choose to cast Savage Beating for free setChoice(playerA, savageBeating); // choose to cast Savage Beating for free
setChoice(playerA, "No"); // opt not to pay entwine cost setChoice(playerA, "No"); // opt not to pay entwine cost
setModeChoice(playerA, "1"); // use first mode of Savage Beating granting double strike setModeChoice(playerA, "1"); // use first mode of Savage Beating granting double strike
setStopAt(3, PhaseStep.END_COMBAT); setStopAt(3, PhaseStep.END_COMBAT);
execute(); execute();
assertGraveyardCount(playerA, savageBeating, 1);
assertTapped(jeleva, true); assertTapped(jeleva, true);
assertLife(playerB, 18); assertLife(playerB, 18);
assertAbility(playerA, jeleva, DoubleStrikeAbility.getInstance(), true); assertAbility(playerA, jeleva, DoubleStrikeAbility.getInstance(), true);
assertGraveyardCount(playerA, savageBeating, 1);
} }
} }

View file

@ -64,7 +64,7 @@ public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility {
return false; return false;
} }
// check now it is in graveyard // check now it is in graveyard
if (before.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(source.getId())) { if (before.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(sourceId)) {
Zone after = game.getState().getZone(sourceId); Zone after = game.getState().getZone(sourceId);
return after != null && Zone.GRAVEYARD.match(after); return after != null && Zone.GRAVEYARD.match(after);
} else { } else {

View file

@ -1,55 +1,59 @@
/* /*
* To change this license header, choose License Headers in Project Properties. * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates * To change this template file, choose Tools | Templates
* and open the template in the editor. * and open the template in the editor.
*/ */
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
* *
* @author LevelX2 * @author LevelX2
*/ */
public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect { public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect {
SubType subtype = null; SubType subtype = null;
public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, boolean excludeSource) { public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, boolean excludeSource) {
super(power, toughness, duration, new FilterCreaturePermanent("All creatures of the chosen type"), excludeSource); super(power, toughness, duration, new FilterCreaturePermanent("All creatures of the chosen type"), excludeSource);
} }
public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) { public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
super(power, toughness, duration, filter, excludeSource); super(power, toughness, duration, filter, excludeSource);
} }
public BoostAllOfChosenSubtypeEffect(final BoostAllOfChosenSubtypeEffect effect) { public BoostAllOfChosenSubtypeEffect(final BoostAllOfChosenSubtypeEffect effect) {
super(effect); super(effect);
this.subtype = effect.subtype; this.subtype = effect.subtype;
} }
@Override @Override
public BoostAllOfChosenSubtypeEffect copy() { public BoostAllOfChosenSubtypeEffect copy() {
return new BoostAllOfChosenSubtypeEffect(this); return new BoostAllOfChosenSubtypeEffect(this);
} }
@Override @Override
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) { protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
if (subtype != null) { if (subtype != null) {
return permanent.hasSubtype(subtype, game); return permanent.hasSubtype(subtype, game);
} }
return false; return false;
} }
@Override @Override
protected void setRuntimeData(Ability source, Game game) { protected void setRuntimeData(Ability source, Game game) {
String s = (String) game.getState().getValue(source.getSourceId() + "_type"); String s = (String) game.getState().getValue(source.getSourceId() + "_type");
subtype = SubType.byDescription(s); if (subtype != null) {
} subtype = SubType.byDescription(s);
} else {
} discard();
}
}
}

View file

@ -953,8 +953,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
} }
if (!game.replaceEvent(GameEvent.getEvent(EventType.DESTROY_PERMANENT, objectId, sourceId, controllerId, noRegen ? 1 : 0))) { if (!game.replaceEvent(GameEvent.getEvent(EventType.DESTROY_PERMANENT, objectId, sourceId, controllerId, noRegen ? 1 : 0))) {
// this means destroy was successful, if object movement to graveyard will be replaced (e.g. commander to command zone) does not count for // this means destroy was successful, if object movement to graveyard will be replaced (e.g. commander to command zone) its still
// successful destroying. // is handled as successful destroying (but not as sucessful "dies this way" for destroying).
if (moveToZone(Zone.GRAVEYARD, sourceId, game, false)) { if (moveToZone(Zone.GRAVEYARD, sourceId, game, false)) {
if (!game.isSimulation()) { if (!game.isSimulation()) {
String logName; String logName;