mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 12:19:59 -08:00
* Variable loyality payment - Fixed a bug that the -X payment of loyality counters was added insted subtracted. Prevented the possibility to announce x loyality counter payment, if already one planeswalker ability was used this turn.
This commit is contained in:
parent
5624e1edfb
commit
6c924edd7a
3 changed files with 17 additions and 9 deletions
|
|
@ -42,12 +42,14 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class PayLoyaltyCost extends CostImpl<PayLoyaltyCost> {
|
||||
|
||||
private int amount;
|
||||
private final int amount;
|
||||
|
||||
public PayLoyaltyCost(int amount) {
|
||||
this.amount = amount;
|
||||
this.text = Integer.toString(amount);
|
||||
if (amount >= 0) this.text = "+" + this.text;
|
||||
if (amount >= 0) {
|
||||
this.text = "+" + this.text;
|
||||
}
|
||||
}
|
||||
|
||||
public PayLoyaltyCost(PayLoyaltyCost cost) {
|
||||
|
|
@ -58,9 +60,7 @@ public class PayLoyaltyCost extends CostImpl<PayLoyaltyCost> {
|
|||
@Override
|
||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
if (planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && !planeswalker.isLoyaltyUsed())
|
||||
return true;
|
||||
return false;
|
||||
return planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && !planeswalker.isLoyaltyUsed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.VariableCostImpl;
|
||||
|
|
@ -55,9 +56,15 @@ public class PayVariableLoyaltyCost extends VariableCostImpl<PayVariableLoyaltyC
|
|||
return new PayVariableLoyaltyCost(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent planeswalker = game.getPermanent(sourceId);
|
||||
return planeswalker!= null && !planeswalker.isLoyaltyUsed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cost getFixedCostsFromAnnouncedValue(int xValue) {
|
||||
return new PayLoyaltyCost(xValue);
|
||||
return new PayLoyaltyCost(-xValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue