mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Improved Crew AI (will now test if the defending player can actually crew the vehicle)
This commit is contained in:
@@ -123,6 +123,11 @@ public class AiAttackController {
|
||||
}
|
||||
for (SpellAbility sa : c.getSpellAbilities()) {
|
||||
if (sa.getApi() == ApiType.Animate) {
|
||||
if (sa.hasParam("Crew")) {
|
||||
if (!ComputerUtilCombat.canCrew(defender, sa)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ComputerUtilCost.canPayCost(sa, defender)
|
||||
&& sa.getRestrictions().checkOtherRestrictions(c, sa, defender)) {
|
||||
Card animatedCopy = CardFactory.copyCard(c, true);
|
||||
|
||||
@@ -45,6 +45,7 @@ import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerHandler;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.TextUtil;
|
||||
import forge.util.collect.FCollection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -2376,6 +2377,25 @@ public class ComputerUtilCombat {
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given player p can crew a vehicle with the crew spell ability crewSA.
|
||||
* @param p player to test
|
||||
* @param crewSa Crew spell ability on an artifact vehicle
|
||||
* @return true if a vehicle can be crewed at this moment, false otherwise
|
||||
*/
|
||||
public final static boolean canCrew(Player p, SpellAbility crewSa) {
|
||||
int totPower = 0;
|
||||
for (Card c : p.getZone(ZoneType.Battlefield).getCards()) {
|
||||
if (c.isCreature() && !c.isTapped()) {
|
||||
totPower += c.getCurrentPower();
|
||||
}
|
||||
}
|
||||
|
||||
int crewReq = Integer.parseInt(TextUtil.split(crewSa.getParam("CostDesc"), ' ', 3)[1]);
|
||||
|
||||
return totPower >= crewReq;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user