mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
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:
parent
2c617a6aaf
commit
05b841577a
2 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,5 @@
|
|||
package org.mage.test.mana;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import mage.Mana;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.constants.ManaType;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue