mirror of
https://github.com/correl/mage.git
synced 2025-04-03 09:18:59 -09:00
change enum comparison
This commit is contained in:
parent
36c004122a
commit
d6450eed94
32 changed files with 41 additions and 40 deletions
Mage.Sets/src/mage/cards
a
b
c
f
g
h
i
j
k
m
n
p
s
t
Mage.Tests/src/test/java/org/mage/test/game/ends
Mage/src/main/java/mage
|
@ -74,7 +74,7 @@ class AbilityActivatedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent aura = game.getPermanent(this.getSourceId());
|
||||
return aura != null && aura.getAttachedTo() != null && aura.getAttachedTo().equals(event.getSourceId());
|
||||
return aura != null && aura.isAttachedTo(event.getSourceId());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ enum AshenGhoulCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (!game.getStep().getType().equals(PhaseStep.UPKEEP)
|
||||
|| !game.getActivePlayerId().equals(source.getControllerId())) {
|
||||
if (game.getStep().getType() != PhaseStep.UPKEEP
|
||||
|| !game.isActivePlayer(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
if (controller != null) {
|
||||
|
|
|
@ -96,7 +96,7 @@ public final class AssaultSuit extends CardImpl {
|
|||
if (event.getType() == GameEvent.EventType.SACRIFICE_PERMANENT) {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
if (equipment != null && equipment.getAttachedTo() != null) {
|
||||
return equipment.getAttachedTo().equals(event.getTargetId());
|
||||
return equipment.isAttachedTo(event.getTargetId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -72,12 +72,7 @@ class BloodSunEffect extends ContinuousEffectImpl {
|
|||
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(StaticFilters.FILTER_LANDS, player.getId(), source.getSourceId(), game)) {
|
||||
switch (layer) {
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
for (Iterator<Ability> it = permanent.getAbilities().iterator(); it.hasNext();) {
|
||||
Ability ability = it.next();
|
||||
if (!ability.getAbilityType().equals(AbilityType.MANA)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
permanent.getAbilities().removeIf(ability -> ability.getAbilityType() != AbilityType.MANA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class DiesWhileInGraveyardTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
for (Zone z : Zone.values()) {
|
||||
if (game.getShortLivingLKI(sourceId, z) && !z.equals(Zone.GRAVEYARD)) {
|
||||
if (game.getShortLivingLKI(sourceId, z) && z != Zone.GRAVEYARD) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class BreathOfFuryAbility extends TriggeredAbilityImpl {
|
|||
Permanent enchantment = game.getPermanent(getSourceId());
|
||||
if (damageEvent.isCombatDamage()
|
||||
&& enchantment != null
|
||||
&& enchantment.getAttachedTo().equals(event.getSourceId())) {
|
||||
&& enchantment.isAttachedTo(event.getSourceId())) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
for (Effect effect : getEffects()) {
|
||||
|
|
|
@ -77,7 +77,7 @@ class BuildersBaneEffect extends OneShotEffect {
|
|||
if (permanent.destroy(source.getSourceId(), game, false)) {
|
||||
game.applyEffects();
|
||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
||||
&& !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
|
||||
&& game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) {
|
||||
// A replacement effect has moved the card to another zone as grvayard
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class CinderCloudEffect extends OneShotEffect {
|
|||
if (permanent != null && permanent.destroy(source.getSourceId(), game, false) && permanent.getColor(game).equals(ObjectColor.WHITE)) {
|
||||
game.applyEffects();
|
||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
||||
&& !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
|
||||
&& game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) {
|
||||
// A replacement effect has moved the card to another zone as grvayard
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -175,8 +175,8 @@ class CorrosiveOozeCombatWatcher extends Watcher {
|
|||
}
|
||||
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) {
|
||||
if (game.getTurn() != null && TurnPhase.COMBAT.equals(game.getTurn().getPhaseType())) {
|
||||
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
if (game.getTurn() != null && TurnPhase.COMBAT == game.getTurn().getPhaseType()) {
|
||||
// Check if a previous blocked or blocked by creatures is leaving the battlefield
|
||||
for (Map.Entry<MageObjectReference, HashSet<MageObjectReference>> entry : oozeBlocksOrBlocked.entrySet()) {
|
||||
for (MageObjectReference mor : entry.getValue()) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public final class CurseOfTheSwine extends CardImpl {
|
|||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility && ability.getAbilityType().equals(AbilityType.SPELL)) {
|
||||
if (ability instanceof SpellAbility && ability.getAbilityType() == AbilityType.SPELL) {
|
||||
ability.getTargets().clear();
|
||||
ability.addTarget(new TargetCreaturePermanent(ability.getManaCostsToPay().getX()));
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ class FlickerformReturnEffect extends OneShotEffect {
|
|||
if (!toBattlefieldAttached.isEmpty()) {
|
||||
controller.moveCards(toBattlefieldAttached, Zone.BATTLEFIELD, source, game);
|
||||
for (Card card : toBattlefieldAttached) {
|
||||
if (game.getState().getZone(card.getId()).equals(Zone.BATTLEFIELD)) {
|
||||
if (game.getState().getZone(card.getId()) == Zone.BATTLEFIELD) {
|
||||
newPermanent.addAttachment(card.getId(), game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ class GarnaTheBloodflameWatcher extends Watcher {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone().equals(Zone.GRAVEYARD)) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null && card.isCreature()) {
|
||||
cards.add(event.getTargetId());
|
||||
|
|
|
@ -66,7 +66,7 @@ class HellfireEffect extends OneShotEffect {
|
|||
filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
|
||||
for (Permanent creature : game.getState().getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
|
||||
if (creature.destroy(source.getSourceId(), game, false)
|
||||
&& game.getState().getZone(creature.getId()).equals(Zone.GRAVEYARD)) { // If a commander is replaced to command zone, the creature does not die) {
|
||||
&& game.getState().getZone(creature.getId()) == Zone.GRAVEYARD) { // If a commander is replaced to command zone, the creature does not die) {
|
||||
destroyedCreature++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,6 @@ class CanAttackAsThoughItHadHasteEnchantedEffect extends AsThoughEffectImpl {
|
|||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
return enchantment != null && enchantment.getAttachedTo() != null && enchantment.getAttachedTo().equals(objectId);
|
||||
return enchantment != null && enchantment.isAttachedTo(objectId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class JourneyToEternityReturnTransformedSourceEffect extends OneShotEffect {
|
|||
if (card != null && controller != null) {
|
||||
Zone zone = game.getState().getZone(card.getId());
|
||||
// cards needs to be in public non battlefield zone
|
||||
if (zone.equals(Zone.BATTLEFIELD) || !zone.isPublicZone()) {
|
||||
if (zone == Zone.BATTLEFIELD || !zone.isPublicZone()) {
|
||||
return true;
|
||||
}
|
||||
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
|
||||
|
|
|
@ -76,7 +76,7 @@ class KaerveksPurgeEffect extends OneShotEffect {
|
|||
if (targetCreature != null && targetCreature.destroy(source.getSourceId(), game, false)) {
|
||||
game.applyEffects();
|
||||
if (targetCreature.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(targetCreature.getId())
|
||||
&& !game.getState().getZone(targetCreature.getId()).equals(Zone.GRAVEYARD)) {
|
||||
&& game.getState().getZone(targetCreature.getId()) != Zone.GRAVEYARD) {
|
||||
// A replacement effect has moved the card to another zone as graveyard
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class KalitasDestroyEffect extends OneShotEffect {
|
|||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null && permanent.destroy(source.getSourceId(), game, false)) { // if not destroyed it returns false
|
||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
||||
&& !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
|
||||
&& game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) {
|
||||
// A replacement effect has moved the card to another zone as grvayard
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class MoggInfestationEffect extends OneShotEffect {
|
|||
if (controller != null && getTargetPointer().getFirst(game, source) != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, getTargetPointer().getFirst(game, source), game)) {
|
||||
if (permanent.destroy(source.getSourceId(), game, false)) {
|
||||
if (game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) { // If a commander is replaced to command zone, the creature does not die
|
||||
if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) { // If a commander is replaced to command zone, the creature does not die
|
||||
Effect effect = new CreateTokenTargetEffect(new GoblinToken(), 2);
|
||||
effect.setTargetPointer(getTargetPointer());
|
||||
effect.apply(game, source);
|
||||
|
|
|
@ -139,13 +139,13 @@ class MuldrothaTheGravetideWatcher extends Watcher {
|
|||
if (event.getType() == GameEvent.EventType.PLAY_LAND) {
|
||||
fromZone = game.getState().getZone(event.getTargetId()); // Remember the Zone the land came from
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.LAND_PLAYED && fromZone.equals(Zone.GRAVEYARD)) {
|
||||
if (event.getType() == GameEvent.EventType.LAND_PLAYED && fromZone == Zone.GRAVEYARD) {
|
||||
addPermanentTypes(event, game.getPermanentOrLKIBattlefield(event.getTargetId()), game);
|
||||
}
|
||||
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell.getFromZone().equals(Zone.GRAVEYARD)) {
|
||||
if (spell.getFromZone() == Zone.GRAVEYARD) {
|
||||
addPermanentTypes(event, spell, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class NetherTraitorTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
for (Zone z : Zone.values()) {
|
||||
if (game.getShortLivingLKI(sourceId, z) && !z.equals(Zone.GRAVEYARD)) {
|
||||
if (game.getShortLivingLKI(sourceId, z) && z != Zone.GRAVEYARD) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ class PurgatoryExileEffect extends OneShotEffect {
|
|||
MageObject sourceObject = source.getSourceObject(game);
|
||||
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
|
||||
if (sourceController != null && exileId != null && sourceObject != null && card != null) {
|
||||
if (game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
|
||||
if (game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
|
||||
sourceController.moveCardsToExile(card, source, game, true, exileId, sourceObject.getIdName());
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -148,7 +148,7 @@ class ShrivelingRotEffect extends OneShotEffect {
|
|||
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId())
|
||||
&& !game.getState().getZone(permanent.getId()).equals(Zone.GRAVEYARD)) {
|
||||
&& game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) {
|
||||
// A replacement effect has moved the card to another zone as graveyard
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class SunbirdsInvocationTriggeredAbility extends SpellCastControllerTriggeredAbi
|
|||
if (event.getPlayerId().equals(getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null
|
||||
&& spell.getFromZone().equals(Zone.HAND)
|
||||
&& spell.getFromZone() == Zone.HAND
|
||||
&& spell.isOwnedBy(getControllerId())) { // must be from the controller's hand
|
||||
if (spell.getCard() != null) {
|
||||
for (Effect effect : getEffects()) {
|
||||
|
|
|
@ -135,7 +135,7 @@ class TravelingPlagueEffect extends OneShotEffect {
|
|||
if (enchantedCreature != null) {
|
||||
Player controllerOfEnchantedCreature = game.getPlayer(enchantedCreature.getControllerId());
|
||||
if (travelingPlague != null
|
||||
&& game.getState().getZone(travelingPlague.getId()).equals(Zone.GRAVEYARD) // aura must come from the graveyard
|
||||
&& game.getState().getZone(travelingPlague.getId()) == Zone.GRAVEYARD // aura must come from the graveyard
|
||||
&& controllerOfEnchantedCreature != null) {
|
||||
TargetPermanent target = new TargetPermanent(new FilterCreaturePermanent("creature to enchant with " + travelingPlague.getName()));
|
||||
target.setNotTarget(true);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class PhageTheUntouchableTest extends CardTestPlayerBase {
|
|||
|
||||
Assert.assertTrue("Game has ended.", currentGame.hasEnded());
|
||||
Assert.assertTrue("Player A has won.", playerA.hasWon());
|
||||
Assert.assertTrue("Game ist At end phase", currentGame.getPhase().getType().equals(TurnPhase.END));
|
||||
Assert.assertTrue("Game ist At end phase", currentGame.getPhase().getType() == TurnPhase.END);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -910,7 +910,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
MageObject object = game.getObject(this.getSourceId());
|
||||
// emblem/planes are always actual
|
||||
if (object != null && (object instanceof Emblem || object instanceof Plane)) {
|
||||
if (object instanceof Emblem || object instanceof Plane) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ExileSourceCost extends CostImpl {
|
|||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
MageObject sourceObject = ability.getSourceObject(game);
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null && sourceObject != null && (sourceObject instanceof Card)) {
|
||||
if (controller != null && sourceObject instanceof Card) {
|
||||
UUID exileZoneId = null;
|
||||
String exileZoneName = "";
|
||||
if (toUniqueExileZone) {
|
||||
|
|
|
@ -88,7 +88,7 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
|
|||
sb.append(cardType.toString().toLowerCase(Locale.ENGLISH)).append(" ");
|
||||
}
|
||||
sb.append("in addition to its other types");
|
||||
if (getDuration().equals(Duration.EndOfTurn)) {
|
||||
if (getDuration() == Duration.EndOfTurn) {
|
||||
sb.append(" until end of turn");
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
@ -29,7 +29,7 @@ public class DiesReplacementEffect extends ReplacementEffectImpl {
|
|||
public DiesReplacementEffect(MageObjectReference objectRef, Duration duration) {
|
||||
super(duration, Outcome.Exile);
|
||||
this.objectRef = objectRef;
|
||||
staticText = "If that creature would die " + (duration.equals(Duration.EndOfTurn) ? "this turn" : "") + ", exile it instead";
|
||||
staticText = "If that creature would die " + (duration == Duration.EndOfTurn ? "this turn" : "") + ", exile it instead";
|
||||
}
|
||||
|
||||
public DiesReplacementEffect(final DiesReplacementEffect effect) {
|
||||
|
|
|
@ -63,7 +63,7 @@ class SpellCastManaCondition extends ManaCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
if (source instanceof SpellAbility) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object != null && (object instanceof StackObject)) {
|
||||
if ((object instanceof StackObject)) {
|
||||
return filter.match((StackObject) object, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,7 @@ class MonarchDealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (((DamagedPlayerEvent) event).isCombatDamage()) {
|
||||
MageObject damagingObject = game.getObject(event.getSourceId());
|
||||
if (damagingObject != null
|
||||
&& damagingObject instanceof Permanent
|
||||
if (damagingObject instanceof Permanent
|
||||
&& damagingObject.isCreature()
|
||||
&& event.getTargetId().equals(game.getMonarchId())) {
|
||||
setControllerId(event.getPlayerId());
|
||||
|
|
|
@ -353,4 +353,11 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
void setCreateOrder(int createOrder);
|
||||
|
||||
default boolean isAttachedTo(UUID otherId){
|
||||
if(getAttachedTo() == null){
|
||||
return false;
|
||||
}
|
||||
return getAttachedTo().equals(otherId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue