mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
Merge pull request #1378 from poixen/mana_cleanup
Removed minus subtraction limits
This commit is contained in:
commit
b0da2f2260
5 changed files with 747 additions and 43 deletions
|
|
@ -135,48 +135,66 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
any += mana.getAny();
|
||||
}
|
||||
|
||||
public void addRed() {
|
||||
public void increaseRed() {
|
||||
red++;
|
||||
}
|
||||
|
||||
public void addGreen() {
|
||||
public void increaseGreen() {
|
||||
green++;
|
||||
}
|
||||
|
||||
public void addBlue() {
|
||||
public void increaseBlue() {
|
||||
blue++;
|
||||
}
|
||||
|
||||
public void addWhite() {
|
||||
public void increaseWhite() {
|
||||
white++;
|
||||
}
|
||||
|
||||
public void addBlack() {
|
||||
public void increaseBlack() {
|
||||
black++;
|
||||
}
|
||||
|
||||
public void addColorless() {
|
||||
public void increaseColorless() {
|
||||
colorless++;
|
||||
}
|
||||
|
||||
public void subtract(Mana mana) {
|
||||
red -= mana.getRed();
|
||||
green -= mana.getGreen();
|
||||
blue -= mana.getBlue();
|
||||
white -= mana.getWhite();
|
||||
black -= mana.getBlack();
|
||||
colorless -= mana.getColorless();
|
||||
any -= mana.getAny();
|
||||
/**
|
||||
* Subtracts the passed in mana values from this instance. Will not
|
||||
* reduce this instances mana below 0.
|
||||
*
|
||||
* @param mana mana values to subtract
|
||||
*/
|
||||
public void subtract(final Mana mana) throws ArithmeticException {
|
||||
red -= mana.red;
|
||||
green -= mana.green;
|
||||
blue -= mana.blue;
|
||||
white -= mana.white;
|
||||
black -= mana.black;
|
||||
colorless -= mana.colorless;
|
||||
any -= mana.any;
|
||||
}
|
||||
|
||||
public void subtractCost(Mana cost) {
|
||||
red -= cost.getRed();
|
||||
green -= cost.getGreen();
|
||||
blue -= cost.getBlue();
|
||||
white -= cost.getWhite();
|
||||
black -= cost.getBlack();
|
||||
any -= cost.getAny();
|
||||
colorless -= cost.getColorless();
|
||||
|
||||
/**
|
||||
* Subtracts the passed in mana values from this instance. Will not
|
||||
* reduce this instances mana below 0. The difference between this and
|
||||
* {@code subtract()} is that if we do not have the available colorlesss
|
||||
* mana to pay, we take mana from our colored mana pools.
|
||||
*
|
||||
* @param mana mana values to subtract
|
||||
* @throws ArithmeticException thrown if there is not enough available
|
||||
* colored mana to make up the negative colorless cost
|
||||
*/
|
||||
public void subtractCost(final Mana mana) throws ArithmeticException {
|
||||
red -= mana.red;
|
||||
green -= mana.green;
|
||||
blue -= mana.blue;
|
||||
white -= mana.white;
|
||||
black -= mana.black;
|
||||
any -= mana.any;
|
||||
colorless -= mana.colorless;
|
||||
|
||||
while (colorless < 0) {
|
||||
int oldColorless = colorless;
|
||||
if (red > 0) {
|
||||
|
|
|
|||
|
|
@ -118,31 +118,31 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
|||
switch (mana) {
|
||||
case B:
|
||||
if (pool.pay(ManaType.BLACK, ability, sourceFilter, game)) {
|
||||
this.payment.addBlack();
|
||||
this.payment.increaseBlack();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case U:
|
||||
if (pool.pay(ManaType.BLUE, ability, sourceFilter, game)) {
|
||||
this.payment.addBlue();
|
||||
this.payment.increaseBlue();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case W:
|
||||
if (pool.pay(ManaType.WHITE, ability, sourceFilter, game)) {
|
||||
this.payment.addWhite();
|
||||
this.payment.increaseWhite();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case G:
|
||||
if (pool.pay(ManaType.GREEN, ability, sourceFilter, game)) {
|
||||
this.payment.addGreen();
|
||||
this.payment.increaseGreen();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case R:
|
||||
if (pool.pay(ManaType.RED, ability, sourceFilter, game)) {
|
||||
this.payment.addRed();
|
||||
this.payment.increaseRed();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -154,27 +154,27 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
|||
int conditionalCount = pool.getConditionalCount(ability, game, null);
|
||||
while (mana > payment.count() && (pool.count() > 0 || conditionalCount > 0)) {
|
||||
if (pool.pay(ManaType.COLORLESS, ability, sourceFilter, game)) {
|
||||
this.payment.addColorless();
|
||||
this.payment.increaseColorless();
|
||||
continue;
|
||||
}
|
||||
if (pool.pay(ManaType.BLACK, ability, sourceFilter, game)) {
|
||||
this.payment.addBlack();
|
||||
this.payment.increaseBlack();
|
||||
continue;
|
||||
}
|
||||
if (pool.pay(ManaType.BLUE, ability, sourceFilter, game)) {
|
||||
this.payment.addBlue();
|
||||
this.payment.increaseBlue();
|
||||
continue;
|
||||
}
|
||||
if (pool.pay(ManaType.WHITE, ability, sourceFilter, game)) {
|
||||
this.payment.addWhite();
|
||||
this.payment.increaseWhite();
|
||||
continue;
|
||||
}
|
||||
if (pool.pay(ManaType.GREEN, ability, sourceFilter, game)) {
|
||||
this.payment.addGreen();
|
||||
this.payment.increaseGreen();
|
||||
continue;
|
||||
}
|
||||
if (pool.pay(ManaType.RED, ability, sourceFilter, game)) {
|
||||
this.payment.addRed();
|
||||
this.payment.increaseRed();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -154,15 +154,15 @@ public class DynamicManaEffect extends BasicManaEffect {
|
|||
}
|
||||
}
|
||||
if (choiceColor.getColor().isBlack()) {
|
||||
computedMana.addBlack();
|
||||
computedMana.increaseBlack();
|
||||
} else if (choiceColor.getColor().isBlue()) {
|
||||
computedMana.addBlue();
|
||||
computedMana.increaseBlue();
|
||||
} else if (choiceColor.getColor().isRed()) {
|
||||
computedMana.addRed();
|
||||
computedMana.increaseRed();
|
||||
} else if (choiceColor.getColor().isGreen()) {
|
||||
computedMana.addGreen();
|
||||
computedMana.increaseGreen();
|
||||
} else if (choiceColor.getColor().isWhite()) {
|
||||
computedMana.addWhite();
|
||||
computedMana.increaseWhite();
|
||||
}
|
||||
if (!oneChoice) {
|
||||
choiceColor.clearChoice();
|
||||
|
|
|
|||
|
|
@ -81,31 +81,31 @@ public class CommanderManaReplacementEffect extends ReplacementEffectImpl {
|
|||
Mana mana = ((ManaEvent) event).getMana();
|
||||
if (mana.getBlack() > 0 && !commanderMana.isBlack()) {
|
||||
for (int i = 0; i < mana.getBlack(); i++) {
|
||||
mana.addColorless();
|
||||
mana.increaseColorless();
|
||||
}
|
||||
mana.setBlack(0);
|
||||
}
|
||||
if (mana.getBlue() > 0 && !commanderMana.isBlue()) {
|
||||
for (int i = 0; i < mana.getBlue(); i++) {
|
||||
mana.addColorless();
|
||||
mana.increaseColorless();
|
||||
}
|
||||
mana.setBlue(0);
|
||||
}
|
||||
if (mana.getGreen() > 0 && !commanderMana.isGreen()) {
|
||||
for (int i = 0; i < mana.getGreen(); i++) {
|
||||
mana.addColorless();
|
||||
mana.increaseColorless();
|
||||
}
|
||||
mana.setGreen(0);
|
||||
}
|
||||
if (mana.getRed() > 0 && !commanderMana.isRed()) {
|
||||
for (int i = 0; i < mana.getRed(); i++) {
|
||||
mana.addColorless();
|
||||
mana.increaseColorless();
|
||||
}
|
||||
mana.setRed(0);
|
||||
}
|
||||
if (mana.getWhite() > 0 && !commanderMana.isWhite()) {
|
||||
for (int i = 0; i < mana.getWhite(); i++) {
|
||||
mana.addColorless();
|
||||
mana.increaseColorless();
|
||||
}
|
||||
mana.setWhite(0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue