mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
some more gui calls gone
This commit is contained in:
@@ -144,7 +144,7 @@ public abstract class SpellAbilityAi extends SaTargetRoutines {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
System.err.println("Warning: default (ie. inherited from base class) implementation of chooseSingleCard is used for " + this.getClass().getName() + ". Consider declaring an overloaded method");
|
System.err.println("Warning: default (ie. inherited from base class) implementation of chooseSingleCard is used for " + this.getClass().getName() + ". Consider declaring an overloaded method");
|
||||||
return Iterables.getFirst(options, null);
|
return Iterables.getFirst(options, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1234,7 +1234,7 @@ public class AttachAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
return attachToCardAIPreferences(ai, sa, true);
|
return attachToCardAIPreferences(ai, sa, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public final class BondAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
return ComputerUtilCard.getBestCreatureAI(options);
|
return ComputerUtilCard.getBestCreatureAI(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1430,7 +1430,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
// Called when looking for creature to attach aura or equipment
|
// Called when looking for creature to attach aura or equipment
|
||||||
return ComputerUtilCard.getBestAI(options);
|
return ComputerUtilCard.getBestAI(options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class ChooseCardAi extends SpellAbilityAi {
|
|||||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.card.spellability.SpellAbility, java.util.List, boolean)
|
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
final Card host = sa.getSourceCard();
|
final Card host = sa.getSourceCard();
|
||||||
final String logic = sa.getParam("AILogic");
|
final String logic = sa.getParam("AILogic");
|
||||||
Card choice = null;
|
Card choice = null;
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(final Player aiChoser, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
if ("NeedsPrevention".equals(sa.getParam("AILogic"))) {
|
if ("NeedsPrevention".equals(sa.getParam("AILogic"))) {
|
||||||
final Player ai = sa.getActivatingPlayer();
|
final Player ai = sa.getActivatingPlayer();
|
||||||
final Game game = ai.getGame();
|
final Game game = ai.getGame();
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class CopyPermanentAi extends SpellAbilityAi {
|
|||||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
// Select a card to attach to
|
// Select a card to attach to
|
||||||
return ComputerUtilCard.getBestAI(options);
|
return ComputerUtilCard.getBestAI(options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package forge.ai.ability;
|
package forge.ai.ability;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import forge.ai.ComputerUtil;
|
import forge.ai.ComputerUtil;
|
||||||
|
import forge.ai.ComputerUtilCard;
|
||||||
import forge.ai.SpellAbilityAi;
|
import forge.ai.SpellAbilityAi;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
@@ -79,6 +81,15 @@ public class DigAi extends SpellAbilityAi {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> valid, boolean isOptional, Player relatedPlayer) {
|
||||||
|
Card chosen = ComputerUtilCard.getBestAI(valid);
|
||||||
|
if (sa.getActivatingPlayer().isOpponentOf(ai) && relatedPlayer.isOpponentOf(ai)) {
|
||||||
|
return ComputerUtilCard.getWorstAI(valid);
|
||||||
|
}
|
||||||
|
return chosen;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
|
* @see forge.card.ability.SpellAbilityAi#confirmAction(forge.card.spellability.SpellAbility, forge.game.player.PlayerActionConfirmMode, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public final class EncodeAi extends SpellAbilityAi {
|
|||||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
Card choice = null;
|
Card choice = null;
|
||||||
// final String logic = sa.getParam("AILogic");
|
// final String logic = sa.getParam("AILogic");
|
||||||
// if (logic == null) {
|
// if (logic == null) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class LegendaryRuleAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
// Choose a single legendary/planeswalker card to keep
|
// Choose a single legendary/planeswalker card to keep
|
||||||
Card firstOption = Iterables.getFirst(options, null);
|
Card firstOption = Iterables.getFirst(options, null);
|
||||||
boolean choosingFromPlanewalkers = firstOption.isPlaneswalker();
|
boolean choosingFromPlanewalkers = firstOption.isPlaneswalker();
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class PlayAi extends SpellAbilityAi {
|
|||||||
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
* @see forge.card.ability.SpellAbilityAi#chooseSingleCard(forge.game.player.Player, forge.card.spellability.SpellAbility, java.util.List, boolean)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional) {
|
public Card chooseSingleCard(final Player ai, SpellAbility sa, Collection<Card> options, boolean isOptional, Player targetedPlayer) {
|
||||||
List<Card> tgtCards = CardLists.filter(options, new Predicate<Card>() {
|
List<Card> tgtCards = CardLists.filter(options, new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(final Card c) {
|
public boolean apply(final Card c) {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import forge.game.spellability.SpellAbility;
|
|||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiChoose;
|
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
@@ -124,7 +123,7 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
hasRevealed = p.getController().confirmAction(sa, null, question);
|
hasRevealed = p.getController().confirmAction(sa, null, question);
|
||||||
if ( hasRevealed )
|
if ( hasRevealed )
|
||||||
p.getGame().getAction().reveal(top, p);
|
game.getAction().reveal(top, p);
|
||||||
|
|
||||||
} else if (sa.hasParam("RevealValid")) {
|
} else if (sa.hasParam("RevealValid")) {
|
||||||
final String revealValid = sa.getParam("RevealValid");
|
final String revealValid = sa.getParam("RevealValid");
|
||||||
@@ -187,17 +186,7 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
prompt = "Leave which card on top of the ";
|
prompt = "Leave which card on top of the ";
|
||||||
}
|
}
|
||||||
|
|
||||||
Card chosen = null;
|
Card chosen = choser.getController().chooseSingleCardForEffect(valid, sa, prompt + destZone2, false, p);
|
||||||
if (choser.isHuman()) {
|
|
||||||
|
|
||||||
|
|
||||||
chosen = GuiChoose.one(prompt + destZone2, valid);
|
|
||||||
} else { // Computer
|
|
||||||
chosen = ComputerUtilCard.getBestAI(valid);
|
|
||||||
if (sa.getActivatingPlayer().isOpponentOf(choser) && p.isOpponentOf(choser)) {
|
|
||||||
chosen = ComputerUtilCard.getWorstAI(valid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
movedCards.remove(chosen);
|
movedCards.remove(chosen);
|
||||||
if (sa.hasParam("RandomOrder")) {
|
if (sa.hasParam("RandomOrder")) {
|
||||||
final Random random = MyRandom.getRandom();
|
final Random random = MyRandom.getRandom();
|
||||||
@@ -205,6 +194,14 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
String prompt = "Choose a card to put into the ";
|
||||||
|
if (destZone1.equals(ZoneType.Library) && libraryPosition == -1) {
|
||||||
|
prompt = "Chose a card to put on the bottom of the ";
|
||||||
|
}
|
||||||
|
if (destZone1.equals(ZoneType.Library) && libraryPosition == 0) {
|
||||||
|
prompt = "Chose a card to put on top of the ";
|
||||||
|
}
|
||||||
|
|
||||||
if (choser.isHuman()) {
|
if (choser.isHuman()) {
|
||||||
while ((j < destZone1ChangeNum) || (anyNumber && (j < numToDig))) {
|
while ((j < destZone1ChangeNum) || (anyNumber && (j < numToDig))) {
|
||||||
// let user get choice
|
// let user get choice
|
||||||
@@ -212,13 +209,7 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Card chosen = null;
|
Card chosen = null;
|
||||||
String prompt = "Choose a card to put into the ";
|
|
||||||
if (destZone1.equals(ZoneType.Library) && (libraryPosition == -1)) {
|
|
||||||
prompt = "Chose a card to put on the bottom of the ";
|
|
||||||
}
|
|
||||||
if (destZone1.equals(ZoneType.Library) && (libraryPosition == 0)) {
|
|
||||||
prompt = "Chose a card to put on top of the ";
|
|
||||||
}
|
|
||||||
|
|
||||||
chosen = choser.getController().chooseSingleCardForEffect(valid, sa, prompt, anyNumber || optional);
|
chosen = choser.getController().chooseSingleCardForEffect(valid, sa, prompt, anyNumber || optional);
|
||||||
if ((chosen == null) || chosen.getName().equals("[No valid cards]")) {
|
if ((chosen == null) || chosen.getName().equals("[No valid cards]")) {
|
||||||
@@ -234,8 +225,6 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
valid.removeAll(andOrCards);
|
valid.removeAll(andOrCards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Singletons.getModel().getGameAction().revealToComputer()
|
|
||||||
// - for when this exists
|
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
} // human
|
} // human
|
||||||
@@ -252,9 +241,6 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
if (chosen == null) {
|
if (chosen == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (changeValid.length() > 0) {
|
|
||||||
GuiChoose.show("Computer picked: ", chosen);
|
|
||||||
}
|
|
||||||
movedCards.add(chosen);
|
movedCards.add(chosen);
|
||||||
valid.remove(chosen);
|
valid.remove(chosen);
|
||||||
if (!andOrValid.equals("")) {
|
if (!andOrValid.equals("")) {
|
||||||
@@ -267,6 +253,9 @@ public class DigEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (changeValid.length() > 0) {
|
||||||
|
game.getAction().reveal(choser + " picked:", movedCards, choser, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sa.hasParam("ForgetOtherRemembered")) {
|
if (sa.hasParam("ForgetOtherRemembered")) {
|
||||||
host.clearRemembered();
|
host.clearRemembered();
|
||||||
|
|||||||
@@ -132,8 +132,9 @@ public abstract class PlayerController {
|
|||||||
public abstract Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility sa, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets);
|
public abstract Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility sa, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets);
|
||||||
|
|
||||||
public abstract List<Card> chooseCardsForEffect(List<Card> sourceList, SpellAbility sa, String title, int amount, boolean isOptional);
|
public abstract List<Card> chooseCardsForEffect(List<Card> sourceList, SpellAbility sa, String title, int amount, boolean isOptional);
|
||||||
public Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title) { return chooseSingleCardForEffect(sourceList, sa, title, false); }
|
public final Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title) { return chooseSingleCardForEffect(sourceList, sa, title, false, null); }
|
||||||
public abstract Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title, boolean isOptional);
|
public final Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title, boolean isOptional) { return chooseSingleCardForEffect(sourceList, sa, title, isOptional, null); }
|
||||||
|
public abstract Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title, boolean isOptional, Player relatedPlayer);
|
||||||
public abstract Player chooseSinglePlayerForEffect(List<Player> options, SpellAbility sa, String title);
|
public abstract Player chooseSinglePlayerForEffect(List<Player> options, SpellAbility sa, String title);
|
||||||
public abstract SpellAbility chooseSingleSpellForEffect(List<SpellAbility> spells, SpellAbility sa, String title);
|
public abstract SpellAbility chooseSingleSpellForEffect(List<SpellAbility> spells, SpellAbility sa, String title);
|
||||||
|
|
||||||
|
|||||||
@@ -144,12 +144,12 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCardForEffect(Collection<Card> options, SpellAbility sa, String title, boolean isOptional) {
|
public Card chooseSingleCardForEffect(Collection<Card> options, SpellAbility sa, String title, boolean isOptional, Player targetedPlayer) {
|
||||||
ApiType api = sa.getApi();
|
ApiType api = sa.getApi();
|
||||||
if (null == api) {
|
if (null == api) {
|
||||||
throw new InvalidParameterException("SA is not api-based, this is not supported yet");
|
throw new InvalidParameterException("SA is not api-based, this is not supported yet");
|
||||||
}
|
}
|
||||||
return api.getAi().chooseSingleCard(player, sa, options, isOptional);
|
return api.getAi().chooseSingleCard(player, sa, options, isOptional, targetedPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCardForEffect(Collection<Card> options, SpellAbility sa, String title, boolean isOptional) {
|
public Card chooseSingleCardForEffect(Collection<Card> options, SpellAbility sa, String title, boolean isOptional, Player targetedPlayer) {
|
||||||
// Human is supposed to read the message and understand from it what to choose
|
// Human is supposed to read the message and understand from it what to choose
|
||||||
if (options.isEmpty()) {
|
if (options.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class PlayerControllerForTests extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title, boolean isOptional) {
|
public Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title, boolean isOptional, Player targetedPlayer) {
|
||||||
return chooseItem(sourceList);
|
return chooseItem(sourceList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user