forked from External/mage
Tyvar Kell and gain ability fixes:
* GainAbilityTargetEffect - reworked to support static/dynamic targets, added support of spells (card + related permanent); * SpellCastControllerTriggeredAbility - now it can setup the target to a card instead a spell; * Added checks/errors on wrong ability adding code (example: if you add permanent's ability by game state instead permanent's method); * Tyvar Kell Emblem now use a standard code; * Test framework: added additional logs for some errors;
This commit is contained in:
parent
f131fd0d12
commit
6dcbcbe962
13 changed files with 291 additions and 140 deletions
|
|
@ -1,8 +1,5 @@
|
|||
package mage.cards;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectImpl;
|
||||
import mage.Mana;
|
||||
|
|
@ -19,6 +16,7 @@ import mage.game.*;
|
|||
import mage.game.command.CommandObject;
|
||||
import mage.game.events.*;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -26,6 +24,10 @@ import mage.util.GameLog;
|
|||
import mage.watchers.Watcher;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -310,6 +312,12 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
abilities.add(subAbility);
|
||||
}
|
||||
|
||||
// dynamic check: you can't add ability to the PermanentCard, use permanent.addAbility(a, source, game) instead
|
||||
// reason: triggered abilities are not processing here
|
||||
if (this instanceof PermanentCard) {
|
||||
throw new IllegalArgumentException("Wrong code usage. Don't use that method for permanents, use permanent.addAbility(a, source, game) instead.");
|
||||
}
|
||||
|
||||
// verify check: draw effect can't be rollback after mana usage (example: Chromatic Sphere)
|
||||
// (player can cheat with cancel button to see next card)
|
||||
// verify test will catch that errors
|
||||
|
|
@ -325,8 +333,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void addAbilities(List<Ability> abilities) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue