Add ignored failing test and fix bug for hybrid mana payments (#9566)

This commit is contained in:
Alex Vasile 2022-09-27 21:51:49 -04:00 committed by GitHub
parent b1b78d6db0
commit 01ee54d416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 10 deletions

View file

@ -6,6 +6,7 @@ import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
@ -65,4 +66,48 @@ public class GainAbilitiesTest extends CardTestPlayerBase {
).count());
}
/**
* Reported bug: https://github.com/magefree/mage/issues/9565
* 1. Cast all three of Frondland Felidar, Jubilant Skybonder, and Proud Wildbonder.
* 2. When the third one is cast (order doesn't matter), the other two will lose their abilities
*/
@Ignore
@Test
public void gainAbilitiesDontRemoveEachOther() {
// {2}{W}{G}
// Vigilance
// Creatures you control with vigilance have {1}, {T}: Tap target creature.
String frondlandFelidar = "Frondland Felidar";
// {1}{W/U}{W/U}
// Flying
// Creatures you control with flying have Spells your opponents cast that target this creature cost {2} more to cast.
String jubilantSkybonder = "Jubilant Skybonder";
// {2}{R/G}{R/G}
// Trample
// Creatures you control with trample have You may have this creature assign its combat damage as though it werent blocked.
String proudWildbonder = "Proud Wildbonder";
addCard(Zone.HAND, playerA, frondlandFelidar);
addCard(Zone.HAND, playerA, jubilantSkybonder);
addCard(Zone.HAND, playerA, proudWildbonder);
addCard(Zone.BATTLEFIELD, playerA, "Alloy Myr", 11);
showAvailableAbilities("", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, frondlandFelidar, true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, jubilantSkybonder, true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, proudWildbonder);
setStopAt(1, PhaseStep.END_TURN);
execute();
Permanent frondlandFelidarPerm = getPermanent(frondlandFelidar);
Permanent jubilantSkybonderPerm = getPermanent(jubilantSkybonder);
Permanent proudWildbonderPerm = getPermanent(proudWildbonder);
Assert.assertEquals(4, frondlandFelidarPerm.getAbilities(currentGame).size()); // Cast + Vigilence/Flying/Trample + "creature you control gain..." + Ability Gained from own effect.
Assert.assertEquals(4, jubilantSkybonderPerm.getAbilities(currentGame).size()); // Cast + Vigilence/Flying/Trample + "creature you control gain..." + Ability Gained from own effect.
Assert.assertEquals(4, proudWildbonderPerm.getAbilities(currentGame).size()); // Cast + Vigilence/Flying/Trample + "creature you control gain..." + Ability Gained from own effect.
}
}

View file

@ -62,37 +62,37 @@ public class HybridManaCost extends ManaCostImpl {
public boolean testPay(Mana testMana) {
switch (mana1) {
case B:
if (testMana.getBlack() > 0) {
if (testMana.getBlack() > 0 || testMana.getAny() > 0) {
return true;
}
case U:
if (testMana.getBlue() > 0) {
if (testMana.getBlue() > 0 || testMana.getAny() > 0) {
return true;
}
case R:
if (testMana.getRed() > 0) {
if (testMana.getRed() > 0 || testMana.getAny() > 0) {
return true;
}
case W:
if (testMana.getWhite() > 0) {
if (testMana.getWhite() > 0 || testMana.getAny() > 0) {
return true;
}
case G:
if (testMana.getGreen() > 0) {
if (testMana.getGreen() > 0 || testMana.getAny() > 0) {
return true;
}
}
switch (mana2) {
case B:
return testMana.getBlack() > 0;
return testMana.getBlack() > 0 || testMana.getAny() > 0;
case U:
return testMana.getBlue() > 0;
return testMana.getBlue() > 0 || testMana.getAny() > 0;
case R:
return testMana.getRed() > 0;
return testMana.getRed() > 0 || testMana.getAny() > 0;
case W:
return testMana.getWhite() > 0;
return testMana.getWhite() > 0 || testMana.getAny() > 0;
case G:
return testMana.getGreen() > 0;
return testMana.getGreen() > 0 || testMana.getAny() > 0;
}
return false;
}