Codota Logo
Cards.count
Code IndexAdd Codota to your IDE (free)

How to use
count
method
in
mage.cards.Cards

Best Java code snippets using mage.cards.Cards.count (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: magefree/mage

@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
  Player player = game.getPlayer(controllerId);
  if (player != null && player.getHand().count(filter, game) > 0) {
    return true;
  }
  if (mana.canPay(ability, sourceId, controllerId, game)) {
    return true;
  }
  return false;
}
origin: magefree/mage

@Override
public int getMaxValue(Ability source, Game game) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller != null) {
    return controller.getHand().count(filter, game);
  }
  return 0;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {   
  Player player = game.getPlayer(source.getControllerId());
  if (player != null && player.getHand().count(new FilterLandCard(), game) == 0) {
    return true;
  }
  return false;
}

origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if(player != null) {
      int handCount = player.getHand().count(new FilterCard(), game);
      player.drawCards(handCount, game);
      player.discard(handCount, false, source, game);
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
  Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
  if (targetPlayer != null && cardName != null && !cardName.isEmpty()) {
    FilterCard filter = new FilterCard();
    filter.add(new NamePredicate(cardName));
    int cardsInHandBefore = targetPlayer.getHand().count(filter, game);
    boolean result = super.applySearchAndExile(game, source, cardName, targetPointer.getFirst(game, source));
    int cardsExiled = cardsInHandBefore - targetPlayer.getHand().count(filter, game);
    if (cardsExiled > 0) {
      targetPlayer.drawCards(cardsExiled, game);
    }
    return result;
  }
  return false;
}
origin: magefree/mage

  @Override
  public void adjustCosts(Ability ability, Game game) {
    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)));
      }
    }
  }
}
origin: magefree/mage

  @Override
  public void adjustCosts(Ability ability, Game game) {
    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)));
      }
    }
  }
}
origin: magefree/mage

  @Override
  public void adjustCosts(Ability ability, Game game) {
    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)));
      }
    }
  }
}
origin: magefree/mage

@Override
public Mana produceMana(boolean netMana, Game game, Ability source) {
  if (netMana) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      return Mana.GreenMana(controller.getHand().count(filter, game));
    }
  }
  TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
  if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) {
    return Mana.GreenMana(target.getTargets().size());
  }
  return null;
}
origin: magefree/mage

@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)));
      }
    }
  }
}
origin: magefree/mage

@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)));
      }
    }
  }
}

origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (controller != null && targetPlayer != null) {
      controller.gainLife(targetPlayer.discard(2, false, source, game).count(new FilterLandCard(), game) * 3, game, source);
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      if (controller.getHand().count(new FilterLandCard(), game) > 6) {
        new FlipSourceEffect(new SasayasEssence()).apply(game, source);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@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)));
      }
    }
  }
}
origin: magefree/mage

@Override
public Mana produceMana(boolean netMana, Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller == null) {
    return null;
  }
  int artifacts = controller.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game);
  if (netMana) {
    return Mana.ColorlessMana(artifacts * 2);
  }
  if (artifacts > 0) {
    TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_ARTIFACT);
    if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
      Cards cards = new CardsImpl(target.getTargets());
      controller.revealCards(source, cards, game);
      return Mana.ColorlessMana(target.getTargets().size() * 2);
    }
  }
  return new Mana();
}
origin: magefree/mage

@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
  Cards cardsToCheck = new CardsImpl();
  Player player = game.getPlayer(sourceControllerId);
  for (Card card : player.getHand().getCards(filter, game)) {
    cardsToCheck.add(card.getId());
  }
  int possibleCards = 0;
  for (UUID cardToCheck : cardsToCheck) {
    FilterCard colorFilter = new FilterCard();
    colorFilter.add(new ColorPredicate(game.getCard(cardToCheck).getColor(game)));
    if (cardsToCheck.count(colorFilter, game) > 1) {
      ++possibleCards;
    }
  }
  return possibleCards > 0;
}
origin: magefree/mage

@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
  Cards cardsToCheck = new CardsImpl();
  Player player = game.getPlayer(sourceControllerId);
  if (player == null) {
    return false;
  }
  for (Card card : player.getHand().getCards(filter, game)) {
    cardsToCheck.add(card.getId());
  }
  int possibleCards = 0;
  for (Card card : cardsToCheck.getCards(game)) {
    FilterCard nameFilter = new FilterCard();
    nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
    if (cardsToCheck.count(nameFilter, game) > 1) {
      ++possibleCards;
    }
  }
  return possibleCards > 0;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      FilterCard filter = new FilterInstantOrSorceryCard();
      int cardsToCast = controller.getHand().count(filter, source.getControllerId(), source.getSourceId(), game);
      if (cardsToCast > 0 && controller.chooseUse(outcome, "Cast an instant or sorcery card from your hand without paying its mana cost?", source, game)) {
        TargetCardInHand target = new TargetCardInHand(filter);
        controller.chooseTarget(outcome, target, source, game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
          controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
        }
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    FilterCard filter = new FilterCard("creature card to discard");
    filter.add(new CardTypePredicate(CardType.CREATURE));
    if (controller != null
        && controller.getHand().count(filter, game) > 0
        && controller.chooseUse(Outcome.Discard, "Do you want to discard a creature card?  If you don't, you must discard 2 cards", source, game)) {
      Cost cost = new DiscardTargetCost(new TargetCardInHand(filter));
      if (cost.canPay(source, source.getSourceId(), controller.getId(), game)) {
        if (cost.pay(source, game, source.getSourceId(), controller.getId(), false, null)) {
          return true;
        }
      }
    }
    if (controller != null) {
      controller.discard(2, false, source, game);
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player you = game.getPlayer(source.getControllerId());
    FilterCard filter = new FilterCard("artifact to discard");
    filter.add(new CardTypePredicate(CardType.ARTIFACT));
    if (you != null
        && you.getHand().count(filter, game) > 0
        && you.chooseUse(Outcome.Discard, "Do you want to discard an artifact?  If you don't, you must discard 2 cards", source, game)) {
      Cost cost = new DiscardTargetCost(new TargetCardInHand(filter));
      if (cost.canPay(source, source.getSourceId(), you.getId(), game)) {
        if (cost.pay(source, game, source.getSourceId(), you.getId(), false, null)) {
          return true;
        }
      }
    }
    if (you != null) {
      you.discard(2, false, source, game);
      return true;
    }
    return false;
  }
}
mage.cardsCardscount

Popular methods of Cards

  • getCards
  • size
  • add
  • isEmpty
  • clear
  • getRandom
  • addAll
  • contains
  • copy
  • get
  • iterator
  • remove
  • iterator,
  • remove,
  • removeAll,
  • toArray,
  • <init>,
  • getUniqueCards,
  • getValue,
  • stream

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • orElseThrow (Optional)
  • notifyDataSetChanged (ArrayAdapter)
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • PrintWriter (java.io)
    Prints formatted representations of objects to a text-output stream. This class implements all of th
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now