Added W mana test case

Added U mana test case
Added B mana test case
Added R mana test case
Added G mana test case
This commit is contained in:
poixen 2015-11-20 19:38:29 +01:00
parent 8a133a43d0
commit f6cc03ec44
2 changed files with 223 additions and 55 deletions

View file

@ -0,0 +1,154 @@
package mage;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Custom unit tests for {@link ManaSymbol}
*/
public class ManaSymbolTest {
@Test
public void shouldCreateWhiteManaSymbol() {
// given
// when
ManaSymbol w = ManaSymbol.W;
// then
assertEquals("{W}", w.toString());
assertFalse(w.isBlack());
assertFalse(w.isBlue());
assertFalse(w.isRed());
assertFalse(w.isGreen());
assertFalse(w.isColorless());
assertFalse(w.isSnow());
assertFalse(w.isPhyrexian());
assertFalse(w.isGeneric());
assertFalse(w.isHybrid());
assertTrue(w.isColored());
assertTrue(w.isWhite());
assertTrue(w.isPrimary());
assertTrue(w.isMonocolored());
assertEquals(null, w.getManaSymbol1());
assertEquals(null, w.getManaSymbol1());
}
@Test
public void shouldCreateBlueManaSymbol() {
// given
// when
ManaSymbol u = ManaSymbol.U;
// then
assertEquals("{U}", u.toString());
assertFalse(u.isBlack());
assertFalse(u.isWhite());
assertFalse(u.isRed());
assertFalse(u.isGreen());
assertFalse(u.isColorless());
assertFalse(u.isSnow());
assertFalse(u.isPhyrexian());
assertFalse(u.isGeneric());
assertFalse(u.isHybrid());
assertTrue(u.isColored());
assertTrue(u.isBlue());
assertTrue(u.isPrimary());
assertTrue(u.isMonocolored());
assertEquals(null, u.getManaSymbol1());
assertEquals(null, u.getManaSymbol1());
}
@Test
public void shouldCreateBlackManaSymbol() {
// given
// when
ManaSymbol b = ManaSymbol.B;
// then
assertEquals("{B}", b.toString());
assertFalse(b.isBlue());
assertFalse(b.isWhite());
assertFalse(b.isRed());
assertFalse(b.isGreen());
assertFalse(b.isColorless());
assertFalse(b.isSnow());
assertFalse(b.isPhyrexian());
assertFalse(b.isGeneric());
assertFalse(b.isHybrid());
assertTrue(b.isColored());
assertTrue(b.isBlack());
assertTrue(b.isPrimary());
assertTrue(b.isMonocolored());
assertEquals(null, b.getManaSymbol1());
assertEquals(null, b.getManaSymbol1());
}
@Test
public void shouldCreateRedManaSymbol() {
// given
// when
ManaSymbol r = ManaSymbol.R;
// then
assertEquals("{R}", r.toString());
assertFalse(r.isBlue());
assertFalse(r.isWhite());
assertFalse(r.isBlack());
assertFalse(r.isGreen());
assertFalse(r.isColorless());
assertFalse(r.isSnow());
assertFalse(r.isPhyrexian());
assertFalse(r.isGeneric());
assertFalse(r.isHybrid());
assertTrue(r.isColored());
assertTrue(r.isRed());
assertTrue(r.isPrimary());
assertTrue(r.isMonocolored());
assertEquals(null, r.getManaSymbol1());
assertEquals(null, r.getManaSymbol1());
}
@Test
public void shouldCreateGreenManaSymbol() {
// given
// when
ManaSymbol g = ManaSymbol.G;
// then
assertEquals("{G}", g.toString());
assertFalse(g.isBlue());
assertFalse(g.isWhite());
assertFalse(g.isBlack());
assertFalse(g.isRed());
assertFalse(g.isColorless());
assertFalse(g.isSnow());
assertFalse(g.isPhyrexian());
assertFalse(g.isGeneric());
assertFalse(g.isHybrid());
assertTrue(g.isColored());
assertTrue(g.isGreen());
assertTrue(g.isPrimary());
assertTrue(g.isMonocolored());
assertEquals(null, g.getManaSymbol1());
assertEquals(null, g.getManaSymbol1());
}
}

View file

@ -1,32 +1,33 @@
package mage; package mage;
/** /**
* Enum representing the mana symbols. * Enum representing the mana symbols.
* * <p>
* 107.4. The mana symbols are {W}, {U}, {B}, {R}, {G}, and {X}; the numerals * 107.4. The mana symbols are {W}, {U}, {B}, {R}, {G}, and {X}; the numerals
* {0}, {1}, {2}, {3}, {4}, and so on; the hybrid symbols {W/U}, {W/B}, {U/B}, * {0}, {1}, {2}, {3}, {4}, and so on; the hybrid symbols {W/U}, {W/B}, {U/B},
* {U/R}, {B/R}, {B/G}, {R/G}, {R/W}, {G/W}, and {G/U}; the monocolored hybrid * {U/R}, {B/R}, {B/G}, {R/G}, {R/W}, {G/W}, and {G/U}; the monocolored hybrid
* symbols {2/W}, {2/U}, {2/B}, {2/R}, and {2/G}; the Phyrexian mana symbols * symbols {2/W}, {2/U}, {2/B}, {2/R}, and {2/G}; the Phyrexian mana symbols
* {W/P}, {U/P}, {B/P}, {R/P}, and {G/P}; and the snow symbol {S}. * {W/P}, {U/P}, {B/P}, {R/P}, and {G/P}; and the snow symbol {S}.
* * <p>
* 107.4a. There are five primary colored mana symbols: {W} is white, {U} blue, * 107.4a. There are five primary colored mana symbols: {W} is white, {U} blue,
* {B} black, {R} red, and {G} green. These symbols are used to represent colored * {B} black, {R} red, and {G} green. These symbols are used to represent colored
* mana, and also to represent colored mana in costs. Colored mana in costs can * mana, and also to represent colored mana in costs. Colored mana in costs can
* be paid only with the appropriate color of mana. See rule 202, "Mana Cost and * be paid only with the appropriate color of mana. See rule 202, "Mana Cost and
* Color." * Color."
* * <p>
* 107.4b. Numeral symbols (such as {1}) and variable symbols (such as {X}) * 107.4b. Numeral symbols (such as {1}) and variable symbols (such as {X})
* represent generic mana in costs. Generic mana in costs can be paid with any * represent generic mana in costs. Generic mana in costs can be paid with any
* type of mana. For more information about {X}, see rule 107.3. * type of mana. For more information about {X}, see rule 107.3.
* * <p>
* 107.4c. Numeral symbols (such as {1}) and variable symbols (such as {X}) can * 107.4c. Numeral symbols (such as {1}) and variable symbols (such as {X}) can
* also represent colorless mana if they appear in the effect of a spell or * also represent colorless mana if they appear in the effect of a spell or
* ability that reads "add [mana symbol] to your mana pool" or something similar. * ability that reads "add [mana symbol] to your mana pool" or something similar.
* (See rule 107.3e.) * (See rule 107.3e.)
* * <p>
* 107.4d. The symbol {0} represents zero mana and is used as a placeholder for a * 107.4d. The symbol {0} represents zero mana and is used as a placeholder for a
* cost that can be paid with no resources. (See rule 117.5.) * cost that can be paid with no resources. (See rule 117.5.)
* * <p>
* 107.4e. Hybrid mana symbols are also colored mana symbols. Each one represents * 107.4e. Hybrid mana symbols are also colored mana symbols. Each one represents
* a cost that can be paid in one of two ways, as represented by the two halves * a cost that can be paid in one of two ways, as represented by the two halves
* of the symbol. A hybrid symbol such as {W/U} can be paid with either white or * of the symbol. A hybrid symbol such as {W/U} can be paid with either white or
@ -34,32 +35,31 @@ package mage;
* either one black mana or two mana of any type. A hybrid mana symbol is all of * either one black mana or two mana of any type. A hybrid mana symbol is all of
* its component colors. Example: {G/W}{G/W} can be paid by spending {G}{G}, * its component colors. Example: {G/W}{G/W} can be paid by spending {G}{G},
* {G}{W}, or {W}{W}. * {G}{W}, or {W}{W}.
* * <p>
* 107.4f. Phyrexian mana symbols are colored mana symbols: {W/P} is white, {U/P} * 107.4f. Phyrexian mana symbols are colored mana symbols: {W/P} is white, {U/P}
* is blue, {B/P} is black, {R/P} is red, and {G/P} is green. A Phyrexian mana * is blue, {B/P} is black, {R/P} is red, and {G/P} is green. A Phyrexian mana
* symbol represents a cost that can be paid either with one mana of its color or * symbol represents a cost that can be paid either with one mana of its color or
* by paying 2 life. Example: {W/P}{W/P} can be paid by spending {W}{W}, by * by paying 2 life. Example: {W/P}{W/P} can be paid by spending {W}{W}, by
* spending {W} and paying 2 life, or by paying 4 life. * spending {W} and paying 2 life, or by paying 4 life.
* * <p>
* 107.4g. In rules text, the Phyrexian symbol {P} with no colored background * 107.4g. In rules text, the Phyrexian symbol {P} with no colored background
* means any of the five Phyrexian mana symbols. * means any of the five Phyrexian mana symbols.
* * <p>
* 107.4h. The snow mana symbol {S} represents one generic mana in a cost. This * 107.4h. The snow mana symbol {S} represents one generic mana in a cost. This
* generic mana can be paid with one mana of any type produced by a snow * generic mana can be paid with one mana of any type produced by a snow
* permanent (see rule 205.4f). Effects that reduce the amount of generic mana * permanent (see rule 205.4f). Effects that reduce the amount of generic mana
* you pay don't affect {S} costs. (There is no such thing as "snow mana"; "snow" * you pay don't affect {S} costs. (There is no such thing as "snow mana"; "snow"
* is not a type of mana.) * is not a type of mana.)
* *
*
* @author noxx * @author noxx
*/ */
public enum ManaSymbol { public enum ManaSymbol {
W("{W}", Type.PRIMARY, Type.COLORED), W("{W}", Type.PRIMARY, Type.COLORED, Type.MONOCOLORED),
U("{U}", Type.PRIMARY, Type.COLORED), U("{U}", Type.PRIMARY, Type.COLORED, Type.MONOCOLORED),
B("{B}", Type.PRIMARY, Type.COLORED), B("{B}", Type.PRIMARY, Type.COLORED, Type.MONOCOLORED),
R("{R}", Type.PRIMARY, Type.COLORED), R("{R}", Type.PRIMARY, Type.COLORED, Type.MONOCOLORED),
G("{G}", Type.PRIMARY, Type.COLORED), G("{G}", Type.PRIMARY, Type.COLORED, Type.MONOCOLORED),
X("{X}", Type.GENERIC, Type.COLORLESS), X("{X}", Type.GENERIC, Type.COLORLESS),
NUMERIC("{N/A}", Type.GENERIC, Type.COLORLESS), NUMERIC("{N/A}", Type.GENERIC, Type.COLORLESS),
HYBRID_WU("{W/U}", W, U, Type.HYBRID, Type.COLORED), HYBRID_WU("{W/U}", W, U, Type.HYBRID, Type.COLORED),
@ -115,7 +115,6 @@ public enum ManaSymbol {
private final ManaSymbol manaSymbol2; private final ManaSymbol manaSymbol2;
/** /**
*
* @param symbol * @param symbol
* @param manaSymbol1 First associated mana symbol. For hybrid mana symbol. * @param manaSymbol1 First associated mana symbol. For hybrid mana symbol.
* @param manaSymbol2 Second associated mana symbol. For hybrid mana symbol. * @param manaSymbol2 Second associated mana symbol. For hybrid mana symbol.
@ -127,14 +126,30 @@ public enum ManaSymbol {
boolean lMonocolored = false, lHybrid = false, lPhyrexian = false, lSnow = false; boolean lMonocolored = false, lHybrid = false, lPhyrexian = false, lSnow = false;
for (Type type : types) { for (Type type : types) {
switch (type) { switch (type) {
case PRIMARY: lPrimary = true; break; case PRIMARY:
case COLORED: lColored = true; break; lPrimary = true;
case GENERIC: lGeneric = true; break; break;
case COLORLESS: lColorless = true; break; case COLORED:
case MONOCOLORED: lMonocolored = true; break; lColored = true;
case HYBRID: lHybrid = true; break; break;
case PHYREXIAN: lPhyrexian = true; break; case GENERIC:
case SNOW: lSnow = true; break; lGeneric = true;
break;
case COLORLESS:
lColorless = true;
break;
case MONOCOLORED:
lMonocolored = true;
break;
case HYBRID:
lHybrid = true;
break;
case PHYREXIAN:
lPhyrexian = true;
break;
case SNOW:
lSnow = true;
break;
} }
} }
primary = lPrimary; primary = lPrimary;
@ -155,7 +170,6 @@ public enum ManaSymbol {
} }
/** /**
*
* @param symbol * @param symbol
* @param manaSymbol Associated mana symbol. For monocolored hybrid and phyrexian mana. * @param manaSymbol Associated mana symbol. For monocolored hybrid and phyrexian mana.
* @param types * @param types