mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
[OGW] Fixed Surge to work with triggered abilities of permanents.
This commit is contained in:
parent
d4692d6371
commit
af5ff0f407
5 changed files with 60 additions and 11 deletions
|
|
@ -27,9 +27,11 @@
|
|||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.keyword.SurgeAbility;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
|
|
@ -52,7 +54,15 @@ public class SurgedCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// if surge is used for permanents we have to chnage implementation
|
||||
return source instanceof SurgeAbility;
|
||||
if (source.getAbilityType().equals(AbilityType.TRIGGERED)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<Integer> surgeActivations = (ArrayList) game.getState().getValue(SurgeAbility.SURGE_ACTIVATION_VALUE_KEY + source.getSourceId());
|
||||
if (surgeActivations != null) {
|
||||
return surgeActivations.contains(game.getState().getZoneChangeCounter(source.getSourceId()) - 1);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return source instanceof SurgeAbility;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
|
|
@ -43,6 +44,8 @@ import mage.watchers.common.CastSpellLastTurnWatcher;
|
|||
*/
|
||||
public class SurgeAbility extends SpellAbility {
|
||||
|
||||
public static final String SURGE_ACTIVATION_VALUE_KEY = "surgeActivation";
|
||||
|
||||
private String rule;
|
||||
|
||||
public SurgeAbility(Card card, String surgeCosts) {
|
||||
|
|
@ -81,6 +84,21 @@ public class SurgeAbility extends SpellAbility {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean activate(Game game, boolean noMana) {
|
||||
if (super.activate(game, noMana)) {
|
||||
ArrayList<Integer> surgeActivations = (ArrayList) game.getState().getValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId());
|
||||
if (surgeActivations == null) {
|
||||
surgeActivations = new ArrayList<>(); // zoneChangeCounter
|
||||
game.getState().setValue(SURGE_ACTIVATION_VALUE_KEY + getSourceId(), surgeActivations);
|
||||
}
|
||||
surgeActivations.add(game.getState().getZoneChangeCounter(getSourceId()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurgeAbility copy() {
|
||||
return new SurgeAbility(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue