Tabnine Logo
Player.canLose
Code IndexAdd Tabnine to your IDE (free)

How to use
canLose
method
in
mage.players.Player

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

origin: magefree/mage

public static List<Permanent> canKillOpponent(Game game, List<Permanent> attackersList, List<Permanent> blockersList,
                       Player defender) {
  List<Permanent> blockableAttackers = new ArrayList<>(blockersList);
  List<Permanent> unblockableAttackers = new ArrayList<>();
  for (Permanent attacker : attackersList) {
    if (!canBeBlocked(game, attacker, blockersList)) {
      unblockableAttackers.add(attacker);
      blockableAttackers.remove(attacker);
    }
  }
  sortByPower(blockableAttackers, true);
  // imagine that most powerful will be blocked as 1-vs-1
  List<Permanent> attackersThatWontBeBlocked = new ArrayList<>(blockableAttackers);
  for (int i = 0; (i < blockersList.size() && i < blockableAttackers.size()); i++) {
    attackersThatWontBeBlocked.remove(blockableAttackers.get(i));
  }
  attackersThatWontBeBlocked.addAll(unblockableAttackers);
  // now count if it is possible to win the game by this attack using unblockable attackers and
  // those attackers that won't be blocked for sure (as player will block other creatures)
  if (sumDamage(attackersThatWontBeBlocked, defender) >= defender.getLife() && defender.isLifeTotalCanChange()
      && defender.canLose(game) && defender.getLife() > 0) {
    blockableAttackers.addAll(unblockableAttackers);
    return blockableAttackers;
  }
  if (sumPoisonDamage(attackersThatWontBeBlocked, defender) >= 10 - defender.getCounters().getCount(CounterType.POISON)) {
    blockableAttackers.addAll(unblockableAttackers);
    return blockableAttackers;
  }
  return emptyList;
}
origin: magefree/mage

@Override
public int doAction(final Game game) {
  oldLosingPlayer = game.getLosingPlayer();
  if (oldLosingPlayer == null && player.canLose(game)) {
    setScore(player, ArtificialScoringSystem.inst.getLoseGameScore(game));
    game.setLosingPlayer(player);
    if (!game.isSimulation())
      game.informPlayer(player, reason);
  }
  return 0;
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player targetPlayer = game.getPlayer(source.getFirstTarget());
  if (targetPlayer != null && targetPlayer.canLose(game)) {
    game.informPlayers(targetPlayer.getLogName() + " was destroyed");
    targetPlayer.lost(game); // double checks canLose, but seems more future-proof than lostForced
  }
  Permanent sourcePermanent = game.getPermanent(source.getSourceId());
  MageObject mageObject = game.getObject(source.getSourceId());
  if (sourcePermanent != null && mageObject != null) {
    if (game.getState().getValue(mageObject.getId() + "_doom") == null) {
      return false;
    }
    Integer doomNumber = 5;
    game.getState().setValue(mageObject.getId() + "_doom", doomNumber);
    ((Permanent) mageObject).addInfo("doom counter", CardUtil.addToolTipMarkTags("Doom counter at: " + doomNumber), game);
    return true;
  }
  return false;
}
mage.playersPlayercanLose

Popular methods of Player

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

Popular in Java

  • Reactive rest calls using spring rest template
  • startActivity (Activity)
  • getContentResolver (Context)
  • getSystemService (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Best IntelliJ plugins
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