public SourceHasRemainedInSameZoneCondition getInstance(UUID cardId) { return new SourceHasRemainedInSameZoneCondition(cardId); }
@Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && sourcePermanent != null && controller.getId().equals(sourcePermanent.getControllerId())) { UUID target = source.getFirstTarget(); if (target != null && game.getPermanent(target) != null) { Permanent targetPermanent = game.getPermanent(target); SourceHasRemainedInSameZoneCondition condition = new SourceHasRemainedInSameZoneCondition(sourcePermanent.getId()); SourceHasRemainedInSameZoneCondition conditionTarget = new SourceHasRemainedInSameZoneCondition(target); ConditionalContinuousEffect effect = new ConditionalContinuousEffect( new GainControlTargetEffect(Duration.Custom), new CompoundCondition(SourceTappedCondition.instance, new CompoundCondition (condition, conditionTarget)), "Gain control of target creature of an opponent's choice that he or she controls for as long as {this} remains tapped"); game.addEffect(effect, source); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); if (controller != null && sourcePermanent != null) { if (target != null && controller.getId().equals(sourcePermanent.getControllerId())) { SourceHasRemainedInSameZoneCondition condition = new SourceHasRemainedInSameZoneCondition(sourcePermanent.getId()); game.addEffect(new ConditionalContinuousEffect( new GainControlTargetEffect(Duration.Custom), new CompoundCondition(new SourceOnBattlefieldControlUnchangedCondition(), condition), null), source); if (!game.isSimulation()) { game.informPlayers(sourcePermanent.getLogName() + ": " + controller.getLogName() + " gained control of " + target.getLogName()); } sourcePermanent.addInfo("gained control of", CardUtil.addToolTipMarkTags("Gained control of: " + GameLog.getColoredObjectIdNameForTooltip(target)), game); } return true; } return false; } }