mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Some further work on the experimental attack/block trading options (disabled by default in all profiles except Experimental).
This commit is contained in:
@@ -916,10 +916,12 @@ public class AiAttackController {
|
||||
if (ratioDiff > 0 && doAttritionalAttack) {
|
||||
this.aiAggression = 5; // attack at all costs
|
||||
} else if ((ratioDiff >= 1 && this.attackers.size() > 1 && (humanLifeToDamageRatio < 2 || outNumber > 0))
|
||||
|| (playAggro && humanLifeToDamageRatio > 1)) {
|
||||
|| (playAggro && MyRandom.percentTrue(chanceToAttackToTrade) && humanLifeToDamageRatio > 1)) {
|
||||
this.aiAggression = 4; // attack expecting to trade or damage player.
|
||||
} else if (MyRandom.percentTrue(chanceToAttackToTrade) && humanLifeToDamageRatio > 1
|
||||
&& ComputerUtil.countUsefulCreatures(ai) > ComputerUtil.countUsefulCreatures(defendingOpponent)) {
|
||||
&& defendingOpponent != null
|
||||
&& ComputerUtil.countUsefulCreatures(ai) > ComputerUtil.countUsefulCreatures(defendingOpponent)
|
||||
&& ai.getLife() > defendingOpponent.getLife()) {
|
||||
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.
|
||||
|
||||
@@ -575,9 +575,10 @@ public class AiBlockController {
|
||||
// Always trade when life in danger
|
||||
doTrade = true;
|
||||
} else if (enableRandomTrades) {
|
||||
// Randomly trade creatures with lower power and worse abilities
|
||||
float chanceStep = (100 - minRandomTradeChance) / 15; // 15 steps between 5 life and 20+ life
|
||||
int chance = (int)Math.max(minRandomTradeChance, (100 - (Math.abs(5 - ai.getLife()) * chanceStep)));
|
||||
// Randomly trade creatures with lower power and [hopefully] worse abilities
|
||||
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)));
|
||||
if (chance > maxRandomTradeChance) {
|
||||
chance = maxRandomTradeChance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user