Fixes for Mana.enough and Mana.needed. For #8153 (#8663)

Fixes to Mana.enough:

mana of any color (ManaType.Any) was being used to pay for colourless mana.
Fixes for Mana.needed:

mana of any color (ManaType.Any) was being used to pay for colourless mana.
calculation for generic mana remaining was using min(0, available) instead of max(0, available) meaning that leftover mana of other types was never used to pay for any leftover generic costs.
Other:

Added tests for both .needed and .enough.
Moved tests some tests from ManaUtilTest to ManaTest
Simplified Mana.subtractCosts by calling Mana.substract first to make use of common functionality.
Added more documentation
Added tests for both .needed
Added more tests for .enough to cover the changes with colourless mana.
This commit is contained in:
Alex Vasile 2022-06-01 08:13:37 -06:00 committed by GitHub
parent 16914632c4
commit e679574a15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 293 additions and 196 deletions

View file

@ -449,9 +449,14 @@ public final class ManaUtil {
}
/**
* Converts a collection of mana symbols into a single condensed string e.g.
* {1}{1}{1}{1}{1}{W} = {5}{W} {2}{B}{2}{B}{2}{B} = {6}{B}{B}{B}
* {1}{2}{R}{U}{1}{1} = {5}{R}{U} {B}{G}{R} = {B}{G}{R}
* Converts a collection of mana symbols into a single condensed string e.g:
* {1}{1}{1}{1}{1}{W} = {5}{W}
* {2}{B}{2}{B}{2}{B} = {6}{B}{B}{B}
* {1}{2}{R}{U}{1}{1} = {5}{R}{U}
* {B}{G}{R} = {B}{G}{R}
*
* @param rawCost the uncondensed version of the mana String.
* @return the condensed version of the mana String.
*/
public static String condenseManaCostString(String rawCost) {
int total = 0;