for (int a=0; a<mAttacker.size(); a++)
{
CardSim attacker = mAttacker.getCard(a);
AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(attacker);
// should be no TARGETS, but only Auras
if (aHints.hasHint(HintAll.HINT_SITUATION_ATTACKER, HintAll.O_WHEN_COMBAT_RESOLVING))
{
doTargetCardEffect(HintAll.HINT_SITUATION_ATTACKER, attacker, null, attacker.owner);
doSourceCardEffect(HintAll.HINT_SITUATION_ATTACKER, attacker, null, attacker.owner);
}
}
for (int a=0; a<mAttacker.size(); a++)
{
// only currently known hints supported!
CardSim attacker = mAttacker.getCard(a);
AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(attacker);
CardSimList blocker = getBlocker(attacker);
String key = HintAll.HINT_SITUATION_ATTACKER;
if (blocker.size() == 0)
{
if (aHints.hasHint(key, HintOccurrence.O_WHEN_NOT_BLOCKED))
{
if (aHints.hasHint(key, HintTargetTypes.TY_HAND_TO_GRAVE))
{
int amount = aHints.getHintValueInt(key, HintTargetCount.CT_TARGET_COUNT);
if (amount == 0)
if (aHints.hasHint(key, HintTargetCount.CT_SINGLE)) amount = 1;
if (mHand[blockingPlayer].size() != 0)
{
mHand[blockingPlayer].remove(0);
}
}
if (aHints.hasHint(key, HintTargetTypes.TY_DAMAGE_AS_BLOCKED))
{
// CSA TODO Cunning Giant...
VirtualMatch vMatch = new VirtualMatch(this);
int damageToDo = attacker.getNowPower();
vMatch.getAttacker().remove(attacker);
vMatch.getAttacker().removeListDirect(attackersDone);
vMatch.doCombat(attacker.getOwner());
Object target = EAIPlanTree.getBestDamageTarget(vMatch, damageToDo, attacker.getOwner(), null);
if (target != null)
{
if (target instanceof Integer)
{
// player
// do nothing, since this is the natural course of things
}
if (target instanceof CardSim)
{
// card
CardSim t = (CardSim) target;
t = allCards.get(t.getCard().getUniqueID());
int tough = t.getNowToughness();
tough -= damageToDo;
if (tough <= 0)
tough = 0;
t.setNowToughness(tough);
combatResult.power.put(t.toUString(), t.getNowPower());
combatResult.toughness.put(t.toUString(), t.getNowToughness());
combatResult.noCache=true;
if (t.getNowToughness() == 0)
{
combatResult.blockerToRemove.addCard(t);
}
}
}
}
}
}
if (mAttacker.size() == 1)
{
if (aHints.hasHint(key, HintTargetTypes.TY_NOT_BLOCKABLE_IF_SINGLE_ATTACKER))
{
attacker.addAbility("Unblockable");
}
}
if (aHints.hasHint(key, HintTargetTypes.TY_ONE_ONLY_BLOCCK))
{
while (blocker.size() > 1)
{
CardSim toRemoveBlocker = blocker.getCard(blocker.size()-1);
blocker.remove(blocker.size()-1);
// must be done, so that combat cashing
// finds this entry...
combatResult.power.put(toRemoveBlocker.toUString(), toRemoveBlocker.getNowPower());
combatResult.toughness.put(toRemoveBlocker.toUString(), toRemoveBlocker.getNowToughness());
}
}
if (aHints.hasHint(key, HintTargetTypes.TY_ALL_BLOCK_ONE))
{
// TODO ALLURING IN DOCOMBAT
// ALLURING, 6639, P2
// All creatures able to block target creature this turn do so.
// todo
// put all blockers to test if they
// can block the attacker
// if so - switch to block it
}
SingleFight sFight = SingleFight.getFight(attacker, blocker, configTMP, false);
if (blocker.size() > 0)
{
key = HintAll.HINT_SITUATION_ATTACKER;
if (aHints.hasHint(key, HintTargetTypes.TY_DAMAGE_AS_NON_BLOCKED))
{
// other daMAGE is a approximasation!
int otherDamage = combatResult.lifeAdjustment;
for (int oa=a+1; oa<mAttacker.size();oa++)
{
CardSim at1 = mAttacker.getCard(oa);
CardSimList blo1 = getBlocker(at1);
if (blo1.size() == 0)
{
otherDamage+=at1.getNowPower();
}
}
boolean damagePlayer = EAIPlanTree.doRatherPlayerDamage(this, sFight, attacker.getOwner(), otherDamage);
sFight.attackerDamageToPlayer = damagePlayer;
}
}
sFight.simAttack(true);
for(int b=0; b<blocker.size(); b++)
{
CardSim bl = blocker.getCard(b);
if (bl.getNowToughness() == 0)
{
combatResult.blockerToRemove.addCard(bl);
}
}
if (attacker.getNowToughness() == 0)
{
combatResult.attackerToRemove.addCard(attacker);
}
combatResult.lifeAdjustment += sFight.playerDamage;
attackersDone.addCard(attacker);
}
for (int a=0; a<mAttacker.size(); a++)
{
CardSim at = mAttacker.getCard(a);
combatResult.power.put(at.toUString(), at.getNowPower());
combatResult.toughness.put(at.toUString(), at.getNowToughness());
for (int b=0; b<at.blockers.size(); b++)
{
CardSim bl = at.blockers.getCard(b);
combatResult.power.put(bl.toUString(), bl.getNowPower());
combatResult.toughness.put(bl.toUString(), bl.getNowToughness());
}
}
// noCahe means, as of yet the result is not well cacheable (e.g. Cunning Giant)
if (!combatResult.noCache)
mCombatMap.put(combatKey, combatResult);
cacheNotHit++;
}
else
{
for (int a=0; a<mAttacker.size(); a++)
{
CardSim at = mAttacker.getCard(a);
at.setNowPower(combatResult.power.get(at.toUString()));
at.setNowToughness(combatResult.toughness.get(at.toUString()));
for (int b=0; b<at.blockers.size(); b++)
{
CardSim bl = at.blockers.getCard(b);
bl.setNowPower(combatResult.power.get(bl.toUString()));
bl.setNowToughness(combatResult.toughness.get(bl.toUString()));
}
AIEnhancedCardHints aHints = AIEnhancedCardHints.getHints(at);
// e.g. hunting cheetah
if (at.blockers.size() == 0)
{
if (aHints.hasHint(HintAll.HINT_SITUATION_ATTACKER, HintDefinition.O_WHEN_PLAYER_DAMAGE_DEALT))
{
if (combatResult.power.get(at.toUString()) >0)
{