mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Code cleanup - deprecations
This commit is contained in:
@@ -1771,7 +1771,7 @@ public class AiController {
|
||||
+ MyRandom.getRandom().nextInt(3);
|
||||
return Math.max(remaining, min) / 2;
|
||||
} else if ("LowestLoseLife".equals(logic)) {
|
||||
return MyRandom.getRandom().nextInt(Math.min(player.getLife() / 3, ComputerUtil.getOpponentFor(player).getLife())) + 1;
|
||||
return MyRandom.getRandom().nextInt(Math.min(player.getLife() / 3, player.getWeakestOpponent().getLife())) + 1;
|
||||
} else if ("HighestGetCounter".equals(logic)) {
|
||||
return MyRandom.getRandom().nextInt(3);
|
||||
} else if (source.hasSVar("EnergyToPay")) {
|
||||
|
||||
@@ -521,7 +521,7 @@ public class ComputerUtilCard {
|
||||
*/
|
||||
public static CardCollectionView getLikelyBlockers(final Player ai, final CardCollectionView blockers) {
|
||||
AiBlockController aiBlk = new AiBlockController(ai);
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
Combat combat = new Combat(opp);
|
||||
//Use actual attackers if available, else consider all possible attackers
|
||||
Combat currentCombat = ai.getGame().getCombat();
|
||||
@@ -884,7 +884,7 @@ public class ComputerUtilCard {
|
||||
List<String> chosen = new ArrayList<String>();
|
||||
Player ai = sa.getActivatingPlayer();
|
||||
final Game game = ai.getGame();
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
if (sa.hasParam("AILogic")) {
|
||||
final String logic = sa.getParam("AILogic");
|
||||
|
||||
@@ -974,7 +974,7 @@ public class ComputerUtilCard {
|
||||
public static boolean useRemovalNow(final SpellAbility sa, final Card c, final int dmg, ZoneType destination) {
|
||||
final Player ai = sa.getActivatingPlayer();
|
||||
final AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
final Game game = ai.getGame();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
final PhaseType phaseType = ph.getPhase();
|
||||
@@ -1269,7 +1269,7 @@ public class ComputerUtilCard {
|
||||
}
|
||||
}
|
||||
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
Card pumped = getPumpedCreature(ai, sa, c, toughness, power, keywords);
|
||||
List<Card> oppCreatures = opp.getCreaturesInPlay();
|
||||
float chance = 0;
|
||||
|
||||
@@ -626,7 +626,7 @@ public class ComputerUtilCost {
|
||||
&& (!source.getName().equals("Tyrannize") || payer.getCardsIn(ZoneType.Hand).size() > 2)
|
||||
&& (!source.getName().equals("Perplex") || payer.getCardsIn(ZoneType.Hand).size() < 2)
|
||||
&& (!source.getName().equals("Breaking Point") || payer.getCreaturesInPlay().size() > 1)
|
||||
&& (!source.getName().equals("Chain of Vapor") || (ComputerUtil.getOpponentFor(payer).getCreaturesInPlay().size() > 0 && payer.getLandsInPlay().size() > 3));
|
||||
&& (!source.getName().equals("Chain of Vapor") || (payer.getWeakestOpponent().getCreaturesInPlay().size() > 0 && payer.getLandsInPlay().size() > 3));
|
||||
}
|
||||
|
||||
public static Set<String> getAvailableManaColors(Player ai, Card additionalLand) {
|
||||
|
||||
@@ -1060,7 +1060,7 @@ public class PlayerControllerAi extends PlayerController {
|
||||
public String chooseCardName(SpellAbility sa, Predicate<ICardFace> cpp, String valid, String message) {
|
||||
if (sa.hasParam("AILogic")) {
|
||||
CardCollectionView aiLibrary = player.getCardsIn(ZoneType.Library);
|
||||
CardCollectionView oppLibrary = ComputerUtil.getOpponentFor(player).getCardsIn(ZoneType.Library);
|
||||
CardCollectionView oppLibrary = player.getWeakestOpponent().getCardsIn(ZoneType.Library);
|
||||
final Card source = sa.getHostCard();
|
||||
final String logic = sa.getParam("AILogic");
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ActivateAbilityAi extends SpellAbilityAi {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getHostCard();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
boolean randomReturn = MyRandom.getRandom().nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
|
||||
List<Card> list = CardLists.getType(opp.getCardsIn(ZoneType.Battlefield), sa.getParamOrDefault("Type", "Card"));
|
||||
@@ -46,7 +46,7 @@ public class ActivateAbilityAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getHostCard();
|
||||
@@ -87,7 +87,7 @@ public class ActivateAbilityAi extends SpellAbilityAi {
|
||||
}
|
||||
} else {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(ComputerUtil.getOpponentFor(ai));
|
||||
sa.getTargets().add(ai.getWeakestOpponent());
|
||||
}
|
||||
|
||||
return randomReturn;
|
||||
|
||||
@@ -77,13 +77,13 @@ public class AnimateAi extends SpellAbilityAi {
|
||||
num = (num == null) ? "1" : num;
|
||||
final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack);
|
||||
CardCollection list = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","),
|
||||
ComputerUtil.getOpponentFor(ai), topStack.getHostCard(), topStack);
|
||||
ai.getWeakestOpponent(), topStack.getHostCard(), topStack);
|
||||
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
|
||||
ComputerUtilCard.sortByEvaluateCreature(list);
|
||||
if (!list.isEmpty() && list.size() == nToSac && ComputerUtilCost.canPayCost(sa, ai)) {
|
||||
Card animatedCopy = becomeAnimated(source, sa);
|
||||
list.add(animatedCopy);
|
||||
list = CardLists.getValidCards(list, valid.split(","), ComputerUtil.getOpponentFor(ai), topStack.getHostCard(),
|
||||
list = CardLists.getValidCards(list, valid.split(","), ai.getWeakestOpponent(), topStack.getHostCard(),
|
||||
topStack);
|
||||
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
|
||||
if (ComputerUtilCard.evaluateCreature(animatedCopy) < ComputerUtilCard.evaluateCreature(list.get(0))
|
||||
|
||||
@@ -17,7 +17,7 @@ public class BalanceAi extends SpellAbilityAi {
|
||||
|
||||
int diff = 0;
|
||||
// TODO Add support for multiplayer logic
|
||||
final Player opp = ComputerUtil.getOpponentFor(aiPlayer);
|
||||
final Player opp = aiPlayer.getWeakestOpponent();
|
||||
final CardCollectionView humPerms = opp.getCardsIn(ZoneType.Battlefield);
|
||||
final CardCollectionView compPerms = aiPlayer.getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class BidLifeAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (tgt.canTgtCreature()) {
|
||||
List<Card> list = CardLists.getTargetableCards(ComputerUtil.getOpponentFor(aiPlayer).getCardsIn(ZoneType.Battlefield), sa);
|
||||
List<Card> list = CardLists.getTargetableCards(aiPlayer.getWeakestOpponent().getCardsIn(ZoneType.Battlefield), sa);
|
||||
list = CardLists.getValidCards(list, tgt.getValidTgts(), source.getController(), source, sa);
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
|
||||
@@ -202,7 +202,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
final Card source = sa.getHostCard();
|
||||
final String sourceName = ComputerUtilAbility.getAbilitySourceName(sa);
|
||||
ZoneType origin = null;
|
||||
final Player opponent = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opponent = ai.getWeakestOpponent();
|
||||
boolean activateForCost = ComputerUtil.activateForCost(sa, ai);
|
||||
|
||||
if (sa.hasParam("Origin")) {
|
||||
@@ -407,7 +407,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
// if putting cards from hand to library and parent is drawing cards
|
||||
// make sure this will actually do something:
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Player opp = ComputerUtil.getOpponentFor(aiPlayer);
|
||||
final Player opp = aiPlayer.getWeakestOpponent();
|
||||
if (tgt != null && tgt.canTgtPlayer()) {
|
||||
boolean isCurse = sa.isCurse();
|
||||
if (isCurse && sa.canTarget(opp)) {
|
||||
@@ -468,7 +468,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
Iterable<Player> pDefined;
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if ((tgt != null) && tgt.canTgtPlayer()) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
if (sa.isCurse()) {
|
||||
if (sa.canTarget(opp)) {
|
||||
sa.getTargets().add(opp);
|
||||
@@ -587,7 +587,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
*/
|
||||
private static Card chooseCreature(final Player ai, CardCollection list) {
|
||||
// Creating a new combat for testing purposes.
|
||||
final Player opponent = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opponent = ai.getWeakestOpponent();
|
||||
Combat combat = new Combat(opponent);
|
||||
for (Card att : opponent.getCreaturesInPlay()) {
|
||||
combat.addAttacker(att, ai);
|
||||
@@ -902,7 +902,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
||||
&& !currCombat.getBlockers(attacker).isEmpty()) {
|
||||
ComputerUtilCard.sortByEvaluateCreature(blockers);
|
||||
Combat combat = new Combat(ai);
|
||||
combat.addAttacker(attacker, ComputerUtil.getOpponentFor(ai));
|
||||
combat.addAttacker(attacker, ai.getWeakestOpponent());
|
||||
for (Card blocker : blockers) {
|
||||
combat.addBlocker(attacker, blocker);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
||||
}
|
||||
} else if (aiLogic.equals("Duneblast")) {
|
||||
CardCollection aiCreatures = ai.getCreaturesInPlay();
|
||||
CardCollection oppCreatures = ComputerUtil.getOpponentFor(ai).getCreaturesInPlay();
|
||||
CardCollection oppCreatures = ai.getWeakestOpponent().getCreaturesInPlay();
|
||||
aiCreatures = CardLists.getNotKeyword(aiCreatures, Keyword.INDESTRUCTIBLE);
|
||||
oppCreatures = CardLists.getNotKeyword(oppCreatures, Keyword.INDESTRUCTIBLE);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ChooseCardNameAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (tgt.canOnlyTgtOpponent()) {
|
||||
sa.getTargets().add(ComputerUtil.getOpponentFor(ai));
|
||||
sa.getTargets().add(ai.getWeakestOpponent());
|
||||
} else {
|
||||
sa.getTargets().add(ai);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ChooseColorAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if ("Addle".equals(sourceName)) {
|
||||
if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) || ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Hand).isEmpty()) {
|
||||
if (ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) || ai.getWeakestOpponent().getCardsIn(ZoneType.Hand).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -61,7 +61,7 @@ public class ChooseColorAi extends SpellAbilityAi {
|
||||
if (logic.equals("MostExcessOpponentControls")) {
|
||||
for (byte color : MagicColor.WUBRG) {
|
||||
CardCollectionView ailist = ai.getCardsIn(ZoneType.Battlefield);
|
||||
CardCollectionView opplist = ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Battlefield);
|
||||
CardCollectionView opplist = ai.getWeakestOpponent().getCardsIn(ZoneType.Battlefield);
|
||||
|
||||
ailist = CardLists.filter(ailist, CardPredicates.isColor(color));
|
||||
opplist = CardLists.filter(opplist, CardPredicates.isColor(color));
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ChooseNumberAi extends SpellAbilityAi {
|
||||
TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
Player opp = ComputerUtil.getOpponentFor(aiPlayer);
|
||||
Player opp = aiPlayer.getWeakestOpponent();
|
||||
if (sa.canTarget(opp)) {
|
||||
sa.getTargets().add(opp);
|
||||
} else {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
if (sa.canTarget(opp)) {
|
||||
sa.getTargets().add(opp);
|
||||
} else {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
|
||||
sa.resetTargets();
|
||||
|
||||
CardCollection list =
|
||||
CardLists.getValidCards(ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa);
|
||||
CardLists.getValidCards(ai.getWeakestOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa);
|
||||
// AI won't try to grab cards that are filtered out of AI decks on
|
||||
// purpose
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
final boolean curse = sa.isCurse();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
hList = CardLists.getValidCards(ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Battlefield), valid, source.getController(), source);
|
||||
hList = CardLists.getValidCards(ai.getWeakestOpponent().getCardsIn(ZoneType.Battlefield), valid, source.getController(), source);
|
||||
cList = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid, source.getController(), source);
|
||||
|
||||
if (abCost != null) {
|
||||
@@ -68,7 +68,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
if (tgt != null) {
|
||||
Player pl = curse ? ComputerUtil.getOpponentFor(ai) : ai;
|
||||
Player pl = curse ? ai.getWeakestOpponent() : ai;
|
||||
sa.getTargets().add(pl);
|
||||
|
||||
hList = CardLists.filterControlledBy(hList, pl);
|
||||
@@ -149,7 +149,7 @@ public class CountersPutAllAi extends SpellAbilityAi {
|
||||
*/
|
||||
@Override
|
||||
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
|
||||
return player.getCreaturesInPlay().size() >= ComputerUtil.getOpponentFor(player).getCreaturesInPlay().size();
|
||||
return player.getCreaturesInPlay().size() >= player.getWeakestOpponent().getCreaturesInPlay().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import forge.util.MyRandom;
|
||||
|
||||
public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
protected boolean avoidTargetP(final Player comp, final SpellAbility sa) {
|
||||
Player enemy = ComputerUtil.getOpponentFor(comp);
|
||||
Player enemy = comp.getWeakestOpponent();
|
||||
// Logic for cards that damage owner, like Fireslinger
|
||||
// Do not target a player if they aren't below 75% of our health.
|
||||
// Unless Lifelink will cancel the damage to us
|
||||
@@ -54,7 +54,7 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
||||
protected boolean shouldTgtP(final Player comp, final SpellAbility sa, final int d, final boolean noPrevention, final boolean noPlaneswalkerRedirection) {
|
||||
int restDamage = d;
|
||||
final Game game = comp.getGame();
|
||||
Player enemy = ComputerUtil.getOpponentFor(comp);
|
||||
Player enemy = comp.getWeakestOpponent();
|
||||
boolean dmgByCardsInHand = false;
|
||||
|
||||
if ("X".equals(sa.getParam("NumDmg")) && sa.getHostCard() != null && sa.hasSVar(sa.getParam("NumDmg")) &&
|
||||
|
||||
@@ -212,7 +212,7 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Evaluate creatures getting killed
|
||||
Player enemy = ComputerUtil.getOpponentFor(ai);
|
||||
Player enemy = ai.getWeakestOpponent();
|
||||
final CardCollection humanList = getKillableCreatures(sa, enemy, dmg);
|
||||
CardCollection computerList = getKillableCreatures(sa, ai, dmg);
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
@@ -294,7 +294,7 @@ public class DamageAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
// Evaluate creatures getting killed
|
||||
Player enemy = ComputerUtil.getOpponentFor(ai);
|
||||
Player enemy = ai.getWeakestOpponent();
|
||||
final CardCollection humanList = getKillableCreatures(sa, enemy, dmg);
|
||||
CardCollection computerList = getKillableCreatures(sa, ai, dmg);
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
@@ -547,7 +547,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
final boolean oppTargetsChoice = sa.hasParam("TargetingPlayer");
|
||||
final String logic = sa.getParamOrDefault("AILogic", "");
|
||||
|
||||
Player enemy = ComputerUtil.getOpponentFor(ai);
|
||||
Player enemy = ai.getWeakestOpponent();
|
||||
|
||||
if ("PowerDmg".equals(logic)) {
|
||||
// check if it is better to target the player instead, the original target is already set in PumpAi.pumpTgtAI()
|
||||
@@ -873,7 +873,7 @@ public class DamageDealAi extends DamageAiBase {
|
||||
// this is for Triggered targets that are mandatory
|
||||
final boolean noPrevention = sa.hasParam("NoPrevention");
|
||||
final boolean divided = sa.hasParam("DividedAsYouChoose");
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
|
||||
while (sa.getTargets().getNumTargeted() < tgt.getMinTargets(sa.getHostCard(), sa)) {
|
||||
if (tgt.canTgtPlaneswalker()) {
|
||||
|
||||
@@ -177,7 +177,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
* @return a CardCollection.
|
||||
*/
|
||||
private CardCollection getCurseCreatures(final Player ai, final SpellAbility sa, final List<String> kws) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
CardCollection list = CardLists.getTargetableCards(opp.getCreaturesInPlay(), sa);
|
||||
if (!list.isEmpty()) {
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
@@ -217,7 +217,7 @@ public class DebuffAi extends SpellAbilityAi {
|
||||
list.remove(c);
|
||||
}
|
||||
|
||||
final CardCollection pref = CardLists.filterControlledBy(list, ComputerUtil.getOpponentFor(ai));
|
||||
final CardCollection pref = CardLists.filterControlledBy(list, ai.getWeakestOpponent());
|
||||
final CardCollection forced = CardLists.filterControlledBy(list, ai);
|
||||
final Card source = sa.getHostCard();
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ public class DestroyAi extends SpellAbilityAi {
|
||||
} else if (sa.hasParam("Defined")) {
|
||||
list = AbilityUtils.getDefinedCards(source, sa.getParam("Defined"), sa);
|
||||
if ("WillSkipTurn".equals(logic) && (sa.getHostCard().getController().equals(ai)
|
||||
|| ai.getCreaturesInPlay().size() < ComputerUtil.getOpponentFor(ai).getCreaturesInPlay().size()
|
||||
|| ai.getCreaturesInPlay().size() < ai.getWeakestOpponent().getCreaturesInPlay().size()
|
||||
|| !source.getGame().getPhaseHandler().isPlayerTurn(ai)
|
||||
|| ai.getLife() <= 5)) {
|
||||
// Basic ai logic for Lethal Vapors
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DestroyAllAi extends SpellAbilityAi {
|
||||
public boolean doMassRemovalLogic(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
final String logic = sa.getParamOrDefault("AILogic", "");
|
||||
Player opponent = ComputerUtil.getOpponentFor(ai); // TODO: how should this AI logic work for multiplayer and getOpponents()?
|
||||
Player opponent = ai.getWeakestOpponent(); // TODO: how should this AI logic work for multiplayer and getOpponents()?
|
||||
|
||||
final int CREATURE_EVAL_THRESHOLD = 200;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class DigAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Game game = ai.getGame();
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
final Card host = sa.getHostCard();
|
||||
Player libraryOwner = ai;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class DigAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
if (sa.usesTargeting()) {
|
||||
sa.resetTargets();
|
||||
if (mandatory && sa.canTarget(opp)) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DigUntilAi extends SpellAbilityAi {
|
||||
final boolean randomReturn = MyRandom.getRandom().nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
|
||||
|
||||
Player libraryOwner = ai;
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
|
||||
if ("DontMillSelf".equals(logic)) {
|
||||
// A card that digs for specific things and puts everything revealed before it into graveyard
|
||||
|
||||
@@ -56,7 +56,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
return SpecialCardAi.VolrathsShapeshifter.consider(ai, sa);
|
||||
}
|
||||
|
||||
final boolean humanHasHand = ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Hand).size() > 0;
|
||||
final boolean humanHasHand = ai.getWeakestOpponent().getCardsIn(ZoneType.Hand).size() > 0;
|
||||
|
||||
if (tgt != null) {
|
||||
if (!discardTargetAI(ai, sa)) {
|
||||
@@ -87,7 +87,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
if (sa.hasParam("NumCards")) {
|
||||
if (sa.getParam("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ComputerUtil.getOpponentFor(ai)
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ai.getWeakestOpponent()
|
||||
.getCardsIn(ZoneType.Hand).size());
|
||||
if (cardsToDiscard < 1) {
|
||||
return false;
|
||||
@@ -150,7 +150,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
|
||||
private boolean discardTargetAI(final Player ai, final SpellAbility sa) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
if (opp.getCardsIn(ZoneType.Hand).isEmpty() && !ComputerUtil.activateForCost(sa, ai)) {
|
||||
return false;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
if (!discardTargetAI(ai, sa)) {
|
||||
if (mandatory && sa.canTarget(opp)) {
|
||||
sa.getTargets().add(opp);
|
||||
@@ -190,7 +190,7 @@ public class DiscardAi extends SpellAbilityAi {
|
||||
}
|
||||
if ("X".equals(sa.getParam("RevealNumber")) && sa.getHostCard().getSVar("X").equals("Count$xPaid")) {
|
||||
// Set PayX here to maximum value.
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ComputerUtil.getOpponentFor(ai)
|
||||
final int cardsToDiscard = Math.min(ComputerUtilMana.determineLeftoverMana(sa, ai), ai.getWeakestOpponent()
|
||||
.getCardsIn(ZoneType.Hand).size());
|
||||
sa.getHostCard().setSVar("PayX", Integer.toString(cardsToDiscard));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getHostCard();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
boolean randomReturn = MyRandom.getRandom().nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn());
|
||||
|
||||
if (tgt == null) {
|
||||
@@ -41,7 +41,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Card source = sa.getHostCard();
|
||||
@@ -82,7 +82,7 @@ public class DrainManaAi extends SpellAbilityAi {
|
||||
}
|
||||
} else {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(ComputerUtil.getOpponentFor(ai));
|
||||
sa.getTargets().add(ai.getWeakestOpponent());
|
||||
}
|
||||
|
||||
return randomReturn;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class FogAi extends SpellAbilityAi {
|
||||
protected boolean doTriggerAINoCost(Player aiPlayer, SpellAbility sa, boolean mandatory) {
|
||||
final Game game = aiPlayer.getGame();
|
||||
boolean chance;
|
||||
if (game.getPhaseHandler().isPlayerTurn(ComputerUtil.getOpponentFor(sa.getActivatingPlayer()))) {
|
||||
if (game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer().getWeakestOpponent())) {
|
||||
chance = game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
|
||||
} else {
|
||||
chance = game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE);
|
||||
|
||||
@@ -9,7 +9,7 @@ import forge.game.spellability.TargetRestrictions;
|
||||
public class GameLossAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
if (opp.cantLose()) {
|
||||
return false;
|
||||
}
|
||||
@@ -34,15 +34,16 @@ public class GameLossAi extends SpellAbilityAi {
|
||||
// Phage the Untouchable
|
||||
// (Final Fortune would need to attach it's delayed trigger to a
|
||||
// specific turn, which can't be done yet)
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
|
||||
if (!mandatory && ComputerUtil.getOpponentFor(ai).cantLose()) {
|
||||
if (!mandatory && opp.cantLose()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(ComputerUtil.getOpponentFor(ai));
|
||||
sa.getTargets().add(opp);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class LifeExchangeAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
final int myLife = aiPlayer.getLife();
|
||||
Player opponent = ComputerUtil.getOpponentFor(aiPlayer);
|
||||
Player opponent = aiPlayer.getWeakestOpponent();
|
||||
final int hLife = opponent.getLife();
|
||||
|
||||
if (!aiPlayer.canGainLife()) {
|
||||
@@ -76,7 +76,7 @@ public class LifeExchangeAi extends SpellAbilityAi {
|
||||
final boolean mandatory) {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (sa.canTarget(opp) && (mandatory || ai.getLife() < opp.getLife())) {
|
||||
|
||||
@@ -149,7 +149,7 @@ public class LifeExchangeVariantAi extends SpellAbilityAi {
|
||||
final boolean mandatory) {
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (sa.canTarget(opp) && (mandatory || ai.getLife() < opp.getLife())) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
// Ability_Cost abCost = sa.getPayCosts();
|
||||
final Card source = sa.getHostCard();
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opponent = ai.getWeakestOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
final String amountStr = sa.getParam("LifeAmount");
|
||||
|
||||
@@ -107,7 +107,7 @@ public class LifeSetAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final int myLife = ai.getLife();
|
||||
final Player opponent = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opponent = ai.getWeakestOpponent();
|
||||
final int hlife = opponent.getLife();
|
||||
final Card source = sa.getHostCard();
|
||||
final String sourceName = ComputerUtilAbility.getAbilitySourceName(sa);
|
||||
|
||||
@@ -95,7 +95,7 @@ public class MustBlockAi extends SpellAbilityAi {
|
||||
boolean chance = false;
|
||||
|
||||
if (abTgt != null) {
|
||||
final List<Card> list = determineGoodBlockers(definedAttacker, ai, ComputerUtil.getOpponentFor(ai), sa, true,true);
|
||||
final List<Card> list = determineGoodBlockers(definedAttacker, ai, ai.getWeakestOpponent(), sa, true,true);
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PowerExchangeAi extends SpellAbilityAi {
|
||||
sa.resetTargets();
|
||||
|
||||
List<Card> list =
|
||||
CardLists.getValidCards(ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa);
|
||||
CardLists.getValidCards(ai.getWeakestOpponent().getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, sa.getHostCard(), sa);
|
||||
// AI won't try to grab cards that are filtered out of AI decks on
|
||||
// purpose
|
||||
list = CardLists.filter(list, new Predicate<Card>() {
|
||||
|
||||
@@ -146,7 +146,7 @@ public class ProtectAi extends SpellAbilityAi {
|
||||
if (s==null) {
|
||||
return false;
|
||||
} else {
|
||||
Player opponent = ComputerUtil.getOpponentFor(ai);
|
||||
Player opponent = ai.getWeakestOpponent();
|
||||
Combat combat = ai.getGame().getCombat();
|
||||
int dmg = ComputerUtilCombat.damageIfUnblocked(c, opponent, combat, true);
|
||||
float ratio = 1.0f * dmg / opponent.getLife();
|
||||
|
||||
@@ -177,7 +177,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
final Game game = ai.getGame();
|
||||
final Combat combat = game.getCombat();
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
final int newPower = card.getNetCombatDamage() + attack;
|
||||
//int defense = getNumDefense(sa);
|
||||
if (!CardUtil.isStackingKeyword(keyword) && card.hasKeyword(keyword)) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PumpAllAi extends PumpAiBase {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
CardCollection comp = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid, source.getController(), source);
|
||||
CardCollection human = CardLists.getValidCards(opp.getCardsIn(ZoneType.Battlefield), valid, source.getController(), source);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RearrangeTopOfLibraryAi extends SpellAbilityAi {
|
||||
// ability is targeted
|
||||
sa.resetTargets();
|
||||
|
||||
Player opp = ComputerUtil.getOpponentFor(aiPlayer);
|
||||
Player opp = aiPlayer.getWeakestOpponent();
|
||||
final boolean canTgtAI = aiPlayer.canBeTargetedBy(sa);
|
||||
final boolean canTgtHuman = opp.canBeTargetedBy(sa);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class RepeatAi extends SpellAbilityAi {
|
||||
protected boolean canPlayAI(Player ai, SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
|
||||
if (tgt != null) {
|
||||
if (!opp.canBeTargetedBy(sa)) {
|
||||
@@ -49,7 +49,7 @@ public class RepeatAi extends SpellAbilityAi {
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
|
||||
if (sa.usesTargeting()) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
if (sa.canTarget(opp)) {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(opp);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SacrificeAi extends SpellAbilityAi {
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
final boolean destroy = sa.hasParam("Destroy");
|
||||
|
||||
Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (!opp.canBeTargetedBy(sa)) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SacrificeAllAi extends SpellAbilityAi {
|
||||
}
|
||||
|
||||
CardCollection humanlist =
|
||||
CardLists.getValidCards(ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source, sa);
|
||||
CardLists.getValidCards(ai.getWeakestOpponent().getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source, sa);
|
||||
CardCollection computerlist =
|
||||
CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","), source.getController(), source, sa);
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
|
||||
* @return a boolean.
|
||||
*/
|
||||
protected boolean tapPrefTargeting(final Player ai, final Card source, final TargetRestrictions tgt, final SpellAbility sa, final boolean mandatory) {
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
final Game game = ai.getGame();
|
||||
CardCollection tapList = CardLists.filterControlledBy(game.getCardsIn(ZoneType.Battlefield), ai.getOpponents());
|
||||
tapList = CardLists.getValidCards(tapList, tgt.getValidTgts(), source.getController(), source, sa);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
// or during upkeep/begin combat?
|
||||
|
||||
final Card source = sa.getHostCard();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
final Game game = ai.getGame();
|
||||
|
||||
if (game.getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_BEGIN)) {
|
||||
@@ -125,8 +125,9 @@ public class TapAllAi extends SpellAbilityAi {
|
||||
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
sa.getTargets().add(ComputerUtil.getOpponentFor(ai));
|
||||
validTappables = ComputerUtil.getOpponentFor(ai).getCardsIn(ZoneType.Battlefield);
|
||||
Player opp = ai.getWeakestOpponent();
|
||||
sa.getTargets().add(opp);
|
||||
validTappables = opp.getCardsIn(ZoneType.Battlefield);
|
||||
}
|
||||
|
||||
if (mandatory) {
|
||||
|
||||
@@ -167,7 +167,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
*/
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = ai.getGame();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
|
||||
if (ComputerUtil.preventRunAwayActivations(sa)) {
|
||||
return false; // prevent infinite tokens?
|
||||
@@ -261,13 +261,13 @@ public class TokenAi extends SpellAbilityAi {
|
||||
num = (num == null) ? "1" : num;
|
||||
final int nToSac = AbilityUtils.calculateAmount(topStack.getHostCard(), num, topStack);
|
||||
CardCollection list = CardLists.getValidCards(ai.getCardsIn(ZoneType.Battlefield), valid.split(","),
|
||||
ComputerUtil.getOpponentFor(ai), topStack.getHostCard(), sa);
|
||||
ai.getWeakestOpponent(), topStack.getHostCard(), sa);
|
||||
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
|
||||
// only care about saving single creature for now
|
||||
if (!list.isEmpty() && nTokens > 0 && list.size() == nToSac) {
|
||||
ComputerUtilCard.sortByEvaluateCreature(list);
|
||||
list.add(token);
|
||||
list = CardLists.getValidCards(list, valid.split(","), ComputerUtil.getOpponentFor(ai), topStack.getHostCard(), sa);
|
||||
list = CardLists.getValidCards(list, valid.split(","), ai.getWeakestOpponent(), topStack.getHostCard(), sa);
|
||||
list = CardLists.filter(list, CardPredicates.canBeSacrificedBy(topStack));
|
||||
if (ComputerUtilCard.evaluateCreature(token) < ComputerUtilCard.evaluateCreature(list.get(0))
|
||||
&& list.contains(token)) {
|
||||
@@ -285,7 +285,7 @@ public class TokenAi extends SpellAbilityAi {
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
if (tgt.canOnlyTgtOpponent()) {
|
||||
sa.getTargets().add(ComputerUtil.getOpponentFor(ai));
|
||||
sa.getTargets().add(ai.getWeakestOpponent());
|
||||
} else {
|
||||
sa.getTargets().add(ai);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TwoPilesAi extends SpellAbilityAi {
|
||||
valid = sa.getParam("ValidCards");
|
||||
}
|
||||
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class UnattachAllAi extends SpellAbilityAi {
|
||||
@Override
|
||||
protected boolean doTriggerAINoCost(Player ai, SpellAbility sa, boolean mandatory) {
|
||||
final Card card = sa.getHostCard();
|
||||
final Player opp = ComputerUtil.getOpponentFor(ai);
|
||||
final Player opp = ai.getWeakestOpponent();
|
||||
// Check if there are any valid targets
|
||||
List<GameObject> targets = new ArrayList<GameObject>();
|
||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
|
||||
@@ -139,7 +139,7 @@ public class UntapAi extends SpellAbilityAi {
|
||||
Player targetController = ai;
|
||||
|
||||
if (sa.isCurse()) {
|
||||
targetController = ComputerUtil.getOpponentFor(ai);
|
||||
targetController = ai.getWeakestOpponent();
|
||||
}
|
||||
|
||||
CardCollection list = CardLists.getTargetableCards(targetController.getCardsIn(ZoneType.Battlefield), sa);
|
||||
|
||||
@@ -205,7 +205,7 @@ public class GameSimulator {
|
||||
}
|
||||
|
||||
// TODO: Support multiple opponents.
|
||||
Player opponent = ComputerUtil.getOpponentFor(aiPlayer);
|
||||
Player opponent = aiPlayer.getWeakestOpponent();
|
||||
resolveStack(simGame, opponent);
|
||||
|
||||
// TODO: If this is during combat, before blockers are declared,
|
||||
|
||||
@@ -46,9 +46,7 @@ public class ImageUtil {
|
||||
cntPictures = db.getPrintCount(card.getName(), edition);
|
||||
hasManyPictures = cntPictures > 1;
|
||||
} else {
|
||||
// without set number of pictures equals number of urls provided in Svar:Picture
|
||||
String urls = card.getPictureUrl(backFace);
|
||||
cntPictures = StringUtils.countMatches(urls, "\\") + 1;
|
||||
cntPictures = 1;
|
||||
|
||||
// raise the art index limit to the maximum of the sets this card was printed in
|
||||
int maxCntPictures = db.getMaxPrintCount(card.getName());
|
||||
|
||||
@@ -388,7 +388,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiers() == InputEvent.ALT_MASK) {
|
||||
else if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiersEx() == InputEvent.ALT_DOWN_MASK) {
|
||||
altKeyLastDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,29 +296,9 @@ public class ImportSourceAnalyzer {
|
||||
return out.toString().toLowerCase();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void addDefaultPicNames(final PaperCard c, final boolean backFace) {
|
||||
final CardRules card = c.getRules();
|
||||
final String urls = card.getPictureUrl(backFace);
|
||||
if (StringUtils.isEmpty(urls)) { return; }
|
||||
|
||||
final int numPics = 1 + StringUtils.countMatches(urls, "\\");
|
||||
if (c.getArtIndex() > numPics) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String filenameBase = ImageUtil.getImageKey(c, backFace, false);
|
||||
final String filename = filenameBase + ".jpg";
|
||||
final boolean alreadyHadIt = null != defaultPicNames.put(filename, filename);
|
||||
if ( alreadyHadIt ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do you shift artIndex by one here?
|
||||
final String newLastSymbol = 0 == c.getArtIndex() ? "" : String.valueOf(c.getArtIndex() /* + 1 */);
|
||||
final String oldFilename = oldCleanString(filenameBase.replaceAll("[0-9]?(\\.full)?$", "")) + newLastSymbol + ".jpg";
|
||||
//if ( numPics > 1 )
|
||||
//System.out.printf("Will move %s -> %s%n", oldFilename, filename);
|
||||
defaultPicOldNameToCurrentName.put(oldFilename, filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> {
|
||||
itemManager.focus();
|
||||
break;
|
||||
case KeyEvent.VK_ENTER:
|
||||
if (e.getModifiers() == 0) {
|
||||
if (e.getModifiersEx() == 0) {
|
||||
if (changeTimer.isRunning()) {
|
||||
applyChange(); //apply change now if currently delayed
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ public abstract class ItemView<T extends InventoryItem> {
|
||||
private boolean popupShowing = false;
|
||||
private Popup popup;
|
||||
private Timer popupTimer;
|
||||
private static final int okModifiers = InputEvent.SHIFT_MASK | InputEvent.ALT_GRAPH_MASK;
|
||||
private static final int okModifiers = InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK;
|
||||
|
||||
public IncrementalSearch() {
|
||||
}
|
||||
@@ -481,7 +481,7 @@ public abstract class ItemView<T extends InventoryItem> {
|
||||
//$FALL-THROUGH$
|
||||
default:
|
||||
// shift and/or alt-graph down is ok. anything else is a hotkey (e.g. ctrl-f)
|
||||
if (okModifiers != (e.getModifiers() | okModifiers)
|
||||
if (okModifiers != (e.getModifiersEx() | okModifiers)
|
||||
|| !CharUtils.isAsciiPrintable(e.getKeyChar())) { // escape sneaks in here on Windows
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -585,7 +585,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
}
|
||||
|
||||
public void addMoveItems(final String verb, final String dest) {
|
||||
addItems(verb, dest, false, 0, InputEvent.SHIFT_DOWN_MASK, InputEvent.ALT_MASK);
|
||||
addItems(verb, dest, false, 0, InputEvent.SHIFT_DOWN_MASK, InputEvent.ALT_DOWN_MASK);
|
||||
}
|
||||
|
||||
public void addMoveAlternateItems(final String verb, final String dest) {
|
||||
@@ -596,7 +596,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
addItems(verb, dest, true, InputEvent.CTRL_DOWN_MASK,
|
||||
//getMenuShortcutKeyMask() instead of CTRL_DOWN_MASK since on OSX, ctrl-shift-space brings up the window manager
|
||||
InputEvent.SHIFT_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),
|
||||
InputEvent.ALT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
|
||||
InputEvent.ALT_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public enum VCardScript implements IVDoc<CCardScript> {
|
||||
txtScript.setDocument(doc);
|
||||
error = doc.addStyle("error", null);
|
||||
error.addAttribute(StyleConstants.Background, Color.red);
|
||||
error.addAttribute(StyleConstants.Bold, new Boolean(true));
|
||||
error.addAttribute(StyleConstants.Bold, Boolean.valueOf(true));
|
||||
}
|
||||
|
||||
public JTextPane getTxtScript() {
|
||||
|
||||
@@ -200,8 +200,8 @@ public class FUndoManager extends UndoManager implements DocumentListener {
|
||||
public UndoAction() {
|
||||
putValue(Action.NAME, "Undo");
|
||||
putValue(Action.SHORT_DESCRIPTION, getValue(Action.NAME));
|
||||
putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_U));
|
||||
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK));
|
||||
putValue(Action.MNEMONIC_KEY, Integer.valueOf(KeyEvent.VK_U));
|
||||
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -229,8 +229,8 @@ public class FUndoManager extends UndoManager implements DocumentListener {
|
||||
public RedoAction() {
|
||||
putValue(Action.NAME, "Redo");
|
||||
putValue(Action.SHORT_DESCRIPTION, getValue(Action.NAME));
|
||||
putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R));
|
||||
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK));
|
||||
putValue(Action.MNEMONIC_KEY, Integer.valueOf(KeyEvent.VK_R));
|
||||
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK));
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import forge.limited.DraftRankCache;
|
||||
import forge.model.FModel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public enum ColumnDef {
|
||||
@@ -533,7 +534,7 @@ public enum ColumnDef {
|
||||
Double ranking = DraftRankCache.getRanking(cp.getName(), cp.getEdition());
|
||||
if (ranking != null) {
|
||||
if (truncate) {
|
||||
return new BigDecimal(ranking).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
return new BigDecimal(ranking).setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
return ranking;
|
||||
}
|
||||
|
||||
@@ -523,26 +523,26 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
tempShow(delayedReveal.getCards());
|
||||
}
|
||||
|
||||
tempShow(optionList1);
|
||||
tempShow(optionList2);
|
||||
tempShow(optionList1);
|
||||
tempShow(optionList2);
|
||||
|
||||
if (useSelectCardsInput(optionList1) && useSelectCardsInput(optionList2)) {
|
||||
final InputSelectFromTwoLists<T> input = new InputSelectFromTwoLists<T>(this, optional, optionList1, optionList2, sa);
|
||||
input.setCancelAllowed(optional);
|
||||
input.setMessage(MessageUtil.formatMessage(title, player, targetedPlayer));
|
||||
input.showAndWait();
|
||||
endTempShowCards();
|
||||
endTempShowCards();
|
||||
return (List<T>) input.getSelected();
|
||||
}
|
||||
}
|
||||
|
||||
final GameEntityView result1 = getGui().chooseSingleEntityForEffect(title, GameEntityView.getEntityCollection(optionList1), null, optional);
|
||||
final GameEntityView result2 = getGui().chooseSingleEntityForEffect(title, GameEntityView.getEntityCollection(optionList2), null, (result1==null)?optional:true);
|
||||
endTempShowCards();
|
||||
List<T> results = new ArrayList<>();
|
||||
GameEntity entity1 = convertToEntity(result1);
|
||||
if (entity1!=null) { results.add((T) entity1); }
|
||||
GameEntity entity2 = convertToEntity(result2);
|
||||
if (entity2!=null) { results.add((T) entity2); }
|
||||
List<T> results = new ArrayList<>();
|
||||
GameEntity entity1 = convertToEntity(result1);
|
||||
if (entity1!=null) { results.add((T) entity1); }
|
||||
GameEntity entity2 = convertToEntity(result2);
|
||||
if (entity2!=null) { results.add((T) entity2); }
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class QuestChallengeGenerator {
|
||||
int id = 0;
|
||||
for (int i=0;i<5;++i) {
|
||||
QuestEventChallenge qc = getFormatChallenge(FModel.getFormats().getModern());
|
||||
qc.setId(new Integer(id).toString());
|
||||
qc.setId(Integer.valueOf(id).toString());
|
||||
qc.setCreditsReward(1000);
|
||||
qc.setWinsReqd(MyRandom.getRandom().nextInt(5));
|
||||
qc.setDifficulty(QuestEventDifficulty.MEDIUM);
|
||||
@@ -27,7 +27,7 @@ public class QuestChallengeGenerator {
|
||||
}
|
||||
for (int i=0;i<5;++i) {
|
||||
QuestEventChallenge qc = getAIHeadstartChallenge(1);
|
||||
qc.setId(new Integer(id).toString());
|
||||
qc.setId(Integer.valueOf(id).toString());
|
||||
qc.setCreditsReward(1000);
|
||||
qc.setCardReward("1 multicolor rare");
|
||||
qc.setWinsReqd(MyRandom.getRandom().nextInt(5));
|
||||
@@ -37,7 +37,7 @@ public class QuestChallengeGenerator {
|
||||
}
|
||||
for (int i=0;i<5;++i) {
|
||||
QuestEventChallenge qc = getFormatChallenge(FModel.getFormats().get("Legacy"));
|
||||
qc.setId(new Integer(id).toString());
|
||||
qc.setId(Integer.valueOf(id).toString());
|
||||
qc.setCreditsReward(5000);
|
||||
qc.setCardReward("2 multicolor rares");
|
||||
qc.setWinsReqd(MyRandom.getRandom().nextInt(25));
|
||||
@@ -47,7 +47,7 @@ public class QuestChallengeGenerator {
|
||||
}
|
||||
for (int i=0;i<5;++i) {
|
||||
QuestEventChallenge qc = getAIHeadstartChallenge(2);
|
||||
qc.setId(new Integer(id).toString());
|
||||
qc.setId(Integer.valueOf(id).toString());
|
||||
qc.setCreditsReward(5000);
|
||||
qc.setCardReward("2 multicolor rares");
|
||||
qc.setWinsReqd(MyRandom.getRandom().nextInt(25));
|
||||
@@ -57,7 +57,7 @@ public class QuestChallengeGenerator {
|
||||
}
|
||||
for (int i=0;i<5;++i) {
|
||||
QuestEventChallenge qc = getFormatChallenge(FModel.getFormats().get("Vintage"));
|
||||
qc.setId(new Integer(id).toString());
|
||||
qc.setId(Integer.valueOf(id).toString());
|
||||
qc.setCreditsReward(10000);
|
||||
qc.setCardReward("3 multicolor rares");
|
||||
qc.setWinsReqd(MyRandom.getRandom().nextInt(50));
|
||||
@@ -67,7 +67,7 @@ public class QuestChallengeGenerator {
|
||||
}
|
||||
for (int i=0;i<5;++i) {
|
||||
QuestEventChallenge qc = getAIHeadstartChallenge(3);
|
||||
qc.setId(new Integer(id).toString());
|
||||
qc.setId(Integer.valueOf(id).toString());
|
||||
qc.setCreditsReward(10000);
|
||||
qc.setCardReward("3 multicolor rares");
|
||||
qc.setWinsReqd(MyRandom.getRandom().nextInt(50));
|
||||
|
||||
@@ -64,11 +64,11 @@ public class QuestEventLDADuelManager implements QuestEventDuelManagerInterface
|
||||
duel.setTitle(archetype.getName());
|
||||
duel.setOpponentName(archetype.getName());
|
||||
QuestEventDifficulty diff = QuestEventDifficulty.EASY;
|
||||
if(i <= (new Float(archetypes.size()))*.1){
|
||||
if(i <= Float.valueOf(archetypes.size())*.1){
|
||||
diff = QuestEventDifficulty.EXPERT;
|
||||
}else if(i <= (new Float(archetypes.size()))*.4){
|
||||
}else if(i <= Float.valueOf(archetypes.size())*.4){
|
||||
diff = QuestEventDifficulty.HARD;
|
||||
}else if(i <= (new Float(archetypes.size()))*.7) {
|
||||
}else if(i <= Float.valueOf(archetypes.size())*.7) {
|
||||
diff = QuestEventDifficulty.MEDIUM;
|
||||
}
|
||||
duel.setDifficulty(diff);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class QuestUtilUnlockSets {
|
||||
}
|
||||
int price = UNLOCK_COST;
|
||||
if (mapPrices.containsKey(TextUtil.concatNoSpace(ed.getName(), " Booster Pack"))) {
|
||||
price = Math.max(new Double(30 * Math.pow(Math.sqrt(mapPrices.get(TextUtil.concatNoSpace(ed.getName(),
|
||||
price = Math.max(Double.valueOf(30 * Math.pow(Math.sqrt(mapPrices.get(TextUtil.concatNoSpace(ed.getName(),
|
||||
" Booster Pack"))), 1.70)).intValue(), UNLOCK_COST);
|
||||
}
|
||||
price = (int) ((double) price * multiplier);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package forge.quest.data;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -99,7 +101,7 @@ public class QuestAssets {
|
||||
QuestItemCondition current = this.inventoryItems.get(itemType);
|
||||
if (!current.getClass().equals(itemType.getModelClass())) {
|
||||
try {
|
||||
QuestItemCondition modern = itemType.getModelClass().newInstance();
|
||||
QuestItemCondition modern = itemType.getModelClass().getDeclaredConstructor().newInstance();
|
||||
modern.takeDataFrom(current);
|
||||
current = modern;
|
||||
inventoryItems.put(itemType, modern);
|
||||
@@ -107,6 +109,10 @@ public class QuestAssets {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,7 +129,7 @@ public class QuestAssets {
|
||||
QuestItemCondition cond = this.inventoryItems.get(itemType);
|
||||
if (null == cond) {
|
||||
try { // care to set appropriate state class here
|
||||
cond = itemType.getModelClass().newInstance();
|
||||
cond = itemType.getModelClass().getDeclaredConstructor().newInstance();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
cond = new QuestItemCondition();
|
||||
|
||||
@@ -18,13 +18,13 @@ public abstract class AbstractGeneticAlgorithm<T> {
|
||||
protected abstract T expandPool();
|
||||
|
||||
public void pruneWeakest(){
|
||||
population = population.subList(0, new Float(population.size()*pruneRatio).intValue());
|
||||
population = population.subList(0, Float.valueOf(population.size()*pruneRatio).intValue());
|
||||
}
|
||||
|
||||
protected void generateChildren(){
|
||||
int prunedSize = population.size();
|
||||
while(population.size()<targetPopulationSize){
|
||||
int randomIndex = new Double(prunedSize*Math.pow(MyRandom.getRandom().nextDouble(), 0.25)/2d).intValue();
|
||||
int randomIndex = Double.valueOf(prunedSize*Math.pow(MyRandom.getRandom().nextDouble(), 0.25)/2d).intValue();
|
||||
float rand = MyRandom.getRandom().nextFloat();
|
||||
if(rand>0.85f){
|
||||
T child = mutateObject(population.get(randomIndex));
|
||||
@@ -34,7 +34,7 @@ public abstract class AbstractGeneticAlgorithm<T> {
|
||||
}else if(rand>0.70f){
|
||||
int secondIndex = randomIndex;
|
||||
while(secondIndex != randomIndex){
|
||||
secondIndex = new Double(prunedSize*Math.pow(MyRandom.getRandom().nextDouble(), 0.25)/2d).intValue();
|
||||
secondIndex = Double.valueOf(prunedSize*Math.pow(MyRandom.getRandom().nextDouble(), 0.25)/2d).intValue();
|
||||
}
|
||||
T child = createChild(population.get(randomIndex)
|
||||
, population.get(secondIndex));
|
||||
|
||||
@@ -181,7 +181,7 @@ public class XmlReader {
|
||||
final T result;
|
||||
if (collectionToLoad == null) {
|
||||
try {
|
||||
result = collectionType.newInstance();
|
||||
result = collectionType.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user