Fixed cards with any color lands produce ability:

* Fixed ManaOptions result (no more duplicated records with same options);
  * Fixed mana types searching (now mana search return {Any} type too);
  * Fixed cards: Fellwar Stone, Harvester Druid, Reflecting Pool (#4125), Sylvok Explorer, Exotic Orchard (#3374), Naga Vitalist;
This commit is contained in:
Oleg Agafonov 2017-12-28 02:15:49 +04:00
parent 8fe1c46ade
commit 68c6551188
8 changed files with 301 additions and 65 deletions

View file

@ -221,6 +221,19 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
return new Mana(0, 0, 0, 0, 0, 0, 0, notNegative(num, "Colorless"));
}
/**
* Creates a {@link Mana} object with the passed in {@code num} of Any
* mana. {@code num} can not be a negative value. Negative values will be
* logged and set to 0.
*
* @param num value of Any mana to create.
* @return a {@link Mana} object with the passed in {@code num} of Any
* mana.
*/
public static Mana AnyMana(int num) {
return new Mana(0, 0, 0, 0, 0, 0, notNegative(num, "Any"), 0);
}
/**
* Adds mana from the passed in {@link Mana} object to this object.
*

View file

@ -225,6 +225,9 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
if (types.getColorless() > 0) {
netManas.add(Mana.ColorlessMana(1));
}
if (types.getAny() > 0) {
netManas.add(Mana.AnyMana(1));
}
return netManas;
}

View file

@ -28,7 +28,10 @@
package mage.abilities.mana;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import mage.Mana;
import mage.game.Game;
@ -326,4 +329,19 @@ public class ManaOptions extends ArrayList<Mana> {
payCombinations.add(newMana);
payCombinationsStrings.add(newMana.toString());
}
public void removeDuplicated(){
Set<String> list = new HashSet<>();
for(int i = this.size() - 1; i >= 0; i--){
String s = this.get(i).toString();
if (list.contains(s)){
// remove duplicated
this.remove(i);
}else{
list.add(s);
}
}
}
}

View file

@ -2439,6 +2439,10 @@ public abstract class PlayerImpl implements Player, Serializable {
for (Abilities<ActivatedManaAbilityImpl> manaAbilities : sourceWithCosts) {
available.addManaWithCost(manaAbilities, game);
}
// remove duplicated variants (see ManaOptionsTest for info - when thats rises)
available.removeDuplicated();
return available;
}