congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Player.cast
Code IndexAdd Tabnine to your IDE (free)

How to use
cast
method
in
mage.players.Player

Best Java code snippets using mage.players.Player.cast (Showing top 20 results out of 315)

origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  Card target = (Card) game.getObject(source.getFirstTarget());
  if (controller != null && target != null) {
    return controller.cast(target.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Card card = (Card) game.getObject(source.getSourceId());
    if (card != null) {
      Player controller = game.getPlayer(source.getControllerId());
      if (controller != null) {
        SpellAbility spellAbility = card.getSpellAbility();
        spellAbility.clear();
        return controller.cast(spellAbility, game, true, new MageObjectReference(source.getSourceObject(game), game));
      }
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (controller == null || card == null) {
      return false;
    }
    controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
    game.addEffect(new WrexialReplacementEffect(card.getId()), source);
    return true;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null) {
      Player player = game.getPlayer(source.getControllerId());
      if (player != null && player.chooseUse(Outcome.Benefit, "Cast " + card.getName() + " without paying cost?", source, game)) {
        player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
      }
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card sourceCard = game.getCard(source.getSourceId());
    if (controller != null
        && sourceCard != null
        && Zone.GRAVEYARD == game.getState().getZone(sourceCard.getId())) {
      controller.cast(sourceCard.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());
  Card cipherCard = game.getCard(cipherCardId);
  if (cipherCard != null && controller != null) {
    Card copyCard = game.copyCard(cipherCard, source, controller.getId());
    SpellAbility ability = copyCard.getSpellAbility();
    // remove the cipher effect from the copy
    ability.getEffects().removeIf(effect -> effect instanceof CipherEffect);
    controller.cast(ability, game, true, new MageObjectReference(source.getSourceObject(game), game));
  }
  return false;
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      Card card = game.getCard(getTargetPointer().getFirst(game, source));
      if (card != null) {
        controller.cast(card.getSpellAbility(), game, false, new MageObjectReference(source.getSourceObject(game), game));
        game.addEffect(new ToshiroUmezawaReplacementEffect(card.getId()), source);
      }
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player player = game.getPlayer(targetPointer.getFirst(game, source));
  if (player != null) {
    Card card = player.getLibrary().getFromTop(game);
    if (card != null) {
      player.moveCards(card, Zone.EXILED, source, game);
      if (card.isLand()) {
        player.moveCards(card, Zone.BATTLEFIELD, source, game);
      } else {
        player.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());

    if (controller != null) {
      Card card = controller.getGraveyard().get(getTargetPointer().getFirst(game, source), game);
      if (card != null) {
        if (controller.chooseUse(outcome, "Cast " + card.getIdName() + " from your graveyard?", source, game)) {
          controller.cast(card.getSpellAbility(), game, false, 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());
    // use target pointer here, so it's the same card that triggered the event (not gone back to library e.g.)
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (controller != null && card != null) {
      SpellAbility abilityToCast = card.getSpellAbility().copy();
      ManaCosts<ManaCost> costRef = abilityToCast.getManaCostsToPay();
      // replace with the new cost
      costRef.clear();
      costRef.add(miracleCosts);
      controller.cast(abilityToCast, game, false, new MageObjectReference(source.getSourceObject(game), game));
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  ExileZone zone = game.getExile().getExileZone(source.getSourceId());
  if (zone == null || zone.isEmpty()) {
    return false;
  }
  Card reboundCard = zone.get(source.getSourceId(), game);
  Player player = game.getPlayer(source.getControllerId());
  if (player != null && reboundCard != null) {
    SpellAbility ability = reboundCard.getSpellAbility();
    player.cast(ability, game, true, new MageObjectReference(source.getSourceObject(game), game));
    zone.remove(reboundCard.getId());
    return true;
  }
  return false;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller != null) {
    Card card = controller.getLibrary().getFromTop(game);
    if (card != null) {
      controller.lookAtCards(source, null, new CardsImpl(card), game);
      if (card.isInstant() || card.isSorcery()) {
        if (controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName() + " without paying its mana cost?", source, game)) {
          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());
    if (controller != null) {
      Card card = game.getCard(getTargetPointer().getFirst(game, source));
      if (card != null) {
        if (controller.moveCards(card, Zone.EXILED, source, game)) {
          Card cardCopy = game.copyCard(card, source, source.getControllerId());
          if (cardCopy.getSpellAbility().canChooseTarget(game)
              && controller.chooseUse(outcome, "Cast copy of " + card.getName() + " without paying its mana cost?", source, game)) {
            controller.cast(cardCopy.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());
    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 player = game.getPlayer(source.getControllerId());
    if (player == null || !player.getLibrary().hasCards()) {
      return false;
    }
    Card card = player.getLibrary().getFromTop(game);
    if (card == null) {
      return false;
    }
    player.revealCards(source, new CardsImpl(card), game);
    if (card.getConvertedManaCost() % 2 == 1) {
      if (player.chooseUse(outcome, "Cast " + card.getLogName() + " without paying its mana cost?", source, game)) {
        player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
      }
    } else {
      player.drawCards(1, game);
    }
    return true;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getCardExileZoneId(game, source));
      if (controller.choose(Outcome.PlayForFree, game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)), target, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
          game.getExile().removeCard(card, game);
          return controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
        }
      }
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (controller != null && opponent != null) {
      TargetCardInLibrary target = new TargetCardInLibrary(0, 1, new FilterInstantOrSorceryCard());
      if (controller.searchLibrary(target, game, opponent.getId())) {
        Card card = opponent.getLibrary().remove(target.getFirstTarget(), game);
        if (card != null) {
          controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game));
        }
      }
      opponent.shuffleLibrary(source, game);
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (opponent != null && controller != null) {
      Cards cardsInHand = new CardsImpl();
      cardsInHand.addAll(opponent.getHand());
      if (!cardsInHand.isEmpty()) {
        TargetCard target = new TargetCard(1, Zone.HAND, new FilterNonlandCard());
        if (controller.chooseTarget(outcome, cardsInHand, 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());
    if (controller != null) {
      Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
      if (card != null) {
        if (controller.chooseUse(outcome, "Cast " + card.getLogName() + '?', source, game)) {
          if (controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game))) {
            ContinuousEffect effect = new GoblinDarkDwellersReplacementEffect(card.getId());
            effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
            game.addEffect(effect, 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) {
      FilterCard filter = new FilterCard();
      filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, source.getManaCostsToPay().getX()));
      TargetCardInExile target = new TargetCardInExile(filter, CardUtil.getCardExileZoneId(game, source));
      Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
      if (!cards.isEmpty() && controller.choose(Outcome.PlayForFree, cards, target, 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;
  }
}
mage.playersPlayercast

Popular methods of Player

  • getId
  • getHand
  • getName
  • getLife
  • getLibrary
  • hasLeft
  • hasWon
  • getCounters
  • hasLost
  • copy
  • damage
  • declareAttacker
  • damage,
  • declareAttacker,
  • getGraveyard,
  • getPlayersUnderYourControl,
  • activateAbility,
  • canLose,
  • choose,
  • declareBlocker,
  • gainLife,
  • getAttachments

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • findViewById (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • 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