mirror of
https://github.com/correl/mage.git
synced 2025-04-10 09:11:04 -09:00
Refactoring: added mana color check and fix
This commit is contained in:
parent
7edcec0dc1
commit
459ef9af94
4 changed files with 21 additions and 7 deletions
Mage.Sets/src/mage/cards
Mage/src/main/java/mage
|
@ -123,7 +123,7 @@ class HallOfGemstoneEffect extends ReplacementEffectImpl {
|
|||
int genericAmount = mana.getGeneric();
|
||||
int colorlessAmount = mana.getColorless();
|
||||
int coloredAmount = mana.countColored();
|
||||
switch (colorChosen.getColoredManaSymbol()) {
|
||||
switch (colorChosen.getOneColoredManaSymbol()) {
|
||||
case W:
|
||||
mana.setToMana(Mana.WhiteMana(coloredAmount));
|
||||
break;
|
||||
|
|
|
@ -124,7 +124,7 @@ class ProtectiveSphereEffect extends PreventionEffectImpl {
|
|||
if (event.getTargetId().equals(source.getControllerId())
|
||||
&& event.getSourceId().equals(target.getFirstTarget())) {
|
||||
colorsOfChosenSource = game.getObject(target.getFirstTarget()).getColor(game).getColors();
|
||||
if (colorsOfChosenSource.stream().anyMatch((c) -> (manaUsed.getColor(c.getColoredManaSymbol()) > 0))) {
|
||||
if (colorsOfChosenSource.stream().anyMatch((c) -> (manaUsed.getColor(c.getOneColoredManaSymbol()) > 0))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,8 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
newColor.black = black && other.black;
|
||||
newColor.red = red && other.red;
|
||||
newColor.green = green && other.green;
|
||||
|
||||
newColor.gold = gold && other.gold;
|
||||
return newColor;
|
||||
}
|
||||
|
||||
|
@ -157,6 +159,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
List<ObjectColor> colors = new ArrayList<>();
|
||||
int firstColor = 5000;
|
||||
int secondColor = -1;
|
||||
|
||||
if (this.isWhite()) {
|
||||
firstColor = 1;
|
||||
secondColor = 1;
|
||||
|
@ -177,6 +180,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
firstColor = Math.min(firstColor, 5);
|
||||
secondColor = Math.max(secondColor, 5);
|
||||
}
|
||||
|
||||
if (this.isWhite()) {
|
||||
colors.add(ObjectColor.WHITE);
|
||||
}
|
||||
|
@ -192,6 +196,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
if (this.isGreen()) {
|
||||
colors.add(ObjectColor.GREEN);
|
||||
}
|
||||
|
||||
if (colors.size() >= 2 && secondColor - firstColor >= 3) {
|
||||
Collections.swap(colors, 0, 1);
|
||||
}
|
||||
|
@ -391,7 +396,11 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
if (test.green != this.green) {
|
||||
return false;
|
||||
}
|
||||
return test.gold == this.gold;
|
||||
if (test.gold != this.gold) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -465,10 +474,10 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
o1 = 4;
|
||||
} else if (this.isWhite()) {
|
||||
o1 = 5;
|
||||
|
||||
} else if (this.isGold()) {
|
||||
o1 = 6;
|
||||
}
|
||||
|
||||
if (o.isMulticolored()) {
|
||||
o2 = 7;
|
||||
} else if (o.isColorless()) {
|
||||
|
@ -483,10 +492,10 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
o2 = 4;
|
||||
} else if (o.isWhite()) {
|
||||
o2 = 5;
|
||||
|
||||
} else if (o.isGold()) {
|
||||
o2 = 6;
|
||||
}
|
||||
|
||||
return o1 - o2;
|
||||
}
|
||||
|
||||
|
@ -496,7 +505,12 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
|||
*
|
||||
* @return null or
|
||||
*/
|
||||
public ColoredManaSymbol getColoredManaSymbol() {
|
||||
public ColoredManaSymbol getOneColoredManaSymbol() {
|
||||
|
||||
if (isMulticolored()) {
|
||||
throw new IllegalStateException("Founded multicolored object, but it's must call with single mana color.");
|
||||
}
|
||||
|
||||
if (isBlack()) {
|
||||
return ColoredManaSymbol.B;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect {
|
|||
else{
|
||||
List<ObjectColor> permanentColors = permanent.getColor(game).getColors();
|
||||
for (ObjectColor color : permanentColors){
|
||||
types.add(new Mana(color.getColoredManaSymbol()));
|
||||
types.add(new Mana(color.getOneColoredManaSymbol()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue