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

How to use
hasWon
method
in
mage.players.Player

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

origin: magefree/mage

public boolean isWinner(UUID playerId) {
  if (game != null) {
    Player player = game.getPlayer(playerId);
    if (player != null && player.hasWon())
      return true;
  }
  return false;
}
origin: magefree/mage

  public int simulate(UUID playerId) {
//        long startTime = System.nanoTime();
    Game sim = createSimulation(game, playerId);
    sim.resume();
//        long duration = System.nanoTime() - startTime;
    int retVal = -1;  //anything other than a win is a loss
    for (Player simPlayer: sim.getPlayers().values()) {
//            logger.info(simPlayer.getName() + " calculated " + ((SimulatedPlayerMCTS)simPlayer).getActionCount() + " actions in " + duration/1000000000.0 + "s");
      if (simPlayer.getId().equals(playerId) && simPlayer.hasWon()) {
//                logger.info("AI won the simulation");
        retVal = 1;
      }
    }
    return retVal;
  }

origin: magefree/mage

if (game.checkIfGameIsOver()) {
  if (player.hasLost() 
      || opponent.hasWon()) {
    return LOSE_GAME_SCORE;
      || player.hasWon()) {
    return WIN_GAME_SCORE;
origin: magefree/mage

  clientPlayer = playerView;
  you = player;
  won = you.hasWon(); // needed to control image
if (player.hasWon()) {
  winner++;
if (you.hasWon()) {
  gameInfo = "You won the game on turn " + game.getTurnNum() + ".";
} else if (winner > 0) {
origin: magefree/mage

sb.append(player.hasWon() ? "W" : "");
sb.append(player.hasLost() ? "L" : "");
sb.append(player.hasQuit() ? "Q" : "");
origin: magefree/mage

protected UUID findWinnersAndLosers() {
  UUID winnerIdFound = null;
  for (Player player : state.getPlayers().values()) {
    if (player.hasWon()) {
      logger.debug(player.getName() + " has won gameId: " + getId());
      winnerIdFound = player.getId();
      break;
    }
    if (!player.hasLost() && !player.hasLeft()) {
      logger.debug(player.getName() + " has not lost so he won gameId: " + this.getId());
      player.won(this);
      winnerIdFound = player.getId();
      break;
    }
  }
  for (Player player : state.getPlayers().values()) {
    if (winnerIdFound != null && !player.getId().equals(winnerIdFound) && !player.hasLost()) {
      player.lost(this);
    }
  }
  return winnerIdFound;
}
origin: magefree/mage

public static int evaluate(UUID playerId, Game game, boolean ignoreTapped) {
  Player player = game.getPlayer(playerId);
  Player opponent = game.getPlayer(game.getOpponents(playerId).iterator().next());
  if (game.checkIfGameIsOver()) {
    if (player.hasLost() || opponent.hasWon()) {
      return LOSE_SCORE;
    }
    if (opponent.hasLost() || player.hasWon()) {
      return WIN_SCORE;
    }
  }
  int lifeScore = (player.getLife() - opponent.getLife()) * LIFE_FACTOR;
  int poisonScore = (opponent.getCounters().getCount(CounterType.POISON) - player.getCounters().getCount(CounterType.POISON)) * LIFE_FACTOR * 2;
  int permanentScore = 0;
  for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
    permanentScore += evaluatePermanent(permanent, game, ignoreTapped);
  }
  for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponent.getId())) {
    permanentScore -= evaluatePermanent(permanent, game, ignoreTapped);
  }
  permanentScore *= PERMANENT_FACTOR;
  int handScore = 0;
  handScore = player.getHand().size() - opponent.getHand().size();
  handScore *= HAND_FACTOR;
  int score = lifeScore + poisonScore + permanentScore + handScore;
  if (logger.isDebugEnabled()) {
    logger.debug("game state for player " + player.getName() + " evaluated to- lifeScore:" + lifeScore + " permanentScore:" + permanentScore + " handScore:" + handScore + " total:" + score);
  }
  return score;
}
origin: magefree/mage

@Override
public void endGame() {
  Game game = getGame();
  for (MatchPlayer matchPlayer : this.players) {
    Player player = game.getPlayer(matchPlayer.getPlayer().getId());
    if (player != null) {
      // get the left time from player priority timer
      if (game.getPriorityTime() > 0) {
        matchPlayer.setPriorityTimeLeft(player.getPriorityTimeLeft());
      }
      if (player.hasQuit()) {
        matchPlayer.setQuit(true);
      }
      if (player.hasWon()) {
        matchPlayer.addWin();
      }
    }
  }
  if (game.isADraw()) {
    addDraw();
  }
  checkIfMatchEnds();
  game.fireGameEndInfo();
  gamesInfo.add(createGameInfo(game));
}
origin: magefree/mage

public int evaluateState() {
  Player opponent = game.getPlayer(game.getOpponents(player.getId()).iterator().next());
  if (game.checkIfGameIsOver()) {
    if (player.hasLost() || opponent.hasWon()) {
      return Integer.MIN_VALUE;
    }
    if (opponent.hasLost() || player.hasWon()) {
      return Integer.MAX_VALUE;
    }
  }
  int value = player.getLife();
  value -= opponent.getLife();
  PermanentEvaluator evaluator = new PermanentEvaluator();
  for (Permanent permanent: game.getBattlefield().getAllActivePermanents(player.getId())) {
    value += evaluator.evaluate(permanent, game);
  }
  for (Permanent permanent: game.getBattlefield().getAllActivePermanents(player.getId())) {
    value -= evaluator.evaluate(permanent, game);
  }
  value += player.getHand().size();
  value -= opponent.getHand().size();
  return value;
}
mage.playersPlayerhasWon

Popular methods of Player

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

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSupportFragmentManager (FragmentActivity)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JPanel (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top plugins for Android Studio
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