Codota Logo
Player.resetStoredBookmark
Code IndexAdd Codota to your IDE (free)

How to use
resetStoredBookmark
method
in
mage.players.Player

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      int xSum = 0;
      xSum += playerPaysXGenericMana(controller, source, game);
      for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        if (!Objects.equals(playerId, controller.getId())) {
          Player player = game.getPlayer(playerId);
          if (player != null) {
            xSum += playerPaysXGenericMana(player, source, game);

          }
        }
      }
      ContinuousEffect effect = new BoostSourceEffect(xSum, 0, Duration.EndOfTurn);
      game.addEffect(effect, source);
      // prevent undo
      controller.resetStoredBookmark(game);
      return true;
    }
    return false;
  }
}
origin: magefree/mage

@Override
public synchronized void rollbackTurns(int turnsToRollback) {
  if (gameOptions.rollbackTurnsAllowed) {
    int turnToGoTo = getTurnNum() - turnsToRollback;
    if (turnToGoTo < 1 || !gameStatesRollBack.containsKey(turnToGoTo)) {
      informPlayers(GameLog.getPlayerRequestColoredText("Player request: It's not possible to rollback " + turnsToRollback + " turn(s)"));
    } else {
      GameState restore = gameStatesRollBack.get(turnToGoTo);
      if (restore != null) {
        informPlayers(GameLog.getPlayerRequestColoredText("Player request: Rolling back to start of turn " + restore.getTurnNum()));
        state.restoreForRollBack(restore);
        playerList.setCurrent(state.getPlayerByOrderId());
        // Reset temporary created bookmarks because no longer valid after rollback
        savedStates.clear();
        gameStates.clear();
        // because restore uses the objects without copy each copy the state again
        gameStatesRollBack.put(getTurnNum(), state.copy());
        executingRollback = true;
        for (Player playerObject : getPlayers().values()) {
          if (playerObject.isHuman() && playerObject.isInGame()) {
            playerObject.resetStoredBookmark(this);
            playerObject.abort();
            playerObject.resetPlayerPassedActions();
          }
        }
        fireUpdatePlayersEvent();
      }
    }
  }
}
origin: magefree/mage

  player.resetStoredBookmark(game); // otherwise you can e.g. undo card drawn with Mentor of the Meek
} else {
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller != null) {
    int xSum = 0;
    xSum += playerPaysXGenericMana(controller, source, game);
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
      if (!Objects.equals(playerId, controller.getId())) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          xSum += playerPaysXGenericMana(player, source, game);
        }
      }
    }
    if (xSum > 0) {
      for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          player.drawCards(xSum, game);
        }
      }
    }
    // prevent undo
    controller.resetStoredBookmark(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) {
      for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter);
          if (player.searchLibrary(target, game)) {
            player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
            player.shuffleLibrary(source, game);
          }
        }
      }
      // prevent undo
      controller.resetStoredBookmark(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) {
    ManaCosts cost = new ManaCostsImpl("{X}{W}{U}{U}");
    if (controller.chooseUse(Outcome.Damage, "Pay " + cost.getText() + "? If you do, you gain X life and draw X cards.", source, game)) {
      int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
      cost.add(new GenericManaCost(costX));
      if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
        controller.resetStoredBookmark(game); // otherwise you can undo the payment
        controller.gainLife(costX, game, source);
        controller.drawCards(costX, 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) {
    int xSum = 0;
    xSum += playerPaysXGenericMana(controller, source, game);
    for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
      if (!Objects.equals(playerId, controller.getId())) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          xSum += playerPaysXGenericMana(player, source, game);
        }
      }
    }
    if (xSum > 0) {
      for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Effect effect = new PutTopCardOfLibraryIntoGraveTargetEffect(xSum);
        effect.setTargetPointer(new FixedTarget(playerId));
        effect.apply(game, source);
      }
    }
    // prevent undo
    controller.resetStoredBookmark(game);
    return true;
  }
  return false;
}
origin: magefree/mage

  protected static int playerPaysXGenericMana(Player player, Ability source, Game game) {
    int xValue = 0;
    boolean payed = false;
    while (player.canRespond() && !payed) {
      int bookmark = game.bookmarkState();
      player.resetStoredBookmark(game);
      xValue = player.announceXMana(0, Integer.MAX_VALUE, "How much mana will you pay?", game, source);
      if (xValue > 0) {
        Cost cost = new GenericManaCost(xValue);
        payed = cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
      } else {
        payed = true;
      }
      if (!payed) {
        game.restoreState(bookmark, "Collective Voyage");
        game.fireUpdatePlayersEvent();
      } else {
        game.removeBookmark(bookmark);
      }
    }
    game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
    return xValue;
  }
}
origin: magefree/mage

@Override
public boolean apply(Game game, Ability source) {
  Player controller = game.getPlayer(source.getControllerId());
  if (controller != null) {
    int xSum = 0;
    xSum += playerPaysXGenericMana(controller, source, game);
    for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
      if (!Objects.equals(playerId, controller.getId())) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          xSum += playerPaysXGenericMana(player, source, game);
        }
      }
    }
    if (xSum > 0) {
      for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum);
        effect.setTargetPointer(new FixedTarget(playerId));
        effect.apply(game, source);
      }
    }
    // prevent undo
    controller.resetStoredBookmark(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) {
      int amount = source.getManaCostsToPay().getX();
      for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null && player.chooseUse(outcome, "Search your library for up to " + amount + " basic lands?", source, game)) {
          TargetCardInLibrary target = new TargetCardInLibrary(0, amount, StaticFilters.FILTER_CARD_BASIC_LAND);
          if (player.searchLibrary(target, game)) {
            player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
            player.shuffleLibrary(source, game);
          }

        }
      }
      // prevent undo
      controller.resetStoredBookmark(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) {
      for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          TargetCardInLibrary target = new TargetCardInLibrary();
          if (player.chooseUse(Outcome.Benefit, "Search your library for a card to put into your hand?", source, game)) {
            player.searchLibrary(target, game);
            for (UUID cardId : target.getTargets()) {
              Card card = player.getLibrary().getCard(cardId, game);
              if (card != null) {
                player.moveCards(card, Zone.HAND, source, game);
              }
            }
            player.shuffleLibrary(source, game);
          }
        }
      }
      // prevent undo
      controller.resetStoredBookmark(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) {
    int xSum = 0;
    xSum += playerPaysXGenericMana(controller, source, game);
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
      if (!Objects.equals(playerId, controller.getId())) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          xSum += playerPaysXGenericMana(player, source, game);
        }
      }
    }
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
      Player player = game.getPlayer(playerId);
      if (player != null) {
        TargetCardInLibrary target = new TargetCardInLibrary(0, xSum, StaticFilters.FILTER_CARD_BASIC_LAND);
        if (player.searchLibrary(target, game)) {
          player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null);
          player.shuffleLibrary(source, game);
        }
      }
    }
    // prevent undo
    controller.resetStoredBookmark(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) {
      for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
          TargetCardInLibrary target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_BASIC_LAND);
          if (player.chooseUse(Outcome.Benefit, "Search your library for a card to put into your hand?", source, game)) {
            player.searchLibrary(target, game);
            for (UUID cardId : target.getTargets()) {
              Card card = player.getLibrary().getCard(cardId, game);
              if (card != null) {
                player.revealCards(source, new CardsImpl(card), game);
                player.moveCards(card, Zone.HAND, source, game);
              }
            }
            player.shuffleLibrary(source, game);
          }
        }
      }
      // prevent undo
      controller.resetStoredBookmark(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) {
      Player player = game.getPlayer(source.getFirstTarget());
      if (player != null) {
        FilterCard filter = new FilterCard("card named " + partnerName);
        filter.add(new NamePredicate(partnerName));
        TargetCardInLibrary target = new TargetCardInLibrary(filter);
        if (player.chooseUse(Outcome.Benefit, "Search your library for a card named " + partnerName + " and put it into your hand?", source, game)) {
          player.searchLibrary(target, game);
          for (UUID cardId : target.getTargets()) {
            Card card = player.getLibrary().getCard(cardId, game);
            if (card != null) {
              player.revealCards(source, new CardsImpl(card), game);
              player.moveCards(card, Zone.HAND, source, game);
            }
          }
          player.shuffleLibrary(source, game);
        }
      }
      // prevent undo
      controller.resetStoredBookmark(game);
      return true;
    }
    return false;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
      return false;
    }
    Cost cost = new OrCost(new ManaCostsImpl("{R}{R}"), new PayLifeCost(2), "{R}{R} or 2 life");
    if (player.chooseUse(Outcome.GainControl, "Gain control of " + sourceObject.getLogName() + "?", source, game)) {
      if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
        ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, false, player.getId());
        effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
        game.addEffect(effect, source);
        player.resetStoredBookmark(game);
      }
    }
    return true;
  }
}
origin: magefree/mage

  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
      ManaCosts cost = new ManaCostsImpl("{X}{R}");
      if (controller.chooseUse(outcome, "Pay " + cost.getText() + "? If you do, you create X 1/1 red Elemental creature tokens that are tapped and attacking.", source, game)) {
        int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
        cost.add(new GenericManaCost(costX));
        if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
          controller.resetStoredBookmark(game); // otherwise you can undo the payment
          CreateTokenEffect effect = new CreateTokenEffect(new TilonallisSummonerElementalToken(), costX, true, true);
          effect.apply(game, source);
          Effect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD)
              .setText("exile those tokens unless you have the city's blessing");
          exileEffect.setTargetPointer(new FixedTargets(new CardsImpl(effect.getLastAddedTokenIds()), game));
          game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
              Zone.ALL, exileEffect, TargetController.ANY, new InvertCondition(CitysBlessingCondition.instance)), source);
        }
      }
      return true;
    }
    return false;
  }
}
origin: magefree/mage

targetPlayer.resetStoredBookmark(game);
for (RestrictionEffect eff : game.getContinuousEffects().getRestrictionEffects()) {
  if (eff instanceof WordOfCommandCantActivateEffect) {
mage.playersPlayerresetStoredBookmark

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

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • orElseThrow (Optional)
  • requestLocationUpdates (LocationManager)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now