diff --git a/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java b/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java index f8e6648a202..f173e108161 100644 --- a/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java +++ b/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java @@ -67,7 +67,7 @@ enum JeganthaTheWellspringCompanionCondition implements CompanionCondition { return deck.stream().noneMatch(JeganthaTheWellspringCompanionCondition::checkCard); } - private static final boolean checkCard(Card card) { + private static boolean checkCard(Card card) { Map symbolMap = new HashMap(); return card.getManaCost() .getSymbols() diff --git a/Mage.Sets/src/mage/cards/k/KaheeraTheOrphanguard.java b/Mage.Sets/src/mage/cards/k/KaheeraTheOrphanguard.java index b43acab4f86..da1aa2f6060 100644 --- a/Mage.Sets/src/mage/cards/k/KaheeraTheOrphanguard.java +++ b/Mage.Sets/src/mage/cards/k/KaheeraTheOrphanguard.java @@ -91,7 +91,7 @@ enum KaheeraTheOrphanguardCompanionCondition implements CompanionCondition { SubType.BEAST ); - private static final boolean checkTypes(Card card) { + private static boolean checkTypes(Card card) { return subtypes.stream().anyMatch(card.getSubtype(null)::contains); } diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java b/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java index b68174a304d..2ca284b7372 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianRevoker.java @@ -1,5 +1,6 @@ package mage.cards.p; +import java.util.Optional; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -14,7 +15,6 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.util.CardUtil; - import java.util.UUID; /** @@ -43,7 +43,6 @@ public final class PhyrexianRevoker extends CardImpl { public PhyrexianRevoker copy() { return new PhyrexianRevoker(this); } - } class PhyrexianRevokerEffect2 extends ContinuousRuleModifyingEffectImpl { @@ -79,11 +78,16 @@ class PhyrexianRevokerEffect2 extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.ACTIVATE_ABILITY) { - MageObject object = game.getObject(event.getSourceId()); - String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); - return CardUtil.haveSameNames(object, cardName, game); + MageObject object = game.getObject(event.getSourceId()); // Can happen for special ability???? + if (object != null) { + Optional optAbility = object.getAbilities().get(event.getTargetId()); + if (optAbility.isPresent() && AbilityType.SPECIAL_ACTION == optAbility.get().getAbilityType()) { + return false; + } + String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); + return CardUtil.haveSameNames(object, cardName, game); + } } return false; } - } diff --git a/Mage/src/main/java/mage/abilities/keyword/CompanionAbility.java b/Mage/src/main/java/mage/abilities/keyword/CompanionAbility.java index bffb8ea9441..dff4f8dcfb1 100644 --- a/Mage/src/main/java/mage/abilities/keyword/CompanionAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/CompanionAbility.java @@ -14,11 +14,11 @@ import java.util.Set; */ public class CompanionAbility extends SpecialAction { - private final CompanionCondition condition; + private final CompanionCondition companionCondition; - public CompanionAbility(CompanionCondition condition) { + public CompanionAbility(CompanionCondition companionCondition) { super(Zone.OUTSIDE); - this.condition = condition; + this.companionCondition = companionCondition; this.addCost(new GenericManaCost(3)); this.addEffect(new CompanionEffect()); this.setTiming(TimingRule.SORCERY); @@ -26,7 +26,7 @@ public class CompanionAbility extends SpecialAction { private CompanionAbility(final CompanionAbility ability) { super(ability); - this.condition = ability.condition; + this.companionCondition = ability.companionCondition; } @Override @@ -36,11 +36,11 @@ public class CompanionAbility extends SpecialAction { @Override public String getRule() { - return "Companion — " + condition.getRule(); + return "Companion — " + companionCondition.getRule(); } public boolean isLegal(Set cards, int startingSize) { - return condition.isLegal(cards, startingSize); + return companionCondition.isLegal(cards, startingSize); } } diff --git a/Mage/src/main/java/mage/game/GameImpl.java b/Mage/src/main/java/mage/game/GameImpl.java index 90a360c0702..6f517a25181 100644 --- a/Mage/src/main/java/mage/game/GameImpl.java +++ b/Mage/src/main/java/mage/game/GameImpl.java @@ -353,7 +353,7 @@ public abstract class GameImpl implements Game, Serializable { // can be an ability of a sacrificed Token trying to get it's source object object = getLastKnownInformation(objectId, Zone.BATTLEFIELD); } - + return object; } @@ -1548,7 +1548,7 @@ public abstract class GameImpl implements Game, Serializable { /** * @param emblem * @param sourceObject - * @param toPlayerId controller and owner of the emblem + * @param toPlayerId controller and owner of the emblem */ @Override public void addEmblem(Emblem emblem, MageObject sourceObject, UUID toPlayerId) { @@ -1566,8 +1566,8 @@ public abstract class GameImpl implements Game, Serializable { /** * @param plane * @param sourceObject - * @param toPlayerId controller and owner of the plane (may only be one per - * game..) + * @param toPlayerId controller and owner of the plane (may only be one + * per game..) * @return boolean - whether the plane was added successfully or not */ @Override diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 9af64c0c37c..b7d352af3c3 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -149,6 +149,17 @@ public class GameEvent implements Serializable { */ SPELL_CAST, ACTIVATE_ABILITY, ACTIVATED_ABILITY, + /* ACTIVATE_ABILITY, ACTIVATED_ABILITY, + targetId id of the ability to activate / use + sourceId sourceId of the object with that ability + playerId player that tries to use this ability + */ + TAKE_SPECIAL_ACTION, TAKEN_SPECIAL_ACTION, // not used in implementation yet + /* TAKE_SPECIAL_ACTION, TAKEN_SPECIAL_ACTION, + targetId id of the ability to activate / use + sourceId sourceId of the object with that ability + playerId player that tries to use this ability + */ TRIGGERED_ABILITY, RESOLVING_ABILITY, COPY_STACKOBJECT, COPIED_STACKOBJECT, diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 7842874ad7f..29be0c4b63a 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -1346,11 +1346,11 @@ public abstract class PlayerImpl implements Player, Serializable { protected boolean specialAction(SpecialAction action, Game game) { //20091005 - 114 if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, - action.getSourceId(), action.getId(), playerId))) { + action.getId(), action.getSourceId(), getId()))) { int bookmark = game.bookmarkState(); if (action.activate(game, false)) { game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATED_ABILITY, - action.getSourceId(), action.getId(), playerId)); + action.getId(), action.getSourceId(), getId())); if (!game.isSimulation()) { game.informPlayers(getLogName() + action.getGameLogMessage(game)); }