mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Some clean up fix
This commit is contained in:
@@ -987,10 +987,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
}
|
||||
final String logic = sa.getParam("AILogic");
|
||||
if (logic == null || logic.equals("MostProminentHumanCreatures")) {
|
||||
CardCollection list = new CardCollection();
|
||||
for (Player opp : player.getOpponents()) {
|
||||
list.addAll(opp.getCreaturesInPlay());
|
||||
}
|
||||
CardCollection list = player.getOpponents().getCreaturesInPlay();
|
||||
if (list.isEmpty()) {
|
||||
list = CardLists.filterControlledBy(getGame().getCardsInGame(), player.getOpponents());
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
return true;
|
||||
} else {
|
||||
// search targetable Opponents
|
||||
final PlayerCollection oppList = new PlayerCollection(Iterables.filter(ai.getOpponents(), PlayerPredicates.isTargetableBy(sa)));
|
||||
final PlayerCollection oppList = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
|
||||
if (oppList.isEmpty()) {
|
||||
return false;
|
||||
@@ -162,8 +162,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
// if human creatures are more valuable
|
||||
if (sa.usesTargeting()) {
|
||||
// search targetable Opponents
|
||||
final PlayerCollection oppList = new PlayerCollection(Iterables.filter(ai.getOpponents(),
|
||||
PlayerPredicates.isTargetableBy(sa)));
|
||||
final PlayerCollection oppList = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
|
||||
if (oppList.isEmpty()) {
|
||||
return false;
|
||||
@@ -386,8 +385,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
if (origin.equals(ZoneType.Hand) || origin.equals(ZoneType.Library)) {
|
||||
if (sa.usesTargeting()) {
|
||||
// search targetable Opponents
|
||||
final PlayerCollection oppList = new PlayerCollection(Iterables.filter(ai.getOpponents(),
|
||||
PlayerPredicates.isTargetableBy(sa)));
|
||||
final PlayerCollection oppList = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
|
||||
if (oppList.isEmpty()) {
|
||||
if (mandatory && !sa.isTargetNumberValid() && sa.canTarget(ai)) {
|
||||
@@ -432,8 +430,7 @@ public class ChangeZoneAllAi extends SpellAbilityAi {
|
||||
} else if (origin.equals(ZoneType.Graveyard)) {
|
||||
if (sa.usesTargeting()) {
|
||||
// search targetable Opponents
|
||||
final PlayerCollection oppList = new PlayerCollection(Iterables.filter(ai.getOpponents(),
|
||||
PlayerPredicates.isTargetableBy(sa)));
|
||||
final PlayerCollection oppList = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
|
||||
if (oppList.isEmpty()) {
|
||||
if (mandatory && !sa.isTargetNumberValid() && sa.canTarget(ai)) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.Map;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.ai.AiAttackController;
|
||||
import forge.ai.ComputerUtilAbility;
|
||||
@@ -42,8 +41,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
if (sa.usesTargeting()) {
|
||||
sa.resetTargets();
|
||||
// search targetable Opponents
|
||||
final List<Player> oppList = Lists.newArrayList(Iterables.filter(
|
||||
ai.getOpponents(), PlayerPredicates.isTargetableBy(sa)));
|
||||
final List<Player> oppList = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
|
||||
if (oppList.isEmpty()) {
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.Set;
|
||||
import com.google.common.base.Predicates;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import forge.ai.AiCardMemory;
|
||||
import forge.ai.ComputerUtilAbility;
|
||||
import forge.ai.ComputerUtilCard;
|
||||
@@ -111,10 +110,8 @@ public class ChooseTypeAi extends SpellAbilityAi {
|
||||
boolean isCurse = sa.isCurse();
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
final List<Player> oppList = Lists.newArrayList(Iterables.filter(
|
||||
ai.getOpponents(), PlayerPredicates.isTargetableBy(sa)));
|
||||
final List<Player> alliesList = Lists.newArrayList(Iterables.filter(
|
||||
ai.getAllies(), PlayerPredicates.isTargetableBy(sa)));
|
||||
final List<Player> oppList = ai.getOpponents().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
final List<Player> alliesList = ai.getAllies().filter(PlayerPredicates.isTargetableBy(sa));
|
||||
|
||||
sa.resetTargets();
|
||||
|
||||
|
||||
@@ -146,13 +146,12 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
String s = aiAtk.toProtectAttacker(sa);
|
||||
if (s == null) {
|
||||
return false;
|
||||
} else {
|
||||
Player opponent = ai.getWeakestOpponent();
|
||||
Combat combat = ai.getGame().getCombat();
|
||||
int dmg = ComputerUtilCombat.damageIfUnblocked(c, opponent, combat, true);
|
||||
float ratio = 1.0f * dmg / opponent.getLife();
|
||||
return MyRandom.getRandom().nextFloat() < ratio;
|
||||
}
|
||||
Player opponent = ai.getWeakestOpponent();
|
||||
Combat combat = ai.getGame().getCombat();
|
||||
int dmg = ComputerUtilCombat.damageIfUnblocked(c, opponent, combat, true);
|
||||
float ratio = 1.0f * dmg / opponent.getLife();
|
||||
return MyRandom.getRandom().nextFloat() < ratio;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -227,7 +226,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return mandatory && protectMandatoryTarget(ai, sa, mandatory);
|
||||
return mandatory && protectMandatoryTarget(ai, sa);
|
||||
}
|
||||
|
||||
while (sa.canAddMoreTarget()) {
|
||||
@@ -237,7 +236,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
if (list.isEmpty()) {
|
||||
if ((sa.getTargets().size() < tgt.getMinTargets(source, sa)) || sa.getTargets().size() == 0) {
|
||||
if (mandatory) {
|
||||
return protectMandatoryTarget(ai, sa, mandatory);
|
||||
return protectMandatoryTarget(ai, sa);
|
||||
}
|
||||
|
||||
sa.resetTargets();
|
||||
@@ -256,7 +255,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
return true;
|
||||
} // protectTgtAI()
|
||||
|
||||
private static boolean protectMandatoryTarget(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||
private static boolean protectMandatoryTarget(final Player ai, final SpellAbility sa) {
|
||||
final Game game = ai.getGame();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
@@ -294,7 +293,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
break;
|
||||
}
|
||||
|
||||
Card c = ComputerUtilCard.getBestAI(list);
|
||||
Card c = ComputerUtilCard.getBestAI(pref);
|
||||
pref.remove(c);
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
@@ -304,7 +303,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
break;
|
||||
}
|
||||
|
||||
Card c = ComputerUtilCard.getBestAI(list);
|
||||
Card c = ComputerUtilCard.getBestAI(pref2);
|
||||
pref2.remove(c);
|
||||
sa.getTargets().add(c);
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ public class PumpAi extends PumpAiBase {
|
||||
// Filter AI-specific targets if provided
|
||||
list = ComputerUtil.filterAITgts(sa, ai, list, true);
|
||||
|
||||
if (list.isEmpty() || ComputerUtil.activateForCost(sa, ai)) {
|
||||
if (list.isEmpty() && (mandatory || ComputerUtil.activateForCost(sa, ai))) {
|
||||
return pumpMandatoryTarget(ai, sa);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ public class DigEffect extends SpellAbilityEffect {
|
||||
final Card host = sa.getHostCard();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final int numToDig = AbilityUtils.calculateAmount(host, sa.getParam("DigNum"), sa);
|
||||
final int numToChange = (sa.hasParam("ChangeNum") ?
|
||||
AbilityUtils.calculateAmount(host, sa.getParam("ChangeNum"), sa) : 1);
|
||||
final String toChange = sa.getParamOrDefault("ChangeNum", "1");
|
||||
final int numToChange = toChange.startsWith("All") ? numToDig : AbilityUtils.calculateAmount(host, sa.getParam("ChangeNum"), sa);
|
||||
final List<Player> tgtPlayers = getTargetPlayers(sa);
|
||||
|
||||
String verb = " looks at ";
|
||||
|
||||
Reference in New Issue
Block a user