Fixed multi color devotion for hybrid mana.

This commit is contained in:
LevelX2 2014-01-25 11:27:14 +01:00
parent bed5dce338
commit 6436a06add
8 changed files with 127 additions and 73 deletions

View file

@ -56,8 +56,9 @@ public class ColoredManaCost extends ManaCostImpl<ColoredManaCost> {
@Override
public boolean isPaid() {
if (paid)
if (paid) {
return true;
}
return this.isColoredPaid(mana);
}
@ -101,4 +102,9 @@ public class ColoredManaCost extends ManaCostImpl<ColoredManaCost> {
return new ColoredManaCost(this);
}
@Override
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
return mana.equals(coloredManaSymbol);
}
}

View file

@ -30,6 +30,7 @@ package mage.abilities.costs.mana;
import mage.Mana;
import mage.abilities.Ability;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;
import mage.players.ManaPool;
@ -88,5 +89,9 @@ public class GenericManaCost extends ManaCostImpl<GenericManaCost> {
public GenericManaCost copy() {
return new GenericManaCost(this);
}
@Override
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
return false;
}
}

View file

@ -1,40 +1,40 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.costs.mana;
import mage.constants.ColoredManaSymbol;
import mage.Mana;
import mage.abilities.Ability;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;
import mage.players.ManaPool;
public class HybridManaCost extends ManaCostImpl<HybridManaCost> {
private ColoredManaSymbol mana1;
private ColoredManaSymbol mana2;
@ -60,15 +60,17 @@ public class HybridManaCost extends ManaCostImpl<HybridManaCost> {
@Override
public boolean isPaid() {
if (paid || isColoredPaid(this.mana1) || isColoredPaid(this.mana2))
if (paid || isColoredPaid(this.mana1) || isColoredPaid(this.mana2)) {
return true;
}
return false;
}
@Override
public void assignPayment(Game game, Ability ability, ManaPool pool) {
if (assignColored(ability, game, pool, this.mana1))
if (assignColored(ability, game, pool, this.mana1)) {
return;
}
assignColored(ability, game, pool, this.mana2);
}
@ -86,20 +88,25 @@ public class HybridManaCost extends ManaCostImpl<HybridManaCost> {
public boolean testPay(Mana testMana) {
switch (mana1) {
case B:
if (testMana.getBlack() > 0)
if (testMana.getBlack() > 0) {
return true;
}
case U:
if (testMana.getBlue() >0)
if (testMana.getBlue() > 0) {
return true;
}
case R:
if (testMana.getRed() > 0)
if (testMana.getRed() > 0) {
return true;
}
case W:
if (testMana.getWhite() > 0)
if (testMana.getWhite() > 0) {
return true;
}
case G:
if (testMana.getGreen() > 0)
if (testMana.getGreen() > 0) {
return true;
}
}
switch (mana2) {
case B:
@ -120,4 +127,9 @@ public class HybridManaCost extends ManaCostImpl<HybridManaCost> {
public HybridManaCost copy() {
return new HybridManaCost(this);
}
@Override
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
return mana1.equals(coloredManaSymbol) || mana2.equals(coloredManaSymbol);
}
}

View file

@ -32,6 +32,7 @@ import mage.abilities.Ability;
import mage.abilities.costs.*;
import mage.Mana;
import mage.abilities.mana.ManaOptions;
import mage.constants.ColoredManaSymbol;
import mage.filter.Filter;
import mage.game.Game;
import mage.players.ManaPool;
@ -48,6 +49,7 @@ public interface ManaCost extends Cost {
boolean testPay(Mana testMana);
Filter getSourceFilter();
void setSourceFilter(Filter filter);
boolean containsColor(ColoredManaSymbol coloredManaSymbol);
@Override
String getText();

View file

@ -410,4 +410,13 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
}
}
@Override
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
for(ManaCost manaCost: this) {
if (manaCost.containsColor(coloredManaSymbol)) {
return true;
}
}
return false;
}
}

View file

@ -1,36 +1,35 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.costs.mana;
import mage.constants.ColoredManaSymbol;
import mage.Mana;
import mage.abilities.Ability;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;
import mage.players.ManaPool;
@ -60,8 +59,9 @@ public class MonoHybridManaCost extends ManaCostImpl<MonoHybridManaCost> {
@Override
public boolean isPaid() {
if (paid || isColoredPaid(this.mana))
if (paid || isColoredPaid(this.mana)) {
return true;
}
return isColorlessPaid(this.mana2);
}
@ -86,20 +86,25 @@ public class MonoHybridManaCost extends ManaCostImpl<MonoHybridManaCost> {
public boolean testPay(Mana testMana) {
switch (mana) {
case B:
if (testMana.getBlack() > 0)
if (testMana.getBlack() > 0) {
return true;
}
case U:
if (testMana.getBlue() > 0)
if (testMana.getBlue() > 0) {
return true;
}
case R:
if (testMana.getRed() > 0)
if (testMana.getRed() > 0) {
return true;
}
case W:
if (testMana.getWhite() > 0)
if (testMana.getWhite() > 0) {
return true;
}
case G:
if (testMana.getGreen() > 0)
if (testMana.getGreen() > 0) {
return true;
}
}
return testMana.count() > 0;
}
@ -109,4 +114,8 @@ public class MonoHybridManaCost extends ManaCostImpl<MonoHybridManaCost> {
return new MonoHybridManaCost(this);
}
@Override
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
return mana.equals(coloredManaSymbol);
}
}

View file

@ -31,6 +31,7 @@ package mage.abilities.costs.mana;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.VariableCost;
import mage.constants.ColoredManaSymbol;
import mage.filter.FilterMana;
import mage.game.Game;
import mage.players.ManaPool;
@ -146,5 +147,9 @@ public class VariableManaCost extends ManaCostImpl<VariableManaCost> implements
public void setMaxX(int maxX) {
this.maxX = maxX;
}
@Override
public boolean containsColor(ColoredManaSymbol coloredManaSymbol) {
return false;
}
}

View file

@ -7,6 +7,7 @@ package mage.abilities.dynamicvalue.common;
import java.util.ArrayList;
import java.util.Arrays;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;
@ -33,8 +34,13 @@ public class DevotionCount implements DynamicValue {
public int calculate(Game game, Ability sourceAbility) {
int devotion = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) {
for(ColoredManaSymbol coloredManaSymbol: devotionColors) {
devotion += permanent.getManaCost().getMana().getColor(coloredManaSymbol);
for(ManaCost manaCost :permanent.getManaCost()) {
for(ColoredManaSymbol coloredManaSymbol: devotionColors) {
if (manaCost.containsColor(coloredManaSymbol)) {
devotion++;
break; // count each manaCost maximum of one time (Hybrid don't count for multiple colors of devotion)
}
}
}
}
return devotion;