mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
- Some additional Evra logic.
This commit is contained in:
@@ -3,6 +3,7 @@ package forge.ai.ability;
|
|||||||
import forge.ai.*;
|
import forge.ai.*;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.game.keyword.Keyword;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
@@ -88,6 +89,27 @@ public class LifeExchangeVariantAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
int aiLife = ai.getLife();
|
int aiLife = ai.getLife();
|
||||||
|
|
||||||
|
// Offensive use of Evra, try to kill the opponent or deal a lot of damage, and hopefully gain a lot of life too
|
||||||
|
if (game.getCombat() != null && game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||||
|
&& game.getCombat().isAttacking(source) && source.getNetPower() > 0
|
||||||
|
&& source.getNetPower() < aiLife) {
|
||||||
|
Player def = game.getCombat().getDefenderPlayerByAttacker(source);
|
||||||
|
if (game.getCombat().isUnblocked(source) && def.canLoseLife() && aiLife >= def.getLife() && source.getNetPower() < def.getLife()) {
|
||||||
|
// Unblocked Evra which can deal lethal damage
|
||||||
|
return true;
|
||||||
|
} else if (ai.getController().isAI() && aiLife > source.getNetPower() && source.hasKeyword(Keyword.LIFELINK)) {
|
||||||
|
int dangerMin = (((PlayerControllerAi) ai.getController()).getAi().getIntProperty(AiProps.AI_IN_DANGER_THRESHOLD));
|
||||||
|
int dangerMax = (((PlayerControllerAi) ai.getController()).getAi().getIntProperty(AiProps.AI_IN_DANGER_MAX_THRESHOLD));
|
||||||
|
int dangerDiff = dangerMax - dangerMin;
|
||||||
|
int lifeInDanger = dangerDiff <= 0 ? dangerMin : MyRandom.getRandom().nextInt(dangerDiff) + dangerMin;
|
||||||
|
if (source.getNetPower() >= lifeInDanger && ComputerUtil.lifegainPositive(ai, source)) {
|
||||||
|
// Blocked or unblocked Evra which will get bigger *and* we're getting our life back through Lifelink
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Defensive use of Evra, try to debuff Evra to try to gain some life
|
||||||
if (source.getNetPower() > aiLife) {
|
if (source.getNetPower() > aiLife) {
|
||||||
if (ComputerUtilCombat.lifeInSeriousDanger(ai, game.getCombat())) {
|
if (ComputerUtilCombat.lifeInSeriousDanger(ai, game.getCombat())) {
|
||||||
return true;
|
return true;
|
||||||
@@ -103,24 +125,6 @@ public class LifeExchangeVariantAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.getCombat() != null && game.getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
|
||||||
&& game.getCombat().isAttacking(source) && source.getNetPower() > 0
|
|
||||||
&& source.getNetPower() < ai.getLife()) {
|
|
||||||
Player def = game.getCombat().getDefenderPlayerByAttacker(source);
|
|
||||||
if (game.getCombat().isUnblocked(source) && def.canLoseLife() && ai.getLife() >= def.getLife() && source.getNetPower() < def.getLife()) {
|
|
||||||
// Unblocked Evra which can deal lethal damage
|
|
||||||
return true;
|
|
||||||
} else if (ai.getLife() > source.getNetPower()) {
|
|
||||||
int dangerMin = (((PlayerControllerAi) ai.getController()).getAi().getIntProperty(AiProps.AI_IN_DANGER_THRESHOLD));
|
|
||||||
int dangerMax = (((PlayerControllerAi) ai.getController()).getAi().getIntProperty(AiProps.AI_IN_DANGER_MAX_THRESHOLD));
|
|
||||||
int dangerDiff = dangerMax - dangerMin;
|
|
||||||
int lifeInDanger = dangerDiff == 0 ? dangerMin : MyRandom.getRandom().nextInt(dangerDiff) + dangerMin;
|
|
||||||
if (source.getNetPower() >= lifeInDanger) {
|
|
||||||
// Blocked or unblocked Evra which will get bigger *and* we're getting our life back through Lifelink
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user