Merge pull request #3372 from ingmargoudt/changelings

change getSubtype(game).contains(..) to hasSubtype(..) to include che…
This commit is contained in:
LevelX2 2017-05-14 06:32:48 +02:00 committed by GitHub
commit d1e4a7f6b0
23 changed files with 28 additions and 34 deletions

View file

@ -96,7 +96,7 @@ class AetherChargeTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
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.isCreature() && permanent.getSubtype(game).contains("Beast") if (permanent.isCreature() && permanent.hasSubtype("Beast", game)
&& permanent.getControllerId().equals(this.controllerId)) { && permanent.getControllerId().equals(this.controllerId)) {
Effect effect = this.getEffects().get(0); Effect effect = this.getEffects().get(0);
effect.setValue("damageSource", event.getTargetId()); effect.setValue("damageSource", event.getTargetId());

View file

@ -113,8 +113,8 @@ class BoldwyrIntimidatorEffect extends RestrictionEffect {
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
if (attacker != null && blocker != null) { if (attacker != null && blocker != null) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && attacker.getSubtype(game).contains("Warrior")) { if (sourcePermanent != null && attacker.hasSubtype("Warrior", game)) {
return !blocker.getSubtype(game).contains("Coward"); return !blocker.hasSubtype("Coward", game);
} }
} }
return true; return true;

View file

@ -119,7 +119,7 @@ class CaptivatingVampireEffect extends ContinuousEffectImpl {
break; break;
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) { if (sublayer == SubLayer.NA) {
if (!permanent.getSubtype(game).contains("Vampire")) { if (!permanent.hasSubtype("Vampire", game)) {
permanent.getSubtype(game).add("Vampire"); permanent.getSubtype(game).add("Vampire");
} }
} }

View file

@ -89,7 +89,7 @@ class CemeteryRecruitmentEffect extends OneShotEffect {
Card card = game.getCard(targetPointer.getFirst(game, source)); Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) { if (card != null) {
if (controller.moveCards(card, Zone.HAND, source, game) if (controller.moveCards(card, Zone.HAND, source, game)
&& card.getSubtype(game).contains("Zombie")) { && card.hasSubtype("Zombie", game)) {
controller.drawCards(1, game); controller.drawCards(1, game);
} }
} }

View file

@ -91,7 +91,7 @@ class DeathcultRogueRestrictionEffect extends RestrictionEffect {
@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.getSubtype(game).contains("Rogue")) { if (blocker.hasSubtype("Rogue", game)) {
return true; return true;
} }
return false; return false;

View file

@ -101,7 +101,7 @@ class DismissIntoDreamEffect extends ContinuousEffectImpl {
object.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), source.getSourceId(), game); object.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), source.getSourceId(), game);
break; break;
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (!object.getSubtype(game).contains("Illusion")) { if (!object.hasSubtype("Illusion", game)) {
object.getSubtype(game).add("Illusion"); object.getSubtype(game).add("Illusion");
} }
break; break;

View file

@ -79,7 +79,7 @@ class DralnusCrusadeEffect extends ContinuousEffectImpl {
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source.getSourceId(), game)) {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (!permanent.getSubtype(game).contains("Zombie")) { if (!permanent.hasSubtype("Zombie", game)) {
permanent.getSubtype(game).add("Zombie"); permanent.getSubtype(game).add("Zombie");
} }
break; break;

View file

@ -124,7 +124,7 @@ class EssenceFluxEffect extends OneShotEffect {
controller.moveCards(cardsToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); controller.moveCards(cardsToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
for (UUID cardId : cardsToBattlefield) { for (UUID cardId : cardsToBattlefield) {
Permanent permanent = game.getPermanent(cardId); Permanent permanent = game.getPermanent(cardId);
if (permanent != null && permanent.getSubtype(game).contains("Spirit")) { if (permanent != null && permanent.hasSubtype("Spirit", game)) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance()); Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setTargetPointer(new FixedTarget(permanent, game)); effect.setTargetPointer(new FixedTarget(permanent, game));
return effect.apply(game, source); return effect.apply(game, source);

View file

@ -168,7 +168,7 @@ class GisaAndGeralfWatcher extends Watcher {
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.GRAVEYARD) { if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.GRAVEYARD) {
Spell spell = (Spell) game.getObject(event.getTargetId()); Spell spell = (Spell) game.getObject(event.getTargetId());
if (spell.isCreature() && spell.getSubtype(game).contains("Zombie")) { if (spell.isCreature() && spell.hasSubtype("Zombie", game)) {
abilityUsed = true; abilityUsed = true;
} }
} }

View file

@ -140,7 +140,7 @@ class DragonCreatureCardPredicate implements Predicate<Card> {
@Override @Override
public boolean apply(Card input, Game game) { public boolean apply(Card input, Game game) {
return input.isCreature() return input.isCreature()
&& input.getSubtype(game).contains("Dragon"); && input.hasSubtype("Dragon", game);
} }
@Override @Override

View file

@ -99,16 +99,12 @@ class LifeAndLimbEffect extends ContinuousEffectImpl {
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (!permanent.isCreature()) {
permanent.addCardType(CardType.CREATURE); permanent.addCardType(CardType.CREATURE);
} if (!permanent.hasSubtype("Saproling", game)) {
if (!permanent.getSubtype(game).contains("Saproling")) {
permanent.getSubtype(game).add("Saproling"); permanent.getSubtype(game).add("Saproling");
} }
if (!permanent.isLand()) {
permanent.addCardType(CardType.LAND); permanent.addCardType(CardType.LAND);
} if (!permanent.hasSubtype("Forest", game)) {
if (!permanent.getSubtype(game).contains("Forest")) {
permanent.getSubtype(game).add("Forest"); permanent.getSubtype(game).add("Forest");
} }
break; break;

View file

@ -117,7 +117,7 @@ class MephidrossVampireEffect extends ContinuousEffectImpl {
creature.addAbility(new DealsDamageToACreatureTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false, false, false), source.getSourceId(), game); creature.addAbility(new DealsDamageToACreatureTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false, false, false), source.getSourceId(), game);
break; break;
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (!creature.getSubtype(game).contains("Vampire")) { if (!creature.hasSubtype("Vampire", game)) {
creature.getSubtype(game).add("Vampire"); creature.getSubtype(game).add("Vampire");
} }
break; break;

View file

@ -97,7 +97,7 @@ class NecromancersStockpileDiscardTargetCost extends CostImpl {
if (card == null) { if (card == null) {
return false; return false;
} }
isZombieCard = card.getSubtype(game).contains("Zombie"); isZombieCard = card.hasSubtype("Zombie", game);
paid |= player.discard(card, null, game); paid |= player.discard(card, null, game);
} }

View file

@ -145,10 +145,8 @@ class NissaSageAnimistMinusSevenEffect extends ContinuousEffectImpl {
if (permanent != null) { if (permanent != null) {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (!permanent.isCreature()) {
permanent.addCardType(CardType.CREATURE); permanent.addCardType(CardType.CREATURE);
} if (!permanent.hasSubtype("Elemental", game)) {
if (!permanent.getSubtype(game).contains("Elemental")) {
permanent.getSubtype(game).add("Elemental"); permanent.getSubtype(game).add("Elemental");
} }
break; break;

View file

@ -55,7 +55,7 @@ public class PhantasmalImage extends CardImpl {
ApplyToPermanent phantasmalImageApplier = new ApplyToPermanent() { ApplyToPermanent phantasmalImageApplier = new ApplyToPermanent() {
@Override @Override
public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) { public boolean apply(Game game, Permanent permanent, Ability source, UUID copyToObjectId) {
if (!permanent.getSubtype(game).contains("Illusion")) { if (!permanent.hasSubtype("Illusion", game)) {
permanent.getSubtype(game).add("Illusion"); permanent.getSubtype(game).add("Illusion");
} }
// Add directly because the created permanent is only used to copy from, so there is no need to add the ability to e.g. TriggeredAbilities // Add directly because the created permanent is only used to copy from, so there is no need to add the ability to e.g. TriggeredAbilities
@ -66,7 +66,7 @@ public class PhantasmalImage extends CardImpl {
@Override @Override
public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) { public boolean apply(Game game, MageObject mageObject, Ability source, UUID copyToObjectId) {
if (!mageObject.getSubtype(game).contains("Illusion")) { if (!mageObject.hasSubtype("Illusion", game)) {
mageObject.getSubtype(game).add("Illusion"); mageObject.getSubtype(game).add("Illusion");
} }
// Add directly because the created permanent is only used to copy from, so there is no need to add the ability to e.g. TriggeredAbilities // Add directly because the created permanent is only used to copy from, so there is no need to add the ability to e.g. TriggeredAbilities

View file

@ -102,7 +102,7 @@ class SageOfFablesReplacementEffect extends ReplacementEffectImpl {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
return creature != null && creature.getControllerId().equals(source.getControllerId()) return creature != null && creature.getControllerId().equals(source.getControllerId())
&& creature.isCreature() && creature.isCreature()
&& creature.getSubtype(game).contains("Wizard") && creature.hasSubtype("Wizard", game)
&& !event.getTargetId().equals(source.getSourceId()); && !event.getTargetId().equals(source.getSourceId());
} }

View file

@ -99,7 +99,7 @@ class CreaturesYouControlBecomesTargetTriggeredAbility extends TriggeredAbilityI
@Override @Override
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 && permanent.getControllerId().equals(this.controllerId) && (permanent.getSubtype(game).contains("Wolf") || permanent.getSubtype(game).contains("Werewolf"))) { if (permanent != null && permanent.getControllerId().equals(this.controllerId) && (permanent.hasSubtype("Wolf", game) || permanent.hasSubtype("Werewolf", game))) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null && object instanceof Spell) { if (object != null && object instanceof Spell) {
Card c = (Spell) object; Card c = (Spell) object;

View file

@ -141,7 +141,7 @@ class SirensCallDestroyEffect extends OneShotEffect {
} }
// Walls are safe. // Walls are safe.
if (permanent.getSubtype(game).contains("Wall")) { if (permanent.hasSubtype("Wall", game)) {
continue; continue;
} }
// Creatures that attacked are safe. // Creatures that attacked are safe.

View file

@ -118,10 +118,10 @@ class BlockedOrWasBlockedByAZombieWatcher extends Watcher {
@Override @Override
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) { if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
if (game.getPermanent(event.getTargetId()).getSubtype(game).contains("Zombie")) { if (game.getPermanent(event.getTargetId()).hasSubtype("Zombie", game)) {
this.blockedOrWasBlockedByAZombieWatcher.add(new MageObjectReference(event.getSourceId(), game)); this.blockedOrWasBlockedByAZombieWatcher.add(new MageObjectReference(event.getSourceId(), game));
} }
if (game.getPermanent(event.getSourceId()).getSubtype(game).contains("Zombie")) { if (game.getPermanent(event.getSourceId()).hasSubtype( "Zombie", game)) {
this.blockedOrWasBlockedByAZombieWatcher.add(new MageObjectReference(event.getTargetId(), game)); this.blockedOrWasBlockedByAZombieWatcher.add(new MageObjectReference(event.getTargetId(), game));
} }
} }

View file

@ -112,13 +112,13 @@ class VenomTriggeredAbility extends TriggeredAbilityImpl {
Permanent enchantedCreature = game.getPermanent(enchantment.getAttachedTo()); Permanent enchantedCreature = game.getPermanent(enchantment.getAttachedTo());
if (enchantedCreature != null) { if (enchantedCreature != null) {
if (blocker != null && !Objects.equals(blocker, enchantedCreature) if (blocker != null && !Objects.equals(blocker, enchantedCreature)
&& !blocker.getSubtype(game).contains("Wall") && !blocker.hasSubtype("Wall", game)
&& Objects.equals(blocked, enchantedCreature)) { && Objects.equals(blocked, enchantedCreature)) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(blocker.getId())); this.getEffects().get(0).setTargetPointer(new FixedTarget(blocker.getId()));
return true; return true;
} }
if (blocker != null && Objects.equals(blocker, enchantedCreature) if (blocker != null && Objects.equals(blocker, enchantedCreature)
&& !blocked.getSubtype(game).contains("Wall")) { && !blocked.hasSubtype("Wall", game)) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(blocked.getId())); this.getEffects().get(0).setTargetPointer(new FixedTarget(blocked.getId()));
return true; return true;
} }

View file

@ -102,7 +102,7 @@ class VizierOfManyFacesApplyToPermanent extends ApplyToPermanent {
for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) { for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) {
if (mor.getSourceId().equals(originalCardId) && game.getState().getZoneChangeCounter(originalCardId) == mor.getZoneChangeCounter()) { if (mor.getSourceId().equals(originalCardId) && game.getState().getZoneChangeCounter(originalCardId) == mor.getZoneChangeCounter()) {
permanent.getManaCost().clear(); permanent.getManaCost().clear();
if (!permanent.getSubtype(game).contains("Zombie")) { if (!permanent.hasSubtype("Zombie", game)) {
permanent.getSubtype(game).add("Zombie"); permanent.getSubtype(game).add("Zombie");
} }
permanent.getColor(game).setColor(ObjectColor.WHITE); permanent.getColor(game).setColor(ObjectColor.WHITE);

View file

@ -96,7 +96,7 @@ class WarrenPilferersReturnEffect extends OneShotEffect {
Card card = game.getCard(source.getFirstTarget()); Card card = game.getCard(source.getFirstTarget());
if (card != null) { if (card != null) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false); card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
if (card.getSubtype(game).contains("Goblin")) { if (card.hasSubtype("Goblin", game)) {
game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.EndOfTurn), source); game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.EndOfTurn), source);
} }
return true; return true;

View file

@ -66,7 +66,7 @@ public class BecomesBlackZombieAdditionEffect extends ContinuousEffectImpl {
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) { if (sublayer == SubLayer.NA) {
if (!creature.getSubtype(game).contains("Zombie")) { if (!creature.hasSubtype("Zombie", game)) {
creature.getSubtype(game).add("Zombie"); creature.getSubtype(game).add("Zombie");
} }
} }