@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { return (appliesToSpells && abilityToModify.getAbilityType() == AbilityType.SPELL) || (!appliesToSpells && (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || abilityToModify.getAbilityType() == AbilityType.MANA)); }
static boolean isActivatedOrTriggeredAbility(StackObject stackObject) { if (stackObject == null) { return false; } if (stackObject instanceof Ability) { Ability ability = (Ability) stackObject; return ability.getAbilityType() == AbilityType.TRIGGERED || ability.getAbilityType() == AbilityType.ACTIVATED; } return false; } }
@Override public boolean apply(Game game, Ability source, Ability abilityToModify) { if (abilityToModify.getAbilityType() == AbilityType.SPELL) { SpellAbility spellAbility = (SpellAbility) abilityToModify; CardUtil.adjustCost(spellAbility, -1); } if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED) { CardUtil.increaseCost(abilityToModify, 1); } return true; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || abilityToModify.getAbilityType() == AbilityType.MANA) { Permanent rebelPermanent = game.getPermanent(abilityToModify.getSourceId()); if (rebelPermanent != null) { return filter2.match(rebelPermanent, game); } } return false; }
@Override public Abilities<Ability> getManaAbilities(Zone zone) { return stream() .filter(ability -> ability.getAbilityType() == AbilityType.MANA) .filter(ability -> ability.getZone().match(zone)) .collect(Collectors.toCollection(AbilitiesImpl::new)); }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) { //Activated abilities of creatures you control Permanent permanent = game.getPermanent(abilityToModify.getSourceId()); if (permanent != null && permanent.isControlledBy(source.getControllerId())) { return true; } } return false; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) { Permanent permanent = game.getPermanent(abilityToModify.getSourceId()); if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { return true; } } return false; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && abilityToModify instanceof ActivatedAbility)) { //Activated abilities of creatures you control Permanent permanent = game.getPermanent(abilityToModify.getSourceId()); if (permanent != null && permanent.isCreature() && permanent.isControlledBy(source.getControllerId())) { return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { if (source != null && source.getAbilityType() == AbilityType.ACTIVATED) { MageObject object = game.getObject(source.getSourceId()); if (object != null && object.isArtifact()) { return true; } } return false; }
@Override public void adjustCosts(Ability ability, Game game) { if (ability.getAbilityType() == AbilityType.SPELL) { Player player = game.getPlayer(ability.getControllerId()); if (player != null && player.getLife() < 4) { CardUtil.adjustCost((SpellAbility) ability, 6); } } } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Ability ability = (Ability) getValue("targetAbility"); if (ability != null && ability.getAbilityType() == AbilityType.TRIGGERED) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); if (permanent != null && permanent.isCreature()) { return (((TriggeredAbility) ability).checkTrigger(event, game)); } } return false; }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.isAttachedTo(event.getSourceId())) { Optional<Ability> ability = game.getAbility(event.getTargetId(), event.getSourceId()); if (ability.isPresent() && ability.get().getAbilityType() != AbilityType.MANA) { return true; } } return false; } }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || (abilityToModify.getAbilityType() == AbilityType.MANA && (abilityToModify instanceof ActivatedAbility))) { // Activated abilities of creatures Card card = game.getCard(abilityToModify.getSourceId()); if (card != null && filter.match(card, source.getSourceId(), source.getControllerId(), game) && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { return true; } } return false; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { return (abilityToModify.getAbilityType() == AbilityType.ACTIVATED || abilityToModify instanceof SpellAbility) && game.getState().getPlayersInRange(source.getControllerId(), game).contains(abilityToModify.getControllerId()); }
@Override public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); for (StackObject stackObject : game.getStack()) { if (stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId()) && filter.match(((StackAbility) stackObject), game)) { possibleTargets.add(stackObject.getStackAbility().getId()); } } return possibleTargets; }
@Override public boolean canTarget(UUID id, Ability source, Game game) { if (source != null && source.getSourceId().equals(id)) { return false; } StackObject stackObject = game.getStack().getStackObject(id); return stackObject != null && stackObject.getStackAbility() != null && stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED && source != null && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game); }
@Override public void adjustCosts(Ability ability, Game game) { if (ability.getAbilityType() == AbilityType.SPELL) { Player controller = game.getPlayer(ability.getControllerId()); if (controller != null) { if (controller.getHand().count(filter, game) > 0) { ability.addCost(new RevealTargetFromHandCost(new TargetCardInHand(0, 1, filter))); } } } }
@Override public void adjustCosts(Ability ability, Game game) { if (ability.getAbilityType() == AbilityType.SPELL) { Player controller = game.getPlayer(ability.getControllerId()); if (controller != null) { if (controller.getHand().count(filter, game) > 0) { ability.addCost(new RevealTargetFromHandCost(new TargetCardInHand(0,1, filter))); } } } }
@Override public void adjustCosts(Ability ability, Game game) { if (ability.getAbilityType() == AbilityType.SPELL) { Player controller = game.getPlayer(ability.getControllerId()); if (controller != null) { if (controller.getHand().count(filter, game) > 0) { ability.addCost(new RevealTargetFromHandCost(new TargetCardInHand(0, 1, filter))); } } } }
@Override public boolean canChoose(UUID sourceControllerId, Game game) { for (StackObject stackObject : game.getStack()) { if (stackObject.getStackAbility() != null && stackObject.getStackAbility().getAbilityType() == AbilityType.ACTIVATED && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())) { return true; } } return false; }