mirror of
https://github.com/correl/mage.git
synced 2024-12-29 11:09:17 +00:00
rework effects which increase loyalty abilities (closes #9626)
This commit is contained in:
parent
3fd3cb27e2
commit
09797d4cf6
9 changed files with 59 additions and 98 deletions
|
@ -11,6 +11,7 @@ import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetE
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
|
@ -112,21 +113,13 @@ class OathOfTeferiLoyaltyEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
controller.setLoyaltyUsePerTurn(Math.max(2, controller.getLoyaltyUsePerTurn()));
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER,
|
||||
source.getControllerId(), source, game
|
||||
)) {
|
||||
permanent.incrementLoyaltyActivationsAvailable(2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.RulesEffects;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
|
||||
package mage.cards.t;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
|
@ -16,30 +12,36 @@ import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class TheChainVeil extends CardImpl {
|
||||
|
||||
public TheChainVeil(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
|
||||
// At the beginning of your end step, if you didn't activate a loyalty ability of a planeswalker this turn, you lose 2 life.
|
||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(
|
||||
Zone.BATTLEFIELD, new LoseLifeSourceControllerEffect(2), TargetController.YOU, TheChainVeilCondition.instance, false), new ActivatedLoyaltyAbilityWatcher());
|
||||
new LoseLifeSourceControllerEffect(2), TargetController.YOU,
|
||||
TheChainVeilCondition.instance, false
|
||||
), new ActivatedLoyaltyAbilityWatcher());
|
||||
|
||||
// {4}, {T}: For each planeswalker you control, you may activate one of its loyalty abilities once this turn as though none of its loyalty abilities had been activated this turn.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new TheChainVeilIncreaseLoyaltyUseEffect(),
|
||||
new ManaCostsImpl<>("{4}"));
|
||||
Ability ability = new SimpleActivatedAbility(
|
||||
new TheChainVeilIncreaseLoyaltyUseEffect(), new ManaCostsImpl<>("{4}")
|
||||
);
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
@ -65,13 +67,14 @@ class ActivatedLoyaltyAbilityWatcher extends Watcher {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
|
||||
StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
|
||||
if (stackObject != null
|
||||
&& stackObject.getStackAbility() != null
|
||||
&& stackObject.getStackAbility() instanceof LoyaltyAbility) {
|
||||
playerIds.add(stackObject.getControllerId());
|
||||
}
|
||||
if (event.getType() != GameEvent.EventType.ACTIVATED_ABILITY) {
|
||||
return;
|
||||
}
|
||||
StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
|
||||
if (stackObject != null
|
||||
&& stackObject.getStackAbility() != null
|
||||
&& stackObject.getStackAbility() instanceof LoyaltyAbility) {
|
||||
playerIds.add(stackObject.getControllerId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,9 +106,11 @@ class TheChainVeilIncreaseLoyaltyUseEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
controller.setLoyaltyUsePerTurn(controller.getLoyaltyUsePerTurn() + 1);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER,
|
||||
source.getControllerId(), source, game
|
||||
)) {
|
||||
permanent.incrementLoyaltyActivationsAvailable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -122,26 +127,16 @@ class TheChainVeilIncreaseLoyaltyUseEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
enum TheChainVeilCondition implements Condition {
|
||||
|
||||
instance;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ActivatedLoyaltyAbilityWatcher watcher = game.getState().getWatcher(ActivatedLoyaltyAbilityWatcher.class);
|
||||
if (watcher != null) {
|
||||
if (!watcher.activatedLoyaltyAbility(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return watcher != null && !watcher.activatedLoyaltyAbility(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if you didn't activate a loyalty ability of a planeswalker this turn";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
package mage.cards.u;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SagaAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.*;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterPlaneswalkerCard;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public final class UrzaAssemblesTheTitans extends CardImpl {
|
||||
|
@ -110,11 +111,12 @@ class UrzaAssemblesTheTitansLoyaltyEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_CONTROLLED_PERMANENT_PLANESWALKER,
|
||||
source.getControllerId(), source, game
|
||||
)) {
|
||||
permanent.incrementLoyaltyActivationsAvailable(2);
|
||||
}
|
||||
controller.setLoyaltyUsePerTurn(Math.max(2, controller.getLoyaltyUsePerTurn()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3352,16 +3352,6 @@ public class TestPlayer implements Player {
|
|||
computerPlayer.setLandsPerTurn(landsPerTurn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoyaltyUsePerTurn() {
|
||||
return computerPlayer.getLoyaltyUsePerTurn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoyaltyUsePerTurn(int loyaltyUsePerTurn) {
|
||||
computerPlayer.setLoyaltyUsePerTurn(loyaltyUsePerTurn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHandSize() {
|
||||
return computerPlayer.getMaxHandSize();
|
||||
|
|
|
@ -275,16 +275,6 @@ public class PlayerStub implements Player {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoyaltyUsePerTurn() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoyaltyUsePerTurn(int loyaltyUsePerTurn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHandSize() {
|
||||
return 0;
|
||||
|
|
|
@ -216,6 +216,8 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
void incrementLoyaltyActivationsAvailable();
|
||||
|
||||
void incrementLoyaltyActivationsAvailable(int max);
|
||||
|
||||
void addLoyaltyUsed();
|
||||
|
||||
boolean canLoyaltyBeUsed(Game game);
|
||||
|
|
|
@ -467,7 +467,14 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
|
||||
@Override
|
||||
public void incrementLoyaltyActivationsAvailable() {
|
||||
this.loyaltyActivationsAvailable++;
|
||||
this.incrementLoyaltyActivationsAvailable(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementLoyaltyActivationsAvailable(int max) {
|
||||
if (this.loyaltyActivationsAvailable < max) {
|
||||
this.loyaltyActivationsAvailable++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -479,7 +486,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
public boolean canLoyaltyBeUsed(Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
return Math.max(controller.getLoyaltyUsePerTurn(), loyaltyActivationsAvailable) > timesLoyaltyUsed;
|
||||
return loyaltyActivationsAvailable > timesLoyaltyUsed;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
* Enum used to indicate what each player is allowed to spend life on.
|
||||
* By default it is set to `allAbilities`, but can be changed by effects.
|
||||
* E.g. Angel of Jubilation sets it to `nonSpellnonActivatedAbilities`,
|
||||
* and Karn's Sylex sets it to `onlyManaAbilities`.
|
||||
*
|
||||
*
|
||||
* and Karn's Sylex sets it to `onlyManaAbilities`.
|
||||
* <p>
|
||||
* <p>
|
||||
* Default is PayLifeCostLevel.allAbilities.
|
||||
*/
|
||||
enum PayLifeCostLevel {
|
||||
|
@ -215,10 +215,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void setLandsPerTurn(int landsPerTurn);
|
||||
|
||||
int getLoyaltyUsePerTurn();
|
||||
|
||||
void setLoyaltyUsePerTurn(int loyaltyUsePerTurn);
|
||||
|
||||
int getMaxHandSize();
|
||||
|
||||
void setMaxHandSize(int maxHandSize);
|
||||
|
|
|
@ -94,7 +94,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
protected Counters counters;
|
||||
protected int landsPlayed;
|
||||
protected int landsPerTurn = 1;
|
||||
protected int loyaltyUsePerTurn = 1;
|
||||
protected int maxHandSize = 7;
|
||||
protected int maxAttackedBy = Integer.MAX_VALUE;
|
||||
protected ManaPool manaPool;
|
||||
|
@ -225,7 +224,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
this.landsPlayed = player.landsPlayed;
|
||||
this.landsPerTurn = player.landsPerTurn;
|
||||
this.loyaltyUsePerTurn = player.loyaltyUsePerTurn;
|
||||
this.maxHandSize = player.maxHandSize;
|
||||
this.maxAttackedBy = player.maxAttackedBy;
|
||||
this.manaPool = player.manaPool.copy();
|
||||
|
@ -326,7 +324,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
this.landsPlayed = player.getLandsPlayed();
|
||||
this.landsPerTurn = player.getLandsPerTurn();
|
||||
this.loyaltyUsePerTurn = player.getLoyaltyUsePerTurn();
|
||||
this.maxHandSize = player.getMaxHandSize();
|
||||
this.maxAttackedBy = player.getMaxAttackedBy();
|
||||
this.manaPool = player.getManaPool().copy();
|
||||
|
@ -464,7 +461,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
public void reset() {
|
||||
this.abilities.clear();
|
||||
this.landsPerTurn = 1;
|
||||
this.loyaltyUsePerTurn = 1;
|
||||
this.maxHandSize = 7;
|
||||
this.maxAttackedBy = Integer.MAX_VALUE;
|
||||
this.canGainLife = true;
|
||||
|
@ -2317,16 +2313,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
this.landsPerTurn = landsPerTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoyaltyUsePerTurn() {
|
||||
return this.loyaltyUsePerTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoyaltyUsePerTurn(int loyaltyUsePerTurn) {
|
||||
this.loyaltyUsePerTurn = loyaltyUsePerTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHandSize() {
|
||||
return maxHandSize;
|
||||
|
|
Loading…
Reference in a new issue