allow human players to make mass select, sometimes

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
Jamin W. Collins
2018-03-10 14:43:42 -07:00
parent 876083b085
commit a564f49381
10 changed files with 199 additions and 58 deletions

View File

@@ -143,7 +143,9 @@ public interface IGuiGame {
<T> List<T> insertInList(String title, T newItem, List<T> oldItems);
List<PaperCard> sideboard(CardPool sideboard, CardPool main);
GameEntityView chooseSingleEntityForEffect(String title, List<? extends GameEntityView> optionList, DelayedReveal delayedReveal, boolean isOptional); void setCard(CardView card);
GameEntityView chooseSingleEntityForEffect(String title, List<? extends GameEntityView> optionList, DelayedReveal delayedReveal, boolean isOptional);
List<GameEntityView> chooseEntitiesForEffect(String title, List<? extends GameEntityView> optionList, DelayedReveal delayedReveal);
void setCard(CardView card);
void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi);
boolean openZones(Collection<ZoneType> zones, Map<PlayerView, Object> players);
void restoreOldZones(Map<PlayerView, Object> playersToRestoreZonesFor);

View File

@@ -62,6 +62,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),
sideboard (Mode.SERVER, List.class, CardPool.class, CardPool.class),
chooseSingleEntityForEffect(Mode.SERVER, GameEntityView.class, String.class, List.class, DelayedReveal.class, Boolean.TYPE),
chooseEntitiesForEffect(Mode.SERVER, GameEntityView.class, String.class, List.class, DelayedReveal.class),
setCard (Mode.SERVER, Void.TYPE, CardView.class),
// TODO case "setPlayerAvatar":
openZones (Mode.SERVER, Boolean.TYPE, Collection/*ZoneType*/.class, Map/*PlayerView,Object*/.class),

View File

@@ -231,6 +231,11 @@ public class NetGuiGame extends AbstractGuiGame {
return sendAndWait(ProtocolMethod.chooseSingleEntityForEffect, title, optionList, delayedReveal, isOptional);
}
@Override
public List<GameEntityView> chooseEntitiesForEffect(final String title, final List<? extends GameEntityView> optionList, final DelayedReveal delayedReveal) {
return sendAndWait(ProtocolMethod.chooseEntitiesForEffect, title, optionList, delayedReveal);
}
@Override
public void setCard(final CardView card) {
updateGameView();

View File

@@ -453,6 +453,70 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return null;
}
@SuppressWarnings("unchecked")
@Override
public <T extends GameEntity> List<T> chooseEntitiesForEffect(final FCollectionView<T> optionList,
final DelayedReveal delayedReveal, final SpellAbility sa, final String title, final Player targetedPlayer) {
// Human is supposed to read the message and understand from it what to
// choose
if (optionList.isEmpty()) {
if (delayedReveal != null) {
reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(),
delayedReveal.getMessagePrefix());
}
return null;
}
boolean canUseSelectCardsInput = true;
for (final GameEntity c : optionList) {
if (c instanceof Player) {
continue;
}
final Zone cz = ((Card) c).getZone();
// can point at cards in own hand and anyone's battlefield
final boolean canUiPointAtCards = cz != null
&& (cz.is(ZoneType.Hand) && cz.getPlayer() == player || cz.is(ZoneType.Battlefield));
if (!canUiPointAtCards) {
canUseSelectCardsInput = false;
break;
}
}
if (canUseSelectCardsInput) {
if (delayedReveal != null) {
reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(),
delayedReveal.getMessagePrefix());
}
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, 0, optionList.size(),
optionList, sa);
input.setCancelAllowed(true);
input.setMessage(MessageUtil.formatMessage(title, player, targetedPlayer));
input.showAndWait();
return (List<T>) Iterables.getFirst(input.getSelected(), null);
}
tempShow(optionList);
if (delayedReveal != null) {
tempShow(delayedReveal.getCards());
}
final List<GameEntityView> chosen = getGui().chooseEntitiesForEffect(title,
GameEntityView.getEntityCollection(optionList), delayedReveal);
endTempShowCards();
List<T> results = new ArrayList<>();
if (chosen instanceof List && chosen.size() > 0) {
for (GameEntityView entry: chosen) {
if (entry instanceof CardView) {
results.add((T)game.getCard((CardView) entry));
}
if (entry instanceof PlayerView) {
results.add((T)game.getPlayer((PlayerView) entry));
}
}
}
return results;
}
@Override
public int chooseNumber(final SpellAbility sa, final String title, final int min, final int max) {
if (min >= max) {
@@ -1633,6 +1697,12 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return chooseSingleEntityForEffect(fetchList, delayedReveal, sa, selectPrompt, isOptional, decider);
}
public List<Card> chooseCardsForZoneChange(final ZoneType destination, final List<ZoneType> origin,
final SpellAbility sa, final CardCollection fetchList, final DelayedReveal delayedReveal,
final String selectPrompt, final Player decider) {
return chooseEntitiesForEffect(fetchList, delayedReveal, sa, selectPrompt, decider);
}
@Override
public boolean isGuiPlayer() {
return lobbyPlayer == GamePlayerUtil.getGuiPlayer();