mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
use Iterators instead of Lists where possible in manipulateCardList
This commit is contained in:
@@ -285,7 +285,7 @@ public class GuiChoose {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<CardView> manipulateCardList(final CMatchUI gui, final String title, final List<CardView> cards, final List<CardView> manipulable,
|
public static List<CardView> manipulateCardList(final CMatchUI gui, final String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable,
|
||||||
final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
||||||
final Callable<List<CardView>> callable = new Callable<List<CardView>>() {
|
final Callable<List<CardView>> callable = new Callable<List<CardView>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1004,7 +1004,7 @@ public final class CMatchUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CardView> manipulateCardList(final String title, final List<CardView> cards, final List<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
public List<CardView> manipulateCardList(final String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
||||||
return GuiChoose.manipulateCardList(this, title, cards, manipulable, toTop, toBottom, toAnywhere);
|
return GuiChoose.manipulateCardList(this, title, cards, manipulable, toTop, toBottom, toAnywhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,11 +59,12 @@ public class ListCardArea extends FloatingCardArea {
|
|||||||
setOpaque(false);
|
setOpaque(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ListCardArea show(final CMatchUI matchUI, final String title0, final List<CardView> cardList0, final List<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) {
|
public static ListCardArea show(final CMatchUI matchUI, final String title0, final Iterable<CardView> cardList0, final Iterable<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) {
|
||||||
if (storedArea==null) {
|
if (storedArea==null) {
|
||||||
storedArea = new ListCardArea(matchUI);
|
storedArea = new ListCardArea(matchUI);
|
||||||
}
|
}
|
||||||
cardList = new ArrayList<CardView>(cardList0);
|
cardList = new ArrayList<CardView>();
|
||||||
|
for ( CardView cv : cardList0 ) { cardList.add(cv) ; }
|
||||||
moveableCards = new ArrayList<CardView>(); // make sure moveable cards are in cardlist
|
moveableCards = new ArrayList<CardView>(); // make sure moveable cards are in cardlist
|
||||||
for ( CardView card : moveableCards0 ) {
|
for ( CardView card : moveableCards0 ) {
|
||||||
if ( cardList.contains(card) ) {
|
if ( cardList.contains(card) ) {
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CardView> manipulateCardList(final String title, final List<CardView> cards, final List<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
public List<CardView> manipulateCardList(final String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
||||||
System.err.println("Not implemented yet - should never be called");
|
System.err.println("Not implemented yet - should never be called");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public interface IGuiGame {
|
|||||||
List<GameEntityView> chooseEntitiesForEffect(String title, List<? extends GameEntityView> optionList, int min, int max, DelayedReveal delayedReveal);
|
List<GameEntityView> chooseEntitiesForEffect(String title, List<? extends GameEntityView> optionList, int min, int max, DelayedReveal delayedReveal);
|
||||||
|
|
||||||
// show a list of cards and allow some of them to be moved around and return new list
|
// show a list of cards and allow some of them to be moved around and return new list
|
||||||
List<CardView> manipulateCardList(String title, final List<CardView> cards, final List<CardView> manipulable, boolean toTop, boolean toBottom, boolean toAnywhere);
|
List<CardView> manipulateCardList(String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable, boolean toTop, boolean toBottom, boolean toAnywhere);
|
||||||
|
|
||||||
void setCard(CardView card);
|
void setCard(CardView card);
|
||||||
void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi);
|
void setPlayerAvatar(LobbyPlayer player, IHasIcon ihi);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public enum ProtocolMethod {
|
|||||||
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, Integer.TYPE, Integer.TYPE, DelayedReveal.class),
|
chooseEntitiesForEffect(Mode.SERVER, GameEntityView.class, String.class, List.class, Integer.TYPE, Integer.TYPE, DelayedReveal.class),
|
||||||
manipulateCardList (Mode.SERVER, List.class, String.class, List.class, List.class, Boolean.TYPE, Boolean.TYPE, Boolean.TYPE),
|
manipulateCardList (Mode.SERVER, List.class, String.class, Iterable.class, Iterable.class, Boolean.TYPE, Boolean.TYPE, Boolean.TYPE),
|
||||||
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),
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ public class NetGuiGame extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CardView> manipulateCardList(final String title, final List<CardView> cards, final List<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
public List<CardView> manipulateCardList(final String title, final Iterable<CardView> cards, final Iterable<CardView> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
||||||
return sendAndWait(ProtocolMethod.manipulateCardList, title, cards, manipulable, toTop, toBottom, toAnywhere);
|
return sendAndWait(ProtocolMethod.manipulateCardList, title, cards, manipulable, toTop, toBottom, toAnywhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -737,25 +737,12 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Card> manipulateCardList(final String title, final List<Card> cards, final List<Card> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
public List<Card> manipulateCardList(final String title, final Iterable<Card> cards, final Iterable<Card> manipulable, final boolean toTop, final boolean toBottom, final boolean toAnywhere) {
|
||||||
ArrayList<CardView> cardViews = new ArrayList<CardView>();
|
Iterable<CardView> result = getGui().manipulateCardList(title, CardView.getCollection(cards), CardView.getCollection(manipulable), toTop, toBottom, toAnywhere);
|
||||||
for ( Card c : cards ) { cardViews.add(c.getView()); }
|
return game.getCardList(result);
|
||||||
ArrayList<CardView> manipulableViews = new ArrayList<CardView>();
|
|
||||||
for ( Card c : manipulable ) { manipulableViews.add(c.getView()); }
|
|
||||||
Iterable<CardView> result = getGui().manipulateCardList(title, cardViews, manipulableViews, toTop, toBottom, toAnywhere);
|
|
||||||
List<Card> resultCards = new ArrayList<Card>();
|
|
||||||
for ( CardView cv : result ) {
|
|
||||||
for ( Card card : cards ) {
|
|
||||||
if ( cv == card.getView() ) {
|
|
||||||
resultCards.add(card);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resultCards;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutablePair<CardCollection, CardCollection> arrangeForMove(final String title, final List<Card> cards, final List<Card> manipulable, final boolean topOK, final boolean bottomOK) {
|
public ImmutablePair<CardCollection, CardCollection> arrangeForMove(final String title, final FCollectionView<Card> cards, final List<Card> manipulable, final boolean topOK, final boolean bottomOK) {
|
||||||
List<Card> result = manipulateCardList("Move cards to top or bottom of library", cards, manipulable, topOK, bottomOK, false);
|
List<Card> result = manipulateCardList("Move cards to top or bottom of library", cards, manipulable, topOK, bottomOK, false);
|
||||||
CardCollection toBottom = new CardCollection();
|
CardCollection toBottom = new CardCollection();
|
||||||
CardCollection toTop = new CardCollection();
|
CardCollection toTop = new CardCollection();
|
||||||
@@ -778,10 +765,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
tempShowCards(topN);
|
tempShowCards(topN);
|
||||||
if ( FModel.getPreferences().getPrefBoolean(FPref.UI_SELECT_FROM_CARD_DISPLAYS) &&
|
if ( FModel.getPreferences().getPrefBoolean(FPref.UI_SELECT_FROM_CARD_DISPLAYS) &&
|
||||||
(!GuiBase.getInterface().isLibgdxPort()) ) {
|
(!GuiBase.getInterface().isLibgdxPort()) ) {
|
||||||
ArrayList<Card> cardList = new ArrayList<Card>(); // pfps there must be a better way
|
CardCollectionView cardList = player.getCardsIn(ZoneType.Library);
|
||||||
for (final Card card : player.getCardsIn(ZoneType.Library)) {
|
|
||||||
cardList.add(card);
|
|
||||||
}
|
|
||||||
ImmutablePair<CardCollection, CardCollection> result =
|
ImmutablePair<CardCollection, CardCollection> result =
|
||||||
arrangeForMove("Move cards to top or bottom of library", cardList, topN, true, true);
|
arrangeForMove("Move cards to top or bottom of library", cardList, topN, true, true);
|
||||||
toTop = result.getLeft();
|
toTop = result.getLeft();
|
||||||
|
|||||||
Reference in New Issue
Block a user