Random cleanup + fixes

This commit is contained in:
tool4EvEr
2022-10-20 22:49:38 +02:00
parent 4024297259
commit d6e51db755
22 changed files with 29 additions and 57 deletions

View File

@@ -768,7 +768,7 @@ public class AiController {
// Account for possible Ward after the spell is fully targeted
// TODO: ideally, this should be done while targeting, so that a different target can be preferred if the best
// one is warded and can't be paid for.
if (sa.usesTargeting() && CardFactoryUtil.isCounterable(host)) {
if (sa.usesTargeting() && (!sa.isSpell() || CardFactoryUtil.isCounterable(host))) {
for (Card tgt : sa.getTargets().getTargetCards()) {
// TODO some older cards don't use the keyword, so check for trigger instead
if (tgt.hasKeyword(Keyword.WARD) && tgt.isInPlay() && tgt.getController().isOpponentOf(host.getController())) {

View File

@@ -797,7 +797,7 @@ public class ComputerUtilCost {
if (ApiType.Counter.equals(sa.getApi())) {
List<SpellAbility> spells = AbilityUtils.getDefinedSpellAbilities(source, sa.getParamOrDefault("Defined", "Targeted"), sa);
for (SpellAbility toBeCountered : spells) {
if (!CardFactoryUtil.isCounterable(toBeCountered.getHostCard())) {
if (sa.isSpell() && !CardFactoryUtil.isCounterable(toBeCountered.getHostCard())) {
return false;
}
// TODO check hasFizzled

View File

@@ -64,7 +64,7 @@ public class CounterAi extends SpellAbilityAi {
if (sa.usesTargeting()) {
final SpellAbility topSA = ComputerUtilAbility.getTopSpellAbilityOnStack(game, sa);
if (!CardFactoryUtil.isCounterableBy(topSA.getHostCard(), sa) || topSA.getActivatingPlayer() == ai
if ((topSA.isSpell() && !CardFactoryUtil.isCounterableBy(topSA.getHostCard(), sa)) || topSA.getActivatingPlayer() == ai
|| ai.getAllies().contains(topSA.getActivatingPlayer())) {
// might as well check for player's friendliness
return false;
@@ -326,7 +326,7 @@ public class CounterAi extends SpellAbilityAi {
leastBadOption = tgtSA;
}
if (!CardFactoryUtil.isCounterableBy(tgtSA.getHostCard(), sa) ||
if ((tgtSA.isSpell() && !CardFactoryUtil.isCounterableBy(tgtSA.getHostCard(), sa)) ||
tgtSA.getActivatingPlayer() == ai ||
!tgtSA.getActivatingPlayer().isOpponentOf(ai)) {
// Is this a "better" least bad option

View File

@@ -673,7 +673,7 @@ public class DamageDealAi extends DamageAiBase {
c = dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, false);
if (c != null) {
//option to hold removal instead only applies for single targeted removal
if (sa.isSpell() && !divided && !immediately && tgt.getMaxTargets(sa.getHostCard(), sa) == 1) {
if (sa.isSpell() && !divided && !immediately && tgt.getMaxTargets(source, sa) == 1) {
if (!ComputerUtilCard.useRemovalNow(sa, c, dmg, ZoneType.Graveyard)) {
return false;
}
@@ -724,7 +724,7 @@ public class DamageDealAi extends DamageAiBase {
final Card c = dealDamageChooseTgtC(ai, sa, dmg, noPrevention, enemy, mandatory);
if (c != null) {
//option to hold removal instead only applies for single targeted removal
if (!immediately && tgt.getMaxTargets(sa.getHostCard(), sa) == 1 && !divided) {
if (!immediately && tgt.getMaxTargets(source, sa) == 1 && !divided) {
if (!ComputerUtilCard.useRemovalNow(sa, c, dmg, ZoneType.Graveyard)) {
return false;
}