mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Pass min/max through choice code so that user can't choose too many cards
This commit is contained in:
@@ -162,7 +162,7 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends GameEntity> List<T> chooseEntitiesForEffect(
|
public <T extends GameEntity> List<T> chooseEntitiesForEffect(
|
||||||
FCollectionView<T> optionList, DelayedReveal delayedReveal, SpellAbility sa, String title,
|
FCollectionView<T> optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title,
|
||||||
Player targetedPlayer) {
|
Player targetedPlayer) {
|
||||||
// this isn't used
|
// this isn't used
|
||||||
return null;
|
return null;
|
||||||
@@ -1090,7 +1090,7 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Card> chooseCardsForZoneChange(
|
public List<Card> chooseCardsForZoneChange(
|
||||||
ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList,
|
ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, int min, int max,
|
||||||
DelayedReveal delayedReveal, String selectPrompt, Player decider) {
|
DelayedReveal delayedReveal, String selectPrompt, Player decider) {
|
||||||
// this isn't used
|
// this isn't used
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -852,7 +852,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
// ensure that selection is within maximum allowed changeNum
|
// ensure that selection is within maximum allowed changeNum
|
||||||
do {
|
do {
|
||||||
selectedCards = decider.getController().chooseCardsForZoneChange(destination, origin, sa, fetchList, delayedReveal, selectPrompt, decider);
|
selectedCards = decider.getController().chooseCardsForZoneChange(destination, origin, sa, fetchList, 0, changeNum, delayedReveal, selectPrompt, decider);
|
||||||
} while (selectedCards != null && selectedCards.size() > changeNum);
|
} while (selectedCards != null && selectedCards.size() > changeNum);
|
||||||
if (selectedCards != null) {
|
if (selectedCards != null) {
|
||||||
for (Card card : selectedCards) {
|
for (Card card : selectedCards) {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public abstract class PlayerController {
|
|||||||
public abstract SpellAbility chooseSingleSpellForEffect(List<SpellAbility> spells, SpellAbility sa, String title,
|
public abstract SpellAbility chooseSingleSpellForEffect(List<SpellAbility> spells, SpellAbility sa, String title,
|
||||||
Map<String, Object> params);
|
Map<String, Object> params);
|
||||||
|
|
||||||
public abstract <T extends GameEntity> List<T> chooseEntitiesForEffect(FCollectionView<T> optionList, DelayedReveal delayedReveal, SpellAbility sa, String title, Player relatedPlayer);
|
public abstract <T extends GameEntity> List<T> chooseEntitiesForEffect(FCollectionView<T> optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title, Player relatedPlayer);
|
||||||
|
|
||||||
public abstract boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message);
|
public abstract boolean confirmAction(SpellAbility sa, PlayerActionConfirmMode mode, String message);
|
||||||
public abstract boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife, String string, int bid, Player winner);
|
public abstract boolean confirmBidAction(SpellAbility sa, PlayerActionConfirmMode bidlife, String string, int bid, Player winner);
|
||||||
@@ -239,7 +239,7 @@ public abstract class PlayerController {
|
|||||||
// better to have this odd method than those if playerType comparison in ChangeZone
|
// better to have this odd method than those if playerType comparison in ChangeZone
|
||||||
public abstract Card chooseSingleCardForZoneChange(ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, DelayedReveal delayedReveal, String selectPrompt, boolean isOptional, Player decider);
|
public abstract Card chooseSingleCardForZoneChange(ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, DelayedReveal delayedReveal, String selectPrompt, boolean isOptional, Player decider);
|
||||||
|
|
||||||
public abstract List<Card> chooseCardsForZoneChange(ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, DelayedReveal delayedReveal, String selectPrompt, Player decider);
|
public abstract List<Card> chooseCardsForZoneChange(ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, int min, int max, DelayedReveal delayedReveal, String selectPrompt, Player decider);
|
||||||
|
|
||||||
public abstract void autoPassCancel();
|
public abstract void autoPassCancel();
|
||||||
|
|
||||||
|
|||||||
@@ -996,11 +996,11 @@ public final class CMatchUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GameEntityView> chooseEntitiesForEffect(final String title, final List<? extends GameEntityView> optionList, final DelayedReveal delayedReveal) {
|
public List<GameEntityView> chooseEntitiesForEffect(final String title, final List<? extends GameEntityView> optionList, final int min, final int max, final DelayedReveal delayedReveal) {
|
||||||
if (delayedReveal != null) {
|
if (delayedReveal != null) {
|
||||||
reveal(delayedReveal.getMessagePrefix(), delayedReveal.getCards()); //TODO: Merge this into search dialog
|
reveal(delayedReveal.getMessagePrefix(), delayedReveal.getCards()); //TODO: Merge this into search dialog
|
||||||
}
|
}
|
||||||
return (List<GameEntityView>) order(title,"Selected", 0, optionList.size(), optionList, null, null, false);
|
return (List<GameEntityView>) order(title,"Selected", min, max, optionList, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ public class PlayerControllerForTests extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends GameEntity> List<T> chooseEntitiesForEffect(FCollectionView<T> optionList, DelayedReveal delayedReveal, SpellAbility sa, String title, Player relatedPlayer) {
|
public <T extends GameEntity> List<T> chooseEntitiesForEffect(FCollectionView<T> optionList, int min, int max, DelayedReveal delayedReveal, SpellAbility sa, String title, Player relatedPlayer) {
|
||||||
// this isn't used
|
// this isn't used
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,7 @@ public class PlayerControllerForTests extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Card> chooseCardsForZoneChange(ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, DelayedReveal delayedReveal, String selectPrompt, Player decider) {
|
public List<Card> chooseCardsForZoneChange(ZoneType destination, List<ZoneType> origin, SpellAbility sa, CardCollection fetchList, int min, int max, DelayedReveal delayedReveal, String selectPrompt, Player decider) {
|
||||||
// this isn't used
|
// this isn't used
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -516,8 +516,8 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GameEntityView> chooseEntitiesForEffect(String title, List<? extends GameEntityView> optionList, DelayedReveal delayedReveal) {
|
public List<GameEntityView> chooseEntitiesForEffect(String title, List<? extends GameEntityView> optionList, int min, int max, DelayedReveal delayedReveal) {
|
||||||
return SGuiChoose.order(title, "Selected", 0, -1, (List<GameEntityView>) optionList, null);
|
return SGuiChoose.order(title, "Selected", min, max, (List<GameEntityView>) optionList, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public interface IGuiGame {
|
|||||||
|
|
||||||
List<PaperCard> sideboard(CardPool sideboard, CardPool main);
|
List<PaperCard> sideboard(CardPool sideboard, CardPool main);
|
||||||
GameEntityView chooseSingleEntityForEffect(String title, List<? extends GameEntityView> optionList, DelayedReveal delayedReveal, boolean isOptional);
|
GameEntityView chooseSingleEntityForEffect(String title, List<? extends GameEntityView> optionList, DelayedReveal delayedReveal, boolean isOptional);
|
||||||
List<GameEntityView> chooseEntitiesForEffect(String title, List<? extends GameEntityView> optionList, DelayedReveal delayedReveal);
|
List<GameEntityView> chooseEntitiesForEffect(String title, List<? extends GameEntityView> optionList, int min, int max, DelayedReveal delayedReveal);
|
||||||
void setCard(CardView card);
|
void setCard(CardView card);
|
||||||
void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi);
|
void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi);
|
||||||
boolean openZones(Collection<ZoneType> zones, Map<PlayerView, Object> players);
|
boolean openZones(Collection<ZoneType> zones, Map<PlayerView, Object> players);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public enum ProtocolMethod {
|
|||||||
order (Mode.SERVER, List.class, String.class, String.class, Integer.TYPE, Integer.TYPE, List.class, List.class, CardView.class, Boolean.TYPE),
|
order (Mode.SERVER, List.class, String.class, String.class, Integer.TYPE, Integer.TYPE, List.class, List.class, CardView.class, Boolean.TYPE),
|
||||||
sideboard (Mode.SERVER, List.class, CardPool.class, CardPool.class),
|
sideboard (Mode.SERVER, List.class, CardPool.class, CardPool.class),
|
||||||
chooseSingleEntityForEffect(Mode.SERVER, GameEntityView.class, String.class, List.class, DelayedReveal.class, Boolean.TYPE),
|
chooseSingleEntityForEffect(Mode.SERVER, GameEntityView.class, String.class, List.class, DelayedReveal.class, Boolean.TYPE),
|
||||||
chooseEntitiesForEffect(Mode.SERVER, GameEntityView.class, String.class, List.class, DelayedReveal.class),
|
chooseEntitiesForEffect(Mode.SERVER, GameEntityView.class, String.class, List.class, Integer.TYPE, Integer.TYPE, DelayedReveal.class),
|
||||||
setCard (Mode.SERVER, Void.TYPE, CardView.class),
|
setCard (Mode.SERVER, Void.TYPE, CardView.class),
|
||||||
// TODO case "setPlayerAvatar":
|
// TODO case "setPlayerAvatar":
|
||||||
openZones (Mode.SERVER, Boolean.TYPE, Collection/*ZoneType*/.class, Map/*PlayerView,Object*/.class),
|
openZones (Mode.SERVER, Boolean.TYPE, Collection/*ZoneType*/.class, Map/*PlayerView,Object*/.class),
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ public class NetGuiGame extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GameEntityView> chooseEntitiesForEffect(final String title, final List<? extends GameEntityView> optionList, final DelayedReveal delayedReveal) {
|
public List<GameEntityView> chooseEntitiesForEffect(final String title, final List<? extends GameEntityView> optionList, final int min, final int max, final DelayedReveal delayedReveal) {
|
||||||
return sendAndWait(ProtocolMethod.chooseEntitiesForEffect, title, optionList, delayedReveal);
|
return sendAndWait(ProtocolMethod.chooseEntitiesForEffect, title, optionList, min, max, delayedReveal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T extends GameEntity> List<T> chooseEntitiesForEffect(final FCollectionView<T> optionList,
|
public <T extends GameEntity> List<T> chooseEntitiesForEffect(final FCollectionView<T> optionList, final int min, final int max,
|
||||||
final DelayedReveal delayedReveal, final SpellAbility sa, final String title, final Player targetedPlayer) {
|
final DelayedReveal delayedReveal, final SpellAbility sa, final String title, final Player targetedPlayer) {
|
||||||
|
|
||||||
// useful details for debugging problems with the mass select logic
|
// useful details for debugging problems with the mass select logic
|
||||||
@@ -483,7 +483,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
delayedReveal.getMessagePrefix());
|
delayedReveal.getMessagePrefix());
|
||||||
}
|
}
|
||||||
tempShow(optionList);
|
tempShow(optionList);
|
||||||
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, 0, optionList.size(),
|
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, min, max,
|
||||||
optionList, sa);
|
optionList, sa);
|
||||||
input.setCancelAllowed(true);
|
input.setCancelAllowed(true);
|
||||||
input.setMessage(MessageUtil.formatMessage(title, player, targetedPlayer));
|
input.setMessage(MessageUtil.formatMessage(title, player, targetedPlayer));
|
||||||
@@ -497,7 +497,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
tempShow(delayedReveal.getCards());
|
tempShow(delayedReveal.getCards());
|
||||||
}
|
}
|
||||||
final List<GameEntityView> chosen = getGui().chooseEntitiesForEffect(title,
|
final List<GameEntityView> chosen = getGui().chooseEntitiesForEffect(title,
|
||||||
GameEntityView.getEntityCollection(optionList), delayedReveal);
|
GameEntityView.getEntityCollection(optionList), min, max, delayedReveal);
|
||||||
endTempShowCards();
|
endTempShowCards();
|
||||||
|
|
||||||
List<T> results = new ArrayList<>();
|
List<T> results = new ArrayList<>();
|
||||||
@@ -1780,9 +1780,9 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Card> chooseCardsForZoneChange(final ZoneType destination, final List<ZoneType> origin,
|
public List<Card> chooseCardsForZoneChange(final ZoneType destination, final List<ZoneType> origin,
|
||||||
final SpellAbility sa, final CardCollection fetchList, final DelayedReveal delayedReveal,
|
final SpellAbility sa, final CardCollection fetchList, final int min, final int max, final DelayedReveal delayedReveal,
|
||||||
final String selectPrompt, final Player decider) {
|
final String selectPrompt, final Player decider) {
|
||||||
return chooseEntitiesForEffect(fetchList, delayedReveal, sa, selectPrompt, decider);
|
return chooseEntitiesForEffect(fetchList, min, max, delayedReveal, sa, selectPrompt, decider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user