added subtraction logic to enough()

+ added subornation logic to enough(). We do not want to mix the public
subtract() call with this method. As doing so would mean that either a)
subtraction can go below 0 (this should not happen) or b) we break this
function with exceptions. This is a work around for these scenarios.
This commit is contained in:
poixen 2015-11-19 17:42:59 +01:00
parent 2c617a6aaf
commit 05b841577a
2 changed files with 7 additions and 2 deletions

View file

@ -1,6 +1,5 @@
package org.mage.test.mana;
import junit.framework.Assert;
import mage.Mana;
import mage.constants.ColoredManaSymbol;
import mage.constants.ManaType;

View file

@ -507,7 +507,13 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
*/
public boolean enough(final Mana avail) {
Mana compare = avail.copy();
compare.subtract(this);
red -= avail.red;
green -= avail.green;
blue -= avail.blue;
white -= avail.white;
black -= avail.black;
colorless -= avail.colorless;
any -= avail.any;
if (compare.getRed() < 0) {
compare.setAny(compare.getAny() + compare.getRed());
if (compare.getAny() < 0) {