mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Added the new AI function "hasAFogEffect".
This commit is contained in:
@@ -754,65 +754,69 @@ public class AiBlockController {
|
|||||||
// == 1. choose best blocks first ==
|
// == 1. choose best blocks first ==
|
||||||
makeGoodBlocks(combat);
|
makeGoodBlocks(combat);
|
||||||
makeGangBlocks(combat);
|
makeGangBlocks(combat);
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
|
||||||
makeTradeBlocks(combat); // choose necessary trade blocks
|
// When the AI holds some Fog effect, don't bother about lifeInDanger
|
||||||
}
|
if (!ComputerUtil.hasAFogEffect(ai)) {
|
||||||
// if life is in danger
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
makeTradeBlocks(combat); // choose necessary trade blocks
|
||||||
makeChumpBlocks(combat); // choose necessary chump blocks
|
}
|
||||||
}
|
// if life is in danger
|
||||||
// if life is still in danger
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
// Reinforce blockers blocking attackers with trample if life is still
|
makeChumpBlocks(combat); // choose necessary chump blocks
|
||||||
// in danger
|
}
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
// if life is still in danger
|
||||||
reinforceBlockersAgainstTrample(combat);
|
// Reinforce blockers blocking attackers with trample if life is still
|
||||||
}
|
// in danger
|
||||||
// Support blockers not destroying the attacker with more blockers to
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
// try to kill the attacker
|
reinforceBlockersAgainstTrample(combat);
|
||||||
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
}
|
||||||
reinforceBlockersToKill(combat);
|
// Support blockers not destroying the attacker with more blockers to
|
||||||
}
|
// try to kill the attacker
|
||||||
|
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
// == 2. If the AI life would still be in danger make a safer approach ==
|
reinforceBlockersToKill(combat);
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
}
|
||||||
lifeInDanger = true;
|
|
||||||
clearBlockers(combat, possibleBlockers); // reset every block assignment
|
// == 2. If the AI life would still be in danger make a safer approach ==
|
||||||
makeTradeBlocks(combat); // choose necessary trade blocks
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
// if life is in danger
|
lifeInDanger = true;
|
||||||
makeGoodBlocks(combat);
|
clearBlockers(combat, possibleBlockers); // reset every block assignment
|
||||||
// choose necessary chump blocks if life is still in danger
|
makeTradeBlocks(combat); // choose necessary trade blocks
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
// if life is in danger
|
||||||
makeChumpBlocks(combat);
|
makeGoodBlocks(combat);
|
||||||
}
|
// choose necessary chump blocks if life is still in danger
|
||||||
// Reinforce blockers blocking attackers with trample if life is
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
// still in danger
|
makeChumpBlocks(combat);
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
}
|
||||||
reinforceBlockersAgainstTrample(combat);
|
// Reinforce blockers blocking attackers with trample if life is
|
||||||
}
|
// still in danger
|
||||||
makeGangBlocks(combat);
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
reinforceBlockersToKill(combat);
|
reinforceBlockersAgainstTrample(combat);
|
||||||
}
|
}
|
||||||
|
makeGangBlocks(combat);
|
||||||
// == 3. If the AI life would be in serious danger make an even safer approach ==
|
reinforceBlockersToKill(combat);
|
||||||
if (lifeInDanger && ComputerUtilCombat.lifeInSeriousDanger(ai, combat)) {
|
}
|
||||||
clearBlockers(combat, possibleBlockers); // reset every block assignment
|
|
||||||
makeChumpBlocks(combat); // choose chump blocks
|
// == 3. If the AI life would be in serious danger make an even safer approach ==
|
||||||
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
if (lifeInDanger && ComputerUtilCombat.lifeInSeriousDanger(ai, combat)) {
|
||||||
makeTradeBlocks(combat); // choose necessary trade
|
clearBlockers(combat, possibleBlockers); // reset every block assignment
|
||||||
}
|
makeChumpBlocks(combat); // choose chump blocks
|
||||||
|
if (ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
makeTradeBlocks(combat); // choose necessary trade
|
||||||
makeGoodBlocks(combat);
|
}
|
||||||
}
|
|
||||||
// Reinforce blockers blocking attackers with trample if life is
|
if (!ComputerUtilCombat.lifeInDanger(ai, combat)) {
|
||||||
// still in danger
|
makeGoodBlocks(combat);
|
||||||
else {
|
}
|
||||||
reinforceBlockersAgainstTrample(combat);
|
// Reinforce blockers blocking attackers with trample if life is
|
||||||
}
|
// still in danger
|
||||||
makeGangBlocks(combat);
|
else {
|
||||||
// Support blockers not destroying the attacker with more blockers
|
reinforceBlockersAgainstTrample(combat);
|
||||||
// to try to kill the attacker
|
}
|
||||||
reinforceBlockersToKill(combat);
|
makeGangBlocks(combat);
|
||||||
|
// Support blockers not destroying the attacker with more blockers
|
||||||
|
// to try to kill the attacker
|
||||||
|
reinforceBlockersToKill(combat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assign blockers that have to block
|
// assign blockers that have to block
|
||||||
|
|||||||
@@ -999,6 +999,26 @@ public class ComputerUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasAFogEffect(final Player ai) {
|
||||||
|
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
|
||||||
|
|
||||||
|
all.addAll(ai.getCardsActivableInExternalZones(true));
|
||||||
|
all.addAll(ai.getCardsIn(ZoneType.Hand));
|
||||||
|
|
||||||
|
for (final Card c : all) {
|
||||||
|
for (final SpellAbility sa : c.getSpellAbilities()) {
|
||||||
|
if (sa.getApi() != ApiType.Fog) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!ComputerUtilCost.canPayCost(sa, ai)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static int possibleNonCombatDamage(Player ai) {
|
public static int possibleNonCombatDamage(Player ai) {
|
||||||
int damage = 0;
|
int damage = 0;
|
||||||
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
|
final CardCollection all = new CardCollection(ai.getCardsIn(ZoneType.Battlefield));
|
||||||
|
|||||||
Reference in New Issue
Block a user