mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
add isOwned and isControlled methods. remove some null-checks, remove some unnecessary casts
This commit is contained in:
parent
e46ad02918
commit
9f06046f22
464 changed files with 567 additions and 562 deletions
|
|
@ -178,7 +178,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
break;
|
||||
case OWNER:
|
||||
Permanent permanent = game.getPermanent(getSourceId());
|
||||
if (!permanent.getOwnerId().equals(playerId)) {
|
||||
if (!permanent.isOwnedBy(playerId)) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
break;
|
||||
|
|
@ -191,7 +191,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
Permanent enchantment = game.getPermanent(getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (enchanted != null && enchanted.getControllerId().equals(playerId)) {
|
||||
if (enchanted != null && enchanted.isControlledBy(playerId)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -223,7 +223,7 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
} else if (mageObject instanceof Plane) {
|
||||
return ((Plane) mageObject).getControllerId().equals(playerId);
|
||||
} else if (game.getState().getZone(this.sourceId) != Zone.BATTLEFIELD) {
|
||||
return ((Card) mageObject).getOwnerId().equals(playerId);
|
||||
return ((Card) mageObject).isOwnedBy(playerId);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class SpecialActions extends AbilitiesImpl<SpecialAction> {
|
|||
public LinkedHashMap<UUID, SpecialAction> getControlledBy(UUID controllerId, boolean manaAction) {
|
||||
LinkedHashMap<UUID, SpecialAction> controlledBy = new LinkedHashMap<>();
|
||||
for (SpecialAction action: this) {
|
||||
if (action.getControllerId().equals(controllerId) && action.isManaAction() == manaAction) {
|
||||
if (action.isControlledBy(controllerId) && action.isManaAction() == manaAction) {
|
||||
controlledBy.put(action.id, action);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
MageObjectReference permittingSource = game.getContinuousEffects().asThough(getSourceId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, null, playerId, game);
|
||||
if (permittingSource == null) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (!(card != null && card.getOwnerId().equals(playerId))) {
|
||||
if (!(card != null && card.isOwnedBy(playerId))) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class AllyEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
EntersTheBattlefieldEvent ebe = (EntersTheBattlefieldEvent) event;
|
||||
return ebe.getTarget().getControllerId().equals(this.controllerId)
|
||||
return ebe.getTarget().isControlledBy(this.controllerId)
|
||||
&& (event.getTargetId().equals(this.getSourceId())
|
||||
|| (ebe.getTarget().hasSubtype(SubType.ALLY, game) && !event.getTargetId().equals(this.getSourceId())));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class AttackedByCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
UUID defendingPlayer = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
|
||||
Permanent attackingCreature = game.getPermanent(event.getSourceId());
|
||||
if (filter.match(attackingCreature, game)
|
||||
&& getControllerId().equals(defendingPlayer)
|
||||
&& isControlledBy(defendingPlayer)
|
||||
&& attackingCreature != null) {
|
||||
switch (setTargetPointer) {
|
||||
case PERMANENT:
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class AttacksAllTriggeredAbility extends TriggeredAbilityImpl {
|
|||
check = true;
|
||||
} else {
|
||||
Permanent planeswalker = game.getPermanent(event.getTargetId());
|
||||
if (planeswalker != null && planeswalker.isPlaneswalker() && planeswalker.getControllerId().equals(getControllerId())) {
|
||||
if (planeswalker != null && planeswalker.isPlaneswalker() && planeswalker.isControlledBy(getControllerId())) {
|
||||
check = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class BecomesMonstrousTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.isCreature()
|
||||
&& (permanent.getControllerId().equals(getControllerId()))) {
|
||||
&& (permanent.isControlledBy(getControllerId()))) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent attachment = game.getPermanent(sourceId);
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||
if (attachedTo != null && attachedTo.isControlledBy(event.getPlayerId())) {
|
||||
if (getTargets().isEmpty()) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent attachment = game.getPermanent(sourceId);
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||
if (attachedTo != null && attachedTo.isControlledBy(event.getPlayerId())) {
|
||||
if (getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Permanent attachment = game.getPermanent(sourceId);
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||
if (attachedTo != null && attachedTo.isControlledBy(event.getPlayerId())) {
|
||||
if (setTargetPointer && getTargets().isEmpty()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class ControlledCreaturesDealCombatDamagePlayerTriggeredAbility extends T
|
|||
if (event.getType() == EventType.DAMAGED_PLAYER) {
|
||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
|
||||
Permanent p = game.getPermanent(event.getSourceId());
|
||||
if (damageEvent.isCombatDamage() && p != null && p.getControllerId().equals(this.getControllerId())) {
|
||||
if (damageEvent.isCombatDamage() && p != null && p.isControlledBy(this.getControllerId())) {
|
||||
madeDamage = true;
|
||||
damagedPlayerIds.add(event.getPlayerId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class CreatureEntersBattlefieldTriggeredAbility extends TriggeredAbilityI
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
|
||||
if (filter.match(permanent, sourceId, controllerId, game)
|
||||
&& (permanent.getControllerId().equals(this.controllerId) ^ opponentController)) {
|
||||
&& (permanent.isControlledBy(this.controllerId) ^ opponentController)) {
|
||||
if (!this.getTargets().isEmpty()) {
|
||||
Target target = this.getTargets().get(0);
|
||||
if (target instanceof TargetPlayer) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbili
|
|||
}
|
||||
}
|
||||
if (targetController == TargetController.YOU) {
|
||||
if (!this.getControllerId().equals(event.getPlayerId())) {
|
||||
if (!this.isControlledBy(event.getPlayerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class EntersBattlefieldControlledTriggeredAbility extends EntersBattlefie
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (super.checkTrigger(event, game)) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
return permanent != null && permanent.getControllerId().equals(this.getControllerId());
|
||||
return permanent != null && permanent.isControlledBy(this.getControllerId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class ExertCreatureControllerTriggeredAbility extends TriggeredAbilityImp
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
boolean weAreExerting = getControllerId().equals(event.getPlayerId());
|
||||
boolean weAreExerting = isControlledBy(event.getPlayerId());
|
||||
Permanent exerted = game.getPermanent(event.getTargetId());
|
||||
boolean exertedIsCreature = (exerted != null) && exerted.isCreature();
|
||||
return weAreExerting && exertedIsCreature;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class LandfallAbility extends TriggeredAbilityImpl {
|
|||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null
|
||||
&& permanent.isLand()
|
||||
&& permanent.getControllerId().equals(this.controllerId)) {
|
||||
&& permanent.isControlledBy(this.controllerId)) {
|
||||
triggeringLand = permanent;
|
||||
if (setTargetPointer == SetTargetPointer.PERMANENT) {
|
||||
for (Effect effect : getAllEffects()) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class PutIntoGraveFromBattlefieldAllTriggeredAbility extends TriggeredAbi
|
|||
if (zEvent.getFromZone() == Zone.BATTLEFIELD
|
||||
&& zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (filter.match(zEvent.getTarget(), this.getSourceId(), this.getControllerId(), game)) {
|
||||
if (onlyToControllerGraveyard && !this.getControllerId().equals(game.getOwnerId(zEvent.getTargetId()))) {
|
||||
if (onlyToControllerGraveyard && !this.isControlledBy(game.getOwnerId(zEvent.getTargetId()))) {
|
||||
return false;
|
||||
}
|
||||
if (setTargetPointer) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class SpellCounteredControllerTriggeredAbility extends TriggeredAbilityIm
|
|||
if (stackObjectThatCountered == null) {
|
||||
stackObjectThatCountered = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
|
||||
}
|
||||
if (stackObjectThatCountered != null && stackObjectThatCountered.getControllerId().equals(getControllerId())) {
|
||||
if (stackObjectThatCountered != null && stackObjectThatCountered.isControlledBy(getControllerId())) {
|
||||
StackObject counteredStackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
|
||||
return counteredStackObject != null && (counteredStackObject instanceof Spell);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class AtTheBeginOfMainPhaseDelayedTriggeredAbility extends DelayedTrigger
|
|||
Permanent attachment = game.getPermanent(sourceId);
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||
if (attachedTo != null && attachedTo.isControlledBy(event.getPlayerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
|
|||
Permanent attachment = game.getPermanent(sourceId);
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = game.getPermanent(attachment.getAttachedTo());
|
||||
if (attachedTo != null && attachedTo.getControllerId().equals(event.getPlayerId())) {
|
||||
if (attachedTo != null && attachedTo.isControlledBy(event.getPlayerId())) {
|
||||
correctEndPhase = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public enum CommanderInPlayCondition implements Condition {
|
|||
if (controller != null) {
|
||||
for (UUID commanderId : controller.getCommandersIds()) {
|
||||
Permanent commander = game.getPermanent(commanderId);
|
||||
if (commander != null && commander.getControllerId().equals(source.getControllerId())) {
|
||||
if (commander != null && commander.isControlledBy(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ public enum ControllerAttackedThisTurnCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||
return source.getControllerId().equals(game.getActivePlayerId()) && watcher != null && !watcher.getAttackedThisTurnCreatures().isEmpty();
|
||||
return source.isControlledBy(game.getActivePlayerId()) && watcher != null && !watcher.getAttackedThisTurnCreatures().isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public class MeldCondition implements Condition {
|
|||
MageObject sourceMageObject = source.getSourceObjectIfItStillExists(game);
|
||||
if (sourceMageObject != null && sourceMageObject instanceof Permanent) {
|
||||
Permanent sourcePermanent = (Permanent) sourceMageObject;
|
||||
if (sourcePermanent.getControllerId().equals(source.getControllerId())
|
||||
&& sourcePermanent.getOwnerId().equals(source.getControllerId())) {
|
||||
if (sourcePermanent.isControlledBy(source.getControllerId())
|
||||
&& sourcePermanent.isOwnedBy(source.getControllerId())) {
|
||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
|
||||
filter.add(new NamePredicate(this.meldWithName));
|
||||
filter.add(new OwnerIdPredicate(source.getControllerId()));
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public enum MonarchIsSourceControllerCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return source.getControllerId().equals(game.getMonarchId());
|
||||
return source.isControlledBy(game.getMonarchId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class PermanentsYouOwnThatOpponentsControlCount implements DynamicValue {
|
|||
int count = 0;
|
||||
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(sourceAbility.getControllerId(), game)) {
|
||||
if (!permanent.getOwnerId().equals(permanent.getControllerId()) && permanent.getOwnerId().equals(sourceAbility.getControllerId())) {
|
||||
if (!permanent.isOwnedBy(permanent.getControllerId()) && permanent.isOwnedBy(sourceAbility.getControllerId())) {
|
||||
if (opponentIds.contains(permanent.getControllerId())) {
|
||||
count++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ public class ContinuousEffects implements Serializable {
|
|||
for (SpliceCardEffect effect : spliceCardEffects) {
|
||||
Set<Ability> abilities = spliceCardEffects.getAbility(effect.getId());
|
||||
for (Ability ability : abilities) {
|
||||
if (ability.getControllerId().equals(playerId) && (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null))) {
|
||||
if (ability.isControlledBy(playerId) && (!(ability instanceof StaticAbility) || ability.isInUseableZone(game, null, null))) {
|
||||
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
|
||||
spliceEffects.add(effect);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class GainAbilitySpellsEffect extends ContinuousEffectImpl {
|
|||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (card.getOwnerId().equals(source.getControllerId()) && filter.match(card, game)) {
|
||||
if (card.isOwnedBy(source.getControllerId()) && filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ public class GainAbilitySpellsEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject.getControllerId().equals(source.getControllerId())) {
|
||||
if (stackObject.isControlledBy(source.getControllerId())) {
|
||||
Card card = game.getCard(stackObject.getSourceId());
|
||||
if (card != null && filter.match(card, game)) {
|
||||
if (!card.getAbilities().contains(ability)) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class CantBeCounteredControlledEffect extends ContinuousRuleModifyingEffe
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.getControllerId().equals(source.getControllerId())
|
||||
if (spell != null && spell.isControlledBy(source.getControllerId())
|
||||
&& filterTarget.match(spell, source.getSourceId(), source.getControllerId(), game)) {
|
||||
if (filterSource == null) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class CreatureExploresTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
|
||||
if (creature != null) {
|
||||
return creature.getControllerId().equals(getControllerId());
|
||||
return creature.isControlledBy(getControllerId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class DontUntapInControllersUntapStepAllEffect extends ContinuousRuleModi
|
|||
if (permanent != null) {
|
||||
switch(targetController) {
|
||||
case YOU:
|
||||
if (!permanent.getControllerId().equals(source.getControllerId())) {
|
||||
if (!permanent.isControlledBy(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class DontUntapInControllersUntapStepEnchantedEffect extends ContinuousRu
|
|||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) {
|
||||
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (permanent != null && permanent.getControllerId().equals(game.getActivePlayerId())) {
|
||||
if (permanent != null && permanent.isControlledBy(game.getActivePlayerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class DontUntapInControllersUntapStepSourceEffect extends ContinuousRuleM
|
|||
if (game.getTurn().getStepType() == PhaseStep.UNTAP
|
||||
&& event.getTargetId().equals(source.getSourceId())) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getControllerId().equals(game.getActivePlayerId())) {
|
||||
if (permanent != null && permanent.isControlledBy(game.getActivePlayerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class DontUntapInPlayersNextUntapStepAllEffect extends ContinuousRuleModi
|
|||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (!permanent.getControllerId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
if (!permanent.isControlledBy(getTargetPointer().getFirst(game, source))) {
|
||||
return false;
|
||||
}
|
||||
if (controller != null && !game.isOpponent(controller, permanent.getControllerId())) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class PutOnLibraryTargetEffect extends OneShotEffect {
|
|||
Cards cardsPlayer = new CardsImpl();
|
||||
for (Iterator<Card> iterator = cards.iterator(); iterator.hasNext();) {
|
||||
Card next = iterator.next();
|
||||
if (next.getOwnerId().equals(owner.getId())) {
|
||||
if (next.isOwnedBy(owner.getId())) {
|
||||
cardsPlayer.add(next);
|
||||
iterator.remove();
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ public class PutOnLibraryTargetEffect extends OneShotEffect {
|
|||
Cards cardsPlayer = new CardsImpl();
|
||||
for (Iterator<Permanent> iterator = permanents.iterator(); iterator.hasNext();) {
|
||||
Permanent next = iterator.next();
|
||||
if (next.getOwnerId().equals(owner.getId())) {
|
||||
if (next.isOwnedBy(owner.getId())) {
|
||||
cardsPlayer.add(next);
|
||||
iterator.remove();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class ReturnToHandTargetEffect extends OneShotEffect {
|
|||
for (Target target : source.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
MageObject mageObject = game.getObject(targetId);
|
||||
if (mageObject instanceof Spell && ((Spell) mageObject).isCopy()) {
|
||||
if (mageObject instanceof Spell && mageObject.isCopy()) {
|
||||
copyIds.add(targetId);
|
||||
} else if (mageObject instanceof Card) {
|
||||
cards.add((Card) mageObject);
|
||||
|
|
@ -68,7 +68,7 @@ public class ReturnToHandTargetEffect extends OneShotEffect {
|
|||
for (UUID targetId : targetPointer.getTargets(game, source)) {
|
||||
MageObject mageObject = game.getObject(targetId);
|
||||
if (mageObject != null) {
|
||||
if (mageObject instanceof Spell && ((Spell) mageObject).isCopy()) {
|
||||
if (mageObject instanceof Spell && mageObject.isCopy()) {
|
||||
copyIds.add(targetId);
|
||||
} else {
|
||||
cards.add((Card) mageObject);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class SacrificeSourceEffect extends OneShotEffect {
|
|||
if (sourceObject instanceof Permanent) {
|
||||
Permanent permanent = (Permanent) sourceObject;
|
||||
// you can only sacrifice a permanent you control
|
||||
if (source.getControllerId().equals(permanent.getControllerId())) {
|
||||
if (source.isControlledBy(permanent.getControllerId())) {
|
||||
return permanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class SkipUntapOptionalSourceEffect extends RestrictionEffect {
|
|||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return permanent.getId().equals(source.getSourceId())
|
||||
&& permanent.getControllerId().equals(game.getActivePlayerId()) && // your untap step
|
||||
&& permanent.isControlledBy(game.getActivePlayerId()) && // your untap step
|
||||
permanent.isTapped();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class WishEffect extends OneShotEffect {
|
|||
}
|
||||
if (alsoFromExile) {
|
||||
for (Card exileCard : exile) {
|
||||
if (exileCard.getOwnerId().equals(source.getControllerId()) && filter.match(exileCard, game)) {
|
||||
if (exileCard.isOwnedBy(source.getControllerId()) && filter.match(exileCard, game)) {
|
||||
filteredCards.add(exileCard);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class CantAttackControllerAttachedEffect extends RestrictionEffect {
|
|||
return false;
|
||||
}
|
||||
Permanent planeswalker = game.getPermanent(defenderId);
|
||||
return planeswalker == null || !planeswalker.getControllerId().equals(source.getControllerId());
|
||||
return planeswalker == null || !planeswalker.isControlledBy(source.getControllerId());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class CantAttackYouOrPlaneswalkerAllEffect extends RestrictionEffect {
|
|||
return false;
|
||||
}
|
||||
Permanent planeswalker = game.getPermanent(defenderId);
|
||||
return planeswalker == null || !planeswalker.getControllerId().equals(source.getControllerId());
|
||||
return planeswalker == null || !planeswalker.isControlledBy(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class CantAttackYouUnlessPayManaAllEffect extends PayCostToAttackBlockEff
|
|||
}
|
||||
}
|
||||
// attack target is controlling player
|
||||
if (source.getControllerId().equals(event.getTargetId())) {
|
||||
if (source.isControlledBy(event.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
// or attack target is a planeswalker of the controlling player
|
||||
|
|
@ -64,7 +64,7 @@ public class CantAttackYouUnlessPayManaAllEffect extends PayCostToAttackBlockEff
|
|||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null
|
||||
&& permanent.isPlaneswalker()
|
||||
&& permanent.getControllerId().equals(source.getControllerId())) {
|
||||
&& permanent.isControlledBy(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class GoadAllEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) {
|
||||
if (!creature.getControllerId().equals(source.getControllerId())) {
|
||||
if (!creature.isControlledBy(source.getControllerId())) {
|
||||
Effect effect = new GoadTargetEffect();
|
||||
effect.setTargetPointer(new FixedTarget(creature, game));
|
||||
effect.apply(game, source);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughE
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
|
||||
return affectedAbility.getControllerId().equals(source.getControllerId())
|
||||
return affectedAbility.isControlledBy(source.getControllerId())
|
||||
&& activatedAbility.isInstance(affectedAbility);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class CastAsThoughItHadFlashAllEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID affectedSpellId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (anyPlayer || source.getControllerId().equals(affectedControllerId)) {
|
||||
if (anyPlayer || source.isControlledBy(affectedControllerId)) {
|
||||
Card card = game.getCard(affectedSpellId);
|
||||
return card != null && filter.match(card, game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class ExchangeControlTargetEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
if (permanent1 != null && permanent2 != null) {
|
||||
// exchange works only for two different controllers
|
||||
if (permanent1.getControllerId().equals(permanent2.getControllerId())) {
|
||||
if (permanent1.isControlledBy(permanent2.getControllerId())) {
|
||||
// discard effect if controller of both permanents is the same
|
||||
discard();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
|
|||
if (player != null && permanent != null) {
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
// only spells cast, so no copies of spells
|
||||
if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.getControllerId().equals(source.getControllerId())) {
|
||||
if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) stackObject;
|
||||
if (filter.match(spell, game)) {
|
||||
if (!spell.getAbilities().contains(ability)) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
|
|||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
targetStillExists = true;
|
||||
if (!permanent.getControllerId().equals(controllingPlayerId)) {
|
||||
if (!permanent.isControlledBy(controllingPlayerId)) {
|
||||
GameEvent loseControlEvent = GameEvent.getEvent(GameEvent.EventType.LOSE_CONTROL, permanentId, source.getId(), permanent.getControllerId());
|
||||
if (game.replaceEvent(loseControlEvent)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl {
|
|||
Card cardOnTop = game.getCard(objectId);
|
||||
if (cardOnTop != null
|
||||
&& affectedControllerId.equals(source.getControllerId())
|
||||
&& cardOnTop.getOwnerId().equals(source.getControllerId())
|
||||
&& cardOnTop.isOwnedBy(source.getControllerId())
|
||||
&& (!cardOnTop.getManaCost().isEmpty() || cardOnTop.isLand())
|
||||
&& filter.match(cardOnTop, game)) {
|
||||
Player player = game.getPlayer(cardOnTop.getOwnerId());
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class UntapAllDuringEachOtherPlayersUntapStepEffect extends ContinuousEff
|
|||
applied = Boolean.FALSE;
|
||||
}
|
||||
if (!applied && layer == Layer.RulesEffects) {
|
||||
if (!source.getControllerId().equals(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
if (!source.isControlledBy(game.getActivePlayerId()) && game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", true);
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
||||
boolean untap = true;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class UntapSourceDuringEachOtherPlayersUntapStepEffect extends Continuous
|
|||
applied = Boolean.FALSE;
|
||||
}
|
||||
if (!applied && layer == Layer.RulesEffects) {
|
||||
if (!source.getControllerId().equals(game.getActivePlayerId())
|
||||
if (!source.isControlledBy(game.getActivePlayerId())
|
||||
&& game.getStep() != null
|
||||
&& game.getStep().getType() == PhaseStep.UNTAP) {
|
||||
game.getState().setValue(source.getSourceId() + "applied", true);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class AbilitiesCostReductionControllerEffect extends CostModificationEffe
|
|||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify.getControllerId().equals(source.getControllerId())
|
||||
return abilityToModify.isControlledBy(source.getControllerId())
|
||||
&& activatedAbility.isInstance(abilityToModify);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class SpellsCostIncreasementControllerEffect extends CostModificationEffe
|
|||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
if (abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
return this.filter.match(spell, game);
|
||||
|
|
|
|||
|
|
@ -120,10 +120,10 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (onlyControlled && !abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
if (onlyControlled && !abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
if (controllerId != null && !abilityToModify.getControllerId().equals(controllerId)) {
|
||||
if (controllerId != null && !abilityToModify.isControlledBy(controllerId)) {
|
||||
return false;
|
||||
}
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class SpellsCostReductionControllerEffect extends CostModificationEffectI
|
|||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof SpellAbility) {
|
||||
if (abilityToModify.getControllerId().equals(source.getControllerId())) {
|
||||
if (abilityToModify.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
return this.filter.match(spell, source.getSourceId(), source.getControllerId(), game);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class AuraSwapEffect extends OneShotEffect {
|
|||
Permanent auraSourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (auraSourcePermanent != null
|
||||
&& auraSourcePermanent.hasSubtype(SubType.AURA, game)
|
||||
&& auraSourcePermanent.getOwnerId().equals(source.getControllerId())) {
|
||||
&& auraSourcePermanent.isOwnedBy(source.getControllerId())) {
|
||||
Permanent enchantedPermanent = game.getPermanent(auraSourcePermanent.getAttachedTo());
|
||||
filterCardToCheck.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId()));
|
||||
TargetCardInHand target = new TargetCardInHand(filterCardToCheck);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class EvolveAbility extends TriggeredAbilityImpl {
|
|||
Permanent triggeringCreature = game.getPermanent(event.getTargetId());
|
||||
if (triggeringCreature != null
|
||||
&& triggeringCreature.isCreature()
|
||||
&& triggeringCreature.getControllerId().equals(this.controllerId)) {
|
||||
&& triggeringCreature.isControlledBy(this.controllerId)) {
|
||||
Permanent sourceCreature = game.getPermanent(sourceId);
|
||||
if (sourceCreature != null && isPowerOrThoughnessGreater(sourceCreature, triggeringCreature)) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class HideawayLookAtFaceDownCardEffect extends AsThoughEffectImpl {
|
|||
// TODO: Does not handle if a player had the control of the land permanent some time before
|
||||
// we would need to add a watcher to handle this
|
||||
Permanent sourcePermanet = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (sourcePermanet != null && sourcePermanet.getControllerId().equals(affectedControllerId)) {
|
||||
if (sourcePermanet != null && sourcePermanet.isControlledBy(affectedControllerId)) {
|
||||
ExileZone exile = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||
Card card = game.getCard(objectId);
|
||||
if (exile != null && exile.contains(objectId) && card != null) {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class OfferingAsThoughEffect extends AsThoughEffectImpl {
|
|||
public boolean applies(UUID sourceId, Ability affectedAbility, Ability source, Game game) {
|
||||
if (sourceId.equals(source.getSourceId())) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (!card.getOwnerId().equals(source.getControllerId())) {
|
||||
if (!card.isOwnedBy(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
// because can activate is always called twice, result from first call will be used
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class RecoverAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (zEvent.getTarget().getOwnerId().equals(getControllerId())
|
||||
if (zEvent.getTarget().isOwnedBy(getControllerId())
|
||||
&& zEvent.getTarget().isCreature()
|
||||
&& !zEvent.getTarget().getId().equals(getSourceId())) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class RepairCastFromGraveyardEffect extends AsThoughEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.getControllerId().equals(affectedControllerId);
|
||||
return source.isControlledBy(affectedControllerId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class SoulbondAbility extends EntersBattlefieldTriggeredAbility {
|
|||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(getControllerId())) {
|
||||
if (permanent.isCreature()) {
|
||||
if (permanent.getId().equals(getSourceId())) {
|
||||
if (permanent.getControllerId().equals(getControllerId())) {
|
||||
if (permanent.isControlledBy(getControllerId())) {
|
||||
self = true;
|
||||
if (other) {
|
||||
return true;
|
||||
|
|
@ -195,7 +195,7 @@ class SoulbondEntersOtherAbility extends EntersBattlefieldAllTriggeredAbility {
|
|||
// if you control both this creature and another creature and both are unpaired
|
||||
if (game.getBattlefield().countAll(filter, getControllerId(), game) > 0) {
|
||||
Permanent sourcePermanent = game.getPermanent(getSourceId());
|
||||
if (sourcePermanent != null && sourcePermanent.getControllerId().equals(getControllerId()) && sourcePermanent.getPairedCard() == null) {
|
||||
if (sourcePermanent != null && sourcePermanent.isControlledBy(getControllerId()) && sourcePermanent.getPairedCard() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,4 +168,8 @@ public interface Card extends MageObject {
|
|||
boolean addAttachment(UUID permanentId, Game game);
|
||||
|
||||
boolean removeAttachment(UUID permanentId, Game game);
|
||||
|
||||
default boolean isOwnedBy(UUID controllerId){
|
||||
return getOwnerId().equals(controllerId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,18 +30,18 @@ public class OwnerPredicate implements ObjectPlayerPredicate<ObjectPlayer<Card>>
|
|||
|
||||
switch (targetOwner) {
|
||||
case YOU:
|
||||
if (card.getOwnerId().equals(playerId)) {
|
||||
if (card.isOwnedBy(playerId)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
if (!card.getOwnerId().equals(playerId)
|
||||
if (!card.isOwnedBy(playerId)
|
||||
&& game.getPlayer(playerId).hasOpponent(card.getOwnerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case NOT_YOU:
|
||||
if (!card.getOwnerId().equals(playerId)) {
|
||||
if (!card.isOwnedBy(playerId)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class AttachedToControlledPermanentPredicate implements ObjectPlayerPredi
|
|||
Permanent attachement = input.getObject();
|
||||
if (attachement != null) {
|
||||
Permanent permanent = game.getPermanent(attachement.getAttachedTo());
|
||||
if (permanent != null && permanent.getControllerId().equals(input.getPlayerId())) {
|
||||
if (permanent != null && permanent.isControlledBy(input.getPlayerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class ControllerPredicate implements ObjectPlayerPredicate<ObjectPlayer<C
|
|||
|
||||
switch (controller) {
|
||||
case YOU:
|
||||
if (object.getControllerId().equals(playerId)) {
|
||||
if (object.isControlledBy(playerId)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -38,18 +38,18 @@ public class ControllerPredicate implements ObjectPlayerPredicate<ObjectPlayer<C
|
|||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
if (!object.getControllerId().equals(playerId)
|
||||
if (!object.isControlledBy(playerId)
|
||||
&& game.getPlayer(playerId).hasOpponent(object.getControllerId(), game)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case NOT_YOU:
|
||||
if (!object.getControllerId().equals(playerId)) {
|
||||
if (!object.isControlledBy(playerId)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ACTIVE:
|
||||
if (object.getControllerId().equals(game.getActivePlayerId())) {
|
||||
if (object.isControlledBy(game.getActivePlayerId())) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class DefendingPlayerControlsPredicate implements ObjectSourcePlayerPredi
|
|||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
|
||||
return input.getObject().getControllerId().equals(game.getCombat().getDefendingPlayerId(input.getSourceId(), game));
|
||||
return input.getObject().isControlledBy(game.getCombat().getDefendingPlayerId(input.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class DefendingPlayerOwnsCardPredicate implements ObjectSourcePlayerPredi
|
|||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Card> input, Game game) {
|
||||
return input.getObject().getOwnerId().equals(game.getCombat().getDefendingPlayerId(input.getSourceId(), game));
|
||||
return input.getObject().isOwnedBy(game.getCombat().getDefendingPlayerId(input.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -10,4 +10,8 @@ import java.util.UUID;
|
|||
public interface Controllable {
|
||||
UUID getControllerId();
|
||||
UUID getId();
|
||||
|
||||
default boolean isControlledBy(UUID controllerID){
|
||||
return getControllerId().equals(controllerID);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1865,7 +1865,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
//702.93e.: ...another player gains control
|
||||
// ...or the creature it's paired with leaves the battlefield.
|
||||
Permanent paired = perm.getPairedCard().getPermanent(this);
|
||||
if (paired == null || !perm.getControllerId().equals(paired.getControllerId()) || paired.getPairedCard() == null) {
|
||||
if (paired == null || !perm.isControlledBy(paired.getControllerId()) || paired.getPairedCard() == null) {
|
||||
perm.setPairedCard(null);
|
||||
if (paired != null && paired.getPairedCard() != null) {
|
||||
paired.setPairedCard(null);
|
||||
|
|
@ -1876,7 +1876,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (perm.getBandedCards() != null && !perm.getBandedCards().isEmpty()) {
|
||||
for (UUID bandedId : new ArrayList<>(perm.getBandedCards())) {
|
||||
Permanent banded = getPermanent(bandedId);
|
||||
if (banded == null || !perm.getControllerId().equals(banded.getControllerId()) || !banded.getBandedCards().contains(perm.getId())) {
|
||||
if (banded == null || !perm.isControlledBy(banded.getControllerId()) || !banded.getBandedCards().contains(perm.getId())) {
|
||||
perm.removeBandedCard(bandedId);
|
||||
if (banded != null && banded.getBandedCards().contains(perm.getId())) {
|
||||
banded.removeBandedCard(perm.getId());
|
||||
|
|
@ -1993,7 +1993,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
} else if (target instanceof TargetCard) {
|
||||
Card attachedTo = getCard(perm.getAttachedTo());
|
||||
if (attachedTo == null
|
||||
|| !((TargetCard) spellAbility.getTargets().get(0)).canTarget(perm.getControllerId(), perm.getAttachedTo(), spellAbility, this)) {
|
||||
|| !(spellAbility.getTargets().get(0)).canTarget(perm.getControllerId(), perm.getAttachedTo(), spellAbility, this)) {
|
||||
if (movePermanentToGraveyardWithInfo(perm)) {
|
||||
if (attachedTo != null) {
|
||||
attachedTo.removeAttachment(perm.getId(), this);
|
||||
|
|
@ -2482,7 +2482,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Set<Card> toOutside = new HashSet<>();
|
||||
for (Iterator<Permanent> it = getBattlefield().getAllPermanents().iterator(); it.hasNext();) {
|
||||
Permanent perm = it.next();
|
||||
if (perm.getOwnerId().equals(playerId)) {
|
||||
if (perm.isOwnedBy(playerId)) {
|
||||
if (perm.getAttachedTo() != null) {
|
||||
Permanent attachedTo = getPermanent(perm.getAttachedTo());
|
||||
if (attachedTo != null) {
|
||||
|
|
@ -2500,7 +2500,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
toOutside.add(perm);
|
||||
// it.remove();
|
||||
} else if (perm.getControllerId().equals(player.getId())) {
|
||||
} else if (perm.isControlledBy(player.getId())) {
|
||||
// and any effects which give that player control of any objects or players end
|
||||
Effects:
|
||||
for (ContinuousEffect effect : getContinuousEffects().getLayeredEffects(this)) {
|
||||
|
|
@ -2533,7 +2533,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
// Then, if that player controlled any objects on the stack not represented by cards, those objects cease to exist.
|
||||
this.getState().getContinuousEffects().removeInactiveEffects(this);
|
||||
getStack().removeIf(object -> object.getControllerId().equals(playerId));
|
||||
getStack().removeIf(object -> object.isControlledBy(playerId));
|
||||
// Then, if there are any objects still controlled by that player, those objects are exiled.
|
||||
applyEffects(); // to remove control from effects removed meanwhile
|
||||
List<Permanent> permanents = this.getBattlefield().getAllActivePermanents(playerId);
|
||||
|
|
@ -2545,7 +2545,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
for (ExileZone exile : this.getExile().getExileZones()) {
|
||||
for (Iterator<UUID> it = exile.iterator(); it.hasNext();) {
|
||||
Card card = this.getCard(it.next());
|
||||
if (card != null && card.getOwnerId().equals(playerId)) {
|
||||
if (card != null && card.isOwnedBy(playerId)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
|
@ -2579,13 +2579,12 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Entry<UUID, Card>> it = gameCards.entrySet().iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Entry<UUID, Card> entry = it.next();
|
||||
Card card = entry.getValue();
|
||||
if (card.getOwnerId().equals(playerId)) {
|
||||
if (card.isOwnedBy(playerId)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
possibleDefenders = new HashSet<>();
|
||||
for (UUID objectId : defenders) {
|
||||
Permanent planeswalker = game.getPermanent(objectId);
|
||||
if (planeswalker != null && planeswalker.getControllerId().equals(playerToAttack)) {
|
||||
if (planeswalker != null && planeswalker.isControlledBy(playerToAttack)) {
|
||||
possibleDefenders.add(objectId);
|
||||
} else if (playerToAttack.equals(objectId)) {
|
||||
possibleDefenders.add(objectId);
|
||||
|
|
@ -964,7 +964,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
if (creatureForcedToBlock == null) {
|
||||
break;
|
||||
}
|
||||
if (!creatureForcedToBlock.getControllerId().equals(player.getId())) {
|
||||
if (!creatureForcedToBlock.isControlledBy(player.getId())) {
|
||||
// ignore creatures controlled by other players
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1473,7 +1473,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
if (group.defenderIsPlaneswalker) {
|
||||
Permanent permanent = game.getPermanent(group.getDefenderId());
|
||||
if (permanent.getControllerId().equals(defenderId)) {
|
||||
if (permanent.isControlledBy(defenderId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class AjaniSteadfastPreventEffect extends PreventionEffectImpl {
|
|||
|
||||
if (event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())) {
|
||||
if (permanent != null && permanent.isControlledBy(source.getControllerId())) {
|
||||
return super.applies(event, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class DarettiScrapSavantTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (zEvent.getToZone() == Zone.GRAVEYARD
|
||||
&& zEvent.getFromZone() == Zone.BATTLEFIELD
|
||||
&& zEvent.getTarget().isArtifact()
|
||||
&& zEvent.getTarget().getOwnerId().equals(this.controllerId)) {
|
||||
&& zEvent.getTarget().isOwnedBy(this.controllerId)) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(zEvent.getTargetId()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class TrailOfTheMageRingsReboundEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
|
||||
StackObject stackObject = iterator.next();
|
||||
if (stackObject instanceof Spell && stackObject.getControllerId().equals(source.getControllerId())) {
|
||||
if (stackObject instanceof Spell && stackObject.isControlledBy(source.getControllerId())) {
|
||||
Spell spell = (Spell) stackObject;
|
||||
Card card = spell.getCard();
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class Battlefield implements Serializable {
|
|||
public int countAll(FilterPermanent filter, UUID controllerId, Game game) {
|
||||
return (int) field.values()
|
||||
.stream()
|
||||
.filter(permanent -> permanent.getControllerId().equals(controllerId)
|
||||
.filter(permanent -> permanent.isControlledBy(controllerId)
|
||||
&& filter.match(permanent, game)
|
||||
&& permanent.isPhasedIn())
|
||||
.count();
|
||||
|
|
@ -124,7 +124,7 @@ public class Battlefield implements Serializable {
|
|||
public boolean contains(FilterPermanent filter, UUID controllerId, int num, Game game) {
|
||||
return field.values()
|
||||
.stream()
|
||||
.filter(permanent -> permanent.getControllerId().equals(controllerId)
|
||||
.filter(permanent -> permanent.isControlledBy(controllerId)
|
||||
&& filter.match(permanent, game)
|
||||
&& permanent.isPhasedIn())
|
||||
.count() >= num;
|
||||
|
|
@ -213,7 +213,7 @@ public class Battlefield implements Serializable {
|
|||
return field.values()
|
||||
.stream()
|
||||
.filter(perm -> perm.isPhasedIn()
|
||||
&& perm.getControllerId().equals(controllerId))
|
||||
&& perm.isControlledBy(controllerId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getAllActivePermanents(FilterPermanent filter, UUID controllerId, Game game) {
|
||||
return field.values()
|
||||
.stream()
|
||||
.filter(perm -> perm.isPhasedIn() && perm.getControllerId().equals(controllerId) && filter.match(perm, game))
|
||||
.filter(perm -> perm.isPhasedIn() && perm.isControlledBy(controllerId) && filter.match(perm, game))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
@ -333,14 +333,14 @@ public class Battlefield implements Serializable {
|
|||
.stream()
|
||||
.filter(perm -> perm.getAbilities().containsKey(PhasingAbility.getInstance().getId())
|
||||
&& perm.isPhasedIn() &&
|
||||
perm.getControllerId().equals(controllerId))
|
||||
perm.isControlledBy(controllerId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Permanent> getPhasedOut(UUID controllerId) {
|
||||
return field.values()
|
||||
.stream()
|
||||
.filter(perm -> !perm.isPhasedIn() && perm.getControllerId().equals(controllerId))
|
||||
.filter(perm -> !perm.isPhasedIn() && perm.isControlledBy(controllerId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
// card will be copied during putOntoBattlefield, so the card of CardPermanent has to be changed
|
||||
// TODO: Find a better way to prevent bestow creatures from being effected by creature affecting abilities
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null && permanent instanceof PermanentCard) {
|
||||
if (permanent instanceof PermanentCard) {
|
||||
permanent.setSpellAbility(ability); // otherwise spell ability without bestow will be set
|
||||
if (!card.getCardType().contains(CardType.CREATURE)) {
|
||||
card.addCardType(CardType.CREATURE);
|
||||
|
|
@ -264,7 +264,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
updateOptionalCosts(0);
|
||||
if (controller.moveCards(card, Zone.BATTLEFIELD, ability, game, false, faceDown, false, null)) {
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null && permanent instanceof PermanentCard) {
|
||||
if (permanent instanceof PermanentCard) {
|
||||
((PermanentCard) permanent).getCard().addCardType(CardType.CREATURE);
|
||||
((PermanentCard) permanent).getCard().getSubtype(game).remove(SubType.AURA);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class Library implements Serializable {
|
|||
}
|
||||
|
||||
public void putOnTop(Card card, Game game) {
|
||||
if (card.getOwnerId().equals(playerId)) {
|
||||
if (card.isOwnedBy(playerId)) {
|
||||
card.setZone(Zone.LIBRARY, game);
|
||||
library.addFirst(card.getId());
|
||||
} else {
|
||||
|
|
@ -125,7 +125,7 @@ public class Library implements Serializable {
|
|||
}
|
||||
|
||||
public void putOnBottom(Card card, Game game) {
|
||||
if (card.getOwnerId().equals(playerId)) {
|
||||
if (card.isOwnedBy(playerId)) {
|
||||
card.setZone(Zone.LIBRARY, game);
|
||||
library.remove(card.getId());
|
||||
library.add(card.getId());
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public boolean putInHand(Card card, Game game) {
|
||||
if (card.getOwnerId().equals(playerId)) {
|
||||
if (card.isOwnedBy(playerId)) {
|
||||
card.setZone(Zone.HAND, game);
|
||||
this.hand.add(card);
|
||||
} else {
|
||||
|
|
@ -834,7 +834,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean putInGraveyard(Card card, Game game) {
|
||||
if (card.getOwnerId().equals(playerId)) {
|
||||
if (card.isOwnedBy(playerId)) {
|
||||
this.graveyard.add(card);
|
||||
} else {
|
||||
return game.getPlayer(card.getOwnerId()).putInGraveyard(card, game);
|
||||
|
|
@ -885,7 +885,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public boolean putCardOnTopXOfLibrary(Card card, Game game, Ability source, int xFromTheTop) {
|
||||
if (card.getOwnerId().equals(getId())) {
|
||||
if (card.isOwnedBy(getId())) {
|
||||
if (library.size() + 1 < xFromTheTop) {
|
||||
putCardsOnBottomOfLibrary(new CardsImpl(card), game, source, true);
|
||||
} else {
|
||||
|
|
@ -1556,7 +1556,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// that phased out indirectly won't phase in by itself, but instead phases in
|
||||
// along with the card it's attached to.
|
||||
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
|
||||
if (!(attachedTo != null && attachedTo.getControllerId().equals(this.getId()))) {
|
||||
if (!(attachedTo != null && attachedTo.isControlledBy(this.getId()))) {
|
||||
permanent.phaseOut(game, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -2325,7 +2325,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
setStoredBookmark(game.bookmarkState()); // makes it possible to UNDO a declared attacker with costs from e.g. Propaganda
|
||||
}
|
||||
Permanent attacker = game.getPermanent(attackerId);
|
||||
if (attacker != null && attacker.canAttack(defenderId, game) && attacker.getControllerId().equals(playerId)) {
|
||||
if (attacker != null && attacker.canAttack(defenderId, game) && attacker.isControlledBy(playerId)) {
|
||||
if (!game.getCombat().declareAttacker(attackerId, defenderId, playerId, game)) {
|
||||
game.undo(playerId);
|
||||
}
|
||||
|
|
@ -3023,7 +3023,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// activated abilities from objects in the command zone (emblems or commanders)
|
||||
for (CommandObject commandObject : game.getState().getCommand()) {
|
||||
for (ActivatedAbility ability : commandObject.getAbilities().getActivatedAbilities(Zone.COMMAND)) {
|
||||
if (ability.getControllerId().equals(getId()) && canPlay(ability, availableMana, game.getObject(ability.getSourceId()), game)) {
|
||||
if (ability.isControlledBy(getId()) && canPlay(ability, availableMana, game.getObject(ability.getSourceId()), game)) {
|
||||
playableActivated.put(ability.toString(), ability);
|
||||
}
|
||||
|
||||
|
|
@ -3578,7 +3578,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
game.informPlayers(getLogName() + " puts "
|
||||
+ (withName ? card.getLogName() : (card.isFaceDown(game) ? "a face down card" : "a card"))
|
||||
+ " from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + ' '
|
||||
+ (card.getOwnerId().equals(this.getId()) ? "into their hand" : "into its owner's hand")
|
||||
+ (card.isOwnedBy(this.getId()) ? "into their hand" : "into its owner's hand")
|
||||
);
|
||||
}
|
||||
result = true;
|
||||
|
|
@ -3601,7 +3601,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
if (cards.isEmpty()) {
|
||||
ownerId = card.getOwnerId();
|
||||
}
|
||||
if (card.getOwnerId().equals(ownerId)) {
|
||||
if (card.isOwnedBy(ownerId)) {
|
||||
it.remove();
|
||||
cards.add(card);
|
||||
}
|
||||
|
|
@ -3672,7 +3672,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
StringBuilder sb = new StringBuilder(this.getLogName())
|
||||
.append(" puts ").append(card.getLogName()).append(' ').append(card.isCopy() ? "(Copy) " : "")
|
||||
.append(fromZone != null ? "from " + fromZone.toString().toLowerCase(Locale.ENGLISH) + ' ' : "");
|
||||
if (card.getOwnerId().equals(getId())) {
|
||||
if (card.isOwnedBy(getId())) {
|
||||
sb.append("into their graveyard");
|
||||
} else {
|
||||
sb.append("it into its owner's graveyard");
|
||||
|
|
@ -3704,7 +3704,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
sb.append("from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(' ');
|
||||
}
|
||||
sb.append("to the ").append(toTop ? "top" : "bottom");
|
||||
if (card.getOwnerId().equals(getId())) {
|
||||
if (card.isOwnedBy(getId())) {
|
||||
sb.append(" of their library");
|
||||
} else {
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class TargetCardInASingleGraveyard extends TargetCard {
|
|||
Card card = game.getCard(firstTarget);
|
||||
Card targetCard = game.getCard(id);
|
||||
if (card == null || targetCard == null
|
||||
|| !card.getOwnerId().equals(targetCard.getOwnerId())) {
|
||||
|| !card.isOwnedBy(targetCard.getOwnerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard {
|
|||
if (game.getPlayer(source.getControllerId()).hasOpponent(card.getOwnerId(), game)) {
|
||||
if (allFromOneOpponent && !targets.isEmpty()) {
|
||||
Card firstCard = game.getCard(targets.keySet().iterator().next());
|
||||
if (firstCard != null && !card.getOwnerId().equals(firstCard.getOwnerId())) {
|
||||
if (firstCard != null && !card.isOwnedBy(firstCard.getOwnerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class TargetCreaturePermanentSameController extends TargetCreaturePermane
|
|||
Permanent targetPermanent = game.getPermanent(targetId);
|
||||
if (targetPermanent != null) {
|
||||
if (!firstTargetPermanent.getId().equals(targetPermanent.getId())) {
|
||||
if (!firstTargetPermanent.getControllerId().equals(targetPermanent.getOwnerId())) {
|
||||
if (!firstTargetPermanent.isControlledBy(targetPermanent.getOwnerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class TargetTriggeredAbility extends TargetObject {
|
|||
return stackObject.getStackAbility() != null
|
||||
&& (stackObject.getStackAbility() instanceof TriggeredAbility)
|
||||
&& source != null
|
||||
&& stackObject.getStackAbility().getControllerId().equals(source.getControllerId());
|
||||
&& stackObject.getStackAbility().isControlledBy(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -53,7 +53,7 @@ public class TargetTriggeredAbility extends TargetObject {
|
|||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject.getStackAbility() != null
|
||||
&& stackObject.getStackAbility() instanceof TriggeredAbility
|
||||
&& stackObject.getStackAbility().getControllerId().equals(sourceControllerId)) {
|
||||
&& stackObject.getStackAbility().isControlledBy(sourceControllerId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ public class TargetTriggeredAbility extends TargetObject {
|
|||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject.getStackAbility() != null
|
||||
&& stackObject.getStackAbility() instanceof TriggeredAbility
|
||||
&& stackObject.getStackAbility().getControllerId().equals(sourceControllerId)) {
|
||||
&& stackObject.getStackAbility().isControlledBy(sourceControllerId)) {
|
||||
possibleTargets.add(stackObject.getStackAbility().getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue