mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
updated how Withering Wisps and limited use activated abilities are implemented
This commit is contained in:
parent
0c8032aa52
commit
79d4c07d20
2 changed files with 21 additions and 49 deletions
|
@ -31,7 +31,6 @@ import java.util.UUID;
|
||||||
import mage.abilities.ActivatedAbilityImpl;
|
import mage.abilities.ActivatedAbilityImpl;
|
||||||
import mage.abilities.TriggeredAbility;
|
import mage.abilities.TriggeredAbility;
|
||||||
import mage.abilities.common.OnEventTriggeredAbility;
|
import mage.abilities.common.OnEventTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
|
||||||
import mage.abilities.condition.common.CreatureCountCondition;
|
import mage.abilities.condition.common.CreatureCountCondition;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||||
|
@ -50,7 +49,6 @@ import mage.filter.FilterPermanent;
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
import mage.util.CardUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -61,7 +59,7 @@ public class WitheringWisps extends CardImpl {
|
||||||
private static final String ruleText = "At the beginning of the end step, if no creatures are on the battlefield, sacrifice {this}.";
|
private static final String ruleText = "At the beginning of the end step, if no creatures are on the battlefield, sacrifice {this}.";
|
||||||
|
|
||||||
public WitheringWisps(UUID ownerId, CardSetInfo setInfo) {
|
public WitheringWisps(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}{B}");
|
||||||
|
|
||||||
// At the beginning of the end step, if no creatures are on the battlefield, sacrifice Withering Wisps.
|
// At the beginning of the end step, if no creatures are on the battlefield, sacrifice Withering Wisps.
|
||||||
TriggeredAbility triggered = new OnEventTriggeredAbility(GameEvent.EventType.END_TURN_STEP_PRE, "beginning of the end step", true, new SacrificeSourceEffect());
|
TriggeredAbility triggered = new OnEventTriggeredAbility(GameEvent.EventType.END_TURN_STEP_PRE, "beginning of the end step", true, new SacrificeSourceEffect());
|
||||||
|
@ -83,63 +81,31 @@ public class WitheringWisps extends CardImpl {
|
||||||
|
|
||||||
class WitheringWispsActivatedAbility extends ActivatedAbilityImpl {
|
class WitheringWispsActivatedAbility extends ActivatedAbilityImpl {
|
||||||
|
|
||||||
static class ActivationInfo {
|
private static final FilterPermanent filter = new FilterPermanent("snow Swamps you control");
|
||||||
|
|
||||||
public int turnNum;
|
static {
|
||||||
public int activationCounter;
|
|
||||||
|
|
||||||
public ActivationInfo(int turnNum, int activationCounter) {
|
|
||||||
this.turnNum = turnNum;
|
|
||||||
this.activationCounter = activationCounter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final FilterPermanent filter = new FilterPermanent("snow lands you control");
|
|
||||||
{
|
|
||||||
filter.add(new SupertypePredicate(SuperType.SNOW));
|
filter.add(new SupertypePredicate(SuperType.SNOW));
|
||||||
filter.add(new SubtypePredicate(SubType.SWAMP));
|
filter.add(new SubtypePredicate(SubType.SWAMP));
|
||||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int maxActivationsPerTurn(Game game) {
|
@Override
|
||||||
|
public int getMaxActivationsPerTurn(Game game) {
|
||||||
return game.getBattlefield().getAllActivePermanents(filter, game).size();
|
return game.getBattlefield().getAllActivePermanents(filter, game).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WitheringWispsActivatedAbility() {
|
public WitheringWispsActivatedAbility() {
|
||||||
super(Zone.BATTLEFIELD, new DamageEverythingEffect(1), new ManaCostsImpl("{B}"));
|
super(Zone.BATTLEFIELD, new DamageEverythingEffect(1), new ManaCostsImpl("{B}"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WitheringWispsActivatedAbility(final WitheringWispsActivatedAbility ability) {
|
public WitheringWispsActivatedAbility(final WitheringWispsActivatedAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasMoreActivationsThisTurn(Game game) {
|
|
||||||
if (this.maxActivationsPerTurn(game) > 0) {
|
|
||||||
ActivationInfo activationInfo = getActivationInfo(game);
|
|
||||||
return activationInfo == null || activationInfo.turnNum != game.getTurnNum() || activationInfo.activationCounter < this.maxActivationsPerTurn(game);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ActivationInfo getActivationInfo(Game game) {
|
|
||||||
Integer turnNum = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsTurn" + originalId, sourceId, game));
|
|
||||||
Integer activationCount = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsCount" + originalId, sourceId, game));
|
|
||||||
if (turnNum == null || activationCount == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ActivationInfo(turnNum, activationCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean resolve(Game game) {
|
|
||||||
return super.resolve(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
StringBuilder sb = new StringBuilder(super.getRule()).append(" Activate this ability no more times each turn than the number of snow Swamps you control.");
|
return super.getRule() + " Activate this ability no more times each turn than the number of snow Swamps you control.";
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,7 +54,7 @@ import mage.util.CardUtil;
|
||||||
*/
|
*/
|
||||||
public abstract class ActivatedAbilityImpl extends AbilityImpl implements ActivatedAbility {
|
public abstract class ActivatedAbilityImpl extends AbilityImpl implements ActivatedAbility {
|
||||||
|
|
||||||
static class ActivationInfo {
|
protected static class ActivationInfo {
|
||||||
|
|
||||||
public int turnNum;
|
public int turnNum;
|
||||||
public int activationCounter;
|
public int activationCounter;
|
||||||
|
@ -276,11 +276,13 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasMoreActivationsThisTurn(Game game) {
|
protected boolean hasMoreActivationsThisTurn(Game game) {
|
||||||
if (maxActivationsPerTurn == Integer.MAX_VALUE) {
|
if (getMaxActivationsPerTurn(game) == Integer.MAX_VALUE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ActivationInfo activationInfo = getActivationInfo(game);
|
ActivationInfo activationInfo = getActivationInfo(game);
|
||||||
return activationInfo == null || activationInfo.turnNum != game.getTurnNum() || activationInfo.activationCounter < maxActivationsPerTurn;
|
return activationInfo == null
|
||||||
|
|| activationInfo.turnNum != game.getTurnNum()
|
||||||
|
|| activationInfo.activationCounter < getMaxActivationsPerTurn(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -307,7 +309,11 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
||||||
this.maxActivationsPerTurn = maxActivationsPerTurn;
|
this.maxActivationsPerTurn = maxActivationsPerTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivationInfo getActivationInfo(Game game) {
|
public int getMaxActivationsPerTurn(Game game) {
|
||||||
|
return maxActivationsPerTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ActivationInfo getActivationInfo(Game game) {
|
||||||
Integer turnNum = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsTurn" + originalId, sourceId, game));
|
Integer turnNum = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsTurn" + originalId, sourceId, game));
|
||||||
Integer activationCount = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsCount" + originalId, sourceId, game));
|
Integer activationCount = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsCount" + originalId, sourceId, game));
|
||||||
if (turnNum == null || activationCount == null) {
|
if (turnNum == null || activationCount == null) {
|
||||||
|
@ -316,7 +322,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
||||||
return new ActivationInfo(turnNum, activationCount);
|
return new ActivationInfo(turnNum, activationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setActivationInfo(ActivationInfo activationInfo, Game game) {
|
protected void setActivationInfo(ActivationInfo activationInfo, Game game) {
|
||||||
game.getState().setValue(CardUtil.getCardZoneString("activationsTurn" + originalId, sourceId, game), activationInfo.turnNum);
|
game.getState().setValue(CardUtil.getCardZoneString("activationsTurn" + originalId, sourceId, game), activationInfo.turnNum);
|
||||||
game.getState().setValue(CardUtil.getCardZoneString("activationsCount" + originalId, sourceId, game), activationInfo.activationCounter);
|
game.getState().setValue(CardUtil.getCardZoneString("activationsCount" + originalId, sourceId, game), activationInfo.activationCounter);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue