forked from External/mage
added new helper methods to test for CardType, to get rid of the contains(CardType.XXX) everywhere, put the logic of that in one place and use the interface call
This commit is contained in:
parent
6b20d352ca
commit
5a57731968
69 changed files with 151 additions and 120 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue