mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Further work on experimental attack/block trade feature (disabled by default).
This commit is contained in:
@@ -590,10 +590,12 @@ public class AiAttackController {
|
||||
|
||||
boolean playAggro = false;
|
||||
int chanceToAttackToTrade = 0;
|
||||
boolean tradeIfTappedOut = false;
|
||||
if (ai.getController().isAI()) {
|
||||
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
|
||||
playAggro = aic.getBooleanProperty(AiProps.PLAY_AGGRO);
|
||||
chanceToAttackToTrade = aic.getIntProperty(AiProps.CHANCE_TO_ATTACK_INTO_TRADE);
|
||||
tradeIfTappedOut = aic.getBooleanProperty(AiProps.ATTACK_INTO_TRADE_WHEN_TAPPED_OUT);
|
||||
}
|
||||
final boolean bAssault = this.doAssault(ai);
|
||||
// TODO: detect Lightmine Field by presence of a card with a specific trigger
|
||||
@@ -921,7 +923,8 @@ public class AiAttackController {
|
||||
} else if (MyRandom.percentTrue(chanceToAttackToTrade) && humanLifeToDamageRatio > 1
|
||||
&& defendingOpponent != null
|
||||
&& ComputerUtil.countUsefulCreatures(ai) > ComputerUtil.countUsefulCreatures(defendingOpponent)
|
||||
&& ai.getLife() > defendingOpponent.getLife()) {
|
||||
&& ai.getLife() > defendingOpponent.getLife()
|
||||
&& (ComputerUtilMana.getAvailableManaEstimate(ai) > 0) || tradeIfTappedOut) {
|
||||
this.aiAggression = 4; // random (chance-based) attack expecting to trade or damage player.
|
||||
} else if (ratioDiff >= 0 && this.attackers.size() > 1) {
|
||||
this.aiAggression = 3; // attack expecting to make good trades or damage player.
|
||||
|
||||
@@ -548,7 +548,7 @@ public class AiBlockController {
|
||||
if (ai.getController().isAI()) {
|
||||
AiController aic = ((PlayerControllerAi) ai.getController()).getAi();
|
||||
enableRandomTrades = aic.getBooleanProperty(AiProps.ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK);
|
||||
randomTradeIfBehindOnBoard = aic.getBooleanProperty(AiProps.RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS);
|
||||
randomTradeIfBehindOnBoard = aic.getBooleanProperty(AiProps.RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS);
|
||||
minRandomTradeChance = aic.getIntProperty(AiProps.MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK);
|
||||
maxRandomTradeChance = aic.getIntProperty(AiProps.MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK);
|
||||
}
|
||||
@@ -575,10 +575,10 @@ public class AiBlockController {
|
||||
// Always trade when life in danger
|
||||
doTrade = true;
|
||||
} else if (enableRandomTrades) {
|
||||
// Randomly trade creatures with lower power and [hopefully] worse abilities
|
||||
// Randomly trade creatures with lower power and [hopefully] worse abilities, if enabled in profile
|
||||
int numSteps = ai.getStartingLife() - 5; // e.g. 15 steps between 5 life and 20 life
|
||||
float chanceStep = (maxRandomTradeChance - minRandomTradeChance) / numSteps;
|
||||
int chance = (int)Math.max(minRandomTradeChance, (maxRandomTradeChance - (Math.abs(5 - ai.getLife()) * chanceStep)));
|
||||
int chance = (int)Math.max(minRandomTradeChance, (maxRandomTradeChance - (Math.max(5, ai.getLife() - 5)) * chanceStep));
|
||||
if (chance > maxRandomTradeChance) {
|
||||
chance = maxRandomTradeChance;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ public enum AiProps { /** */
|
||||
RESERVE_MANA_FOR_MAIN2_CHANCE ("0"), /** */
|
||||
PLAY_AGGRO ("false"),
|
||||
CHANCE_TO_ATTACK_INTO_TRADE ("100"), /** */
|
||||
ATTACK_INTO_TRADE_WHEN_TAPPED_OUT ("false"), /** */
|
||||
ENABLE_RANDOM_FAVORABLE_TRADES_ON_BLOCK ("false"), /** */
|
||||
RANDOMLY_TRADE_EVEN_IF_HAS_LESS_CREATS ("false"), /** */
|
||||
RANDOMLY_TRADE_EVEN_WHEN_HAVE_LESS_CREATS ("false"), /** */
|
||||
MIN_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK ("20"), /** */
|
||||
MAX_CHANCE_TO_RANDOMLY_TRADE_ON_BLOCK ("100"), /** */
|
||||
MIN_SPELL_CMC_TO_COUNTER ("0"),
|
||||
|
||||
Reference in New Issue
Block a user