else if (inculdeScoringInfo)
{
int playerScore = weighting.buildScore(match, player, false);
int opponentScore = weighting.buildScore(match, (player+1)%2, false);
int oldScore = playerScore - opponentScore;
Scoring score = new Scoring();
// inculdeScoringInfo
/*
Blocking analyses
-----------------
a) will die? -> decide MUST Block / no need
b) if Must block:
- decide best kill, if best kill is less expansive than attacker -> kill
- if not -> block with cheapest
c) if no need to block
- check if score of cheapest block is
- higher than damage, than block
- otherwise accept damage
*
*/
int maxAttackerCreaturs = mAttackCandidates.size();
int maxOpponentCreaturs = mBlockCandidates.getSubListByType("Creature").size();
/*
1) is it possible to kill all attackers wo any own dying -> yes? ->done
2) Kill all with least own dead -> score
3) Kill all with no dead, take damage -> score
4) Block all with least dead -> score
5) Block as much as possible with no dead, take damage -> score
6) Block has much as possible, deaths dont matter, take damage -> score
7) Kill in expansive order, take rest damage -> score
8) block in expansive order, kill in cheapest order, take damage -> score
9) take all damage -> score
*/
// 1) is it possible to kill all attackers wo any own dying -> yes? ->done
if (maxAttackerCreaturs <= maxOpponentCreaturs)
{
// only possible if more blockers than attackers
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByToughness();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
simpleFormation = new CombatFormation();
boolean canKillAll = true;
// go thru all attackers
// most tough first
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSimList blockers = getNoDeadKillers(attacker, blockerTest, 0, true, config);
if (blockers == null)
{
canKillAll = false;
break;
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
simpleFormation.singleFights.add(s);
}
if (canKillAll)
{
for (int a = 0; a < mToBeAddedAttackers.size(); a++)
{
CardSim attacker = mToBeAddedAttackers.getCard(a);
SingleFight s = SingleFight.getFight(attacker, new CardSimList(), config);
// add the new single Fight
simpleFormation.singleFights.add(s);
}
return true;
}
}
// 2) Kill all with least own dead -> score
CombatFormation killAllFormation = new CombatFormation();
killAllFormation.name = "killAllFormation";
int killAllScore = -100000;
if (maxAttackerCreaturs <= maxOpponentCreaturs)
{
// only possible if more blockers than attackers
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByToughness();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
boolean canKillAll = true;
// go thru all attackers
// most tough first
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSimList blockers = getNoDeadKillers(attacker, blockerTest, 0, true, config);
if (blockers == null)
{
blockers = getLeastDeadKillers(attacker, blockerTest, 0, true, config);
}
if (blockers == null)
{
canKillAll = false;
break;
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
killAllFormation.singleFights.add(s);
}
if (killAllFormation.singleFights.size() > 0)
{
killAllScore = difScoreFormation(killAllFormation, match, player, oldScore, weighting);
score.addScore(killAllScore, killAllFormation);
}
}
//3) Kill all with no dead, take damage -> score
CombatFormation killTakeDamageFormation = new CombatFormation();
killTakeDamageFormation.name = "killTakeDamageFormation";
int killKeepDamageScore = Integer.MIN_VALUE;
//if (maxAttackerCreaturs <= maxOpponentCreaturs)
{
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByToughness();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
boolean canKillAll = true;
// go thru all attackers
// most tough first
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSimList blockers = getNoDeadKillers(attacker, blockerTest, 0, true, config);
if (blockers == null)
{
continue;
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
killTakeDamageFormation.singleFights.add(s);
}
if (killTakeDamageFormation.singleFights.size() > 0)
{
killKeepDamageScore = difScoreFormation(killTakeDamageFormation, match, player, oldScore, weighting);
score.addScore(killKeepDamageScore, killTakeDamageFormation);
}
}
// 4) Block allpossible with No dead -> score
CombatFormation blockNoDeadAll = new CombatFormation();
blockNoDeadAll.name = "blockNoDeadAll";
int blockNoDeadAllScore = Integer.MIN_VALUE;
if (maxAttackerCreaturs <= maxOpponentCreaturs)
{
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByToughness();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
// go thru all attackers
// most tough first
boolean blockAll = true;
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSim oneBlock = hasSingleKiller( attacker, blockerTest, config);
CardSimList blockers = new CardSimList();
if (oneBlock == null)
{
oneBlock = hasSingleNoDeadBlock(attacker, blockerTest, config);
if (oneBlock == null)
{
blockAll = false;
break;
}
else
blockers.addCard(oneBlock);
}
else
{
blockers.addCard(oneBlock);
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
blockNoDeadAll.singleFights.add(s);
}
if (blockAll)
{
blockNoDeadAllScore = difScoreFormation(blockNoDeadAll, match, player, oldScore, weighting);
score.addScore(blockNoDeadAllScore, blockNoDeadAll);
}
}
// 5) Block as much as possible with no dead, take damage -> score
CombatFormation blockNoDead = new CombatFormation();
blockNoDead.name = "blockNoDead";
int blockNoDeadScore = Integer.MIN_VALUE;
{
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByToughness();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
// go thru all attackers
// most tough first
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSimList blockers = getNoDeadKillers(attacker, blockerTest, 0, true, config);
if (blockers == null)
{
CardSim oneBlock = hasSingleNoDeadBlock(attacker, blockerTest, config);
if (oneBlock == null)
continue;
blockers = new CardSimList();
blockers.addCard(oneBlock);
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
blockNoDead.singleFights.add(s);
}
if (blockNoDead.singleFights.size() > 0)
{
blockNoDeadScore = difScoreFormation(blockNoDead, match, player, oldScore, weighting);
score.addScore(blockNoDeadScore, blockNoDead);
}
}
// 6) Block has much as possible, deaths dont matter, take damage -> score
CombatFormation blockManyFormation = new CombatFormation();
blockManyFormation.name = "blockManyFormation";
int blockMany = Integer.MIN_VALUE;
{
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByToughness();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
// go thru all attackers
// most tough first
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSim oneBlock = hasSingleNoDeadKiller(attacker, blockerTest, config);
CardSimList blockers = new CardSimList();
if (oneBlock != null)
{
blockers.addCard(oneBlock);
}
else
{
oneBlock = hasSingleKiller(attacker, blockerTest, config);
if (oneBlock != null)
{
blockers.addCard(oneBlock);
}
else
{
oneBlock = hasSingleNoDeadBlock(attacker, blockerTest, config);
if (oneBlock != null)
{
blockers.addCard(oneBlock);
}
else
{
if (blockerTest.size() > 0)
{
oneBlock = blockerTest.getCard(0);
blockers.addCard(oneBlock);
}
}
}
}
if (oneBlock == null)
{
continue;
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
blockManyFormation.singleFights.add(s);
}
if (blockerTest.size() > 0)
{
// there are more blockers than attackers,
// try to kill attackers with
// left over blockers.
addToKill(blockManyFormation, blockerTest);
}
blockMany = difScoreFormation(blockManyFormation, match, player, oldScore, weighting);
score.addScore(blockMany, blockManyFormation);
}
// 7) Kill in expansive order, take rest damage -> score
CombatFormation killExpansiveFormation = new CombatFormation();
killExpansiveFormation.name = "killExpansiveFormation";
int killExpansiveScore = Integer.MIN_VALUE;
{
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByCost();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
// go thru all attackers
// most tough first
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSimList blockers = getNoDeadKillers(attacker, blockerTest, 0, true, config);
if (blockers == null)
{
blockers = getLeastDeadKillers(attacker, blockerTest, 0, true, config);
}
if (blockers == null)
{
continue;
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
killExpansiveFormation.singleFights.add(s);
}
if (killExpansiveFormation.singleFights.size() > 0)
{
killExpansiveScore = difScoreFormation(killExpansiveFormation, match, player, oldScore, weighting);
score.addScore(killExpansiveScore, killExpansiveFormation);
}
}
// 8) block in expansive order, kill in cheapest order, take damage -> score
CombatFormation blockExpansiveFormation = new CombatFormation();
blockExpansiveFormation.name = "blockExpansiveFormation";
int blockExpansiveMany = Integer.MIN_VALUE;
{
// smallest first
CardSimList attackerTest = mAttackCandidates.sortListByCost();
CardSimList blockerTest = mBlockCandidates.sortListByPower();
// go thru all attackers
// most tough first
for (int a = attackerTest.size()-1; a >=0; a--)
{
CardSim attacker = attackerTest.getCard(a);
CardSim oneBlock = hasSingleNoDeadKiller(attacker, blockerTest, config);
CardSimList blockers = new CardSimList();
if (oneBlock != null)
{
blockers.addCard(oneBlock);
}
else
{
oneBlock = hasSingleKiller(attacker, blockerTest, config);
if (oneBlock != null)
{
blockers.addCard(oneBlock);
}
else
{
oneBlock = hasSingleNoDeadBlock(attacker, blockerTest, config);
if (oneBlock != null)
{
blockers.addCard(oneBlock);
}
else
{
if (blockerTest.size() > 0)
{
oneBlock = blockerTest.getCard(0);
blockers.addCard(oneBlock);
}
}
}
}
if (oneBlock == null)
{
continue;
}
blockerTest.removeListDirect(blockers);
SingleFight s = SingleFight.getFight(attacker, blockers, config);
blockExpansiveFormation.singleFights.add(s);
}
if (blockerTest.size() > 0)
{
// there are more blockers than attackers,
// try to kill attackers with
// left over blockers.
addToKill(blockExpansiveFormation, blockerTest);
}
blockExpansiveMany = difScoreFormation(blockExpansiveFormation, match, player, oldScore, weighting);
score.addScore(blockExpansiveMany, blockExpansiveFormation);
}
// 9) take all damage -> score
CombatFormation takeAllDamageFormation = new CombatFormation();
takeAllDamageFormation.name = "takeAllDamageFormation";
int takeAllDamageScore = difScoreFormation(null, match, player, oldScore, weighting);
score.addScore(takeAllDamageScore, takeAllDamageFormation);
simpleFormation = (CombatFormation) score.getHighScoreTypeObject();
for (int a = 0; a < mToBeAddedAttackers.size(); a++)
{
CardSim attacker = mToBeAddedAttackers.getCard(a);
SingleFight s = SingleFight.getFight(attacker, new CardSimList(), config);