mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Added Choice of Damnations
This commit is contained in:
@@ -1276,8 +1276,7 @@ public class AiController {
|
||||
}
|
||||
|
||||
public int chooseNumber(SpellAbility sa, String title, int min, int max) {
|
||||
//TODO: AILogic
|
||||
final String logic = sa.getParam("AILogic");
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if ("GainLife".equals(logic)) {
|
||||
if (player.getLife() < 5 || player.getCardsIn(ZoneType.Hand).size() >= player.getMaxHandSize()) {
|
||||
return min;
|
||||
@@ -1287,12 +1286,17 @@ public class AiController {
|
||||
return min;
|
||||
}
|
||||
else if ("DigACard".equals(logic)) {
|
||||
int random = MyRandom.getRandom().nextInt(Math.min(4, max)) + 1;
|
||||
if (player.getLife() < random + 5) {
|
||||
return min;
|
||||
} else {
|
||||
return random;
|
||||
}
|
||||
int random = MyRandom.getRandom().nextInt(Math.min(4, max)) + 1;
|
||||
if (player.getLife() < random + 5) {
|
||||
return min;
|
||||
} else {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
else if ("Damnation".equals(logic)) {
|
||||
int chosenMax = player.getLife() - 1;
|
||||
int cardsInPlay = player.getCardsIn(ZoneType.Battlefield).size();
|
||||
return Math.min(chosenMax, cardsInPlay);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum SpellApiToAi {
|
||||
apiToClass.put(ApiType.Charm, CharmAi.class);
|
||||
apiToClass.put(ApiType.ChooseCard, ChooseCardAi.class);
|
||||
apiToClass.put(ApiType.ChooseColor, ChooseColorAi.class);
|
||||
apiToClass.put(ApiType.ChooseNumber, CannotPlayAi.class);
|
||||
apiToClass.put(ApiType.ChooseNumber, ChooseNumberAi.class);
|
||||
apiToClass.put(ApiType.ChoosePlayer, ChoosePlayerAi.class);
|
||||
apiToClass.put(ApiType.ChooseSource, ChooseSourceAi.class);
|
||||
apiToClass.put(ApiType.ChooseType, ChooseTypeAi.class);
|
||||
|
||||
34
forge-ai/src/main/java/forge/ai/ability/ChooseNumberAi.java
Normal file
34
forge-ai/src/main/java/forge/ai/ability/ChooseNumberAi.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class ChooseNumberAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
if (!sa.hasParam("AILogic")) {
|
||||
return false;
|
||||
}
|
||||
TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (sa.canTarget(aiPlayer.getOpponent())) {
|
||||
sa.getTargets().add(aiPlayer.getOpponent());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean chance = MyRandom.getRandom().nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
return chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
return mandatory || canPlayAI(ai, sa);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user