congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Cards.getRandom
Code IndexAdd Tabnine to your IDE (free)

How to use
getRandom
method
in
mage.cards.Cards

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

origin: magefree/mage

@Override
public Card discardOne(boolean random, Ability source, Game game) {
  Cards cards = discard(1, random, source, game);
  if (cards.isEmpty()) {
    return null;
  }
  return cards.getRandom(game);
}
origin: magefree/mage

@Override
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
  if (cards.isEmpty()) {
    return !target.isRequired(source);
  }
  Card card = cards.getRandom(game);
  if (card != null) {
    target.addTarget(card.getId(), source, game);
    return true;
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
      player.drawCards(1, game);
      Card card = player.getHand().getRandom(game);
      if (card != null) {
        player.discard(card, source, game);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
      player.drawCards(2, game);
      Cards hand = player.getHand();
      Card card = hand.getRandom(game);
      if (card != null) {
        player.discard(card, source, game);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player player = game.getPlayer(targetPointer.getFirst(game, source));
  if (player != null && !player.getHand().isEmpty()) {
    Cards revealed = new CardsImpl();
    revealed.add(player.getHand().getRandom(game));
    player.revealCards("Merfolk Spy", revealed, game);
    return true;
  }
  return false;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player player = game.getPlayer(targetPointer.getFirst(game, source));
  if (player != null && !player.getHand().isEmpty()) {
    Cards revealed = new CardsImpl();
    revealed.add(player.getHand().getRandom(game));
    player.revealCards("Hired Torturer", revealed, game);
    return true;
  }
  return false;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  boolean result = false;
  Player player = game.getPlayer(source.getControllerId());
  if (player != null) {
    if (randomDiscard) {
      int maxAmount = Math.min(amount.calculate(game, source, this), player.getHand().size());
      for (int i = 0; i < maxAmount; i++) {
        Card card = player.getHand().getRandom(game);
        if (card != null) {
          result |= player.discard(card, source, game);
        }
      }
    } else {
      player.discard(amount.calculate(game, source, this), false, source, game);
      result = true;
    }
  }
  return result;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null) {
      ExileZone exZone = game.getExile().getExileZone(source.getSourceId());
      if (exZone != null) {
        Cards exiledCards = new CardsImpl(exZone.getCards(game));
        return player.moveCards(exiledCards.getRandom(game), Zone.BATTLEFIELD, source, game);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player you = game.getPlayer(source.getControllerId());
  if (you != null) {
    you.discard(you.getHand().size(), false, source, game);
    you.drawCards(7, game);
    Cards hand = you.getHand();
    for (int i = 0; i < 3; i++) {
      Card card = hand.getRandom(game);
      if (card != null) {
        you.discard(card, source, game);
      }
    }
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer != null && !targetPlayer.getHand().isEmpty()) {
      Cards revealed = new CardsImpl();
      Card card = targetPlayer.getHand().getRandom(game);
      if (card != null) {
        revealed.add(card);
        targetPlayer.revealCards("Singe-Mind Ogre", revealed, game);
        targetPlayer.loseLife(card.getConvertedManaCost(), game, false);
        return true;
      }
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
  if (opponent != null && !opponent.getHand().isEmpty()) {
    Cards revealed = new CardsImpl();
    Card card = opponent.getHand().getRandom(game);
    if (card != null) {
      revealed.add(card);
      opponent.revealCards("Planeswalker's Fury", revealed, game);
      opponent.damage(card.getConvertedManaCost(), source.getSourceId(), game, false, true);
    }
    return true;
  }
  return false;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  MageObject sourceObject = game.getObject(source.getSourceId());
  if (controller != null && sourceObject != null) {
    if (!controller.getHand().isEmpty()) {
      CardsImpl randomCard = new CardsImpl();
      Card card = controller.getHand().getRandom(game);
      randomCard.add(card);
      controller.revealCards(sourceObject.getIdName(), randomCard, game);
    }
    return true;
  }
  return false;
}

origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
      Cards cards = player.getGraveyard();
      for (int i = 0; i < 2 && !cards.isEmpty(); i++) {
        Card card = cards.getRandom(game);
        if (card != null) {
          card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
          cards.remove(card);
          game.informPlayers(card.getName() + " returned to the hand of " + player.getLogName());
        } else {
          return false;
        }
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  private Card pickCard(Game game, Player player, Cards cards, String message) {
    if (cards.isEmpty()) {
      return null;
    }
    if (cards.size() == 1) {
      Card card = cards.getRandom(game);
      cards.remove(card);
      return card;
    }

    TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard(message));
    if (player.choose(Outcome.Benefit, cards, target, game)) {
      Card card = cards.get(target.getFirstTarget(), game);
      if (card != null) {
        cards.remove(card);
        return card;
      }
    }

    return null;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
  Player player = game.getPlayer(source.getControllerId());
  if (opponent != null && player!= null && !opponent.getHand().isEmpty()) {
    Cards revealed = new CardsImpl();
    Card card = opponent.getHand().getRandom(game);
    if (card != null) {
      revealed.add(card);
      opponent.revealCards("Planeswalker's Mirth", revealed, game);
      player.gainLife(card.getConvertedManaCost(), game, source);
    }
    return true;
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetOpponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (controller != null && targetOpponent != null) {
      Cards creatureCards = new CardsImpl();
      for (Card card : targetOpponent.getGraveyard().getCards(new FilterCreatureCard(), game)) {
        creatureCards.add(card);
      }
      if (!creatureCards.isEmpty()) {
        Card card = creatureCards.getRandom(game);
        controller.moveCards(card, Zone.BATTLEFIELD, source, game);
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player you = game.getPlayer(source.getControllerId());
  Player targetPlayer = game.getPlayer(source.getFirstTarget());
  MageObject sourceObject = game.getObject(source.getSourceId());
  if (you != null && targetPlayer != null && sourceObject != null) {
    if(!targetPlayer.getHand().isEmpty())
    {
      Cards randomCard = new CardsImpl();
      Card card = targetPlayer.getHand().getRandom(game);
      randomCard.add(card);
      you.lookAtCards(sourceObject.getName(), randomCard, game);
    }
    return true;
  }
  return false;
}

origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(targetPointer.getFirst(game, source));
  MageObject sourceObject = source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    if (!controller.getHand().isEmpty()) {
      Cards revealed = new CardsImpl();
      Card card = controller.getHand().getRandom(game);
      if (card != null) {
        revealed.add(card);
        controller.revealCards(sourceObject.getIdName(), revealed, game);
        controller.damage(card.getConvertedManaCost(), source.getSourceId(), game, false, true);
        return true;
      }
      return false;
    }
    return true;
  }
  return false;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player opponent = game.getPlayer(source.getTargets().get(0).getFirstTarget());
  if (opponent != null && !opponent.getHand().isEmpty()) {
    Cards revealed = new CardsImpl();
    Card card = opponent.getHand().getRandom(game);
    if (card != null) {
      revealed.add(card);
      int boostValue = -1 * card.getConvertedManaCost();
      opponent.revealCards("Planeswalker's Scorn", revealed, game);
      ContinuousEffect effect = new BoostTargetEffect(boostValue, boostValue, Duration.EndOfTurn);
      effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget()));
      game.addEffect(effect, source);
    }
    return true;
  }
  return false;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player opponent = game.getPlayer(source.getTargets().get(0).getFirstTarget());
  if (opponent != null && !opponent.getHand().isEmpty()) {
    Cards revealed = new CardsImpl();
    Card card = opponent.getHand().getRandom(game);
    if (card != null) {
      revealed.add(card);
      int boostValue = card.getConvertedManaCost();
      opponent.revealCards("Planeswalker's Favor", revealed, game);
      ContinuousEffect effect = new BoostTargetEffect(boostValue, boostValue, Duration.EndOfTurn);
      effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget()));
      game.addEffect(effect, source);
    }
    return true;
  }
  return false;
}
mage.cardsCardsgetRandom

Popular methods of Cards

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

Popular in Java

  • Finding current android device location
  • getApplicationContext (Context)
  • runOnUiThread (Activity)
  • getSystemService (Context)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JLabel (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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