use of mage.MageObjectReference in project mage by magefree.
the class DauntlessBodyguardGainAbilityEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent == null) {
return false;
}
MageObjectReference mor = (MageObjectReference) game.getState().getValue(sourcePermanent.getId() + "_chosenCreature");
if (mor == null) {
return false;
}
Permanent chosenPermanent = mor.getPermanent(game);
if (chosenPermanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(chosenPermanent, game));
game.addEffect(effect, source);
}
return true;
}
use of mage.MageObjectReference in project mage by magefree.
the class GideonJuraEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
creatingPermanent = new MageObjectReference(source.getSourceId(), game);
// setup startingController to calc isYourTurn calls
setStartingControllerAndTurnNum(game, source.getFirstTarget(), game.getActivePlayerId());
}
use of mage.MageObjectReference in project mage by magefree.
the class GideonChampionOfJusticeToken method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
MageObjectReference mor = new MageObjectReference(source.getSourceObject(game), game);
Cards cards = new CardsImpl();
game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, source.getControllerId(), game).stream().filter(Objects::nonNull).filter(permanent -> !mor.refersTo(permanent, game)).forEach(cards::add);
return player.moveCards(cards, Zone.EXILED, source, game);
}
use of mage.MageObjectReference in project mage by magefree.
the class GideonTheOathswornToken method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getCombat().getAttackingPlayerId().equals(getControllerId())) {
int attackerCount = 0;
Set<MageObjectReference> attackers = new HashSet();
for (UUID attackerId : game.getCombat().getAttackers()) {
Permanent permanent = game.getPermanent(attackerId);
if (permanent != null && permanent.isCreature(game) && !permanent.hasSubtype(SubType.GIDEON, game)) {
attackerCount++;
attackers.add(new MageObjectReference(permanent, game));
}
}
if (attackerCount >= 2) {
this.getEffects().clear();
this.addEffect(new GideonTheOathswornEffect(attackers));
return true;
}
}
return false;
}
use of mage.MageObjectReference in project mage by magefree.
the class GideonsSacrificeEffectReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Target target = new TargetPermanent(filter);
target.setNotTarget(true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
game.addEffect(new GideonsSacrificeEffectReplacementEffect(new MageObjectReference(target.getFirstTarget(), game)), source);
return true;
}
Aggregations