mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
[BRO] Implemented In the Trenches (#9704)
This commit is contained in:
parent
a246e729a9
commit
9410434f05
5 changed files with 115 additions and 27 deletions
|
|
@ -8,7 +8,6 @@ import mage.abilities.costs.Costs;
|
|||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.*;
|
||||
|
|
@ -29,14 +28,17 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
|
||||
public int turnNum;
|
||||
public int activationCounter;
|
||||
public int totalActivations;
|
||||
|
||||
public ActivationInfo(int turnNum, int activationCounter) {
|
||||
public ActivationInfo(int turnNum, int activationCounter, int totalActivations) {
|
||||
this.turnNum = turnNum;
|
||||
this.activationCounter = activationCounter;
|
||||
this.totalActivations = totalActivations;
|
||||
}
|
||||
}
|
||||
|
||||
protected int maxActivationsPerTurn = Integer.MAX_VALUE;
|
||||
protected int maxActivationsPerGame = Integer.MAX_VALUE;
|
||||
protected Condition condition;
|
||||
protected TimingRule timing = TimingRule.INSTANT;
|
||||
protected TargetController mayActivate = TargetController.YOU;
|
||||
|
|
@ -52,6 +54,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
mayActivate = ability.mayActivate;
|
||||
activatorId = ability.activatorId;
|
||||
maxActivationsPerTurn = ability.maxActivationsPerTurn;
|
||||
maxActivationsPerGame = ability.maxActivationsPerGame;
|
||||
condition = ability.condition;
|
||||
}
|
||||
|
||||
|
|
@ -243,12 +246,17 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
}
|
||||
|
||||
protected boolean hasMoreActivationsThisTurn(Game game) {
|
||||
if (getMaxActivationsPerTurn(game) == Integer.MAX_VALUE) {
|
||||
if (getMaxActivationsPerTurn(game) == Integer.MAX_VALUE && maxActivationsPerGame == Integer.MAX_VALUE) {
|
||||
return true;
|
||||
}
|
||||
ActivationInfo activationInfo = getActivationInfo(game);
|
||||
return activationInfo == null
|
||||
|| activationInfo.turnNum != game.getTurnNum()
|
||||
if (activationInfo == null) {
|
||||
return true;
|
||||
}
|
||||
if (activationInfo.totalActivations >= maxActivationsPerGame) {
|
||||
return false;
|
||||
}
|
||||
return activationInfo.turnNum != game.getTurnNum()
|
||||
|| activationInfo.activationCounter < getMaxActivationsPerTurn(game);
|
||||
}
|
||||
|
||||
|
|
@ -259,13 +267,14 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
}
|
||||
ActivationInfo activationInfo = getActivationInfo(game);
|
||||
if (activationInfo == null) {
|
||||
activationInfo = new ActivationInfo(game.getTurnNum(), 1);
|
||||
activationInfo = new ActivationInfo(game.getTurnNum(), 1, 0);
|
||||
} else if (activationInfo.turnNum != game.getTurnNum()) {
|
||||
activationInfo.turnNum = game.getTurnNum();
|
||||
activationInfo.activationCounter = 1;
|
||||
} else {
|
||||
activationInfo.activationCounter++;
|
||||
}
|
||||
activationInfo.totalActivations++;
|
||||
setActivationInfo(activationInfo, game);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -285,10 +294,12 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
.getValue(CardUtil.getCardZoneString("activationsTurn" + originalId, sourceId, game));
|
||||
Integer activationCount = (Integer) game.getState()
|
||||
.getValue(CardUtil.getCardZoneString("activationsCount" + originalId, sourceId, game));
|
||||
if (turnNum == null || activationCount == null) {
|
||||
Integer totalActivations = (Integer) game.getState()
|
||||
.getValue(CardUtil.getCardZoneString("totalActivations" + originalId, sourceId, game));
|
||||
if (turnNum == null || activationCount == null || totalActivations == null) {
|
||||
return null;
|
||||
}
|
||||
return new ActivationInfo(turnNum, activationCount);
|
||||
return new ActivationInfo(turnNum, activationCount, totalActivations);
|
||||
}
|
||||
|
||||
protected void setActivationInfo(ActivationInfo activationInfo, Game game) {
|
||||
|
|
@ -296,5 +307,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
.getCardZoneString("activationsTurn" + originalId, sourceId, game), activationInfo.turnNum);
|
||||
game.getState().setValue(CardUtil
|
||||
.getCardZoneString("activationsCount" + originalId, sourceId, game), activationInfo.activationCounter);
|
||||
game.getState().setValue(CardUtil
|
||||
.getCardZoneString("totalActivations" + originalId, sourceId, game), activationInfo.totalActivations);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public class ActivateOncePerGameActivatedAbility extends ActivatedAbilityImpl {
|
||||
|
||||
public ActivateOncePerGameActivatedAbility(Zone zone, Effect effect, Cost cost, TimingRule timingRule) {
|
||||
super(zone, effect, cost);
|
||||
this.timing = timingRule;
|
||||
this.maxActivationsPerGame = 1;
|
||||
}
|
||||
|
||||
private ActivateOncePerGameActivatedAbility(final ActivateOncePerGameActivatedAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivateOncePerGameActivatedAbility copy() {
|
||||
return new ActivateOncePerGameActivatedAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder(super.getRule());
|
||||
sb.append(" Activate ");
|
||||
if (this.timing == TimingRule.SORCERY) {
|
||||
sb.append("only as a sorcery and ");
|
||||
}
|
||||
sb.append("only once.");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue