mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* Opal Palcar - Fixed a bug that the first mana ability also wrongly gave the commander boost.
This commit is contained in:
parent
a1ba324dba
commit
acc3ac7b60
4 changed files with 105 additions and 48 deletions
|
@ -133,22 +133,27 @@ class OpalPalaceManaEffect extends ManaEffect<OpalPalaceManaEffect> {
|
||||||
choice.getChoices().add("White");
|
choice.getChoices().add("White");
|
||||||
}
|
}
|
||||||
if (choice.getChoices().size() > 0) {
|
if (choice.getChoices().size() > 0) {
|
||||||
|
Mana mana = new Mana();
|
||||||
if (choice.getChoices().size() == 1) {
|
if (choice.getChoices().size() == 1) {
|
||||||
choice.setChoice(choice.getChoices().iterator().next());
|
choice.setChoice(choice.getChoices().iterator().next());
|
||||||
} else {
|
} else {
|
||||||
controller.choose(outcome, choice, game);
|
controller.choose(outcome, choice, game);
|
||||||
}
|
}
|
||||||
if (choice.getChoice().equals("Black")) {
|
if (choice.getChoice().equals("Black")) {
|
||||||
controller.getManaPool().addMana(Mana.BlackMana, game, source);
|
mana.addBlack();
|
||||||
} else if (choice.getChoice().equals("Blue")) {
|
} else if (choice.getChoice().equals("Blue")) {
|
||||||
controller.getManaPool().addMana(Mana.BlueMana, game, source);
|
mana.addBlue();
|
||||||
} else if (choice.getChoice().equals("Red")) {
|
} else if (choice.getChoice().equals("Red")) {
|
||||||
controller.getManaPool().addMana(Mana.RedMana, game, source);
|
mana.addRed();
|
||||||
} else if (choice.getChoice().equals("Green")) {
|
} else if (choice.getChoice().equals("Green")) {
|
||||||
controller.getManaPool().addMana(Mana.GreenMana, game, source);
|
mana.addGreen();
|
||||||
} else if (choice.getChoice().equals("White")) {
|
} else if (choice.getChoice().equals("White")) {
|
||||||
controller.getManaPool().addMana(Mana.WhiteMana, game, source);
|
mana.addWhite();
|
||||||
}
|
}
|
||||||
|
// set to indicate, that the mana can boost the commander
|
||||||
|
mana.setFlag(true);
|
||||||
|
controller.getManaPool().addMana(mana, game, source);
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +182,7 @@ class OpalPalaceWatcher extends WatcherImpl<OpalPalaceWatcher> {
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
|
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
|
||||||
if (event.getSourceId().equals(this.getSourceId())) {
|
if (event.getSourceId().equals(this.getSourceId()) && event.getFlag()) { // flag indicates that mana was produced with second ability
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
Card card = spell.getCard();
|
Card card = spell.getCard();
|
||||||
|
|
|
@ -28,13 +28,12 @@
|
||||||
|
|
||||||
package mage;
|
package mage;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.filter.FilterMana;
|
import mage.filter.FilterMana;
|
||||||
import mage.util.Copyable;
|
import mage.util.Copyable;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -48,6 +47,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
protected int black;
|
protected int black;
|
||||||
protected int colorless;
|
protected int colorless;
|
||||||
protected int any;
|
protected int any;
|
||||||
|
protected boolean flag = false;
|
||||||
|
|
||||||
public static final Mana RedMana = RedMana(1);
|
public static final Mana RedMana = RedMana(1);
|
||||||
public static final Mana GreenMana = GreenMana(1);
|
public static final Mana GreenMana = GreenMana(1);
|
||||||
|
@ -59,13 +59,14 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
public Mana() {}
|
public Mana() {}
|
||||||
|
|
||||||
public Mana(final Mana mana) {
|
public Mana(final Mana mana) {
|
||||||
red = mana.red;
|
this.red = mana.red;
|
||||||
green = mana.green;
|
this.green = mana.green;
|
||||||
blue = mana.blue;
|
this.blue = mana.blue;
|
||||||
white = mana.white;
|
this.white = mana.white;
|
||||||
black = mana.black;
|
this.black = mana.black;
|
||||||
colorless = mana.colorless;
|
this.colorless = mana.colorless;
|
||||||
any = mana.any;
|
this.any = mana.any;
|
||||||
|
this.flag = mana.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mana(ColoredManaSymbol color) {
|
public Mana(ColoredManaSymbol color) {
|
||||||
|
@ -175,12 +176,24 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
return count();
|
return count();
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (filter.isBlack()) count += black;
|
if (filter.isBlack()) {
|
||||||
if (filter.isBlue()) count += blue;
|
count += black;
|
||||||
if (filter.isWhite()) count += white;
|
}
|
||||||
if (filter.isGreen()) count += green;
|
if (filter.isBlue()) {
|
||||||
if (filter.isRed()) count += red;
|
count += blue;
|
||||||
if (filter.isColorless()) count += colorless;
|
}
|
||||||
|
if (filter.isWhite()) {
|
||||||
|
count += white;
|
||||||
|
}
|
||||||
|
if (filter.isGreen()) {
|
||||||
|
count += green;
|
||||||
|
}
|
||||||
|
if (filter.isRed()) {
|
||||||
|
count += red;
|
||||||
|
}
|
||||||
|
if (filter.isColorless()) {
|
||||||
|
count += colorless;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,18 +211,24 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sbMana = new StringBuilder();
|
StringBuilder sbMana = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < red; i++)
|
for (int i = 0; i < red; i++) {
|
||||||
sbMana.append("{R}");
|
sbMana.append("{R}");
|
||||||
for (int i = 0; i < green; i++)
|
}
|
||||||
|
for (int i = 0; i < green; i++) {
|
||||||
sbMana.append("{G}");
|
sbMana.append("{G}");
|
||||||
for (int i = 0; i < blue; i++)
|
}
|
||||||
|
for (int i = 0; i < blue; i++) {
|
||||||
sbMana.append("{U}");
|
sbMana.append("{U}");
|
||||||
for (int i = 0; i < black; i++)
|
}
|
||||||
|
for (int i = 0; i < black; i++) {
|
||||||
sbMana.append("{B}");
|
sbMana.append("{B}");
|
||||||
for (int i = 0; i < white; i++)
|
}
|
||||||
|
for (int i = 0; i < white; i++) {
|
||||||
sbMana.append("{W}");
|
sbMana.append("{W}");
|
||||||
for (int i = 0; i < any; i++)
|
}
|
||||||
|
for (int i = 0; i < any; i++) {
|
||||||
sbMana.append("{Any}");
|
sbMana.append("{Any}");
|
||||||
|
}
|
||||||
if (colorless > 0) {
|
if (colorless > 0) {
|
||||||
sbMana.append("{").append(Integer.toString(colorless)).append("}");
|
sbMana.append("{").append(Integer.toString(colorless)).append("}");
|
||||||
}
|
}
|
||||||
|
@ -226,39 +245,45 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
compare.subtract(this);
|
compare.subtract(this);
|
||||||
if (compare.getRed() < 0) {
|
if (compare.getRed() < 0) {
|
||||||
compare.setAny(compare.getAny() + compare.getRed());
|
compare.setAny(compare.getAny() + compare.getRed());
|
||||||
if (compare.getAny() < 0)
|
if (compare.getAny() < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
compare.setRed(0);
|
compare.setRed(0);
|
||||||
}
|
}
|
||||||
if (compare.getGreen() < 0) {
|
if (compare.getGreen() < 0) {
|
||||||
compare.setAny(compare.getAny() + compare.getGreen());
|
compare.setAny(compare.getAny() + compare.getGreen());
|
||||||
if (compare.getAny() < 0)
|
if (compare.getAny() < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
compare.setGreen(0);
|
compare.setGreen(0);
|
||||||
}
|
}
|
||||||
if (compare.getBlue() < 0) {
|
if (compare.getBlue() < 0) {
|
||||||
compare.setAny(compare.getAny() + compare.getBlue());
|
compare.setAny(compare.getAny() + compare.getBlue());
|
||||||
if (compare.getAny() < 0)
|
if (compare.getAny() < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
compare.setBlue(0);
|
compare.setBlue(0);
|
||||||
}
|
}
|
||||||
if (compare.getBlack() < 0) {
|
if (compare.getBlack() < 0) {
|
||||||
compare.setAny(compare.getAny() + compare.getBlack());
|
compare.setAny(compare.getAny() + compare.getBlack());
|
||||||
if (compare.getAny() < 0)
|
if (compare.getAny() < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
compare.setBlack(0);
|
compare.setBlack(0);
|
||||||
}
|
}
|
||||||
if (compare.getWhite() < 0) {
|
if (compare.getWhite() < 0) {
|
||||||
compare.setAny(compare.getAny() + compare.getWhite());
|
compare.setAny(compare.getAny() + compare.getWhite());
|
||||||
if (compare.getAny() < 0)
|
if (compare.getAny() < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
compare.setWhite(0);
|
compare.setWhite(0);
|
||||||
}
|
}
|
||||||
if (compare.getColorless() < 0) {
|
if (compare.getColorless() < 0) {
|
||||||
int remaining = compare.getRed() + compare.getGreen() + compare.getBlack() + compare.getBlue() + compare.getWhite() + compare.getAny();
|
int remaining = compare.getRed() + compare.getGreen() + compare.getBlack() + compare.getBlue() + compare.getWhite() + compare.getAny();
|
||||||
if (compare.getColorless() + remaining < 0)
|
if (compare.getColorless() + remaining < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,18 +329,24 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mana needed = new Mana();
|
Mana needed = new Mana();
|
||||||
if (compare.getRed() < 0)
|
if (compare.getRed() < 0) {
|
||||||
needed.setRed(Math.abs(compare.getRed()));
|
needed.setRed(Math.abs(compare.getRed()));
|
||||||
if (compare.getWhite() < 0)
|
}
|
||||||
|
if (compare.getWhite() < 0) {
|
||||||
needed.setWhite(Math.abs(compare.getWhite()));
|
needed.setWhite(Math.abs(compare.getWhite()));
|
||||||
if (compare.getGreen() < 0)
|
}
|
||||||
|
if (compare.getGreen() < 0) {
|
||||||
needed.setGreen(Math.abs(compare.getGreen()));
|
needed.setGreen(Math.abs(compare.getGreen()));
|
||||||
if (compare.getBlack() < 0)
|
}
|
||||||
|
if (compare.getBlack() < 0) {
|
||||||
needed.setBlack(Math.abs(compare.getBlack()));
|
needed.setBlack(Math.abs(compare.getBlack()));
|
||||||
if (compare.getBlue() < 0)
|
}
|
||||||
|
if (compare.getBlue() < 0) {
|
||||||
needed.setBlue(Math.abs(compare.getBlue()));
|
needed.setBlue(Math.abs(compare.getBlue()));
|
||||||
if (compare.getColorless() < 0)
|
}
|
||||||
|
if (compare.getColorless() < 0) {
|
||||||
needed.setColorless(Math.abs(compare.getColorless()));
|
needed.setColorless(Math.abs(compare.getColorless()));
|
||||||
|
}
|
||||||
return needed;
|
return needed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,18 +417,24 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
* @return true if this contains any values that mana has
|
* @return true if this contains any values that mana has
|
||||||
*/
|
*/
|
||||||
public boolean contains(Mana mana) {
|
public boolean contains(Mana mana) {
|
||||||
if (mana.black > 0 && this.black > 0)
|
if (mana.black > 0 && this.black > 0) {
|
||||||
return true;
|
return true;
|
||||||
if (mana.blue > 0 && this.blue > 0)
|
}
|
||||||
|
if (mana.blue > 0 && this.blue > 0) {
|
||||||
return true;
|
return true;
|
||||||
if (mana.red > 0 && this.red > 0)
|
}
|
||||||
|
if (mana.red > 0 && this.red > 0) {
|
||||||
return true;
|
return true;
|
||||||
if (mana.white > 0 && this.white > 0)
|
}
|
||||||
|
if (mana.white > 0 && this.white > 0) {
|
||||||
return true;
|
return true;
|
||||||
if (mana.green > 0 && this.green > 0)
|
}
|
||||||
|
if (mana.green > 0 && this.green > 0) {
|
||||||
return true;
|
return true;
|
||||||
if (mana.colorless > 0 && this.count() > 0)
|
}
|
||||||
|
if (mana.colorless > 0 && this.count() > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -462,4 +499,12 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFlag(boolean flag) {
|
||||||
|
this.flag = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getFlag() {
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class ManaPool implements Serializable {
|
||||||
if (filter == null || filter.match(game.getObject(mana.getSourceId()), game)) {
|
if (filter == null || filter.match(game.getObject(mana.getSourceId()), game)) {
|
||||||
boolean spendAnyMana = spendAnyMana(ability, game);
|
boolean spendAnyMana = spendAnyMana(ability, game);
|
||||||
if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
|
if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
|
||||||
game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId()));
|
game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag()));
|
||||||
if (spendAnyMana) {
|
if (spendAnyMana) {
|
||||||
mana.removeAny();
|
mana.removeAny();
|
||||||
} else {
|
} else {
|
||||||
|
@ -290,7 +290,7 @@ public class ManaPool implements Serializable {
|
||||||
if (mana instanceof ConditionalMana) {
|
if (mana instanceof ConditionalMana) {
|
||||||
this.manaItems.add(new ManaPoolItem((ConditionalMana)mana, source.getSourceId()));
|
this.manaItems.add(new ManaPoolItem((ConditionalMana)mana, source.getSourceId()));
|
||||||
} else {
|
} else {
|
||||||
this.manaItems.add(new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getColorless(), source.getSourceId()));
|
this.manaItems.add(new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getColorless(), source.getSourceId(), mana.getFlag()));
|
||||||
}
|
}
|
||||||
GameEvent event = GameEvent.getEvent(GameEvent.EventType.MANA_ADDED, source.getSourceId(), source.getId(), source.getControllerId());
|
GameEvent event = GameEvent.getEvent(GameEvent.EventType.MANA_ADDED, source.getSourceId(), source.getId(), source.getControllerId());
|
||||||
event.setData(mana.toString());
|
event.setData(mana.toString());
|
||||||
|
|
|
@ -47,10 +47,11 @@ public class ManaPoolItem implements Serializable {
|
||||||
private int colorless = 0;
|
private int colorless = 0;
|
||||||
private ConditionalMana conditionalMana;
|
private ConditionalMana conditionalMana;
|
||||||
private UUID sourceId;
|
private UUID sourceId;
|
||||||
|
private boolean flag = false;
|
||||||
|
|
||||||
public ManaPoolItem() {}
|
public ManaPoolItem() {}
|
||||||
|
|
||||||
public ManaPoolItem(int red, int green, int blue, int white, int black, int colorless, UUID sourceId) {
|
public ManaPoolItem(int red, int green, int blue, int white, int black, int colorless, UUID sourceId, boolean flag) {
|
||||||
this.red = red;
|
this.red = red;
|
||||||
this.green = green;
|
this.green = green;
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
|
@ -58,6 +59,7 @@ public class ManaPoolItem implements Serializable {
|
||||||
this.black = black;
|
this.black = black;
|
||||||
this.colorless = colorless;
|
this.colorless = colorless;
|
||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManaPoolItem(ConditionalMana conditionalMana, UUID sourceId) {
|
public ManaPoolItem(ConditionalMana conditionalMana, UUID sourceId) {
|
||||||
|
@ -77,6 +79,7 @@ public class ManaPoolItem implements Serializable {
|
||||||
this.conditionalMana = item.conditionalMana.copy();
|
this.conditionalMana = item.conditionalMana.copy();
|
||||||
}
|
}
|
||||||
this.sourceId = item.sourceId;
|
this.sourceId = item.sourceId;
|
||||||
|
this.flag = item.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManaPoolItem copy() {
|
public ManaPoolItem copy() {
|
||||||
|
@ -87,6 +90,10 @@ public class ManaPoolItem implements Serializable {
|
||||||
return sourceId;
|
return sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getFlag() {
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
public int getRed() {
|
public int getRed() {
|
||||||
return red;
|
return red;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue