mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Merge pull request #2911 from ingmargoudt/master
added new helper methods to test for CardType, to get rid of the cont…
This commit is contained in:
commit
545b21881b
69 changed files with 151 additions and 120 deletions
|
@ -209,8 +209,8 @@ public class TransformTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerA, "Startled Awake", 0);
|
||||
assertPermanentCount(playerA, "Persistent Nightmare", 1); // Night-side card of Startled Awake
|
||||
Permanent nightmare = getPermanent("Persistent Nightmare", playerA);
|
||||
Assert.assertTrue("Has to have creature card type", nightmare.getCardType().contains(CardType.CREATURE));
|
||||
Assert.assertFalse("Has not to have sorcery card type", nightmare.getCardType().contains(CardType.SORCERY));
|
||||
Assert.assertTrue("Has to have creature card type", nightmare.isCreature());
|
||||
Assert.assertFalse("Has not to have sorcery card type", nightmare.isSorcery());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -82,4 +82,34 @@ public interface MageObject extends MageItem, Serializable {
|
|||
|
||||
void setZoneChangeCounter(int value, Game game);
|
||||
|
||||
|
||||
|
||||
default boolean isCreature(){
|
||||
return getCardType().contains(CardType.CREATURE);
|
||||
}
|
||||
|
||||
default boolean isArtifact(){
|
||||
return getCardType().contains(CardType.ARTIFACT);
|
||||
}
|
||||
|
||||
default boolean isLand(){
|
||||
return getCardType().contains(CardType.LAND);
|
||||
}
|
||||
|
||||
default boolean isEnchantment(){
|
||||
return getCardType().contains(CardType.ENCHANTMENT);
|
||||
}
|
||||
|
||||
default boolean isInstant(){
|
||||
return getCardType().contains(CardType.INSTANT);
|
||||
}
|
||||
|
||||
default boolean isSorcery(){
|
||||
return getCardType().contains(CardType.SORCERY);
|
||||
}
|
||||
|
||||
default boolean isPlaneswalker(){
|
||||
return getCardType().contains(CardType.PLANESWALKER);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
public ObjectColor getFrameColor(Game game) {
|
||||
// For lands, add any colors of mana the land can produce to
|
||||
// its frame colors.
|
||||
if (getCardType().contains(CardType.LAND)) {
|
||||
if (this.isLand()) {
|
||||
ObjectColor cl = frameColor.copy();
|
||||
for (Ability ab: getAbilities()) {
|
||||
if (ab instanceof ActivatedManaAbilityImpl) {
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ConstellationAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.ENCHANTMENT)) {
|
||||
if (permanent != null && permanent.isEnchantment()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class AttacksAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
check = true;
|
||||
} else {
|
||||
Permanent planeswalker = game.getPermanent(event.getTargetId());
|
||||
if (planeswalker != null && planeswalker.getCardType().contains(CardType.PLANESWALKER) && planeswalker.getControllerId().equals(getControllerId())) {
|
||||
if (planeswalker != null && planeswalker.isPlaneswalker() && planeswalker.getControllerId().equals(getControllerId())) {
|
||||
check = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class DealtDamageAndDiedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getTarget().getCardType().contains(CardType.CREATURE)) {
|
||||
if (zEvent.getTarget().isCreature()) {
|
||||
boolean damageDealt = false;
|
||||
for (MageObjectReference mor : zEvent.getTarget().getDealtDamageByThisTurn()) {
|
||||
if (mor.refersTo(getSourceObject(game), game)) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class FeralDeceiverAbility extends LimitedTimesPerTurnActivatedAbility {
|
|||
Card card = player.getLibrary().getFromTop(game);
|
||||
cards.add(card);
|
||||
player.revealCards("Feral Deceiver", cards, game);
|
||||
if (card != null && card.getCardType().contains(CardType.LAND)) {
|
||||
if (card != null && card.isLand()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class LandfallAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null
|
||||
&& permanent.getCardType().contains(CardType.LAND)
|
||||
&& permanent.isLand()
|
||||
&& permanent.getControllerId().equals(this.controllerId)) {
|
||||
triggeringLand = permanent;
|
||||
if (setTargetPointer == SetTargetPointer.PERMANENT) {
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TapLandForManaAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
|
||||
if (permanent != null && permanent.isLand()) {
|
||||
if (setTargetPointer) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TapLandForManaAllTriggeredManaAbility extends TriggeredManaAbility
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
|
||||
if (permanent != null && permanent.isLand()) {
|
||||
if (setTargetPointer) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class EnchantedSourceCondition implements Condition {
|
|||
if (permanent != null) {
|
||||
for (UUID uuid : permanent.getAttachments()) {
|
||||
Permanent attached = game.getBattlefield().getPermanent(uuid);
|
||||
if (attached != null && attached.getCardType().contains(CardType.ENCHANTMENT)) {
|
||||
if (attached != null && attached.isEnchantment()) {
|
||||
if (++numberOfFoundEnchantments >= numberOfEnchantments) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class EnchantedTargetCondition implements Condition {
|
|||
if (targetPermanent != null) {
|
||||
for (UUID uuid : targetPermanent.getAttachments()) {
|
||||
Permanent attached = game.getBattlefield().getPermanent(uuid);
|
||||
if (attached != null && attached.getCardType().contains(CardType.ENCHANTMENT)) {
|
||||
if (attached != null && attached.isEnchantment()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ public class SourceIsSpellCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
return object != null && !object.getCardType().contains(CardType.LAND);
|
||||
return object != null && !object.isLand();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,39 +39,34 @@ import mage.players.Player;
|
|||
*/
|
||||
public class TopLibraryCardTypeCondition implements Condition {
|
||||
|
||||
public static enum CheckType {
|
||||
public enum CheckType {
|
||||
CREATURE, LAND, SORCERY, INSTANT
|
||||
}
|
||||
|
||||
private TopLibraryCardTypeCondition.CheckType type;
|
||||
private CheckType type;
|
||||
|
||||
public TopLibraryCardTypeCondition(TopLibraryCardTypeCondition.CheckType type) {
|
||||
public TopLibraryCardTypeCondition(CheckType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean conditionApplies = false;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && controller.getLibrary().size() > 0) {
|
||||
Card card = controller.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
switch (this.type) {
|
||||
case CREATURE:
|
||||
conditionApplies |= card.getCardType().contains(CardType.CREATURE);
|
||||
break;
|
||||
return card.isCreature();
|
||||
case LAND:
|
||||
conditionApplies |= card.getCardType().contains(CardType.LAND);
|
||||
break;
|
||||
return card.isLand();
|
||||
case SORCERY:
|
||||
conditionApplies |= card.getCardType().contains(CardType.SORCERY);
|
||||
break;
|
||||
return card.isSorcery();
|
||||
case INSTANT:
|
||||
conditionApplies |= card.getCardType().contains(CardType.INSTANT);
|
||||
break;
|
||||
return card.isInstant();
|
||||
}
|
||||
}
|
||||
}
|
||||
return conditionApplies;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ExileTopCreatureCardOfGraveyardCost extends CostImpl {
|
|||
if(controller != null) {
|
||||
Card topCard = null;
|
||||
for (Card card :controller.getGraveyard().getCards(game)) {
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card.isCreature()) {
|
||||
topCard = card;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class DomainValue implements DynamicValue {
|
|||
targetPlayer = sourceAbility.getControllerId();
|
||||
}
|
||||
for (Permanent p : game.getBattlefield().getAllActivePermanents(targetPlayer)) {
|
||||
if (p.getCardType().contains(CardType.LAND)) {
|
||||
if (p.isLand()) {
|
||||
if (havePlains == 0 && p.getSubtype(game).contains("Plains")) {
|
||||
havePlains = 1;
|
||||
}
|
||||
|
@ -98,6 +98,6 @@ public class DomainValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "basic land type among lands " + (countTargetPlayer ? "he or she controls" : "you control");
|
||||
return "basic land type among lands " + (countTargetPlayer ? "he or she controls" : "you control");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ParleyCount implements DynamicValue, MageSingleton {
|
|||
if (player != null) {
|
||||
Card card = player.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
if (!card.getCardType().contains(CardType.LAND)) {
|
||||
if (!card.isLand()) {
|
||||
parleyValue++;
|
||||
}
|
||||
player.revealCards(sourceObject.getIdName() + " (" + player.getName() + ')', new CardsImpl(card), game);
|
||||
|
|
|
@ -208,11 +208,11 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
|
||||
&& (((ZoneChangeEvent) event).getFromZone() != Zone.STACK)) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && (card.getCardType().contains(CardType.ENCHANTMENT) && card.hasSubtype("Aura", game)
|
||||
if (card != null && (card.isEnchantment() && card.hasSubtype("Aura", game)
|
||||
|| // in case of transformable enchantments
|
||||
(game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null
|
||||
&& card.getSecondCardFace() != null
|
||||
&& card.getSecondCardFace().getCardType().contains(CardType.ENCHANTMENT)
|
||||
&& card.getSecondCardFace().isEnchantment()
|
||||
&& card.getSecondCardFace().hasSubtype("Aura", game)))) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -66,8 +66,8 @@ public class DamageEachOtherEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
if (sourceCreature != null && targetCreature != null
|
||||
&& sourceCreature.getCardType().contains(CardType.CREATURE)
|
||||
&& targetCreature.getCardType().contains(CardType.CREATURE)) {
|
||||
&& sourceCreature.isCreature()
|
||||
&& targetCreature.isCreature()) {
|
||||
targetCreature.damage(sourceCreature.getPower().getValue(), sourceCreature.getId(), game, false, true);
|
||||
if (sourceOnBattlefield) {
|
||||
sourceCreature.damage(targetCreature.getPower().getValue(), targetCreature.getId(), game, false, true);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class FightTargetSourceEffect extends OneShotEffect {
|
|||
Permanent creature1 = game.getPermanent(source.getTargets().get(0).getFirstTarget());
|
||||
// 20110930 - 701.10
|
||||
if (creature1 != null && sourcePermanent != null) {
|
||||
if (creature1.getCardType().contains(CardType.CREATURE) && sourcePermanent.getCardType().contains(CardType.CREATURE)) {
|
||||
if (creature1.isCreature() && sourcePermanent.isCreature()) {
|
||||
return sourcePermanent.fight(creature1, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class FightTargetsEffect extends OneShotEffect {
|
|||
Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
// 20110930 - 701.10
|
||||
if (creature1 != null && creature2 != null) {
|
||||
if (creature1.getCardType().contains(CardType.CREATURE) && creature2.getCardType().contains(CardType.CREATURE)) {
|
||||
if (creature1.isCreature() && creature2.isCreature()) {
|
||||
return creature1.fight(creature2, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class HideawayPlayEffect extends OneShotEffect {
|
|||
* If the removed card is a land, you may play it as a result of the last ability only if it's your turn
|
||||
* and you haven't already played a land that turn. This counts as your land play for the turn.
|
||||
*/
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
if (card.isLand()) {
|
||||
UUID playerId = controller.getId();
|
||||
if (!game.getActivePlayerId().equals(playerId) || !game.getPlayer(playerId).canPlayLand()) {
|
||||
return false;
|
||||
|
|
|
@ -73,7 +73,7 @@ public class PreventDamageByTargetEffect extends PreventionEffectImpl {
|
|||
if (!this.used && super.applies(event, source, game)) {
|
||||
MageObject mageObject = game.getObject(event.getSourceId());
|
||||
if (mageObject != null
|
||||
&& (mageObject.getCardType().contains(CardType.INSTANT) || mageObject.getCardType().contains(CardType.SORCERY))) {
|
||||
&& (mageObject.isInstant() || mageObject.isSorcery())) {
|
||||
for (Target target : source.getTargets()) {
|
||||
if (target instanceof TargetSpell) {
|
||||
if (((TargetSpell) target).getSourceIds().contains(event.getSourceId())) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RevealTopLandToBattlefieldElseHandEffect extends OneShotEffect {
|
|||
}
|
||||
cards.add(card);
|
||||
controller.revealCards(sourceObject.getName(), cards, game);
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
if (card.isLand()) {
|
||||
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
} else {
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
|
|
|
@ -68,7 +68,7 @@ public class UntapAllThatAttackedEffect extends OneShotEffect {
|
|||
Set<UUID> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||
for (UUID uuid : attackedThisTurn) {
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
if (permanent != null && permanent.isCreature()) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class CantAttackYouUnlessPayManaAllEffect extends PayCostToAttackBlockEff
|
|||
if (payAlsoForAttackingPlaneswalker) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null
|
||||
&& permanent.getCardType().contains(CardType.PLANESWALKER)
|
||||
&& permanent.isPlaneswalker()
|
||||
&& permanent.getControllerId().equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
// Attention: Cards like Unstable Frontier that use this class do not give the "Basic" supertype to the target
|
||||
if (!land.getCardType().contains(CardType.LAND)) {
|
||||
if (!land.isLand()) {
|
||||
land.getCardType().add(CardType.LAND);
|
||||
}
|
||||
if (loseOther) {
|
||||
|
|
|
@ -120,7 +120,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
}
|
||||
}
|
||||
}
|
||||
if (type != null && type.isEmpty() || type == null && permanent.getCardType().contains(CardType.LAND)) {
|
||||
if (type != null && type.isEmpty() || type == null && permanent.isLand()) {
|
||||
permanent.getSubtype(game).retainAll(CardRepository.instance.getLandTypes());
|
||||
}
|
||||
if (!token.getSubtype(game).isEmpty()) {
|
||||
|
|
|
@ -101,7 +101,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl {
|
|||
int affectedTargets = 0;
|
||||
for (UUID permanentId : targetPointer.getTargets(game, source)) {
|
||||
Permanent target = game.getPermanent(permanentId);
|
||||
if (target != null && target.getCardType().contains(CardType.CREATURE)) {
|
||||
if (target != null && target.isCreature()) {
|
||||
target.addPower(power.calculate(game, source, this));
|
||||
target.addToughness(toughness.calculate(game, source, this));
|
||||
affectedTargets++;
|
||||
|
|
|
@ -78,7 +78,7 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl {
|
|||
if (cardOnTop != null
|
||||
&& affectedControllerId.equals(source.getControllerId())
|
||||
&& cardOnTop.getOwnerId().equals(source.getControllerId())
|
||||
&& (!cardOnTop.getManaCost().isEmpty() || cardOnTop.getCardType().contains(CardType.LAND))
|
||||
&& (!cardOnTop.getManaCost().isEmpty() || cardOnTop.isLand())
|
||||
&& filter.match(cardOnTop, game)) {
|
||||
Player player = game.getPlayer(cardOnTop.getOwnerId());
|
||||
if (player != null && cardOnTop.equals(player.getLibrary().getFromTop(game))) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class DealtDamageToCreatureBySourceDies extends ReplacementEffectImpl {
|
|||
|
||||
public DealtDamageToCreatureBySourceDies(Card card, Duration duration) {
|
||||
super(duration, Outcome.Exile);
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card.isCreature()) {
|
||||
staticText = "If a creature dealt damage by {this} this turn would die, exile it instead";
|
||||
} else {
|
||||
staticText = "If a creature dealt damage this way would die this turn, exile it instead";
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ManifestEffect extends OneShotEffect {
|
|||
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
|
||||
for (Card card : cards) {
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card.isCreature()) {
|
||||
manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
|
||||
if (manaCosts == null) {
|
||||
manaCosts = new ManaCostsImpl("{0}");
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
|
|||
Set<Card> cards = targetPlayer.getLibrary().getTopCards(game, amount);
|
||||
for (Card card : cards) {
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card.isCreature()) {
|
||||
manaCosts = card.getSpellAbility().getManaCosts();
|
||||
if (manaCosts == null) {
|
||||
manaCosts = new ManaCostsImpl("{0}");
|
||||
|
|
|
@ -50,7 +50,7 @@ public class SupportEffect extends AddCountersTargetEffect {
|
|||
super(CounterType.P1P1.createInstance(0), new StaticValue(1));
|
||||
this.amountSupportTargets = new StaticValue(amount);
|
||||
this.otherPermanent = otherPermanent;
|
||||
if (card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY)) {
|
||||
if (card.isInstant() || card.isSorcery()) {
|
||||
card.getSpellAbility().addTarget(new TargetCreaturePermanent(0, amount, new FilterCreaturePermanent("target creatures"), false));
|
||||
}
|
||||
staticText = setText();
|
||||
|
|
|
@ -150,12 +150,12 @@ public class BestowAbility extends SpellAbility {
|
|||
MageObject basicObject = permanent.getBasicMageObject(game);
|
||||
if (basicObject != null) {
|
||||
basicObject.getSubtype(null).remove("Aura");
|
||||
if (!basicObject.getCardType().contains(CardType.CREATURE)) {
|
||||
if (!basicObject.isCreature()) {
|
||||
basicObject.getCardType().add(CardType.CREATURE);
|
||||
}
|
||||
}
|
||||
permanent.getSubtype(null).remove("Aura");
|
||||
if (!permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
if (!permanent.isCreature()) {
|
||||
permanent.getCardType().add(CardType.CREATURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class CascadeEffect extends OneShotEffect {
|
|||
}
|
||||
controller.moveCardsToExile(card, source, game, true, exile.getId(), exile.getName());
|
||||
} while (controller.isInGame()
|
||||
&& (card.getCardType().contains(CardType.LAND)
|
||||
&& (card.isLand()
|
||||
|| !cardThatCostsLess(sourceCost, card, game)));
|
||||
|
||||
controller.getLibrary().reset(); // set back empty draw state if that caused an empty draw
|
||||
|
|
|
@ -110,7 +110,7 @@ public class EvolveAbility extends TriggeredAbilityImpl {
|
|||
if (!event.getTargetId().equals(this.getSourceId())) {
|
||||
Permanent triggeringCreature = game.getPermanent(event.getTargetId());
|
||||
if (triggeringCreature != null
|
||||
&& triggeringCreature.getCardType().contains(CardType.CREATURE)
|
||||
&& triggeringCreature.isCreature()
|
||||
&& triggeringCreature.getControllerId().equals(this.controllerId)) {
|
||||
Permanent sourceCreature = game.getPermanent(sourceId);
|
||||
if (sourceCreature != null && isPowerOrThoughnessGreater(sourceCreature, triggeringCreature)) {
|
||||
|
|
|
@ -91,7 +91,7 @@ class FearEffect extends RestrictionEffect implements MageSingleton {
|
|||
|
||||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
if (blocker.getCardType().contains(CardType.ARTIFACT) || blocker.getColor(game).isBlack()) {
|
||||
if (blocker.isArtifact() || blocker.getColor(game).isBlack()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -69,7 +69,7 @@ public class HauntAbility extends TriggeredAbilityImpl {
|
|||
|
||||
public HauntAbility(Card card, Effect effect) {
|
||||
super(Zone.ALL, effect , false);
|
||||
creatureHaunt = card.getCardType().contains(CardType.CREATURE);
|
||||
creatureHaunt = card.isCreature();
|
||||
addSubAbility(new HauntExileAbility(creatureHaunt));
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class IntimidateEffect extends RestrictionEffect implements MageSingleton {
|
|||
@Override
|
||||
public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) {
|
||||
boolean result = false;
|
||||
if (blocker.getCardType().contains(CardType.ARTIFACT) && (blocker.getCardType().contains(CardType.CREATURE))) {
|
||||
if (blocker.isArtifact() && (blocker.isCreature())) {
|
||||
result = true;
|
||||
}
|
||||
if (attacker.getColor(game).shares(blocker.getColor(game))) {
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ProtectionAbility extends StaticAbility {
|
|||
// object is still a card and not a spell yet. So return only if the source object can't be a spell
|
||||
// otherwise the following FilterObject check will be applied
|
||||
if (source instanceof StackObject
|
||||
|| (!source.getCardType().contains(CardType.INSTANT) && !source.getCardType().contains(CardType.SORCERY))) {
|
||||
|| (!source.isInstant() && !source.isSorcery())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ import mage.players.Player;
|
|||
public class RecoverAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public RecoverAbility(Cost cost, Card card) {
|
||||
super(Zone.GRAVEYARD, new RecoverEffect(cost, card.getCardType().contains(CardType.CREATURE)), false);
|
||||
super(Zone.GRAVEYARD, new RecoverEffect(cost, card.isCreature()), false);
|
||||
}
|
||||
|
||||
public RecoverAbility(final RecoverAbility ability) {
|
||||
|
@ -77,7 +77,7 @@ public class RecoverAbility extends TriggeredAbilityImpl {
|
|||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (zEvent.getTarget().getOwnerId().equals(getControllerId())
|
||||
&& zEvent.getTarget().getCardType().contains(CardType.CREATURE)
|
||||
&& zEvent.getTarget().isCreature()
|
||||
&& !zEvent.getTarget().getId().equals(getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public class SoulbondAbility extends EntersBattlefieldTriggeredAbility {
|
|||
boolean self = false;
|
||||
boolean other = false;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(getControllerId())) {
|
||||
if (permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
if (permanent.isCreature()) {
|
||||
if (permanent.getId().equals(getSourceId())) {
|
||||
if (permanent.getControllerId().equals(getControllerId())) {
|
||||
self = true;
|
||||
|
@ -158,7 +158,7 @@ class SoulboundEntersSelfEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
if (permanent != null && permanent.isCreature()) {
|
||||
Player controller = game.getPlayer(permanent.getControllerId());
|
||||
if (controller != null) {
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(filter);
|
||||
|
@ -259,11 +259,11 @@ class SoulboundEntersOtherEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getPairedCard() == null
|
||||
&& permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
&& permanent.isCreature()) {
|
||||
Player controller = game.getPlayer(permanent.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent enteringPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (enteringPermanent != null && enteringPermanent.getCardType().contains(CardType.CREATURE) && enteringPermanent.getPairedCard() == null) {
|
||||
if (enteringPermanent != null && enteringPermanent.isCreature() && enteringPermanent.getPairedCard() == null) {
|
||||
enteringPermanent.setPairedCard(new MageObjectReference(permanent, game));
|
||||
permanent.setPairedCard(new MageObjectReference(enteringPermanent, game));
|
||||
if (!game.isSimulation()) {
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SunburstAbility extends EntersBattlefieldAbility {
|
|||
|
||||
public SunburstAbility(Card card) {
|
||||
super(new SunburstEffect(), "");
|
||||
isCreature = card.getCardType().contains(CardType.CREATURE);
|
||||
isCreature = card.isCreature();
|
||||
}
|
||||
|
||||
public SunburstAbility(final SunburstAbility ability) {
|
||||
|
@ -91,7 +91,7 @@ class SunburstEffect extends OneShotEffect {
|
|||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
Counter counter;
|
||||
if (permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
if (permanent.isCreature()) {
|
||||
counter = CounterType.P1P1.createInstance(amount.calculate(game, source, this));
|
||||
} else {
|
||||
counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this));
|
||||
|
|
|
@ -48,9 +48,9 @@ public class SupportAbility extends EntersBattlefieldTriggeredAbility {
|
|||
|
||||
public SupportAbility(Card card, int amount) {
|
||||
super(new SupportEffect(card, amount, true));
|
||||
if (!card.getCardType().contains(CardType.INSTANT) && !card.getCardType().contains(CardType.SORCERY)) {
|
||||
if (!card.isInstant() && !card.isSorcery()) {
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures");
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card.isCreature()) {
|
||||
filter.add(new AnotherPredicate());
|
||||
filter.setMessage("other target creatures");
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ public class SuspendAbility extends SpecialAction {
|
|||
.append((suspend == 1 ? "a time counter" : (suspend == Integer.MAX_VALUE ? "X time counters" : suspend + " time counters")))
|
||||
.append(" on it.")
|
||||
.append(" At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost.")
|
||||
.append(card.getCardType().contains(CardType.CREATURE) ? " If you play it this way and it's a creature, it gains haste until you lose control of it." : "")
|
||||
.append(card.isCreature() ? " If you play it this way and it's a creature, it gains haste until you lose control of it." : "")
|
||||
.append(")</i>");
|
||||
}
|
||||
if (card.getManaCost().isEmpty()) {
|
||||
|
@ -241,7 +241,7 @@ public class SuspendAbility extends SpecialAction {
|
|||
return false;
|
||||
}
|
||||
MageObject object = game.getObject(sourceId);
|
||||
return (object.getCardType().contains(CardType.INSTANT)
|
||||
return (object.isInstant()
|
||||
|| object.hasAbility(FlashAbility.getInstance().getId(), game)
|
||||
|| game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId, game)
|
||||
|| game.canPlaySorcery(playerId));
|
||||
|
@ -384,7 +384,7 @@ class SuspendPlayCardEffect extends OneShotEffect {
|
|||
}
|
||||
// cast the card for free
|
||||
if (player.cast(card.getSpellAbility(), game, true)) {
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card.isCreature()) {
|
||||
ContinuousEffect effect = new GainHasteEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
|
||||
game.addEffect(effect, source);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ArtifactCastManaCondition extends ManaCondition implements Conditio
|
|||
public boolean apply(Game game, Ability source) {
|
||||
if (source instanceof SpellAbility) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object != null && object.getCardType().contains(CardType.ARTIFACT)) {
|
||||
if (object != null && object.isArtifact()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CreatureCastManaCondition extends ManaCondition implements Conditio
|
|||
public boolean apply(Game game, Ability source) {
|
||||
if (source instanceof SpellAbility) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object != null && object.getCardType().contains(CardType.CREATURE)) {
|
||||
if (object != null && object.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import mage.Mana;
|
|||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.Counter;
|
||||
|
@ -174,4 +175,7 @@ public interface Card extends MageObject {
|
|||
* returned
|
||||
*/
|
||||
Card getMainCard();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -93,13 +93,13 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
this.cardType.addAll(Arrays.asList(cardTypes));
|
||||
this.manaCost.load(costs);
|
||||
setDefaultColor();
|
||||
if (cardType.contains(CardType.LAND)) {
|
||||
if (this.isLand()) {
|
||||
Ability ability = new PlayLandAbility(name);
|
||||
ability.setSourceId(this.getId());
|
||||
abilities.add(ability);
|
||||
} else {
|
||||
SpellAbility ability = new SpellAbility(manaCost, name, Zone.HAND, spellAbilityType);
|
||||
if (!cardType.contains(CardType.INSTANT)) {
|
||||
if (!this.isInstant()) {
|
||||
ability.setTiming(TimingRule.SORCERY);
|
||||
}
|
||||
ability.setSourceId(this.getId());
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MockCard extends CardImpl {
|
|||
this.secondSideCard = new MockCard(CardRepository.instance.findCard(card.getSecondSideName()));
|
||||
}
|
||||
|
||||
if (this.cardType.contains(CardType.PLANESWALKER)) {
|
||||
if (this.isPlaneswalker()) {
|
||||
String startingLoyaltyString = card.getStartingLoyalty();
|
||||
if (startingLoyaltyString.isEmpty()) {
|
||||
//Logger.getLogger(MockCard.class).warn("Planeswalker `" + this.name + "` has empty starting loyalty.");
|
||||
|
|
|
@ -188,7 +188,7 @@ public class CardInfo {
|
|||
}
|
||||
|
||||
// Starting loyalty
|
||||
if (card.getCardType().contains(CardType.PLANESWALKER)) {
|
||||
if (card.isPlaneswalker()) {
|
||||
for (Ability ab : card.getAbilities()) {
|
||||
if (ab instanceof PlanswalkerEntersWithLoyalityCountersAbility) {
|
||||
this.startingLoyalty = "" + ((PlanswalkerEntersWithLoyalityCountersAbility) ab).getStartingLoyalty();
|
||||
|
|
|
@ -125,7 +125,7 @@ class MonarchDealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
MageObject damagingObject = game.getObject(event.getSourceId());
|
||||
if (damagingObject != null
|
||||
&& damagingObject instanceof Permanent
|
||||
&& damagingObject.getCardType().contains(CardType.CREATURE)
|
||||
&& damagingObject.isCreature()
|
||||
&& event.getTargetId().equals(game.getMonarchId())) {
|
||||
setControllerId(event.getPlayerId());
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(((Permanent) damagingObject).getControllerId()));
|
||||
|
|
|
@ -20,7 +20,7 @@ public class CommanderPredicate implements Predicate<Permanent> {
|
|||
@Override
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
Player owner = game.getPlayer(input.getOwnerId());
|
||||
return input.getCardType().contains(CardType.CREATURE)
|
||||
return input.isCreature()
|
||||
&& owner != null
|
||||
&& owner.getCommandersIds().contains(input.getId());
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class EnchantedPredicate implements Predicate<Permanent> {
|
|||
public boolean apply(Permanent input, Game game) {
|
||||
for (UUID attachmentId : input.getAttachments()) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && attachment.getCardType().contains(CardType.ENCHANTMENT)) {
|
||||
if (attachment != null && attachment.isEnchantment()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1688,7 +1688,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
List<Permanent> legendary = new ArrayList<>();
|
||||
List<Permanent> worldEnchantment = new ArrayList<>();
|
||||
for (Permanent perm : getBattlefield().getAllActivePermanents()) {
|
||||
if (perm.getCardType().contains(CardType.CREATURE)) {
|
||||
if (perm.isCreature()) {
|
||||
//20091005 - 704.5f
|
||||
if (perm.getToughness().getValue() <= 0) {
|
||||
if (movePermanentToGraveyardWithInfo(perm)) {
|
||||
|
@ -1723,7 +1723,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
somethingHappened = true;
|
||||
}
|
||||
if (perm.getCardType().contains(CardType.PLANESWALKER)) {
|
||||
if (perm.isPlaneswalker()) {
|
||||
//20091005 - 704.5i
|
||||
if (perm.getCounters(this).getCount(CounterType.LOYALTY) == 0) {
|
||||
if (movePermanentToGraveyardWithInfo(perm)) {
|
||||
|
@ -1740,7 +1740,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
//20091005 - 704.5n, 702.14c
|
||||
if (perm.getAttachedTo() == null) {
|
||||
Card card = this.getCard(perm.getId());
|
||||
if (card != null && !card.getCardType().contains(CardType.CREATURE)) { // no bestow creature
|
||||
if (card != null && !card.isCreature()) { // no bestow creature
|
||||
if (movePermanentToGraveyardWithInfo(perm)) {
|
||||
somethingHappened = true;
|
||||
}
|
||||
|
@ -1767,7 +1767,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (attachedTo == null || !attachedTo.getAttachments().contains(perm.getId())) {
|
||||
// handle bestow unattachment
|
||||
Card card = this.getCard(perm.getId());
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card != null && card.isCreature()) {
|
||||
UUID wasAttachedTo = perm.getAttachedTo();
|
||||
perm.attachTo(null, this);
|
||||
BestowAbility.becomeCreature(perm, this);
|
||||
|
@ -1787,7 +1787,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
} else if (!auraFilter.match(attachedTo, this) || attachedTo.cantBeAttachedBy(perm, this)) {
|
||||
// handle bestow unattachment
|
||||
Card card = this.getCard(perm.getId());
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card != null && card.isCreature()) {
|
||||
UUID wasAttachedTo = perm.getAttachedTo();
|
||||
perm.attachTo(null, this);
|
||||
fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId()));
|
||||
|
@ -1835,7 +1835,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
UUID wasAttachedTo = perm.getAttachedTo();
|
||||
perm.attachTo(null, this);
|
||||
fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId()));
|
||||
} else if (!attachedTo.getCardType().contains(CardType.CREATURE) || attachedTo.hasProtectionFrom(perm, this)) {
|
||||
} else if (!attachedTo.isCreature() || attachedTo.hasProtectionFrom(perm, this)) {
|
||||
if (attachedTo.removeAttachment(perm.getId(), this)) {
|
||||
somethingHappened = true;
|
||||
}
|
||||
|
@ -1847,7 +1847,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Permanent land = getPermanent(perm.getAttachedTo());
|
||||
if (land == null || !land.getAttachments().contains(perm.getId())) {
|
||||
perm.attachTo(null, this);
|
||||
} else if (!land.getCardType().contains(CardType.LAND) || land.hasProtectionFrom(perm, this)) {
|
||||
} else if (!land.isLand() || land.hasProtectionFrom(perm, this)) {
|
||||
if (land.removeAttachment(perm.getId(), this)) {
|
||||
somethingHappened = true;
|
||||
}
|
||||
|
@ -1861,7 +1861,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
for (UUID attachmentId : perm.getAttachments()) {
|
||||
Permanent attachment = getPermanent(attachmentId);
|
||||
if (attachment != null
|
||||
&& (attachment.getCardType().contains(CardType.CREATURE)
|
||||
&& (attachment.isCreature()
|
||||
|| !(attachment.getSubtype(this).contains("Aura")
|
||||
|| attachment.getSubtype(this).contains("Equipment")
|
||||
|| attachment.getSubtype(this).contains("Fortification")))) {
|
||||
|
@ -2293,7 +2293,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
// check if it's a creature and must be removed from combat
|
||||
if (perm.getCardType().contains(CardType.CREATURE) && this.getCombat() != null) {
|
||||
if (perm.isCreature() && this.getCombat() != null) {
|
||||
perm.removeFromCombat(this, true);
|
||||
}
|
||||
it.remove();
|
||||
|
|
|
@ -172,13 +172,13 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
public void checkForRemoveFromCombat(Game game) {
|
||||
for (UUID creatureId : getAttackers()) {
|
||||
Permanent creature = game.getPermanent(creatureId);
|
||||
if (creature != null && !creature.getCardType().contains(CardType.CREATURE)) {
|
||||
if (creature != null && !creature.isCreature()) {
|
||||
removeFromCombat(creatureId, game, true);
|
||||
}
|
||||
}
|
||||
for (UUID creatureId : getBlockers()) {
|
||||
Permanent creature = game.getPermanent(creatureId);
|
||||
if (creature != null && !creature.getCardType().contains(CardType.CREATURE)) {
|
||||
if (creature != null && !creature.isCreature()) {
|
||||
removeFromCombat(creatureId, game, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,7 +359,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
|
||||
@Override
|
||||
public boolean canTap() {
|
||||
return !cardType.contains(CardType.CREATURE) || !hasSummoningSickness();
|
||||
return !isCreature() || !hasSummoningSickness();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -701,7 +701,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
private int damage(int damageAmount, UUID sourceId, Game game, boolean preventable, boolean combat, boolean markDamage, ArrayList<UUID> appliedEffects) {
|
||||
int damageDone = 0;
|
||||
if (damageAmount > 0 && canDamage(game.getObject(sourceId), game)) {
|
||||
if (cardType.contains(CardType.PLANESWALKER)) {
|
||||
if (this.isPlaneswalker()) {
|
||||
damageDone = damagePlaneswalker(damageAmount, sourceId, game, preventable, combat, markDamage, appliedEffects);
|
||||
} else {
|
||||
damageDone = damageCreature(damageAmount, sourceId, game, preventable, combat, markDamage, appliedEffects);
|
||||
|
@ -945,7 +945,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
} else {
|
||||
logName = this.getLogName();
|
||||
}
|
||||
if (this.getCardType().contains(CardType.CREATURE)) {
|
||||
if (this.isCreature()) {
|
||||
game.informPlayers(logName + " died");
|
||||
} else {
|
||||
game.informPlayers(logName + " was destroyed");
|
||||
|
@ -1175,7 +1175,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
public boolean removeFromCombat(Game game, boolean withInfo) {
|
||||
if (this.isAttacking() || this.blocking > 0) {
|
||||
return game.getCombat().removeFromCombat(objectId, game, withInfo);
|
||||
} else if (getCardType().contains(CardType.PLANESWALKER)) {
|
||||
} else if (this.isPlaneswalker()) {
|
||||
if (game.getCombat().getDefenders().contains(getId())) {
|
||||
game.getCombat().removePlaneswalkerFromCombat(objectId, game, withInfo);
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ public class Token extends MageObjectImpl {
|
|||
expansionSetCodeChecked = this.updateExpansionSetCode(setCode);
|
||||
}
|
||||
|
||||
GameEvent event = new GameEvent(EventType.CREATE_TOKEN, null, sourceId, controllerId, amount, this.getCardType().contains(CardType.CREATURE));
|
||||
GameEvent event = new GameEvent(EventType.CREATE_TOKEN, null, sourceId, controllerId, amount, this.isCreature());
|
||||
if (!game.replaceEvent(event)) {
|
||||
amount = event.getAmount();
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.getCardType().contains(CardType.INSTANT) || this.getCardType().contains(CardType.SORCERY)) {
|
||||
if (this.isInstant() || this.isSorcery()) {
|
||||
int index = 0;
|
||||
result = false;
|
||||
boolean legalParts = false;
|
||||
|
@ -239,7 +239,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
counter(null, game);
|
||||
return false;
|
||||
} else if (this.getCardType().contains(CardType.ENCHANTMENT) && this.getSubtype(game).contains("Aura")) {
|
||||
} else if (this.isEnchantment() && this.getSubtype(game).contains("Aura")) {
|
||||
if (ability.getTargets().stillLegal(ability, game)) {
|
||||
updateOptionalCosts(0);
|
||||
boolean bestow = ability instanceof BestowAbility;
|
||||
|
@ -432,7 +432,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
@Override
|
||||
public String getLogName() {
|
||||
if (faceDown) {
|
||||
if (getCardType().contains(CardType.CREATURE)) {
|
||||
if (this.isCreature()) {
|
||||
return "face down creature spell";
|
||||
} else {
|
||||
return "face down spell";
|
||||
|
|
|
@ -938,7 +938,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return false;
|
||||
}
|
||||
boolean result;
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
if (card.isLand()) {
|
||||
result = playLand(card, game, ignoreTiming);
|
||||
} else {
|
||||
result = cast(card.getSpellAbility(), game, noMana);
|
||||
|
@ -1264,7 +1264,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
useable.put(ability.getId(), (ActivatedAbility) ability);
|
||||
}
|
||||
} else if (ability instanceof AlternativeSourceCosts) {
|
||||
if (object.getCardType().contains(CardType.LAND)) {
|
||||
if (object.isLand()) {
|
||||
for (Ability ability2 : object.getAbilities().copy()) {
|
||||
if (ability2 instanceof PlayLandAbility) {
|
||||
useable.put(ability2.getId(), (ActivatedAbility) ability2);
|
||||
|
@ -1319,7 +1319,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (card.isSplitCard() && ability instanceof FlashbackAbility) {
|
||||
FlashbackAbility flashbackAbility;
|
||||
// Left Half
|
||||
if (card.getCardType().contains(CardType.INSTANT)) {
|
||||
if (card.isInstant()) {
|
||||
flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.INSTANT);
|
||||
} else {
|
||||
flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.SORCERY);
|
||||
|
@ -1332,7 +1332,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
useable.put(flashbackAbility.getId(), flashbackAbility);
|
||||
}
|
||||
// Right Half
|
||||
if (card.getCardType().contains(CardType.INSTANT)) {
|
||||
if (card.isInstant()) {
|
||||
flashbackAbility = new FlashbackAbility(((SplitCard) card).getRightHalfCard().getManaCost(), TimingRule.INSTANT);
|
||||
} else {
|
||||
flashbackAbility = new FlashbackAbility(((SplitCard) card).getRightHalfCard().getManaCost(), TimingRule.SORCERY);
|
||||
|
@ -2616,11 +2616,11 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
} else if (ability instanceof AlternativeSourceCosts) {
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
if (card.isLand()) {
|
||||
if (canLandPlayAlternateSourceCostsAbility(card, availableMana, ability, game)) { // e.g. Land with Morph
|
||||
playable.add(ability);
|
||||
}
|
||||
} else if (card.getCardType().contains(CardType.CREATURE)) { // e.g. makes a card available for play by Morph if the card may not be cast normally
|
||||
} else if (card.isCreature()) { // e.g. makes a card available for play by Morph if the card may not be cast normally
|
||||
if (!playable.contains(card.getSpellAbility())) {
|
||||
if (((AlternativeSourceCosts) ability).isAvailable(card.getSpellAbility(), game)) {
|
||||
playable.add(card.getSpellAbility());
|
||||
|
@ -2766,7 +2766,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
break;
|
||||
case STATIC:
|
||||
if (card.getCardType().contains(CardType.LAND) && ability instanceof AlternativeSourceCosts) {
|
||||
if (card.isLand() && ability instanceof AlternativeSourceCosts) {
|
||||
if (canLandPlayAlternateSourceCostsAbility(card, available, ability, game)) { // e.g. Land with Morph
|
||||
if (game.canPlaySorcery(getId())) {
|
||||
playable.add(card.getId());
|
||||
|
|
|
@ -124,7 +124,7 @@ public final class CardUtil {
|
|||
throw new IllegalArgumentException("Params can't be null");
|
||||
}
|
||||
|
||||
if (card1.getCardType().contains(CardType.CREATURE) && card2.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card1.isCreature() && card2.isCreature()) {
|
||||
if (card1.getAbilities().contains(ChangelingAbility.getInstance())
|
||||
|| card1.getSubtype(game).contains(ChangelingAbility.ALL_CREATURE_TYPE)
|
||||
|| card2.getAbilities().contains(ChangelingAbility.getInstance())
|
||||
|
@ -411,11 +411,11 @@ public final class CardUtil {
|
|||
public static boolean isPermanentCard(Card card) {
|
||||
boolean permanent = false;
|
||||
|
||||
permanent |= card.getCardType().contains(CardType.ARTIFACT);
|
||||
permanent |= card.getCardType().contains(CardType.CREATURE);
|
||||
permanent |= card.getCardType().contains(CardType.ENCHANTMENT);
|
||||
permanent |= card.getCardType().contains(CardType.LAND);
|
||||
permanent |= card.getCardType().contains(CardType.PLANESWALKER);
|
||||
permanent |= card.isArtifact();
|
||||
permanent |= card.isCreature();
|
||||
permanent |= card.isEnchantment();
|
||||
permanent |= card.isLand();
|
||||
permanent |= card.isPlaneswalker();
|
||||
|
||||
return permanent;
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ public final class CardUtil {
|
|||
}
|
||||
|
||||
public static boolean cardCanBePlayedNow(Card card, UUID playerId, Game game) {
|
||||
if (card.getCardType().contains(CardType.LAND)) {
|
||||
if (card.isLand()) {
|
||||
return game.canPlaySorcery(playerId) && game.getPlayer(playerId).canPlayLand();
|
||||
} else {
|
||||
return card.getSpellAbility() != null && card.getSpellAbility().spellCanBeActivatedRegularlyNow(playerId, game);
|
||||
|
|
|
@ -58,7 +58,7 @@ public final class TraceUtil {
|
|||
if (hasIntimidate(attacker)) {
|
||||
for (UUID blockerId : group.getBlockers()) {
|
||||
Permanent blocker = game.getPermanent(blockerId);
|
||||
if (blocker != null && !blocker.getCardType().contains(CardType.ARTIFACT)
|
||||
if (blocker != null && !blocker.isArtifact()
|
||||
&& !attacker.getColor(game).shares(blocker.getColor(game))) {
|
||||
log.warn("Found creature with intimidate blocked by non artifact not sharing color creature");
|
||||
traceCombat(game, attacker, blocker);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class CreatureWasCastWatcher extends Watcher {
|
|||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell != null) {
|
||||
Card card = game.getCard(spell.getSourceId());
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card != null && card.isCreature()) {
|
||||
creaturesCasted.add(card.getId());
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class CreatureWasCastWatcher extends Watcher {
|
|||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
|
||||
if (card != null && card.isCreature()) {
|
||||
creaturesCasted.remove(card.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,9 @@ public class CreaturesDiedWatcher extends Watcher {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTarget().getCardType().contains(CardType.CREATURE)) {
|
||||
if (zEvent.isDiesEvent()
|
||||
&& zEvent.getTarget() != null
|
||||
&& zEvent.getTarget().isCreature()) {
|
||||
amountOfCreaturesThatDied++;
|
||||
int amount = 0;
|
||||
if (amountOfCreaturesThatDiedByController.containsKey(zEvent.getTarget().getControllerId())) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class LandfallWatcher extends Watcher {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND) && !playerPlayedLand.contains(event.getPlayerId())) {
|
||||
if (permanent != null && permanent.isLand() && !playerPlayedLand.contains(event.getPlayerId())) {
|
||||
playerPlayedLand.add(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class MorbidWatcher extends Watcher {
|
|||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
|
||||
Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (p != null && p.getCardType().contains(CardType.CREATURE)) {
|
||||
if (p != null && p.isCreature()) {
|
||||
condition = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class PermanentsEnteredBattlefieldWatcher extends Watcher {
|
|||
for (Permanent permanent : enteringBattlefieldLastTurn.get(sourcePermanent.getControllerId())) {
|
||||
if (!permanent.getId().equals(sourcePermanent.getId())
|
||||
//|| permanent.getZoneChangeCounter(game) == sourcePermanent.getZoneChangeCounter(game) why is this needed?
|
||||
&& permanent.getCardType().contains(CardType.CREATURE)) {
|
||||
&& permanent.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PlayerCastCreatureWatcher extends Watcher {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell.getCardType().contains(CardType.CREATURE)) {
|
||||
if (spell.isCreature()) {
|
||||
playerIds.add(spell.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue