mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08: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
|
|
@ -123,7 +123,7 @@ class HallOfGemstoneEffect extends ReplacementEffectImpl {
|
||||||
int genericAmount = mana.getGeneric();
|
int genericAmount = mana.getGeneric();
|
||||||
int colorlessAmount = mana.getColorless();
|
int colorlessAmount = mana.getColorless();
|
||||||
int coloredAmount = mana.countColored();
|
int coloredAmount = mana.countColored();
|
||||||
switch (colorChosen.getColoredManaSymbol()) {
|
switch (colorChosen.getOneColoredManaSymbol()) {
|
||||||
case W:
|
case W:
|
||||||
mana.setToMana(Mana.WhiteMana(coloredAmount));
|
mana.setToMana(Mana.WhiteMana(coloredAmount));
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ class ProtectiveSphereEffect extends PreventionEffectImpl {
|
||||||
if (event.getTargetId().equals(source.getControllerId())
|
if (event.getTargetId().equals(source.getControllerId())
|
||||||
&& event.getSourceId().equals(target.getFirstTarget())) {
|
&& event.getSourceId().equals(target.getFirstTarget())) {
|
||||||
colorsOfChosenSource = game.getObject(target.getFirstTarget()).getColor(game).getColors();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,8 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
newColor.black = black && other.black;
|
newColor.black = black && other.black;
|
||||||
newColor.red = red && other.red;
|
newColor.red = red && other.red;
|
||||||
newColor.green = green && other.green;
|
newColor.green = green && other.green;
|
||||||
|
|
||||||
|
newColor.gold = gold && other.gold;
|
||||||
return newColor;
|
return newColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,6 +159,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
List<ObjectColor> colors = new ArrayList<>();
|
List<ObjectColor> colors = new ArrayList<>();
|
||||||
int firstColor = 5000;
|
int firstColor = 5000;
|
||||||
int secondColor = -1;
|
int secondColor = -1;
|
||||||
|
|
||||||
if (this.isWhite()) {
|
if (this.isWhite()) {
|
||||||
firstColor = 1;
|
firstColor = 1;
|
||||||
secondColor = 1;
|
secondColor = 1;
|
||||||
|
|
@ -177,6 +180,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
firstColor = Math.min(firstColor, 5);
|
firstColor = Math.min(firstColor, 5);
|
||||||
secondColor = Math.max(secondColor, 5);
|
secondColor = Math.max(secondColor, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isWhite()) {
|
if (this.isWhite()) {
|
||||||
colors.add(ObjectColor.WHITE);
|
colors.add(ObjectColor.WHITE);
|
||||||
}
|
}
|
||||||
|
|
@ -192,6 +196,7 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
if (this.isGreen()) {
|
if (this.isGreen()) {
|
||||||
colors.add(ObjectColor.GREEN);
|
colors.add(ObjectColor.GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colors.size() >= 2 && secondColor - firstColor >= 3) {
|
if (colors.size() >= 2 && secondColor - firstColor >= 3) {
|
||||||
Collections.swap(colors, 0, 1);
|
Collections.swap(colors, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
@ -391,7 +396,11 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
if (test.green != this.green) {
|
if (test.green != this.green) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return test.gold == this.gold;
|
if (test.gold != this.gold) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -465,10 +474,10 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
o1 = 4;
|
o1 = 4;
|
||||||
} else if (this.isWhite()) {
|
} else if (this.isWhite()) {
|
||||||
o1 = 5;
|
o1 = 5;
|
||||||
|
|
||||||
} else if (this.isGold()) {
|
} else if (this.isGold()) {
|
||||||
o1 = 6;
|
o1 = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.isMulticolored()) {
|
if (o.isMulticolored()) {
|
||||||
o2 = 7;
|
o2 = 7;
|
||||||
} else if (o.isColorless()) {
|
} else if (o.isColorless()) {
|
||||||
|
|
@ -483,10 +492,10 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
o2 = 4;
|
o2 = 4;
|
||||||
} else if (o.isWhite()) {
|
} else if (o.isWhite()) {
|
||||||
o2 = 5;
|
o2 = 5;
|
||||||
|
|
||||||
} else if (o.isGold()) {
|
} else if (o.isGold()) {
|
||||||
o2 = 6;
|
o2 = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
return o1 - o2;
|
return o1 - o2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,7 +505,12 @@ public class ObjectColor implements Serializable, Copyable<ObjectColor>, Compara
|
||||||
*
|
*
|
||||||
* @return null or
|
* @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()) {
|
if (isBlack()) {
|
||||||
return ColoredManaSymbol.B;
|
return ColoredManaSymbol.B;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect {
|
||||||
else{
|
else{
|
||||||
List<ObjectColor> permanentColors = permanent.getColor(game).getColors();
|
List<ObjectColor> permanentColors = permanent.getColor(game).getColors();
|
||||||
for (ObjectColor color : permanentColors){
|
for (ObjectColor color : permanentColors){
|
||||||
types.add(new Mana(color.getColoredManaSymbol()));
|
types.add(new Mana(color.getOneColoredManaSymbol()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue