mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
renamed input classes, used a common branch in modular
This commit is contained in:
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -13832,8 +13832,8 @@ src/main/java/forge/control/input/InputPayManaX.java -text
|
|||||||
src/main/java/forge/control/input/InputPayment.java -text
|
src/main/java/forge/control/input/InputPayment.java -text
|
||||||
src/main/java/forge/control/input/InputSelectCards.java -text
|
src/main/java/forge/control/input/InputSelectCards.java -text
|
||||||
src/main/java/forge/control/input/InputSelectCardsFromList.java -text
|
src/main/java/forge/control/input/InputSelectCardsFromList.java -text
|
||||||
src/main/java/forge/control/input/InputSelectList.java -text
|
src/main/java/forge/control/input/InputSelectMany.java -text
|
||||||
src/main/java/forge/control/input/InputSelectListBase.java -text
|
src/main/java/forge/control/input/InputSelectManyBase.java -text
|
||||||
src/main/java/forge/control/input/InputSynchronized.java -text
|
src/main/java/forge/control/input/InputSynchronized.java -text
|
||||||
src/main/java/forge/control/input/InputSyncronizedBase.java -text
|
src/main/java/forge/control/input/InputSyncronizedBase.java -text
|
||||||
src/main/java/forge/control/input/package-info.java svneol=native#text/plain
|
src/main/java/forge/control/input/package-info.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import forge.card.trigger.TriggerHandler;
|
|||||||
import forge.card.trigger.TriggerType;
|
import forge.card.trigger.TriggerType;
|
||||||
import forge.control.input.InputBase;
|
import forge.control.input.InputBase;
|
||||||
import forge.control.input.InputSelectCards;
|
import forge.control.input.InputSelectCards;
|
||||||
|
import forge.control.input.InputSelectCardsFromList;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.ai.ComputerUtil;
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.ai.ComputerUtilCard;
|
import forge.game.ai.ComputerUtilCard;
|
||||||
@@ -3555,42 +3556,33 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
final Player modularPlayer = card.getController();
|
||||||
|
final List<Card> choices = Lists.newArrayList();
|
||||||
|
for(Card c : modularPlayer.getGame().getCardsIn(ZoneType.Battlefield)) {
|
||||||
|
if( c.isCreature() && c.isArtifact() && c.canBeTargetedBy(ability))
|
||||||
|
choices.add(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
Card card2 = null;
|
||||||
// Target as Modular is Destroyed
|
// Target as Modular is Destroyed
|
||||||
if (card.getController().isComputer()) {
|
if (modularPlayer.isComputer()) {
|
||||||
List<Card> choices =
|
final List<Card> aiChoices = CardLists.filterControlledBy(choices, modularPlayer);
|
||||||
CardLists.filter(card.getController().getCardsIn(ZoneType.Battlefield), new Predicate<Card>() {
|
if (!aiChoices.isEmpty()) {
|
||||||
@Override
|
card2 = ComputerUtilCard.getBestCreatureAI(aiChoices);
|
||||||
public boolean apply(final Card c) {
|
|
||||||
return c.isCreature() && c.isArtifact();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (choices.size() != 0) {
|
|
||||||
ability.setTargetCard(ComputerUtilCard.getBestCreatureAI(choices));
|
|
||||||
|
|
||||||
if (ability.getTargetCard() != null) {
|
|
||||||
ability.setStackDescription("Put " + card.getCounters(CounterType.P1P1)
|
|
||||||
+ " +1/+1 counter/s from " + card + " on " + ability.getTargetCard());
|
|
||||||
Singletons.getModel().getGame().getStack().addSimultaneousStackEntry(ability);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
InputSelectCards inp = new InputSelectCards(1,1) {
|
InputSelectCards inp = new InputSelectCardsFromList(0, 1, choices);
|
||||||
private static final long serialVersionUID = -7895723996302990127L;
|
inp.setMessage("Select target artifact creature to put +1/+1 counter on it");
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isValidChoice(Card card2) {
|
|
||||||
return card2.isCreature() && card2.isArtifact() && card.isInPlay() && card.canBeTargetedBy(ability);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
FThreads.setInputAndWait(inp);
|
FThreads.setInputAndWait(inp);
|
||||||
if( !inp.hasCancelled() ) {
|
if( !inp.hasCancelled() ) {
|
||||||
Card card2 = inp.getSelected().get(0);
|
card2 = inp.getSelected().get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
ability.setTargetCard(card2);
|
ability.setTargetCard(card2);
|
||||||
|
if ( null != card2 ) {
|
||||||
String desc = String.format("Put %d +1/+1 counter/s from %s on %s", card.getCounters(CounterType.P1P1), card, card2);
|
String desc = String.format("Put %d +1/+1 counter/s from %s on %s", card.getCounters(CounterType.P1P1), card, card2);
|
||||||
ability.setStackDescription(desc);
|
ability.setStackDescription(desc);
|
||||||
Singletons.getModel().getGame().getStack().add(ability);
|
modularPlayer.getGame().getStack().addSimultaneousStackEntry(ability);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class TargetSelection {
|
|||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
sb.append(tgt.getVTSelection());
|
sb.append(tgt.getVTSelection());
|
||||||
|
|
||||||
CMatchUI.SINGLETON_INSTANCE.showMessage(sb.toString());
|
showMessage(sb.toString());
|
||||||
|
|
||||||
// If reached Minimum targets, enable OK button
|
// If reached Minimum targets, enable OK button
|
||||||
if (!tgt.isMinTargetsChosen(sa.getSourceCard(), sa) || tgt.isDividedAsYouChoose()) {
|
if (!tgt.isMinTargetsChosen(sa.getSourceCard(), sa) || tgt.isDividedAsYouChoose()) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package forge.control.input;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
|
||||||
public abstract class InputSelectCards extends InputSelectListBase<Card> {
|
public abstract class InputSelectCards extends InputSelectManyBase<Card> {
|
||||||
private static final long serialVersionUID = -6609493252672573139L;
|
private static final long serialVersionUID = -6609493252672573139L;
|
||||||
|
|
||||||
protected InputSelectCards(int min, int max) {
|
protected InputSelectCards(int min, int max) {
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ public class InputSelectCardsFromList extends InputSelectCards {
|
|||||||
public InputSelectCardsFromList(int min, int max, List<Card> validCards) {
|
public InputSelectCardsFromList(int min, int max, List<Card> validCards) {
|
||||||
super(min, Math.min(max, validCards.size())); // to avoid hangs
|
super(min, Math.min(max, validCards.size())); // to avoid hangs
|
||||||
this.validChoices = validCards;
|
this.validChoices = validCards;
|
||||||
|
|
||||||
|
if ( min > validCards.size() )
|
||||||
|
throw new RuntimeException(String.format("Trying to choose at least %d cards from a list with only %d cards!", min, validCards.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
* TODO: Write javadoc for this type.
|
* TODO: Write javadoc for this type.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface InputSelectList<T> extends InputSynchronized {
|
public interface InputSelectMany<T> extends InputSynchronized {
|
||||||
boolean hasCancelled();
|
boolean hasCancelled();
|
||||||
List<T> getSelected();
|
List<T> getSelected();
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import forge.GameEntity;
|
|||||||
import forge.gui.match.CMatchUI;
|
import forge.gui.match.CMatchUI;
|
||||||
import forge.view.ButtonUtil;
|
import forge.view.ButtonUtil;
|
||||||
|
|
||||||
public abstract class InputSelectListBase<T extends GameEntity> extends InputSyncronizedBase implements InputSelectList<T> {
|
public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyncronizedBase implements InputSelectMany<T> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2305549394512889450L;
|
private static final long serialVersionUID = -2305549394512889450L;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ public abstract class InputSelectListBase<T extends GameEntity> extends InputSyn
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected InputSelectListBase(int min, int max) {
|
protected InputSelectManyBase(int min, int max) {
|
||||||
selected = new ArrayList<T>();
|
selected = new ArrayList<T>();
|
||||||
if (min > max) {
|
if (min > max) {
|
||||||
throw new IllegalArgumentException("Min must not be greater than Max");
|
throw new IllegalArgumentException("Min must not be greater than Max");
|
||||||
@@ -82,10 +82,6 @@ public abstract class InputSelectListBase<T extends GameEntity> extends InputSyn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void selectButtonOK() {
|
public final void selectButtonOK() {
|
||||||
// should check here if it still gets into an infinite loop
|
|
||||||
// if an ability is put on stack before this input is stopped;
|
|
||||||
// if it does, uncomment the 5 lines below, use them as method body
|
|
||||||
|
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user