mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Merge branch 'master' of https://github.com/magefree/mage
This commit is contained in:
commit
1b3d31c670
6 changed files with 35 additions and 13 deletions
|
@ -60,19 +60,19 @@ public class PayLoyaltyCost extends CostImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||||
Permanent planeswalker = game.getPermanent(sourceId);
|
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
|
@Override
|
||||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||||
Permanent planeswalker = game.getPermanent(sourceId);
|
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) {
|
if (amount > 0) {
|
||||||
planeswalker.getCounters().addCounter(CounterType.LOYALTY.createInstance(amount));
|
planeswalker.getCounters().addCounter(CounterType.LOYALTY.createInstance(amount));
|
||||||
} else if (amount < 0) {
|
} else if (amount < 0) {
|
||||||
planeswalker.getCounters().removeCounter(CounterType.LOYALTY, Math.abs(amount));
|
planeswalker.getCounters().removeCounter(CounterType.LOYALTY, Math.abs(amount));
|
||||||
}
|
}
|
||||||
planeswalker.setLoyaltyUsed(true);
|
planeswalker.addLoyaltyUsed();
|
||||||
this.paid = true;
|
this.paid = true;
|
||||||
}
|
}
|
||||||
return paid;
|
return paid;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class PayVariableLoyaltyCost extends VariableCostImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||||
Permanent planeswalker = game.getPermanent(sourceId);
|
Permanent planeswalker = game.getPermanent(sourceId);
|
||||||
return planeswalker!= null && !planeswalker.isLoyaltyUsed();
|
return planeswalker!= null && planeswalker.canLoyaltyBeUsed(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -116,8 +116,9 @@ public interface Permanent extends Card, Controllable {
|
||||||
|
|
||||||
void removeAllAbilities(UUID sourceId, Game game);
|
void removeAllAbilities(UUID sourceId, Game game);
|
||||||
|
|
||||||
void setLoyaltyUsed(boolean used);
|
void addLoyaltyUsed();
|
||||||
boolean isLoyaltyUsed();
|
boolean canLoyaltyBeUsed(Game game);
|
||||||
|
|
||||||
|
|
||||||
public void resetControl();
|
public void resetControl();
|
||||||
boolean changeControllerId(UUID controllerId, Game game);
|
boolean changeControllerId(UUID controllerId, Game game);
|
||||||
|
|
|
@ -92,7 +92,6 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
protected int minBlockedBy = 1;
|
protected int minBlockedBy = 1;
|
||||||
// maximal number of creatures the creature can be blocked by 0 = no restriction
|
// maximal number of creatures the creature can be blocked by 0 = no restriction
|
||||||
protected int maxBlockedBy = 0;
|
protected int maxBlockedBy = 0;
|
||||||
protected boolean loyaltyUsed;
|
|
||||||
protected boolean deathtouched;
|
protected boolean deathtouched;
|
||||||
protected List<UUID> attachments = new ArrayList<>();
|
protected List<UUID> attachments = new ArrayList<>();
|
||||||
protected Map<String, List<UUID>> connectedCards = new HashMap<>();
|
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 attachedTo;
|
||||||
protected UUID pairedCard;
|
protected UUID pairedCard;
|
||||||
protected List<Counter> markedDamage;
|
protected List<Counter> markedDamage;
|
||||||
|
protected int timesLoyaltyUsed = 0;
|
||||||
|
|
||||||
private static final List<UUID> emptyList = Collections.unmodifiableList(new ArrayList<UUID>());
|
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.attacking = permanent.attacking;
|
||||||
this.blocking = permanent.blocking;
|
this.blocking = permanent.blocking;
|
||||||
this.maxBlocks = permanent.maxBlocks;
|
this.maxBlocks = permanent.maxBlocks;
|
||||||
this.loyaltyUsed = permanent.loyaltyUsed;
|
|
||||||
this.deathtouched = permanent.deathtouched;
|
this.deathtouched = permanent.deathtouched;
|
||||||
this.attachments.addAll(permanent.attachments);
|
this.attachments.addAll(permanent.attachments);
|
||||||
for (Map.Entry<String, List<UUID>> entry: permanent.connectedCards.entrySet()) {
|
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.transformed = permanent.transformed;
|
||||||
this.monstrous = permanent.monstrous;
|
this.monstrous = permanent.monstrous;
|
||||||
this.pairedCard = permanent.pairedCard;
|
this.pairedCard = permanent.pairedCard;
|
||||||
|
this.timesLoyaltyUsed = permanent.timesLoyaltyUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -276,7 +276,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
@Override
|
@Override
|
||||||
public void endOfTurn(Game game) {
|
public void endOfTurn(Game game) {
|
||||||
this.damage = 0;
|
this.damage = 0;
|
||||||
this.loyaltyUsed = false;
|
this.timesLoyaltyUsed = 0;
|
||||||
this.turnsOnBattlefield++;
|
this.turnsOnBattlefield++;
|
||||||
this.deathtouched = false;
|
this.deathtouched = false;
|
||||||
dealtDamageByThisTurn = null;
|
dealtDamageByThisTurn = null;
|
||||||
|
@ -286,15 +286,20 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLoyaltyUsed(boolean used) {
|
public void addLoyaltyUsed() {
|
||||||
this.loyaltyUsed = used;
|
this.timesLoyaltyUsed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLoyaltyUsed() {
|
public boolean canLoyaltyBeUsed(Game game) {
|
||||||
return this.loyaltyUsed;
|
Player controller = game.getPlayer(controllerId);
|
||||||
|
if (controller != null) {
|
||||||
|
return controller.getLoyaltyUsePerTurn() > timesLoyaltyUsed;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTapped() {
|
public boolean isTapped() {
|
||||||
return tapped;
|
return tapped;
|
||||||
|
|
|
@ -119,6 +119,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
int getLandsPlayed();
|
int getLandsPlayed();
|
||||||
int getLandsPerTurn();
|
int getLandsPerTurn();
|
||||||
void setLandsPerTurn(int landsPerTurn);
|
void setLandsPerTurn(int landsPerTurn);
|
||||||
|
int getLoyaltyUsePerTurn();
|
||||||
|
void setLoyaltyUsePerTurn(int loyaltyUsePerTurn);
|
||||||
int getMaxHandSize();
|
int getMaxHandSize();
|
||||||
void setMaxHandSize(int maxHandSize);
|
void setMaxHandSize(int maxHandSize);
|
||||||
int getMaxAttackedBy();
|
int getMaxAttackedBy();
|
||||||
|
|
|
@ -142,6 +142,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
protected Counters counters;
|
protected Counters counters;
|
||||||
protected int landsPlayed;
|
protected int landsPlayed;
|
||||||
protected int landsPerTurn = 1;
|
protected int landsPerTurn = 1;
|
||||||
|
protected int loyaltyUsePerTurn = 1;
|
||||||
protected int maxHandSize = 7;
|
protected int maxHandSize = 7;
|
||||||
protected int maxAttackedBy = Integer.MAX_VALUE;
|
protected int maxAttackedBy = Integer.MAX_VALUE;
|
||||||
protected ManaPool manaPool;
|
protected ManaPool manaPool;
|
||||||
|
@ -230,6 +231,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
|
|
||||||
this.landsPlayed = player.landsPlayed;
|
this.landsPlayed = player.landsPlayed;
|
||||||
this.landsPerTurn = player.landsPerTurn;
|
this.landsPerTurn = player.landsPerTurn;
|
||||||
|
this.loyaltyUsePerTurn = player.loyaltyUsePerTurn;
|
||||||
this.maxHandSize = player.maxHandSize;
|
this.maxHandSize = player.maxHandSize;
|
||||||
this.maxAttackedBy = player.maxAttackedBy;
|
this.maxAttackedBy = player.maxAttackedBy;
|
||||||
this.manaPool = player.manaPool.copy();
|
this.manaPool = player.manaPool.copy();
|
||||||
|
@ -287,6 +289,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
|
|
||||||
this.landsPlayed = player.getLandsPlayed();
|
this.landsPlayed = player.getLandsPlayed();
|
||||||
this.landsPerTurn = player.getLandsPerTurn();
|
this.landsPerTurn = player.getLandsPerTurn();
|
||||||
|
this.loyaltyUsePerTurn = player.getLoyaltyUsePerTurn();
|
||||||
this.maxHandSize = player.getMaxHandSize();
|
this.maxHandSize = player.getMaxHandSize();
|
||||||
this.maxAttackedBy = player.getMaxAttackedBy();
|
this.maxAttackedBy = player.getMaxAttackedBy();
|
||||||
this.manaPool = player.getManaPool().copy();
|
this.manaPool = player.getManaPool().copy();
|
||||||
|
@ -377,6 +380,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.abilities.clear();
|
this.abilities.clear();
|
||||||
this.landsPerTurn = 1;
|
this.landsPerTurn = 1;
|
||||||
|
this.loyaltyUsePerTurn = 1;
|
||||||
this.maxHandSize = 7;
|
this.maxHandSize = 7;
|
||||||
this.maxAttackedBy = Integer.MAX_VALUE;
|
this.maxAttackedBy = Integer.MAX_VALUE;
|
||||||
this.canGainLife = true;
|
this.canGainLife = true;
|
||||||
|
@ -1457,6 +1461,16 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
this.landsPerTurn = landsPerTurn;
|
this.landsPerTurn = landsPerTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLoyaltyUsePerTurn() {
|
||||||
|
return this.loyaltyUsePerTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLoyaltyUsePerTurn(int loyaltyUsePerTurn) {
|
||||||
|
this.loyaltyUsePerTurn = loyaltyUsePerTurn;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxHandSize() {
|
public int getMaxHandSize() {
|
||||||
return maxHandSize;
|
return maxHandSize;
|
||||||
|
|
Loading…
Reference in a new issue