rework effects which increase loyalty abilities (closes #9626)

This commit is contained in:
Evan Kranzler 2022-10-10 18:01:58 -04:00
parent 3fd3cb27e2
commit 09797d4cf6
9 changed files with 59 additions and 98 deletions

View file

@ -216,6 +216,8 @@ public interface Permanent extends Card, Controllable {
void incrementLoyaltyActivationsAvailable();
void incrementLoyaltyActivationsAvailable(int max);
void addLoyaltyUsed();
boolean canLoyaltyBeUsed(Game game);

View file

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

View file

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

View file

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