Skip to content

Commit

Permalink
Some changes related to #4893.
Browse files Browse the repository at this point in the history
  • Loading branch information
LevelX2 committed May 2, 2018
1 parent 9919a34 commit cddd811
Show file tree
Hide file tree
Showing 37 changed files with 245 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ public static String generateTokenImagePath(CardDownloadData card) {
pathCache.put(card, filePath);
return filePath;
}

log.warn("Token image file not found. Set: " + card.getSet() + " Token Set Code: " + card.getTokenSetCode() + " Name: " + card.getName() + " File path: " + filePath);
} else {
log.warn("Trying to get token path for non token card. Set: " + card.getSet() + " Set Code: " + card.getTokenSetCode() + " Name: " + card.getName());
}
log.warn("Token image file not found: " + card.getSet() + " - " + card.getTokenSetCode() + " - " + card.getName());
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ protected void resolve(SimulationNode2 node, int depth, Game game) {
}
stackObject.resolve(game);
if (stackObject instanceof StackAbility) {
game.getStack().remove(stackObject);
game.getStack().remove(stackObject, game);
}
game.applyEffects();
game.getPlayers().resetPassed();
Expand Down Expand Up @@ -968,7 +968,7 @@ protected final void getSuggestedActions() {
// swallow
e.printStackTrace();
} finally {
if(scanner != null) {
if (scanner != null) {
scanner.close();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Mage.Sets/src/mage/cards/n/NorinTheWary.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class NorinTheWary extends CardImpl {

public NorinTheWary(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WARRIOR);
Expand Down Expand Up @@ -94,7 +94,7 @@ public boolean checkTrigger(GameEvent event, Game game) {

@Override
public String getRule() {
return new StringBuilder("When a player casts a spell or a creature attacks, ").append(super.getRule()).toString();
return "When a player casts a spell or a creature attacks, " + super.getRule();
}

@Override
Expand Down
14 changes: 7 additions & 7 deletions Mage.Sets/src/mage/cards/u/UndeadLeotau.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/

package mage.cards.u;

import java.util.UUID;
Expand All @@ -37,8 +36,8 @@
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;

/**
Expand All @@ -47,21 +46,22 @@
*/
public class UndeadLeotau extends CardImpl {

public UndeadLeotau (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{B}");
public UndeadLeotau(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{B}");
this.subtype.add(SubType.ZOMBIE);
this.subtype.add(SubType.CAT);

this.power = new MageInt(3);
this.toughness = new MageInt(4);

// {R}: Undead Leotau gets +1/-1 until end of turn.
// Unearth {2}{B}
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(+1, -1, Duration.EndOfTurn), new ManaCostsImpl("{R}")));

// Unearth {2}{B}
this.addAbility(new UnearthAbility(new ManaCostsImpl("{2}{B}")));
}

public UndeadLeotau (final UndeadLeotau card) {
public UndeadLeotau(final UndeadLeotau card) {
super(card);
}

Expand Down
11 changes: 6 additions & 5 deletions Mage.Sets/src/mage/cards/v/VoiceOfAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;

/**
Expand All @@ -48,17 +48,18 @@
public class VoiceOfAll extends CardImpl {

public VoiceOfAll(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}");
this.subtype.add(SubType.ANGEL);
this.power = new MageInt(2);
this.toughness = new MageInt(2);

// Flying
this.addAbility(FlyingAbility.getInstance());

// As Voice of All enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit)));


// Voice of All has protection from the chosen color.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ProtectionChosenColorSourceEffect()));
}

Expand All @@ -70,4 +71,4 @@ public VoiceOfAll(final VoiceOfAll card) {
public VoiceOfAll copy() {
return new VoiceOfAll(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;

import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;

/**
* @author noxx
Expand Down Expand Up @@ -179,6 +176,9 @@ public void testCopyAlreadyTransformed() {
@Test
public void testCopyEntersTapped() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
// You may have Phantasmal Image enter the battlefield as a copy of any creature
// on the battlefield, except it's an Illusion in addition to its other types and
// it gains "When this creature becomes the target of a spell or ability, sacrifice it."
addCard(Zone.HAND, playerA, "Phantasmal Image");
addCard(Zone.BATTLEFIELD, playerB, "Geralf's Messenger");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

/**
* Harm's Way: The next 2 damage that a source of your choice would deal to you
* and/or permanents you control this turn is dealt to any target
* instead.
* and/or permanents you control this turn is dealt to any target instead.
*
* @author noxx
*/
Expand All @@ -23,7 +22,7 @@ public void testRedirectTwoDamage() {
addCard(Zone.HAND, playerA, "Lightning Bolt");
addCard(Zone.BATTLEFIELD, playerA, "Mountain");

addCard(Zone.HAND, playerB, "Harm's Way");
addCard(Zone.HAND, playerB, "Harm's Way"); // Instant {W}
addCard(Zone.BATTLEFIELD, playerB, "Plains");

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
Expand All @@ -33,6 +32,9 @@ public void testRedirectTwoDamage() {
setStopAt(1, PhaseStep.END_TURN);
execute();

assertGraveyardCount(playerA, "Lightning Bolt", 1);
assertGraveyardCount(playerB, "Harm's Way", 1);

// 2 damage was redirected back
assertLife(playerA, 18);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;

Expand Down
4 changes: 3 additions & 1 deletion Mage/src/main/java/mage/abilities/AbilityImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public UUID getId() {
public void newId() {
if (!(this instanceof MageSingleton)) {
this.id = UUID.randomUUID();
// this.sourceObject = null;
// this.sourceObjectZoneChangeCounter = -1;
}
getEffects().newId();
}
Expand Down Expand Up @@ -1211,7 +1213,7 @@ public MageObject getSourceObjectIfItStillExists(Game game) {

@Override
public Permanent getSourcePermanentIfItStillExists(Game game) {
if (sourceObject == null) {
if (sourceObject == null || !sourceObject.getId().equals(getSourceId())) {
setSourceObject(game.getObject(getSourceId()), game);
}
if (sourceObject instanceof Permanent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId,
}
String spellName = spellToExile.getName();
if (spellToExile.isCopy()) {
game.getStack().remove(spellToExile);
game.getStack().remove(spellToExile, game);
} else {
spellToExile.moveToExile(null, "", ability.getSourceId(), game);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common;

import java.util.Objects;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
Expand All @@ -36,8 +37,6 @@
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;

import java.util.Objects;

/**
*
* @author jeffwadsworth
Expand Down Expand Up @@ -67,6 +66,17 @@ public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.REGENERATE;
}

@Override
public void init(Ability source, Game game) {
super.init(source, game); //To change body of generated methods, choose Tools | Templates.
if (duration.isOnlyValidIfNoZoneChange()) {
// If source permanent is no longer onto battlefield discard the effect
if (source.getSourcePermanentIfItStillExists(game) == null) {
discard();
}
}
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return Objects.equals(source.getSourceId(), event.getTargetId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public DestroySourceEffect copy() {

@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null) {
permanent.destroy(source.getSourceId(), game, noRegen);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common;

import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
Expand All @@ -50,21 +51,19 @@ public FightTargetSourceEffect(final FightTargetSourceEffect effect) {

@Override
public boolean apply(Game game, Ability source) {
Permanent originalPermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (originalPermanent != null) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
// only if target is legal the effect will be applied
if (source.getTargets().get(0).isLegal(source, game)) {
Permanent creature1 = game.getPermanent(source.getTargets().get(0).getFirstTarget());
// 20110930 - 701.10
if (creature1 != null && sourcePermanent != null) {
if (creature1.isCreature() && sourcePermanent.isCreature()) {
return sourcePermanent.fight(creature1, source, game);
}
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
Permanent creature1 = game.getPermanent(getTargetPointer().getFirst(game, source));
// 20110930 - 701.10
if (creature1 != null && sourcePermanent != null) {
if (creature1.isCreature() && sourcePermanent.isCreature()) {
return sourcePermanent.fight(creature1, source, game);
}
}
if (!game.isSimulation())
game.informPlayers(originalPermanent.getLogName() + ": Fighting effect has been fizzled.");
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ": Fighting effect has been fizzled.");
}
}
return false;
}
Expand All @@ -83,4 +82,3 @@ public String getText(Mode mode) {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.players.Player;


/**
* @author Loki
*/
Expand All @@ -33,14 +31,15 @@ public FlipSourceEffect(final FlipSourceEffect effect) {

@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
Player controller = game.getPlayer(source.getControllerId());
if (permanent != null && controller != null) {
if (permanent.flip(game)) {
ContinuousEffect effect = new ConditionalContinuousEffect(new CopyTokenEffect(flipToken), FlippedCondition.instance, "");
game.addEffect(effect, source);
if (!game.isSimulation())
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(controller.getLogName()).append(" flips ").append(permanent.getName()).toString());
}
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package mage.abilities.effects.common;

import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
Expand Down Expand Up @@ -34,9 +33,8 @@ public PhaseOutSourceEffect copy() {

@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (sourceObject instanceof Permanent) {
Permanent permanent = (Permanent) sourceObject;
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null) {
return permanent.phaseOut(game);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ public PreventDamageToSourceEffect copy() {
return new PreventDamageToSourceEffect(this);
}

@Override
public void init(Ability source, Game game) {
super.init(source, game); //To change body of generated methods, choose Tools | Templates.
if (duration.isOnlyValidIfNoZoneChange()) {
// If source permanent is no longer onto battlefield discard the effect
if (source.getSourcePermanentIfItStillExists(game) == null) {
discard();
}
}
}

@Override
public boolean apply(Game game, Ability source) {
return true;
Expand Down

0 comments on commit cddd811

Please sign in to comment.