/** * Lose score is lowered in function of the turn and phase when it occurs. * Encourages AI to win as fast as possible. * * @param game * @return */ @Override public int getLoseGameScore(final Game game) { if (game.getStep() == null) { return 0; } return ScoringConstants.LOSE_GAME_SCORE + game.getTurnNum() * 2500 + game.getStep().getType().getIndex() * 200; }
private void informOthers(UUID playerId) throws MageException { StringBuilder message = new StringBuilder(); if (game.getStep() != null) { message.append(game.getStep().getType().toString()).append(" - "); } message.append("Waiting for ").append(game.getPlayer(playerId).getLogName()); for (final Entry<UUID, GameSessionPlayer> entry : getGameSessionsMap().entrySet()) { if (!entry.getKey().equals(playerId)) { entry.getValue().inform(message.toString()); } } for (final GameSessionWatcher watcher : getGameSessionWatchers()) { watcher.inform(message.toString()); } }
@Override public boolean apply(Game game, Ability source) { return game.getStep().getType().isBefore(PhaseStep.DECLARE_BLOCKERS); }
@Override public boolean apply(Game game, Ability source) { return game.getStep().getType().isAfter(PhaseStep.UPKEEP); }
@Override public boolean apply(Game game, Ability source) { return game.getStep().getType().isAfter(PhaseStep.END_COMBAT); }
private void setPlayer() { if (game.getStep().getStepPart() == StepPart.PRIORITY) { playerId = game.getPriorityPlayerId(); } else { if (game.getStep().getType() == PhaseStep.DECLARE_BLOCKERS) { playerId = game.getCombat().getDefenders().iterator().next(); } else { playerId = game.getActivePlayerId(); } } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if(event.getSourceId().equals(source.getSourceId())) { if(game.getPhase().getType() == TurnPhase.COMBAT // There cannot be a legal target before declare attackers, // so in practice it is limited to these two steps. && (game.getStep().getType() == PhaseStep.DECLARE_ATTACKERS || game.getStep().getType() == PhaseStep.DECLARE_BLOCKERS)) { return false; } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { PhaseStep phaseStep = game.getStep().getType(); if(phaseStep.getIndex() < PhaseStep.END_COMBAT.getIndex()) { return true; } return false; }
@Override public boolean apply(Game game, Ability source) { PhaseStep phaseStep = game.getStep().getType(); if(phaseStep.getIndex() < PhaseStep.FIRST_COMBAT_DAMAGE.getIndex()) { return true; } return false; }
@Override public boolean isInactive(Ability source, Game game) { if (super.isInactive(source, game) && game.getStep().getType().isAfter(PhaseStep.UPKEEP)) { return true; } return false; }
@Override public boolean apply(Game game, Ability source) { return phaseStep == game.getStep().getType() && (!onlyDuringYourSteps || game.isActivePlayer(source.getControllerId())); }
@Override public ActivationStatus canActivate(UUID playerId, Game game) { // May be activated only during the upkeep step of the card's owner // Because it can only be activated from a players hand it should be ok to check here with controllerId instead of card.getOwnerId(). if (!game.isActivePlayer(controllerId) || PhaseStep.UPKEEP != game.getStep().getType()) { return ActivationStatus.getFalse(); } return super.canActivate(playerId, game); }
@Override public boolean isInactive(Ability source, Game game) { if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) { if (game.isActivePlayer(source.getControllerId())) { return true; } } return false; }
protected int simulatePostCombatMain(Game game, SimulationNode node, int alpha, int beta) { if (Thread.interrupted()) { Thread.currentThread().interrupt(); logger.debug(indent(node.depth) + "interrupted"); return GameStateEvaluator.evaluate(playerId, game); } logger.debug(indent(node.depth) + "simulating -- post combat main"); game.getTurn().setPhase(new PostCombatMainPhase()); if (game.getPhase().beginPhase(game, game.getActivePlayerId())) { game.getPhase().setStep(new PostCombatMainStep()); game.getStep().beginStep(game, playerId); game.getPlayers().resetPassed(); return addActions(node, alpha, beta); } return simulateCounterAttack(game, node, alpha, beta); }
@Override public boolean apply(Game game, Ability source) { Permanent hakimLoreweaver = game.getPermanent(source.getSourceId()); if (hakimLoreweaver != null) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(auras, game)) { if (permanent != null && hakimLoreweaver.getAttachments().contains(permanent.getId())) { return false; } } return PhaseStep.UPKEEP == game.getStep().getType() && game.isActivePlayer(source.getControllerId()); } return false; }
@Override public boolean isInactive(Ability source, Game game) { // the PRE step part is directly after the UNTAP events for permanents if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) { if (game.isActivePlayer(targetPlayerId) || game.getPlayer(source.getControllerId()).hasReachedNextTurnAfterLeaving()) { return true; } } return false; }
@Override public ActivationStatus canActivate(UUID playerId, Game game) { if (!super.hasMoreActivationsThisTurn(game) || !(condition == null || condition.apply(game, this))) { return ActivationStatus.getFalse(); } Player player = game.getPlayer(playerId); if (player != null && playerId.equals(game.getActivePlayerId()) && game.getStep().getType().isBefore(PhaseStep.END_TURN)) { if (costs.canPay(this, sourceId, playerId, game)) { this.setControllerId(playerId); return ActivationStatus.getTrue(); } } return ActivationStatus.getFalse(); }
@Override public boolean isInactive(Ability source, Game game) { if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) { if (game.isActivePlayer(source.getControllerId()) || game.getPlayer(source.getControllerId()).hasReachedNextTurnAfterLeaving()) { for (FixedTarget fixedTarget : this.detainedObjects) { Permanent permanent = game.getPermanent(fixedTarget.getFirst(game, source)); if (permanent != null) { permanent.addInfo("detain" + getId(), "", game); } } return true; } } return false; }
@Override public boolean isInactive(Ability source, Game game) { if (game.getPhase().getStep().getType() == PhaseStep.UNTAP && game.getStep().getStepPart() == Step.StepPart.PRE) { if (game.isActivePlayer(source.getControllerId()) || game.getPlayer(source.getControllerId()).hasReachedNextTurnAfterLeaving()) { for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { Permanent permanent = game.getPermanent(targetId); if (permanent != null) { permanent.addInfo("detain" + getId(), "", game); } } return true; } } return false; }