- Added Choice of Damnations

This commit is contained in:
swordshine
2014-03-04 04:52:31 +00:00
parent 6323462350
commit d53cc62788
6 changed files with 66 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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);

View 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);
}
}