mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Planeswalker - Changed handling of LoyayltyAbilities to a times used based handling.
This commit is contained in:
parent
dc7d6cd452
commit
810434932b
6 changed files with 35 additions and 13 deletions
|
@ -60,19 +60,19 @@ public class PayLoyaltyCost extends CostImpl {
|
|||
@Override
|
||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
return planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && !planeswalker.isLoyaltyUsed();
|
||||
return planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
if (planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && !planeswalker.isLoyaltyUsed()) {
|
||||
if (planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game)) {
|
||||
if (amount > 0) {
|
||||
planeswalker.getCounters().addCounter(CounterType.LOYALTY.createInstance(amount));
|
||||
} else if (amount < 0) {
|
||||
planeswalker.getCounters().removeCounter(CounterType.LOYALTY, Math.abs(amount));
|
||||
}
|
||||
planeswalker.setLoyaltyUsed(true);
|
||||
planeswalker.addLoyaltyUsed();
|
||||
this.paid = true;
|
||||
}
|
||||
return paid;
|
||||
|
|
|
@ -59,7 +59,7 @@ public class PayVariableLoyaltyCost extends VariableCostImpl {
|
|||
@Override
|
||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
return planeswalker!= null && !planeswalker.isLoyaltyUsed();
|
||||
return planeswalker!= null && planeswalker.canLoyaltyBeUsed(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -116,8 +116,9 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
void removeAllAbilities(UUID sourceId, Game game);
|
||||
|
||||
void setLoyaltyUsed(boolean used);
|
||||
boolean isLoyaltyUsed();
|
||||
void addLoyaltyUsed();
|
||||
boolean canLoyaltyBeUsed(Game game);
|
||||
|
||||
|
||||
public void resetControl();
|
||||
boolean changeControllerId(UUID controllerId, Game game);
|
||||
|
|
|
@ -92,7 +92,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
protected int minBlockedBy = 1;
|
||||
// maximal number of creatures the creature can be blocked by 0 = no restriction
|
||||
protected int maxBlockedBy = 0;
|
||||
protected boolean loyaltyUsed;
|
||||
protected boolean deathtouched;
|
||||
protected List<UUID> attachments = new ArrayList<>();
|
||||
protected Map<String, List<UUID>> connectedCards = new HashMap<>();
|
||||
|
@ -100,6 +99,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
protected UUID attachedTo;
|
||||
protected UUID pairedCard;
|
||||
protected List<Counter> markedDamage;
|
||||
protected int timesLoyaltyUsed = 0;
|
||||
|
||||
private static final List<UUID> emptyList = Collections.unmodifiableList(new ArrayList<UUID>());
|
||||
|
||||
|
@ -128,7 +128,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
this.attacking = permanent.attacking;
|
||||
this.blocking = permanent.blocking;
|
||||
this.maxBlocks = permanent.maxBlocks;
|
||||
this.loyaltyUsed = permanent.loyaltyUsed;
|
||||
this.deathtouched = permanent.deathtouched;
|
||||
this.attachments.addAll(permanent.attachments);
|
||||
for (Map.Entry<String, List<UUID>> entry: permanent.connectedCards.entrySet()) {
|
||||
|
@ -149,6 +148,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
this.transformed = permanent.transformed;
|
||||
this.monstrous = permanent.monstrous;
|
||||
this.pairedCard = permanent.pairedCard;
|
||||
this.timesLoyaltyUsed = permanent.timesLoyaltyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -276,7 +276,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
@Override
|
||||
public void endOfTurn(Game game) {
|
||||
this.damage = 0;
|
||||
this.loyaltyUsed = false;
|
||||
this.timesLoyaltyUsed = 0;
|
||||
this.turnsOnBattlefield++;
|
||||
this.deathtouched = false;
|
||||
dealtDamageByThisTurn = null;
|
||||
|
@ -286,14 +286,19 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setLoyaltyUsed(boolean used) {
|
||||
this.loyaltyUsed = used;
|
||||
public void addLoyaltyUsed() {
|
||||
this.timesLoyaltyUsed++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoyaltyUsed() {
|
||||
return this.loyaltyUsed;
|
||||
public boolean canLoyaltyBeUsed(Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
return controller.getLoyaltyUsePerTurn() > timesLoyaltyUsed;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isTapped() {
|
||||
|
|
|
@ -119,6 +119,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
int getLandsPlayed();
|
||||
int getLandsPerTurn();
|
||||
void setLandsPerTurn(int landsPerTurn);
|
||||
int getLoyaltyUsePerTurn();
|
||||
void setLoyaltyUsePerTurn(int loyaltyUsePerTurn);
|
||||
int getMaxHandSize();
|
||||
void setMaxHandSize(int maxHandSize);
|
||||
int getMaxAttackedBy();
|
||||
|
|
|
@ -142,6 +142,7 @@ 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;
|
||||
|
@ -230,6 +231,7 @@ 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();
|
||||
|
@ -287,6 +289,7 @@ 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();
|
||||
|
@ -377,6 +380,7 @@ 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;
|
||||
|
@ -1457,6 +1461,16 @@ 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