mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
as asked in /forum/viewtopic.php?f=52&t=8312
This commit is contained in:
@@ -241,5 +241,19 @@ public final class CardManaCost implements Comparable<CardManaCost> {
|
||||
}
|
||||
return iX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this mana cost be paid with unlimited mana of given color set
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
|
||||
public boolean canBePaidWithManaOfColor(CardColor color) {
|
||||
for (ManaCostShard shard : shards) {
|
||||
if (!shard.canBePaidWithManaOfColor(color))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,19 +72,19 @@ public class ManaCostShard {
|
||||
public static final int COLORLESS = 1 << 0;
|
||||
|
||||
/** The Constant WHITE. */
|
||||
public static final int WHITE = 1 << 1;
|
||||
public static final int WHITE = CardColor.WHITE; // 1 << 1;
|
||||
|
||||
/** The Constant BLUE. */
|
||||
public static final int BLUE = 1 << 2;
|
||||
public static final int BLUE = CardColor.BLUE; // 1 << 2;
|
||||
|
||||
/** The Constant BLACK. */
|
||||
public static final int BLACK = 1 << 3;
|
||||
public static final int BLACK = CardColor.BLACK; // 1 << 3;
|
||||
|
||||
/** The Constant RED. */
|
||||
public static final int RED = 1 << 4;
|
||||
public static final int RED = CardColor.RED; // 1 << 4;
|
||||
|
||||
/** The Constant GREEN. */
|
||||
public static final int GREEN = 1 << 5;
|
||||
public static final int GREEN = CardColor.GREEN; // 1 << 5;
|
||||
|
||||
/** The Constant IS_X. */
|
||||
public static final int IS_X = 1 << 8;
|
||||
@@ -354,4 +354,18 @@ public class ManaCostShard {
|
||||
public boolean isOr2Colorless() {
|
||||
return (this.shard & Atom.OR_2_COLORLESS) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Can pay for this shard with unlimited mana of given color combination?
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
public boolean canBePaidWithManaOfColor(CardColor color) {
|
||||
// can pay with life?
|
||||
if ( (this.shard & Atom.OR_2_LIFE) != 0 ) return true;
|
||||
// can pay with any color?
|
||||
if ( (this.shard & Atom.OR_2_COLORLESS) != 0 || 0 != ( this.shard & Atom.COLORLESS ) ) return true;
|
||||
// either colored part is empty, or there are same colors in shard and mana source
|
||||
return ( 0xFF & this.shard ) == 0 || ( color.getColor() & this.shard ) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,9 @@ public class GenerateDeckUtil {
|
||||
|
||||
@Override
|
||||
public boolean apply(CardRules subject) {
|
||||
return allowedColor.containsAllColorsFrom(subject.getManaCost().getColorProfile());
|
||||
CardManaCost mc = subject.getManaCost();
|
||||
return !mc.isPureGeneric() && mc.canBePaidWithManaOfColor(allowedColor);
|
||||
// return allowedColor.containsAllColorsFrom(mc.getColorProfile());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user