@Override public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) { return game.getStack().stream() .filter(TargetActivatedOrTriggeredAbility::isActivatedOrTriggeredAbility) .map(stackObject -> stackObject.getStackAbility().getId()) .collect(Collectors.toSet()); }
private void activateConspire(Ability ability, Game game) { Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId()); if (activations == null) { activations = new HashSet<>(); game.getState().setValue(CONSPIRE_ACTIVATION_KEY + ability.getId(), activations); } activations.add(getConspireId()); }
@Override public boolean isInactive(Ability source, Game game) { return game.getState().getZoneChangeCounter(source.getId()) != zoneChangeCounter; }
public boolean isActivated(Ability ability, Game game) { Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId()); if (activations != null) { return activations.contains(getConspireId()); } return false; }
private void resetConspire(Ability ability, Game game) { Set<UUID> activations = (Set<UUID>) game.getState().getValue(CONSPIRE_ACTIVATION_KEY + ability.getId()); if (activations != null) { activations.remove(getConspireId()); } }
@Override public void init(Ability source, Game game) { super.init(source, game); zoneChangeCounter = game.getState().getZoneChangeCounter(source.getId()); }
private boolean abilityActive(Ability ability, Game game) { MageObject object = game.getObject(ability.getSourceId()); return object != null && object.hasAbility(ability.getId(), game); }
@Override public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) { Set<UUID> possibleTargets = new HashSet<>(); for (StackObject stackObject : game.getStack()) { if (stackObject.getStackAbility() != null && stackObject.getStackAbility() instanceof TriggeredAbility && stackObject.getStackAbility().isControlledBy(sourceControllerId)) { possibleTargets.add(stackObject.getStackAbility().getId()); } } return possibleTargets; }
@Override public boolean canTarget(UUID id, Ability source, Game game) { // rule 114.4. A spell or ability on the stack is an illegal target for itself. if (source == null || source.getId().equals(id)) { return false; } Spell spell = game.getStack().getSpell(id); return spell != null && filter.match(spell, source.getSourceId(), source.getControllerId(), game); }
@Override public boolean canTarget(UUID id, Ability source, Game game) { // rule 114.4. A spell or ability on the stack is an illegal target for itself. if (source != null && source.getId().equals(id)) { return false; } StackObject stackObject = game.getStack().getStackObject(id); return isActivatedOrTriggeredAbility(stackObject) && source != null && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game); }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if ((abilityToModify instanceof SpellAbility) && abilityToModify.isControlledBy(source.getControllerId())) { Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); return spell != null && StaticFilters.FILTER_SPELL_INSTANT_OR_SORCERY.match(spell, game); } return false; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { if (abilityToModify.isControlledBy(source.getControllerId())) { Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); if (spell != null) { return DashedCondition.instance.apply(game, abilityToModify); } } } return false; }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { if (abilityToModify.isControlledBy(source.getControllerId())) { Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); if (spell != null) { return spell.isCreature(); } } } return false; }
@Override public boolean apply(Game game, Ability source) { List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getId(), game); for (Permanent p : permanents) { p.sacrifice(source.getSourceId(), game); } return true; }
@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 apply(Game game, Ability source) { Permanent equipment = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if(equipment != null){ Permanent creature = game.getPermanent(equipment.getAttachedTo()); if(creature != null){ creature.damage(2, source.getId(), game, false, true); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(targetPointer.getFirst(game, source)); if (target != null) { Player player = game.getPlayer(target.getControllerId()); if (player != null) { int power = target.getPower().getValue(); player.damage(power, source.getId(), game, false, true); } } return false; }
public CardsView(Collection<? extends Ability> abilities, GameState state) { for (Ability ability : abilities) { Card sourceCard = state.getPermanent(ability.getSourceId()); if (sourceCard != null) { this.put(ability.getId(), new AbilityView(ability, sourceCard.getName(), new CardView(sourceCard))); } } }
@Override public boolean apply(Game game, Ability source) { MageObject sourceObject = game.getObject(source.getSourceId()); Player firstPlayer = game.getPlayer(game.getActivePlayerId()); Player secondPlayer = game.getPlayer(source.getFirstTarget()); if (sourceObject == null || firstPlayer == null) { return false; } if (firstPlayer.chooseUse(outcome, "Deal one damage to " + secondPlayer.getLogName() + "?", source, game)) { secondPlayer.damage(1, source.getId(), game, false, true); } return true; }
private void removeConditional(ManaType manaType, Ability ability, Game game, Cost costToPay, Mana usedManaToPay) { for (ConditionalMana mana : getConditionalMana()) { if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId(), costToPay)) { mana.set(manaType, mana.get(manaType) - 1); usedManaToPay.increase(manaType); GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAID, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag()); event.setData(mana.getManaProducerOriginalId().toString()); game.fireEvent(event); break; } } }