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; }
@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; }
@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; }