aiPlayer.setObjectData(dblockerKey+"BLOCKER_LIST", myCreatures);
blockerList = myCreatures;
}
int state = aiPlayer.getIntData(dblockerKey+"STATE");
CombatFormation blockerFormation;
if (state == 0)
{
int loop = aiPlayer.getIntData(dblockerKey+"TLOOP");
E.D.addLog("EAI: state 0 enter, tapper size = "+ tapperList.size()+", loop = "+ loop,debugLevel);
while ((loop < tapperList.size()) && (state == 0))
{
loop = aiPlayer.getIntData(dblockerKey+"TLOOP");
boolean tappingDone = false;
if (tapperList.size() != 0)
{
E.D.addLog("EAI: tapper found enter: " +tapperList.size(),debugLevel);
E.D.addLog("EAI: tapper loop: " + loop,debugLevel);
Card card = tapperList.getCard(loop);
E.D.addLog("EAI: current tapper: " + card,debugLevel);
boolean sense = AIHelper.tapHintMakesSenseNow(E.player, E.match, card);
if ((!card.isTapped()) && (sense))
{
E.D.addLog("EAI: tapping in blocking possible: "+card,debugLevel);
boolean doTap=true;
if (AIHelper.hasHint(card, "OPPONENT_ATTACKER_NEED"))
{
doTap = E.match.getAttackerList().size()>0;
}
if (doTap)
{
E.D.addLog("EAI: tapping!: "+card,debugLevel);
E.match.playAbility(E.player, card);
tappingDone = true;
}
else
{
E.D.addLog("EAI: not tapping!: "+card,debugLevel);
}
}
}
loop++;
if (loop >= tapperList.size())
{
loop = 0;
aiPlayer.setIntData(dblockerKey+"TLOOP", 0);
state++;
aiPlayer.setIntData(dblockerKey+"STATE", state);
if ((tapperList.size() > 0) && (tappingDone))
{
E.D.addLog("EAI: Todo one tap - than come back to block " + loop,debugLevel);
return false;
}
}
if (loop != 0)
{
E.D.addLog("EAI: Todo one tap - than come back to tap more " + loop,debugLevel);
aiPlayer.setIntData(dblockerKey+"TLOOP", loop);
if (tappingDone)
{
E.D.addLog("EAI: Tapping was done! " ,debugLevel);
return false;
}
}
}
E.D.addLog("EAI: state 0 ends (state = "+state+")",debugLevel);
state = 1;
aiPlayer.setIntData(dblockerKey+"STATE", state);
}
// init declaration
if (state == 1)
{
state++;
aiPlayer.setIntData(dblockerKey+"STATE", state);
int mood = aiPlayer.mStrategie.getMood();
int intelligence = aiPlayer.mStrategie.getIntelligence();
int majorMood = mood/3;
if (majorMood>2) majorMood = 2;
int minorMood = mood - (majorMood*3);
if (majorMood==0)
{
// defense
blockerFormation = AIHelper.getDefensiveBlocker(
blockerList,
E.match.getAttackerList(),
E.match.getLand(E.player),
E.match.getLand(E.opponent) , minorMood, intelligence);
}
else if (majorMood==1)
{
// equal
blockerFormation = AIHelper.getMediumBlocker(
blockerList,
E.match.getAttackerList(),
E.match.getLand(E.player),
E.match.getLand(E.opponent) , minorMood, intelligence);
}
else // 2
{
// offense
blockerFormation = AIHelper.getAgressiveBlocker(
blockerList,
E.match.getAttackerList(),
E.match.getLand(E.player),
E.match.getLand(E.opponent) , minorMood, intelligence);
}
aiPlayer.setObjectData(dblockerKey+"BlockerFormation", blockerFormation);
E.D.addLog("EAI: Block formation: "+blockerFormation ,debugLevel);
}
// blocker declaration
if (state == 2)
{
blockerFormation = (CombatFormation) aiPlayer.getObjectData(dblockerKey+"BlockerFormation");
int loopAttacker = aiPlayer.getIntData(dblockerKey+"ATTACKER_LOOP");
int loopBlocker = aiPlayer.getIntData(dblockerKey+"BLOCKER_LOOP");
while (loopAttacker < blockerFormation.getFormation().size())
{
E.D.addLog("EAI: entering loop, A counter = "+loopAttacker+" from "+(blockerFormation.getFormation().size()+1) ,debugLevel);
E.D.addLog("EAI: B counter = "+loopBlocker+" from "+(blockerFormation.getFormation().elementAt(loopAttacker).blocker.size()+1) ,debugLevel);
SingleFight sFight = blockerFormation.getFormation().elementAt(loopAttacker);
E.D.addLog("EAI: SingleFight: "+sFight ,debugLevel);
CardList blockers = sFight.blocker;
Card attacker = sFight.attacker;
while (loopBlocker < blockers.size())