Пример #1
0
 @java.lang.Override
 public boolean apply(Game game, Ability source) {
   Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
   if (sourceObject != null) {
     // create cost for sacrificing an artifact
     Player controller = game.getPlayer(source.getControllerId());
     if (controller != null) {
       TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
       // if they can pay the cost, then they must pay
       if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
         controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
         Permanent artifactSacrifice = game.getPermanent(target.getFirstTarget());
         if (artifactSacrifice != null) {
           // sacrifice the chosen artifact
           artifactSacrifice.sacrifice(source.getSourceId(), game);
         }
       } else {
         sourceObject.tap(game);
         controller.damage(4, source.getSourceId(), game, false, true);
       }
     }
     return true;
   }
   return false;
 }
Пример #2
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   Permanent creature = game.getPermanent(source.getSourceId());
   if (controller != null && creature != null) {
     if (controller.flipCoin(game)) {
       return true;
     } else {
       creature.removeFromCombat(game);
       creature.tap(game);
       return true;
     }
   }
   return false;
 }
Пример #3
0
  @Override
  public boolean apply(Game game, Ability source) {
    if (source.getFirstTarget() == null) {
      return false;
    }

    FilterLandPermanent filter = new FilterLandPermanent();
    filter.add(new ControllerIdPredicate(source.getFirstTarget()));

    List<Permanent> lands =
        game.getBattlefield()
            .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
    for (Permanent land : lands) {
      land.tap(game);
    }
    return true;
  }
Пример #4
0
 @Override
 public boolean apply(Game game, Ability source) {
   List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
   for (Permanent creature :
       game.getBattlefield()
           .getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
     creature.tap(game);
     doNotUntapNextUntapStep.add(creature);
   }
   if (!doNotUntapNextUntapStep.isEmpty()) {
     ContinuousEffect effect =
         new DontUntapInControllersNextUntapStepTargetEffect("This creature");
     effect.setTargetPointer(new FixedTargets(doNotUntapNextUntapStep, game));
     game.addEffect(effect, source);
   }
   return true;
 }
Пример #5
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent sourcePermanent = game.getPermanent(source.getSourceId());
   if (sourcePermanent != null) {
     sourcePermanent.clearConnectedCards("DesertersQuarters");
   }
   for (UUID target : targetPointer.getTargets(game, source)) {
     Permanent permanent = game.getPermanent(target);
     if (sourcePermanent != null) {
       sourcePermanent.addConnectedCard("DesertersQuarters", permanent.getId());
     }
     if (permanent != null) {
       permanent.tap(game);
     }
   }
   return true;
 }
Пример #6
0
  @Override
  public boolean apply(Game game, Ability source) {
    Map<Integer, Set<String>> attackerMap = null;
    Object object = game.getState().getValue("blockedAttackers" + source.getSourceId());
    if (object != null && object instanceof Map) {
      attackerMap = (Map<Integer, Set<String>>) object;
      for (Set<String> attackerSet : attackerMap.values()) {
        List<Permanent> doNotUntapNextUntapStep = new ArrayList<>();
        for (Permanent creature :
            game.getBattlefield()
                .getActivePermanents(
                    new FilterCreaturePermanent(), source.getControllerId(), game)) {
          if (attackerSet.contains(CardUtil.getCardZoneString(null, creature.getId(), game))) {
            // tap creature and add the not untap effect
            creature.tap(game);
            doNotUntapNextUntapStep.add(creature);
            game.informPlayers(
                new StringBuilder("Triton Tactics: ")
                    .append(creature.getName())
                    .append(" doesn't untap during its controller's next untap step")
                    .toString());
          }
        }
        if (!doNotUntapNextUntapStep.isEmpty()) {
          ContinuousEffect effect =
              new DontUntapInControllersNextUntapStepTargetEffect("This creature");
          effect.setTargetPointer(new FixedTargets(doNotUntapNextUntapStep, game));
          game.addEffect(effect, source);
        }
      }
    }
    if (attackerMap != null) {
      attackerMap.clear();
    }

    return true;
  }
Пример #7
0
  @Override
  public void adjustCosts(Ability ability, Game game) {
    Player player = game.getPlayer(controllerId);
    if (player == null || !(ability instanceof SpellAbility)) {
      return;
    }
    Target target = new TargetControlledCreaturePermanent(1, Integer.MAX_VALUE, filter, true);
    target.setTargetName("creatures to convoke");
    if (!target.canChoose(sourceId, controllerId, game)) {
      return;
    }
    if (player.chooseUse(Outcome.Detriment, "Convoke creatures?", game)) {
      player.chooseTarget(Outcome.Tap, target, ability, game);
      if (target.getTargets().size() > 0) {
        int adjCost = 0;
        for (UUID creatureId : target.getTargets()) {
          Permanent perm = game.getPermanent(creatureId);
          if (perm == null) {
            continue;
          }
          ManaCosts manaCostsCreature = perm.getSpellAbility().getManaCosts();
          if (manaCostsCreature != null
              && manaCostsCreature.convertedManaCost() > 0
              && perm.tap(game)) {
            Choice chooseManaType = buildChoice(manaCostsCreature, ability.getManaCostsToPay());
            if (chooseManaType.getChoices().size() > 0) {
              if (chooseManaType.getChoices().size() > 1) {
                chooseManaType.getChoices().add("Colorless");
                chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName());
                while (!chooseManaType.isChosen()) {
                  player.choose(Outcome.Benefit, chooseManaType, game);
                }
              } else {
                chooseManaType.setChoice(chooseManaType.getChoices().iterator().next());
              }

              ManaCosts manaCostsToReduce = new ManaCostsImpl();
              if (chooseManaType.getChoice().equals("Black")) {
                manaCostsToReduce.load("{B}");
              }
              if (chooseManaType.getChoice().equals("Blue")) {
                manaCostsToReduce.load("{U}");
              }
              if (chooseManaType.getChoice().equals("Green")) {
                manaCostsToReduce.load("{G}");
              }
              if (chooseManaType.getChoice().equals("White")) {
                manaCostsToReduce.load("{W}");
              }
              if (chooseManaType.getChoice().equals("Red")) {
                manaCostsToReduce.load("{R}");
              }
              if (chooseManaType.getChoice().equals("Colorless")) {
                ++adjCost;
              }
              CardUtil.adjustCost((SpellAbility) ability, manaCostsToReduce);
            } else {
              ++adjCost;
            }
          }
        }
        this.getTargets().add(target);
        CardUtil.adjustCost((SpellAbility) ability, adjCost);
      }
    }
  }