mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Tests: added verify check for wrong optional settings on DoIfCostPaid usage;
This commit is contained in:
parent
9dc3d514bd
commit
61bfdf8108
2 changed files with 13 additions and 1 deletions
|
@ -1499,7 +1499,8 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_CardsCreatingAndConstructorErrors() {
|
||||
public void test_checkCardConstructors() {
|
||||
Collection<String> errorsList = new ArrayList<>();
|
||||
int errorsCount = 0;
|
||||
Collection<ExpansionSet> sets = Sets.getInstance().values();
|
||||
for (ExpansionSet set : sets) {
|
||||
|
@ -1509,15 +1510,18 @@ public class VerifyCardDataTest {
|
|||
Card card = CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
|
||||
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()));
|
||||
if (card == null) {
|
||||
errorsList.add("Broken constructor: " + setInfo.getCardClass());
|
||||
errorsCount++;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// CardImpl.createCard don't throw exceptions (only error logs), so that logs are useless here
|
||||
logger.error("Can't create card " + setInfo.getName() + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errorsCount > 0) {
|
||||
printMessages(errorsList);
|
||||
Assert.fail("Founded " + errorsCount + " broken cards, look at logs for stack error");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package mage.abilities;
|
|||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DoIfCostPaid;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
@ -32,6 +33,13 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
addEffect(effect);
|
||||
}
|
||||
this.optional = optional;
|
||||
|
||||
// verify check: DoIfCostPaid effect already asks about action (optional), so no needs to ask it again in triggered ability
|
||||
if (effect instanceof DoIfCostPaid) {
|
||||
if (this.optional && ((DoIfCostPaid) effect).isOptional()) {
|
||||
throw new IllegalArgumentException("DoIfCostPaid effect must have only one optional settings, but it have two (trigger + DoIfCostPaid): " + this.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TriggeredAbilityImpl(final TriggeredAbilityImpl ability) {
|
||||
|
|
Loading…
Reference in a new issue