{
for (int i=0; i < varAttackers.size(); i++)
{
CardSim at = varAttackers.getCard(i);
CardSimList shorter = varAttackers.copyList();
shorter.remove(at);
// add one without this attacker
EAIPlanTree leaf = new EAIPlanTree(this);
leafs.addElement(leaf);
leaf.buildAttackerLeafs(attackers, analyze, shorter, removedPossibleAttackers);
CardAndMana cam = new CardAndMana(CardAndMana.CAM_ATTACK , at, ManaCollection.NO_COST );
AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(at);
Vector<Vector> sources = createSources(cam, hints); // at least one empty target! or null -> must targets not available!
if (sources == null) { continue; }
int sourceCount = sources.size();
for (int s=0; s< sourceCount; s++)
{
Vector<EAIAction> currentSource = sources.elementAt(s);
Vector<Vector> targets = createTargets(cam, hints, currentSource); // at least one empty target! or null -> must targets not available!
// cunning giant should be in var list
if (targets == null) { break; }
int targetCount = targets.size();
for (int t=0; t< targetCount; t++)
{
Vector<EAIAction> currentTargets = targets.elementAt(t);
Vector<EAIAction> target = joinSourceAndTarget(currentSource, currentTargets);
// add one WITH this attacker
leaf = new EAIPlanTree(this);
leaf.leafExceuteOneAttackAction(at, target);
leafs.addElement(leaf);
leaf.buildAttackerLeafs(attackers, analyze, shorter, removedPossibleAttackers);
}
}
}
return;
}
EAIPlanTree leaf = new EAIPlanTree(this, false);
if (attackers.size() == 0)
{
// add branch without this one !
leafs.addElement(leaf);
// if no attackers - leave
return;
}
// smallest first
CardSimList shorten = (CardSimList) attackers.clone();
CardSimList possibleBlockers = vMatch.getBattlefield((player+1)%2).getSubListByType("Creature");
possibleBlockers = possibleBlockers.onlyTapstate(false);
CardSimList undangeredAttackers = new CardSimList();
CardSimList blockCheck = new CardSimList(shorten);
if (possibleBlockers.size() != 0)
{
CardSimList unblockablAttackers = getSubListUnblockable(shorten, possibleBlockers, player);
CardSimList undieAbleAttackers = getSubListUndieable(shorten, possibleBlockers, player);
undangeredAttackers = CardSimList.merge(unblockablAttackers, undieAbleAttackers);
shorten.removeListDirect(undangeredAttackers);
}
// search for undangered attackers, that
// should attack (no different try outs)
// since the rest of undangered attackers are
// able to do all blockings by themselfs!
//-> further todo reduce attackers to (local) top scorers
CardSimList mustAttack = undangeredAttackers.copyList();
possibleBlockers = vMatch.getBattlefield((player+1)%2).getSubListByType("Creature");
// ? possibleBlockers = assumeNoBlockers(possibleBlockers);
// returns the blocker that can be used to block
// in block check remain the blockers that are not used.
undangeredAttackers = removeBlockerTillAttackerDead(blockCheck, possibleBlockers, (player+1)%2);
for (int i=0; i< mustAttack.size(); i++)
{
CardSim at = mustAttack.getCard(i);
if (blockCheck.isInList(at))
{
leafExceuteOneAttackAction(at, null);
undangeredAttackers.remove(at);
}