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