Search in sources :

Example 1 with CreatureSimulator

use of mage.player.ai.simulators.CreatureSimulator in project mage by magefree.

the class ComputerPlayer method selectBlockers.

@Override
public void selectBlockers(Ability source, Game game, UUID defendingPlayerId) {
    log.debug("selectBlockers");
    List<Permanent> blockers = getAvailableBlockers(game);
    CombatSimulator sim = simulateBlock(CombatSimulator.load(game), blockers, game);
    List<CombatGroup> groups = game.getCombat().getGroups();
    for (int i = 0; i < groups.size(); i++) {
        for (CreatureSimulator creature : sim.groups.get(i).blockers) {
            groups.get(i).addBlocker(creature.id, playerId, game);
        }
    }
}
Also used : Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent) CombatSimulator(mage.player.ai.simulators.CombatSimulator) CreatureSimulator(mage.player.ai.simulators.CreatureSimulator) CombatGroup(mage.game.combat.CombatGroup)

Example 2 with CreatureSimulator

use of mage.player.ai.simulators.CreatureSimulator in project mage by magefree.

the class ComputerPlayer method addBlockSimulations.

protected void addBlockSimulations(List<Permanent> blockers, TreeNode<CombatSimulator> node, Game game) {
    int numGroups = node.getData().groups.size();
    Copier<CombatSimulator> copier = new Copier<>();
    for (Permanent blocker : blockers) {
        List<Permanent> subList = remove(blockers, blocker);
        for (int i = 0; i < numGroups; i++) {
            if (node.getData().groups.get(i).canBlock(blocker, game)) {
                CombatSimulator combat = copier.copy(node.getData());
                combat.groups.get(i).blockers.add(new CreatureSimulator(blocker));
                TreeNode<CombatSimulator> child = new TreeNode<>(combat);
                node.addChild(child);
                addBlockSimulations(subList, child, game);
                combat.simulate(game);
            }
        }
    }
}
Also used : Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent) CombatSimulator(mage.player.ai.simulators.CombatSimulator) CreatureSimulator(mage.player.ai.simulators.CreatureSimulator)

Aggregations

FilterPermanent (mage.filter.FilterPermanent)2 Permanent (mage.game.permanent.Permanent)2 CombatSimulator (mage.player.ai.simulators.CombatSimulator)2 CreatureSimulator (mage.player.ai.simulators.CreatureSimulator)2 CombatGroup (mage.game.combat.CombatGroup)1