* Fixed wrong event attributes for special action ACITIVATE_ABILITY event (see also 6753). Fixed that Phyrexian Revoker also prevented using special actions (fixes #6747).

This commit is contained in:
LevelX2 2020-06-30 15:34:29 +02:00
parent 83135f347f
commit 60cce5c11b
7 changed files with 35 additions and 20 deletions

View file

@ -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<String, Integer> symbolMap = new HashMap();
return card.getManaCost()
.getSymbols()

View file

@ -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);
}

View file

@ -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<Ability> 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;
}
}

View file

@ -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 &mdash; " + condition.getRule();
return "Companion &mdash; " + companionCondition.getRule();
}
public boolean isLegal(Set<Card> cards, int startingSize) {
return condition.isLegal(cards, startingSize);
return companionCondition.isLegal(cards, startingSize);
}
}

View file

@ -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

View file

@ -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,

View file

@ -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));
}