mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
refactor: improved some error messages/tests
This commit is contained in:
parent
7f8526192f
commit
f0da749e0a
3 changed files with 11 additions and 7 deletions
|
|
@ -5,10 +5,7 @@ import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.common.LegendarySpellAbility;
|
import mage.abilities.common.*;
|
||||||
import mage.abilities.common.SagaAbility;
|
|
||||||
import mage.abilities.common.WerewolfBackTriggeredAbility;
|
|
||||||
import mage.abilities.common.WerewolfFrontTriggeredAbility;
|
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.FightTargetsEffect;
|
import mage.abilities.effects.common.FightTargetsEffect;
|
||||||
import mage.abilities.effects.common.counter.ProliferateEffect;
|
import mage.abilities.effects.common.counter.ProliferateEffect;
|
||||||
|
|
@ -1734,6 +1731,11 @@ public class VerifyCardDataTest {
|
||||||
fail(card, "abilities", "the back face of a double-faced card should be nightCard = true");
|
fail(card, "abilities", "the back face of a double-faced card should be nightCard = true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special check: siege ability must be used in double faced cards only
|
||||||
|
if (card.getAbilities().containsClass(SiegeAbility.class) && card.getSecondCardFace() == null) {
|
||||||
|
fail(card, "abilities", "miss second side settings in card with siege ability");
|
||||||
|
}
|
||||||
|
|
||||||
// special check: legendary spells need to have legendary spell ability
|
// special check: legendary spells need to have legendary spell ability
|
||||||
if (card.isLegendary() && !card.isPermanent() && !card.getAbilities().containsClass(LegendarySpellAbility.class)) {
|
if (card.isLegendary() && !card.isPermanent() && !card.getAbilities().containsClass(LegendarySpellAbility.class)) {
|
||||||
fail(card, "abilities", "legendary nonpermanent cards need to have LegendarySpellAbility");
|
fail(card, "abilities", "legendary nonpermanent cards need to have LegendarySpellAbility");
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,12 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
||||||
if (event == null || !game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) {
|
if (event == null || !game.getContinuousEffects().preventedByRuleModification(event, ability, game, false)) {
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
boolean controllerSet = false;
|
boolean controllerSet = false;
|
||||||
if (ability.getZone() != Zone.COMMAND && event != null
|
if (ability.getZone() != Zone.COMMAND
|
||||||
|
&& event != null
|
||||||
&& event.getTargetId() != null
|
&& event.getTargetId() != null
|
||||||
&& ability.isLeavesTheBattlefieldTrigger()
|
&& ability.isLeavesTheBattlefieldTrigger()
|
||||||
&& game.getLKI().get(Zone.BATTLEFIELD) != null && game.getLKI().get(Zone.BATTLEFIELD).containsKey(ability.getSourceId())) {
|
&& game.getLKI().get(Zone.BATTLEFIELD) != null
|
||||||
|
&& game.getLKI().get(Zone.BATTLEFIELD).containsKey(ability.getSourceId())) {
|
||||||
// need to check if object was face down for dies and destroy events because the ability triggers in the new zone, zone counter -1 is used
|
// need to check if object was face down for dies and destroy events because the ability triggers in the new zone, zone counter -1 is used
|
||||||
Permanent permanent = (Permanent) game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD, ability.getSourceObjectZoneChangeCounter() - 1);
|
Permanent permanent = (Permanent) game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD, ability.getSourceObjectZoneChangeCounter() - 1);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
public SpellAbility getSecondFaceSpellAbility() {
|
public SpellAbility getSecondFaceSpellAbility() {
|
||||||
Card secondFace = getSecondCardFace();
|
Card secondFace = getSecondCardFace();
|
||||||
if (secondFace == null || secondFace.getClass().equals(getClass())) {
|
if (secondFace == null || secondFace.getClass().equals(getClass())) {
|
||||||
throw new IllegalArgumentException("Wrong code usage. getSecondFaceSpellAbility can only be used for double faced card (main side).");
|
throw new IllegalArgumentException("Wrong code usage: getSecondFaceSpellAbility can only be used for double faced card (main side), broken card: " + this.getName());
|
||||||
}
|
}
|
||||||
return secondFace.getSpellAbility();
|
return secondFace.getSpellAbility();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue