mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- Added three bid life cards
This commit is contained in:
@@ -922,6 +922,22 @@ public class AiController {
|
||||
return SpellApiToAi.Converter.get(api).confirmAction(player, sa, mode, message);
|
||||
}
|
||||
|
||||
public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode mode, String message,
|
||||
int bid, Player winner) {
|
||||
if (mode != null) switch (mode) {
|
||||
case BidLife:
|
||||
if (sa.hasParam("AIBidMax")) {
|
||||
return !player.equals(winner) && bid < Integer.parseInt(sa.getParam("AIBidMax")) && player.getLife() > bid + 5;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) {
|
||||
if (logic.equalsIgnoreCase("ProtectFriendly")) {
|
||||
final Player controller = hostCard.getController();
|
||||
|
||||
@@ -122,6 +122,8 @@ public class PlayerControllerAi extends PlayerController {
|
||||
switch (ability.getApi()) {
|
||||
case ChooseNumber:
|
||||
return ability.getActivatingPlayer().isOpponentOf(player) ? 0 : ComputerUtilMana.determineLeftoverMana(ability, player);
|
||||
case BidLife:
|
||||
return 0;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -166,6 +168,12 @@ public class PlayerControllerAi extends PlayerController {
|
||||
public boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
return getAi().confirmAction(sa, mode, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode mode, String string,
|
||||
int bid, Player winner) {
|
||||
return getAi().confirmBidAction(sa, mode, string, bid, winner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean confirmStaticApplication(Card hostCard, GameEntity affected, String logic, String message) {
|
||||
|
||||
@@ -22,6 +22,7 @@ public enum SpellApiToAi {
|
||||
apiToClass.put(ApiType.Attach, AttachAi.class);
|
||||
apiToClass.put(ApiType.Balance, BalanceAi.class);
|
||||
apiToClass.put(ApiType.BecomesBlocked, BecomesBlockedAi.class);
|
||||
apiToClass.put(ApiType.BidLife, BidLifeAi.class);
|
||||
apiToClass.put(ApiType.Bond, BondAi.class);
|
||||
apiToClass.put(ApiType.ChangeTargets, ChangeTargetsAi.class);
|
||||
apiToClass.put(ApiType.ChangeZone, ChangeZoneAi.class);
|
||||
|
||||
53
forge-ai/src/main/java/forge/ai/ability/BidLifeAi.java
Normal file
53
forge-ai/src/main/java/forge/ai/ability/BidLifeAi.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.ai.ComputerUtilCard;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.MyRandom;
|
||||
|
||||
public class BidLifeAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (tgt.canTgtCreature()) {
|
||||
List<Card> list = CardLists.getTargetableCards(aiPlayer.getOpponent().getCardsIn(ZoneType.Battlefield), sa);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source);
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Card c = ComputerUtilCard.getBestCreatureAI(list);
|
||||
sa.getTargets().add(c);
|
||||
} else if (tgt.getZone().contains(ZoneType.Stack)) {
|
||||
if (game.getStack().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final SpellAbility topSA = game.getStack().peekAbility();
|
||||
if (!CardFactoryUtil.isCounterableBy(topSA.getHostCard(), sa) || aiPlayer.equals(topSA.getActivatingPlayer())) {
|
||||
return false;
|
||||
}
|
||||
if (sa.canTargetSpellAbility(topSA)) {
|
||||
sa.getTargets().add(topSA);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean chance = MyRandom.getRandom().nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
return chance;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user