mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
some reworking of sagas, added tests
This commit is contained in:
parent
949b2671e0
commit
6ca7b06ab9
2 changed files with 83 additions and 33 deletions
|
@ -13,6 +13,8 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
public class SagaTest extends CardTestPlayerBase {
|
public class SagaTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
private static final String rite = "Rite of Belzenlok";
|
private static final String rite = "Rite of Belzenlok";
|
||||||
|
private static final String vorinclex = "Vorinclex, Monstrous Raider";
|
||||||
|
private static final String flicker = "Flicker";
|
||||||
private static final String boomerang = "Boomerang";
|
private static final String boomerang = "Boomerang";
|
||||||
private static final String saga = "Urza's Saga";
|
private static final String saga = "Urza's Saga";
|
||||||
private static final String moon = "Blood Moon";
|
private static final String moon = "Blood Moon";
|
||||||
|
@ -45,6 +47,38 @@ public class SagaTest extends CardTestPlayerBase {
|
||||||
assertPermanentCount(playerA, "Demon", 1);
|
assertPermanentCount(playerA, "Demon", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRiteOfBelzenlokFlicker() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
||||||
|
addCard(Zone.HAND, playerA, rite);
|
||||||
|
addCard(Zone.HAND, playerA, flicker);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, rite);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
assertCounterCount(rite, CounterType.LORE, 1);
|
||||||
|
assertPermanentCount(playerA, "Cleric", 2);
|
||||||
|
|
||||||
|
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertCounterCount(rite, CounterType.LORE, 2);
|
||||||
|
assertPermanentCount(playerA, "Cleric", 4);
|
||||||
|
|
||||||
|
castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerA, flicker, rite);
|
||||||
|
setStopAt(3, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, rite, 0);
|
||||||
|
assertPermanentCount(playerA, rite, 1);
|
||||||
|
assertCounterCount(playerA, rite, CounterType.LORE, 1);
|
||||||
|
assertPermanentCount(playerA, "Cleric", 6);
|
||||||
|
assertPermanentCount(playerA, "Demon", 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRiteOfBelzenlokBounced() {
|
public void testRiteOfBelzenlokBounced() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||||
|
@ -77,6 +111,29 @@ public class SagaTest extends CardTestPlayerBase {
|
||||||
assertPermanentCount(playerA, "Demon", 1);
|
assertPermanentCount(playerA, "Demon", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRiteOfBelzenlokVorinclex() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, vorinclex);
|
||||||
|
addCard(Zone.HAND, playerA, rite);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, rite);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
assertCounterCount(rite, CounterType.LORE, 2);
|
||||||
|
assertPermanentCount(playerA, "Cleric", 4);
|
||||||
|
|
||||||
|
setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, rite, 1);
|
||||||
|
assertPermanentCount(playerA, rite, 0);
|
||||||
|
assertPermanentCount(playerA, "Cleric", 4);
|
||||||
|
assertPermanentCount(playerA, "Demon", 1);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUrzasSagaThenBloodMoon() {
|
public void testUrzasSagaThenBloodMoon() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
||||||
|
@ -125,7 +182,7 @@ public class SagaTest extends CardTestPlayerBase {
|
||||||
assertPermanentCount(playerA, moon, 1);
|
assertPermanentCount(playerA, moon, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore // TODO: fix this
|
@Ignore // TODO: fix this, related to blood moon etb issues
|
||||||
@Test
|
@Test
|
||||||
public void testBloodMoonThenUrzasSagaThenBounce() {
|
public void testBloodMoonThenUrzasSagaThenBounce() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
|
||||||
|
|
|
@ -17,18 +17,22 @@ import mage.game.stack.StackAbility;
|
||||||
import mage.game.stack.StackObject;
|
import mage.game.stack.StackObject;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.Targets;
|
import mage.target.Targets;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class SagaAbility extends SimpleStaticAbility {
|
public class SagaAbility extends SimpleStaticAbility {
|
||||||
|
|
||||||
private SagaChapter maxChapter;
|
private final SagaChapter maxChapter;
|
||||||
|
|
||||||
public SagaAbility(Card card, SagaChapter maxChapter) {
|
public SagaAbility(Card card, SagaChapter maxChapter) {
|
||||||
super(Zone.ALL, new AddCountersSourceEffect(CounterType.LORE.createInstance()));
|
super(Zone.ALL, new AddCountersSourceEffect(CounterType.LORE.createInstance()));
|
||||||
this.maxChapter = maxChapter;
|
this.maxChapter = maxChapter;
|
||||||
this.setRuleVisible(false);
|
this.setRuleVisible(true);
|
||||||
|
this.setRuleAtTheTop(true);
|
||||||
Ability ability = new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LORE.createInstance()));
|
Ability ability = new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LORE.createInstance()));
|
||||||
ability.setRuleVisible(false);
|
ability.setRuleVisible(false);
|
||||||
card.addAbility(ability);
|
card.addAbility(ability);
|
||||||
|
@ -86,9 +90,6 @@ public class SagaAbility extends SimpleStaticAbility {
|
||||||
}
|
}
|
||||||
card.addAbility(ability);
|
card.addAbility(ability);
|
||||||
}
|
}
|
||||||
if (maxChapter == null || toChapter.getNumber() > maxChapter.getNumber()) {
|
|
||||||
maxChapter = toChapter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SagaChapter getMaxChapter() {
|
public SagaChapter getMaxChapter() {
|
||||||
|
@ -119,7 +120,7 @@ public class SagaAbility extends SimpleStaticAbility {
|
||||||
|
|
||||||
class ChapterTriggeredAbility extends TriggeredAbilityImpl {
|
class ChapterTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
private SagaChapter chapterFrom, chapterTo;
|
private final SagaChapter chapterFrom, chapterTo;
|
||||||
|
|
||||||
public ChapterTriggeredAbility(Effect effect, SagaChapter chapterFrom, SagaChapter chapterTo, boolean optional) {
|
public ChapterTriggeredAbility(Effect effect, SagaChapter chapterFrom, SagaChapter chapterTo, boolean optional) {
|
||||||
super(Zone.ALL, effect, optional);
|
super(Zone.ALL, effect, optional);
|
||||||
|
@ -140,22 +141,18 @@ class ChapterTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getTargetId().equals(getSourceId()) && event.getData().equals(CounterType.LORE.getName())) {
|
if (!event.getTargetId().equals(getSourceId())
|
||||||
int amountAdded = event.getAmount();
|
|| !event.getData().equals(CounterType.LORE.getName())) {
|
||||||
int loreCounters = amountAdded;
|
|
||||||
//Permanent sourceSaga = game.getPermanentOrLKIBattlefield(getSourceId()); BUG #5393
|
|
||||||
Permanent sourceSaga = game.getPermanent(getSourceId());
|
|
||||||
if (sourceSaga == null) {
|
|
||||||
sourceSaga = game.getPermanentEntering(getSourceId());
|
|
||||||
}
|
|
||||||
if (sourceSaga != null) {
|
|
||||||
loreCounters = sourceSaga.getCounters(game).getCount(CounterType.LORE);
|
|
||||||
}
|
|
||||||
return loreCounters - amountAdded < chapterFrom.getNumber()
|
|
||||||
&& chapterFrom.getNumber() <= loreCounters;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Permanent permanent = getSourcePermanentIfItStillExists(game);
|
||||||
|
if (permanent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int loreCounters = permanent.getCounters(game).getCount(CounterType.LORE);
|
||||||
|
return loreCounters - event.getAmount() < chapterFrom.getNumber()
|
||||||
|
&& chapterFrom.getNumber() <= loreCounters;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChapterTriggeredAbility copy() {
|
public ChapterTriggeredAbility copy() {
|
||||||
|
@ -177,17 +174,13 @@ class ChapterTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
StringBuilder sb = new StringBuilder();
|
return Arrays
|
||||||
for (SagaChapter chapter : SagaChapter.values()) {
|
.stream(SagaChapter.values())
|
||||||
if (chapter.getNumber() >= getChapterFrom().getNumber()
|
.filter(chapter -> chapterFrom.getNumber() <= chapter.getNumber())
|
||||||
&& chapter.getNumber() < getChapterTo().getNumber()) {
|
.filter(chapter -> chapter.getNumber() <= chapterTo.getNumber())
|
||||||
sb.append(chapter.toString()).append(", ");
|
.map(SagaChapter::toString)
|
||||||
} else if (chapter.equals(getChapterTo())) {
|
.reduce((a, b) -> a + ", " + b)
|
||||||
sb.append(chapter.toString());
|
.orElse("")
|
||||||
}
|
+ " - " + CardUtil.getTextWithFirstCharUpperCase(super.getRule());
|
||||||
}
|
|
||||||
String text = super.getRule();
|
|
||||||
sb.append(" - ").append(Character.toUpperCase(text.charAt(0))).append(text.substring(1));
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue