Fixed some problems with UUID comparing and some problems with card moving.

This commit is contained in:
LevelX2 2015-10-14 17:54:55 +02:00
parent 4d8263ff82
commit 52d0adcac1
45 changed files with 364 additions and 360 deletions

1
.gitignore vendored
View file

@ -90,3 +90,4 @@ Mage.Server.Plugins/Mage.Draft.8PlayerBooster/target
*.txt
Mage.Client/serverlist.txt
/bin/
/target/

View file

@ -184,7 +184,7 @@ public class GameView implements Serializable {
}
if (isPlayer) {
// has only to be set for active palyer with priority (e.g. pay mana by delve or Quenchable Fire special action)
if (state.getPriorityPlayerId() == createdForPlayerId && createdForPlayer != null) {
if (createdForPlayer != null && createdForPlayerId.equals(state.getPriorityPlayerId())) {
this.special = state.getSpecialActions().getControlledBy(state.getPriorityPlayerId(), createdForPlayer.isInPayManaMode()).size() > 0;
}
} else {

View file

@ -60,9 +60,6 @@ public class Thraximundar extends CardImpl {
this.subtype.add("Zombie");
this.subtype.add("Assassin");
this.power = new MageInt(6);
this.toughness = new MageInt(6);
@ -116,7 +113,8 @@ class ThraximundarTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId() == this.getSourceId()) {
if (event.getSourceId() != null
&& event.getSourceId().equals(this.getSourceId())) {
UUID defender = game.getCombat().getDefendingPlayerId(this.getSourceId(), game);
this.getEffects().get(0).setTargetPointer(new FixedTarget(defender));
return true;

View file

@ -25,13 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.apocalypse;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -41,6 +37,9 @@ import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.KickerAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -79,6 +78,7 @@ public class DesolationAngel extends CardImpl {
}
class DesolationAngelEntersBattlefieldEffect extends OneShotEffect {
DesolationAngelEntersBattlefieldEffect() {
super(Outcome.DestroyPermanent);
staticText = "destroy all lands you control. If it was kicked, destroy all lands instead";
@ -93,7 +93,7 @@ class DesolationAngelEntersBattlefieldEffect extends OneShotEffect {
Card p = game.getCard(source.getSourceId());
boolean kicked = KickedCondition.getInstance().apply(game, source);
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game)) {
if ((!kicked && permanent.getControllerId() == source.getControllerId())
if ((!kicked && permanent.getControllerId().equals(source.getControllerId()))
|| kicked) {
permanent.destroy(source.getSourceId(), game, false);
}

View file

@ -143,7 +143,9 @@ class UlamogAttackTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
if (sourcePermanent != null && event.getSourceId() == this.getSourceId()) {
if (sourcePermanent != null
&& event.getSourceId() != null
&& event.getSourceId().equals(this.getSourceId())) {
UUID defender = game.getCombat().getDefendingPlayerId(this.getSourceId(), game);
this.getEffects().get(0).setTargetPointer(new FixedTarget(defender));
return true;

View file

@ -105,7 +105,8 @@ class SpitefulReturnedTriggeredAbility extends TriggeredAbilityImpl {
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
if (sourcePermanent != null) {
if (sourcePermanent.getCardType().contains(CardType.CREATURE)) {
if (event.getSourceId() == this.getSourceId()) {
if (event.getSourceId() != null
&& event.getSourceId().equals(this.getSourceId())) {
UUID defender = game.getCombat().getDefendingPlayerId(this.getSourceId(), game);
this.getEffects().get(0).setTargetPointer(new FixedTarget(defender));
return true;

View file

@ -115,7 +115,10 @@ class HallOfTheBanditLordWatcher extends Watcher {
public void watch(GameEvent event, Game game) {
if (event.getType() == EventType.MANA_PAYED) {
MageObject target = game.getObject(event.getTargetId());
if (event.getSourceId() == this.getSourceId() && target != null && target.getCardType().contains(CardType.CREATURE) && event.getFlag()) {
if (event.getSourceId() != null
&& event.getSourceId().equals(this.getSourceId())
&& target != null && target.getCardType().contains(CardType.CREATURE)
&& event.getFlag()) {
if (target instanceof Spell) {
this.creatures.add(((Spell) target).getCard().getId());
}

View file

@ -25,14 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.championsofkamigawa;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleActivatedAbility;
@ -44,7 +39,10 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.Filter;
import mage.filter.common.FilterNonlandCard;
@ -83,7 +81,6 @@ public class NightDealings extends CardImpl {
return new NightDealings(this);
}
private class NightDealingsTriggeredAbility extends TriggeredAbilityImpl {
public NightDealingsTriggeredAbility() {
@ -110,7 +107,7 @@ public class NightDealings extends CardImpl {
if (this.getControllerId() != event.getTargetId()) {
// a source you control
UUID sourceControllerId = game.getControllerId(event.getSourceId());
if (sourceControllerId != null && sourceControllerId == this.getControllerId()) {
if (sourceControllerId != null && sourceControllerId.equals(this.getControllerId())) {
// save amount of damage to effect
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
return true;

View file

@ -32,8 +32,8 @@ import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.discard.DiscardControllerEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.discard.DiscardControllerEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -56,6 +56,7 @@ public class SiftThroughSands extends CardImpl {
private static final String rule = "If you've cast a spell named Peer Through Depths and a spell named Reach Through Mists this turn, you may search your library for a card named The Unspeakable, put it onto the battlefield, then shuffle your library";
private static final FilterCreatureCard filter = new FilterCreatureCard("a card named The Unspeakable");
static {
filter.add(new NamePredicate("The Unspeakable"));
}
@ -65,7 +66,6 @@ public class SiftThroughSands extends CardImpl {
this.expansionSetCode = "CHK";
this.subtype.add("Arcane");
// Draw two cards, then discard a card.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(2));
Effect effect = new DiscardControllerEffect(1);
@ -125,7 +125,7 @@ class SiftThroughSandsWatcher extends Watcher {
return;
}
if (event.getType() == EventType.SPELL_CAST
&& controllerId == event.getPlayerId()) {
&& controllerId.equals(event.getPlayerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell.getCard().getName().equals("Peer Through Depths")) {
castPeerThroughDepths = true;

View file

@ -44,8 +44,8 @@ import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.events.GameEvent.EventType;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
@ -98,7 +98,7 @@ class HibernationsEndAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getSourceId() == this.getSourceId();
return event.getSourceId() != null && event.getSourceId().equals(this.getSourceId());
}
@Override
@ -138,4 +138,3 @@ class HibernationsEndEffect extends OneShotEffect {
return false;
}
}

View file

@ -135,7 +135,7 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId() == source.getControllerId()) {
if (event.getPlayerId().equals(source.getControllerId())) {
MageObject spellObject = game.getObject(event.getSourceId());
if (spellObject != null) {
return spellObject.getCardType().contains(CardType.CREATURE);

View file

@ -94,7 +94,7 @@ class RubiniaSoulsingerCondition implements Condition {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.isTapped()) {
return controllerId == source.getControllerId();
return controllerId.equals(source.getControllerId());
}
}
return false;

View file

@ -61,7 +61,6 @@ public class InfernalOffering extends CardImpl {
super(ownerId, 24, "Infernal Offering", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{B}");
this.expansionSetCode = "C14";
// Choose an opponent. You and that player each sacrifice a creature. Each player who sacrificed a creature this way draws two cards.
this.getSpellAbility().addEffect(new InfernalOfferingSacrificeEffect());
@ -106,7 +105,7 @@ class InfernalOfferingSacrificeEffect extends OneShotEffect {
//Choose creatures to sacrifice
Map<UUID, UUID> toSacrifice = new HashMap<>(2);
for (UUID playerId : player.getInRange()) {
if (playerId == player.getId() || playerId == opponent.getId()) {
if (playerId.equals(player.getId()) || playerId.equals(opponent.getId())) {
target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true);
if (target.choose(Outcome.Sacrifice, playerId, source.getControllerId(), game)) {
toSacrifice.put(playerId, target.getFirstTarget());

View file

@ -93,7 +93,7 @@ class LichsTombTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId() == this.getControllerId()) {
if (event.getPlayerId().equals(this.getControllerId())) {
((SacrificeEffect) this.getEffects().get(0)).setAmount(new StaticValue(event.getAmount()));
return true;
}

View file

@ -98,6 +98,7 @@ class CastBlueSpellThisTurnCondition implements Condition {
class DreamThiefWatcher extends Watcher {
private static final FilterSpell filter = new FilterSpell();
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
}
@ -125,7 +126,7 @@ class DreamThiefWatcher extends Watcher {
return;
}
if (event.getType() == EventType.SPELL_CAST
&& controllerId == event.getPlayerId()) {
&& controllerId.equals(event.getPlayerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (!spell.getSourceId().equals(cardId) && filter.match(spell, game)) {
condition = true;

View file

@ -40,11 +40,13 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterLandCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.ExileZone;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import mage.util.CardUtil;
@ -58,7 +60,6 @@ public class EndlessHorizons extends CardImpl {
super(ownerId, 4, "Endless Horizons", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}");
this.expansionSetCode = "EVE";
// When Endless Horizons enters the battlefield, search your library for any number of Plains cards and exile them. Then shuffle your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new EndlessHorizonsEffect(), false));
@ -140,16 +141,23 @@ class EndlessHorizonsEffect extends SearchEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ExileZone exZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
if (exZone != null) {
for (Card card : exZone.getCards(game)) {
if (card.getOwnerId() == source.getControllerId()) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
break; // only one
}
Card card = null;
if (exZone.size() > 1) {
TargetCard target = new TargetCard(Zone.EXILED, new FilterCard());
controller.choose(outcome, exZone, target, game);
card = game.getCard(target.getFirstTarget());
} else {
card = exZone.getRandom(game);
}
controller.moveCards(card, null, Zone.HAND, source, game);
}
return true;
}
return false;
}
}

View file

@ -99,6 +99,7 @@ class CastRedSpellThisTurnCondition implements Condition {
class HotHeadedGiantWatcher extends Watcher {
private static final FilterSpell filter = new FilterSpell();
static {
filter.add(new ColorPredicate(ObjectColor.RED));
}
@ -126,7 +127,7 @@ class HotHeadedGiantWatcher extends Watcher {
return;
}
if (event.getType() == EventType.SPELL_CAST
&& controllerId == event.getPlayerId()) {
&& controllerId.equals(event.getPlayerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (!spell.getSourceId().equals(cardId) && filter.match(spell, game)) {
condition = true;

View file

@ -32,7 +32,6 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
@ -72,7 +71,6 @@ public class SoulReap extends CardImpl {
super(ownerId, 44, "Soul Reap", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}");
this.expansionSetCode = "EVE";
// Destroy target nongreen creature. Its controller loses 3 life if you've cast another black spell this turn.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
@ -134,7 +132,7 @@ class SoulReapWatcher extends Watcher {
return;
}
if (event.getType() == EventType.SPELL_CAST
&& controllerId == event.getPlayerId()) {
&& controllerId.equals(event.getPlayerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (!spell.getSourceId().equals(cardId) && filter.match(spell, game)) {
condition = true;

View file

@ -34,7 +34,6 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -159,7 +158,7 @@ class TalarasBattalionWatcher extends Watcher {
return;
}
if (event.getType() == EventType.SPELL_CAST
&& controllerId == event.getPlayerId()) {
&& controllerId.equals(event.getPlayerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (!spell.getSourceId().equals(cardId) && filter.match(spell, game)) {
condition = true;

View file

@ -99,7 +99,7 @@ class SoltariVisionaryTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent soltari = game.getPermanent(event.getSourceId());
if (soltari != null && soltari.getId() == this.getSourceId()) {
if (soltari != null && soltari.getId().equals(this.getSourceId())) {
FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("enchantment that player controls.");
filter.add(new ControllerIdPredicate(event.getPlayerId()));
filter.setMessage("enchantment controlled by " + game.getPlayer(event.getTargetId()).getLogName());

View file

@ -99,7 +99,7 @@ class MarduWoeReaperTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && (permanent.getId() == this.getSourceId() || permanent.hasSubtype("Warrior"))) {
if (permanent != null && (permanent.getId().equals(this.getSourceId()) || permanent.hasSubtype("Warrior"))) {
return true;
}
}

View file

@ -62,7 +62,6 @@ public class WardscaleDragon extends CardImpl {
// As long as Wardscale Dragon is attacking, defending player can't cast spells.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WardscaleDragonRuleEffect()));
}
public WardscaleDragon(final WardscaleDragon card) {
@ -105,7 +104,7 @@ class WardscaleDragonRuleEffect extends ContinuousRuleModifyingEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && sourcePermanent.isAttacking()) {
return event.getPlayerId() == game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game);
return event.getPlayerId().equals(game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game));
}
return false;
}

View file

@ -92,6 +92,7 @@ public class InstillEnergy extends CardImpl {
}
class CanAttackAsThoughItHadHasteEnchantedEffect extends AsThoughEffectImpl {
public CanAttackAsThoughItHadHasteEnchantedEffect(Duration duration) {
super(AsThoughEffectType.ATTACK, duration, Outcome.Benefit);
staticText = "Enchanted creature can attack as though it had haste";
@ -114,7 +115,7 @@ class CanAttackAsThoughItHadHasteEnchantedEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
return enchantment != null && enchantment.getAttachedTo() != null && enchantment.getAttachedTo() == objectId;
return enchantment != null && enchantment.getAttachedTo() != null && enchantment.getAttachedTo().equals(objectId);
}
}

View file

@ -52,14 +52,12 @@ public class Fastbond extends CardImpl {
super(ownerId, 101, "Fastbond", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{G}");
this.expansionSetCode = "LEA";
// You may play any number of additional lands on each of your turns.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayAdditionalLandsControllerEffect(Integer.MAX_VALUE, Duration.WhileOnBattlefield)));
// Whenever you play a land, if it wasn't the first land you played this turn, Fastbond deals 1 damage to you.
this.addAbility(new PlayALandTriggeredAbility());
}
public Fastbond(final Fastbond card) {
super(card);
}
@ -70,7 +68,6 @@ public class Fastbond extends CardImpl {
}
}
class PlayALandTriggeredAbility extends TriggeredAbilityImpl {
public PlayALandTriggeredAbility() {
@ -88,7 +85,7 @@ class PlayALandTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getPlayerId() == this.getControllerId();
return event.getPlayerId().equals(this.getControllerId());
}
@Override
@ -112,7 +109,4 @@ class PlayALandTriggeredAbility extends TriggeredAbilityImpl {
return "Whenever you play a land, if it wasn't the first land you played this turn, {source} deals 1 damage to you";
}
}

View file

@ -113,8 +113,8 @@ class GeneratorServantWatcher extends Watcher {
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
MageObject target = game.getObject(event.getTargetId());
MageObject source = game.getObject(this.getSourceId());
if (event.getSourceId() == this.getSourceId() && target != null && target.getCardType().contains(CardType.CREATURE) && event.getFlag()) {
if (event.getSourceId() != null
&& event.getSourceId().equals(this.getSourceId()) && target != null && target.getCardType().contains(CardType.CREATURE) && event.getFlag()) {
if (target instanceof Spell) {
this.creatures.add(((Spell) target).getCard().getId());
}

View file

@ -105,7 +105,9 @@ class SigilOfValorTriggeredAbility extends TriggeredAbilityImpl {
if (game.getCombat().attacksAlone()) {
Permanent equipment = game.getPermanent(getSourceId());
UUID attackerId = game.getCombat().getAttackers().get(0);
if (equipment != null && equipment.getAttachedTo() == attackerId) {
if (equipment != null
&& equipment.getAttachedTo() != null
&& equipment.getAttachedTo().equals(attackerId)) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(attackerId));
return true;
}

View file

@ -100,7 +100,7 @@ class ThoughtLashTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getSourceId() == this.getSourceId();
return event.getSourceId() != null && event.getSourceId().equals(this.getSourceId());
}
@Override

View file

@ -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.sets.planeshift;
import java.util.UUID;
@ -56,7 +55,6 @@ public class OrimsChant extends CardImpl {
super(ownerId, 11, "Orim's Chant", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{W}");
this.expansionSetCode = "PLS";
// Kicker {W} (You may pay an additional {W} as you cast this spell.)
this.addAbility(new KickerAbility("{W}"));
@ -97,12 +95,12 @@ class OrimsChantCantCastEffect extends ContinuousRuleModifyingEffectImpl {
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
return GameEvent.EventType.CAST_SPELL.equals(event.getType());
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getPlayerId() == getTargetPointer().getFirst(game, source);
return event.getPlayerId().equals(getTargetPointer().getFirst(game, source));
}
}

View file

@ -76,7 +76,6 @@ public class VraskaTheUnseen extends CardImpl {
this.expansionSetCode = "RTR";
this.subtype.add("Vraska");
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(5)), false));
// +1: Until your next turn, whenever a creature deals combat damage to Vraska the Unseen, destroy that creature.
@ -101,7 +100,6 @@ public class VraskaTheUnseen extends CardImpl {
}
}
class VraskaTheUnseenGainAbilityEffect extends ContinuousEffectImpl {
protected Ability ability;
@ -142,8 +140,7 @@ class VraskaTheUnseenGainAbilityEffect extends ContinuousEffectImpl {
@Override
public boolean isInactive(Ability source, Game game) {
if (startingTurn != 0 && game.getTurnNum() != startingTurn)
{
if (startingTurn != 0 && game.getTurnNum() != startingTurn) {
if (game.getActivePlayerId().equals(source.getControllerId())) {
return true;
}
@ -153,6 +150,7 @@ class VraskaTheUnseenGainAbilityEffect extends ContinuousEffectImpl {
}
class AssassinToken extends Token {
AssassinToken() {
super("Assassin", "1/1 black Assassin creature tokens with \"Whenever this creature deals combat damage to a player, that player loses the game.\"");
cardType.add(CardType.CREATURE);
@ -186,7 +184,7 @@ class VraskaTheUnseenTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedPlaneswalkerEvent) event).isCombatDamage() && event.getTargetId() == sourceId) {
if (((DamagedPlaneswalkerEvent) event).isCombatDamage() && getSourceId().equals(event.getTargetId())) {
Permanent sourceOfDamage = game.getPermanent(event.getSourceId());
if (sourceOfDamage != null && sourceOfDamage.getCardType().contains(CardType.CREATURE)) {
Effect effect = this.getEffects().get(0);

View file

@ -25,25 +25,24 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.scarsofmirrodin;
import mage.constants.CardType;
import mage.constants.Rarity;
import java.util.UUID;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author Loki
*/
public class RevokeExistence extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("artifact or enchantment");
static {
@ -56,6 +55,7 @@ public class RevokeExistence extends CardImpl {
super(ownerId, 18, "Revoke Existence", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{W}");
this.expansionSetCode = "SOM";
// Exile target artifact or enchantment.
this.getSpellAbility().addEffect(new ExileTargetEffect());
this.getSpellAbility().addTarget(new TargetPermanent(filter));
}

View file

@ -118,7 +118,8 @@ class MossbridgeTrollReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getTargetId() == source.getSourceId();
return event.getTargetId() != null
&& event.getTargetId().equals(source.getSourceId());
}
@Override
@ -178,4 +179,3 @@ class MossbridgeTrollCost extends CostImpl {
return new MossbridgeTrollCost(this);
}
}

View file

@ -50,7 +50,6 @@ public class ThoughtweftGambit extends CardImpl {
super(ownerId, 154, "Thoughtweft Gambit", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{4}{W/U}{W/U}");
this.expansionSetCode = "SHM";
// Tap all creatures your opponents control and untap all creatures you control.
this.getSpellAbility().addEffect(new ThoughtweftGambitEffect());
@ -94,7 +93,7 @@ class ThoughtweftGambitEffect extends OneShotEffect {
}
if (controller != null) {
for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (controller.getId() == creature.getControllerId()) {
if (controller.getId().equals(creature.getControllerId())) {
creature.untap(game);
}
}

View file

@ -52,10 +52,8 @@ public class GatherSpecimens extends CardImpl {
super(ownerId, 45, "Gather Specimens", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{3}{U}{U}{U}");
this.expansionSetCode = "ALA";
// If a creature would enter the battlefield under an opponent's control this turn, it enters the battlefield under your control instead.
this.getSpellAbility().addEffect(new GatherSpecimensReplacementEffect());
}
public GatherSpecimens(final GatherSpecimens card) {

View file

@ -94,7 +94,7 @@ class HelmOfPossessionCondition implements Condition {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.isTapped()) {
return controllerId == source.getControllerId();
return controllerId.equals(source.getControllerId());
}
}
return false;

View file

@ -100,7 +100,7 @@ class TuktukScrapperTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null) {
if (permanent.getId() == this.getSourceId()) {
if (permanent.getId().equals(this.getSourceId())) {
return true;
}
if (permanent.hasSubtype("Ally")

View file

@ -28,11 +28,6 @@
package mage.sets.worldwake;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
@ -42,6 +37,11 @@ import mage.abilities.keyword.IslandwalkAbility;
import mage.abilities.keyword.SwampwalkAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -50,7 +50,6 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.Target;
@ -160,11 +159,8 @@ class WrexialReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() == Zone.GRAVEYARD
&& ((ZoneChangeEvent) event).getTargetId() == cardid) {
return true;
}
return false;
return zEvent.getToZone() == Zone.GRAVEYARD
&& ((ZoneChangeEvent) event).getTargetId().equals(cardid);
}
@Override
@ -173,12 +169,8 @@ class WrexialReplacementEffect extends ReplacementEffectImpl {
StackObject card = game.getStack().getStackObject(eventObject);
Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) {
if (card instanceof Spell) {
game.rememberLKI(card.getId(), Zone.STACK, (Spell) card);
}
if (card instanceof Card) {
controller.moveCardToExileWithInfo((Card)card, null, "", source.getSourceId(), game, game.getState().getZone(event.getTargetId()), true);
return true;
return controller.moveCards((Card) card, null, Zone.EXILED, source, game);
}
}
return false;

View file

@ -90,6 +90,7 @@ public class OblivionRingTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.HAND, playerA, "Oblivion Ring");
addCard(Zone.BATTLEFIELD, playerA, "Jace Beleren");
// Exile target artifact or enchantment.
addCard(Zone.HAND, playerA, "Revoke Existence");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "-1: Target player draws a card", playerA);
@ -100,7 +101,10 @@ public class OblivionRingTest extends CardTestPlayerBase {
setStopAt(1, PhaseStep.END_TURN);
execute();
assertExileCount("Oblivion Ring", 1);
assertGraveyardCount(playerA, "Revoke Existence", 1);
assertPermanentCount(playerA, "Oblivion Ring", 0);
assertGraveyardCount(playerA, "Jace Beleren", 0);
assertPermanentCount(playerA, "Jace Beleren", 1); // returns back
assertHandCount(playerA, 2); // can use ability twice
}

View file

@ -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.abilities.common;
import mage.abilities.StaticAbility;
@ -45,9 +44,11 @@ public class EntersBattlefieldAbility extends StaticAbility {
public EntersBattlefieldAbility(Effect effect) {
this(effect, true);
}
/**
*
* @param effect effect that happens when the permanent enters the battlefield
* @param effect effect that happens when the permanent enters the
* battlefield
* @param showRule show the rule for this ability
*/
public EntersBattlefieldAbility(Effect effect, Boolean showRule) {
@ -57,16 +58,19 @@ public class EntersBattlefieldAbility extends StaticAbility {
public EntersBattlefieldAbility(Effect effect, String effectText) {
this(effect, null, true, null, effectText);
}
/**
*
* @param effect effect that happens when the permanent enters the battlefield
* @param effect effect that happens when the permanent enters the
* battlefield
* @param condition only if this condition is true, the effect will happen
* @param ruleVisible show the rule for this ability
* @param abilityRule rule for this ability (no text from effects will be added)
* @param abilityRule rule for this ability (no text from effects will be
* added)
* @param effectText this text will be used for the EnterBattlefieldEffect
*/
public EntersBattlefieldAbility(Effect effect, Condition condition, Boolean ruleVisible, String abilityRule, String effectText) {
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(effect, condition, effectText));
super(Zone.ALL, new EntersBattlefieldEffect(effect, condition, effectText));
this.setRuleVisible(ruleVisible);
this.abilityRule = abilityRule;
}

View file

@ -68,7 +68,7 @@ public class DiscardTargetCost extends CostImpl {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
this.cards.clear();
this.targets.clear();
this.targets.clearChosen();;
Player player = game.getPlayer(controllerId);
if (player == null) {
return false;

View file

@ -1246,7 +1246,7 @@ public class ContinuousEffects implements Serializable {
HashSet<Ability> abilities = preventionEffects.getAbility(effect.getId());
for (Ability ability : abilities) {
if (ability.getSourceId().equals(sourceId)) {
if (controllerFound == null || controllerFound == ability.getControllerId()) {
if (controllerFound == null || controllerFound.equals(ability.getControllerId())) {
controllerFound = ability.getControllerId();
} else {
// not unique controller - No solution yet
@ -1260,7 +1260,7 @@ public class ContinuousEffects implements Serializable {
for (Ability ability : abilities) {
if (ability.getSourceId() != null) {
if (ability.getSourceId().equals(sourceId)) {
if (controllerFound == null || controllerFound == ability.getControllerId()) {
if (controllerFound == null || controllerFound.equals(ability.getControllerId())) {
controllerFound = ability.getControllerId();
} else {
// not unique controller - No solution yet

View file

@ -101,8 +101,12 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
}
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved
if (returnToZone.equals(Zone.BATTLEFIELD)) {
controller.moveCards(exile.getCards(game), returnToZone, source, game, false, false, true, null);
} else {
controller.moveCards(exile, null, returnToZone, source, game);
}
}
return true;
}
return false;

View file

@ -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.abilities.keyword;
import java.util.UUID;
@ -48,27 +47,28 @@ import mage.game.stack.Spell;
import mage.players.Player;
/**
* This ability has no effect by default and will always return false on the call
* to apply. This is because of how the {@link ReboundEffect} works. It will
* install the effect if and only if the spell was cast from the {@link Zone#HAND Hand}.
* This ability has no effect by default and will always return false on the
* call to apply. This is because of how the {@link ReboundEffect} works. It
* will install the effect if and only if the spell was cast from the
* {@link Zone#HAND Hand}.
* <p/>
* 702.85. Rebound
* <p/>
* 702.85a Rebound appears on some instants and sorceries. It represents a static
* ability that functions while the spell is on the stack and may create a delayed
* triggered ability. "Rebound" means "If this spell was cast from your hand,
* instead of putting it into your graveyard as it resolves, exile it and, at
* the beginning of your next upkeep, you may cast this card from exile without
* paying its mana cost."
* 702.85a Rebound appears on some instants and sorceries. It represents a
* static ability that functions while the spell is on the stack and may create
* a delayed triggered ability. "Rebound" means "If this spell was cast from
* your hand, instead of putting it into your graveyard as it resolves, exile it
* and, at the beginning of your next upkeep, you may cast this card from exile
* without paying its mana cost."
* <p/>
* 702.85b Casting a card without paying its mana cost as the result of a rebound
* ability follows the rules for paying alternative costs in rules 601.2b and 601.2e-g.
* 702.85b Casting a card without paying its mana cost as the result of a
* rebound ability follows the rules for paying alternative costs in rules
* 601.2b and 601.2e-g.
* <p/>
* 702.85c Multiple instances of rebound on the same spell are redundant.
*
* @author maurer.it_at_gmail.com, noxx
*/
public class ReboundAbility extends SimpleStaticAbility {
public ReboundAbility() {
@ -103,9 +103,10 @@ class ReboundCastFromHandReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (((ZoneChangeEvent) event).getFromZone() == Zone.STACK &&
((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD &&
event.getSourceId() == source.getSourceId()) { // if countered the source.sourceId is different or null if it fizzles
if (((ZoneChangeEvent) event).getFromZone() == Zone.STACK
&& ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD
&& event.getSourceId() != null
&& event.getSourceId().equals(source.getSourceId())) { // if countered the source.sourceId is different or null if it fizzles
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && spell.getFromZone().equals(Zone.HAND)) {
return true;
@ -113,6 +114,7 @@ class ReboundCastFromHandReplacementEffect extends ReplacementEffectImpl {
}
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Spell sourceSpell = game.getStack().getSpell(source.getSourceId());
@ -144,7 +146,6 @@ class ReboundCastFromHandReplacementEffect extends ReplacementEffectImpl {
}
class ReboundEffectCastFromExileDelayedTrigger extends DelayedTriggeredAbility {
ReboundEffectCastFromExileDelayedTrigger(UUID cardId, UUID sourceId) {
@ -171,6 +172,7 @@ class ReboundEffectCastFromExileDelayedTrigger extends DelayedTriggeredAbility {
public boolean checkTrigger(GameEvent event, Game game) {
return MyTurnCondition.getInstance().apply(game, this);
}
@Override
public String getRule() {
return "Rebound - You may cast {this} from exile without paying its mana cost.";
@ -178,8 +180,8 @@ class ReboundEffectCastFromExileDelayedTrigger extends DelayedTriggeredAbility {
}
/**
* Will be triggered by {@link ReboundEffectCastFromExileDelayedTrigger} and will
* simply cast the spell then remove it from its former home in exile.
* Will be triggered by {@link ReboundEffectCastFromExileDelayedTrigger} and
* will simply cast the spell then remove it from its former home in exile.
*
* @author maurer.it_at_gmail.com
*/

View file

@ -507,8 +507,8 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
break;
case EXILED:
if (game.getExile().getCard(getId(), game) != null) {
game.getExile().removeCard(this, game);
removed = true;
removed = game.getExile().removeCard(this, game);
}
break;
case STACK:
@ -552,8 +552,9 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
+ "] source [" + (sourceObject != null ? sourceObject.getName() : "null") + "]");
break;
}
if (removed) {
game.rememberLKI(objectId, fromZone, lkiObject != null ? lkiObject : this);
if (!removed) {
} else {
logger.warn("Couldn't find card in fromZone, card=" + getIdName() + ", fromZone=" + fromZone);
}
return removed;

View file

@ -107,12 +107,13 @@ public class Exile implements Serializable, Copyable<Exile> {
return cards;
}
public void removeCard(Card card, Game game) {
public boolean removeCard(Card card, Game game) {
for (ExileZone exile : exileZones.values()) {
if (exile.contains(card.getId())) {
exile.remove(card);
return exile.remove(card.getId());
}
}
return false;
}
@Override

View file

@ -3052,7 +3052,7 @@ public abstract class PlayerImpl implements Player, Serializable {
ZoneChangeEvent event = new ZoneChangeEvent(card.getId(), source.getSourceId(), controllingPlayerId, fromZone, Zone.BATTLEFIELD, appliedEffects, tapped);
if (!game.replaceEvent(event)) {
// get permanent
Permanent permanent = new PermanentCard(card, controllingPlayerId, game);
Permanent permanent = new PermanentCard(card, event.getPlayerId(), game);// controlling player can be replaced so use event player now
permanents.add(permanent);
card.checkForCountersToAdd(permanent, game);
permanent.setTapped(tapped);