Tabnine Logo
Cards.count
Code IndexAdd Tabnine 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)

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 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 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());
    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

  • Making http post requests using okhttp
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • JFrame (javax.swing)
  • JList (javax.swing)
  • JPanel (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now