mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
* caching implementation CardPrinted.getMatchingForgeCard replaces toForgeCard without parameters.
This commit is contained in:
@@ -228,18 +228,7 @@ public class GameNew {
|
|||||||
int hand = p.getValue().getStartingHand();
|
int hand = p.getValue().getStartingHand();
|
||||||
player.setMaxHandSize(hand);
|
player.setMaxHandSize(hand);
|
||||||
player.setStartingHandSize(hand);
|
player.setStartingHandSize(hand);
|
||||||
// what if I call it for AI player?
|
putCardsOnBattlefield(player, p.getValue().getCardsOnBattlefield(player));
|
||||||
PlayerZone bf = player.getZone(ZoneType.Battlefield);
|
|
||||||
Iterable<Card> onTable = p.getValue().getCardsOnBattlefield();
|
|
||||||
if (onTable != null) {
|
|
||||||
for (final Card c : onTable) {
|
|
||||||
c.setOwner(player);
|
|
||||||
bf.add(c, false);
|
|
||||||
c.setSickness(true);
|
|
||||||
c.setStartsGameInPlay(true);
|
|
||||||
c.refreshUniqueNumber();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerZone com = player.getZone(ZoneType.Command);
|
PlayerZone com = player.getZone(ZoneType.Command);
|
||||||
Iterable<Card> inCommand = p.getValue().getCardsInCommand(player);
|
Iterable<Card> inCommand = p.getValue().getCardsInCommand(player);
|
||||||
@@ -267,7 +256,7 @@ public class GameNew {
|
|||||||
|
|
||||||
prepareSingleLibrary(player, toUse, removedAnteCards, rAICards, canRandomFoil);
|
prepareSingleLibrary(player, toUse, removedAnteCards, rAICards, canRandomFoil);
|
||||||
player.updateObservers();
|
player.updateObservers();
|
||||||
bf.updateObservers();
|
player.getZone(ZoneType.Battlefield).updateObservers();
|
||||||
player.getZone(ZoneType.Hand).updateObservers();
|
player.getZone(ZoneType.Hand).updateObservers();
|
||||||
player.getZone(ZoneType.Command).updateObservers();
|
player.getZone(ZoneType.Command).updateObservers();
|
||||||
player.getZone(ZoneType.Battlefield).updateObservers();
|
player.getZone(ZoneType.Battlefield).updateObservers();
|
||||||
@@ -291,6 +280,21 @@ public class GameNew {
|
|||||||
GameNew.actuateGame(game, false);
|
GameNew.actuateGame(game, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void putCardsOnBattlefield(Player player, Iterable<Card> cards) {
|
||||||
|
PlayerZone bf = player.getZone(ZoneType.Battlefield);
|
||||||
|
if (cards != null) {
|
||||||
|
for (final Card c : cards) {
|
||||||
|
c.addController(player);
|
||||||
|
bf.add(c, false);
|
||||||
|
c.setSickness(true);
|
||||||
|
c.setStartsGameInPlay(true);
|
||||||
|
c.refreshUniqueNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ultimate of Karn the Liberated
|
||||||
public static void restartGame(final GameState game, final Player startingTurn, Map<Player, List<Card>> playerLibraries) {
|
public static void restartGame(final GameState game, final Player startingTurn, Map<Player, List<Card>> playerLibraries) {
|
||||||
MatchController match = Singletons.getModel().getMatch();
|
MatchController match = Singletons.getModel().getMatch();
|
||||||
|
|
||||||
@@ -320,19 +324,7 @@ public class GameNew {
|
|||||||
final Player player = p.getKey();
|
final Player player = p.getKey();
|
||||||
player.setStartingLife(p.getValue().getStartingLife());
|
player.setStartingLife(p.getValue().getStartingLife());
|
||||||
player.setNumLandsPlayed(0);
|
player.setNumLandsPlayed(0);
|
||||||
// what if I call it for AI player?
|
putCardsOnBattlefield(player, p.getValue().getCardsOnBattlefield(player));
|
||||||
PlayerZone bf = player.getZone(ZoneType.Battlefield);
|
|
||||||
Iterable<Card> onTable = p.getValue().getCardsOnBattlefield();
|
|
||||||
if (onTable != null) {
|
|
||||||
for (final Card c : onTable) {
|
|
||||||
c.addController(player);
|
|
||||||
c.setOwner(player);
|
|
||||||
bf.add(c, false);
|
|
||||||
c.setSickness(true);
|
|
||||||
c.setStartsGameInPlay(true);
|
|
||||||
c.refreshUniqueNumber();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerZone library = player.getZone(ZoneType.Library);
|
PlayerZone library = player.getZone(ZoneType.Library);
|
||||||
List<Card> newLibrary = playerLibraries.get(player);
|
List<Card> newLibrary = playerLibraries.get(player);
|
||||||
@@ -341,7 +333,7 @@ public class GameNew {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.shuffle();
|
player.shuffle();
|
||||||
bf.updateObservers();
|
player.getZone(ZoneType.Battlefield).updateObservers();
|
||||||
player.updateObservers();
|
player.updateObservers();
|
||||||
player.getZone(ZoneType.Hand).updateObservers();
|
player.getZone(ZoneType.Hand).updateObservers();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package forge.game;
|
package forge.game;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
@@ -14,7 +12,7 @@ public class PlayerStartConditions {
|
|||||||
|
|
||||||
private int startingLife = 20;
|
private int startingLife = 20;
|
||||||
private int startingHand = 7;
|
private int startingHand = 7;
|
||||||
private Supplier<Iterable<Card>> cardsOnBattlefield = null;
|
private Function<Player, Iterable<Card>> cardsOnBattlefield = null;
|
||||||
private Function<Player, Iterable<Card>> cardsInCommand = null;
|
private Function<Player, Iterable<Card>> cardsInCommand = null;
|
||||||
private Function<Player, Iterable<Card>> schemes = null;
|
private Function<Player, Iterable<Card>> schemes = null;
|
||||||
|
|
||||||
@@ -34,15 +32,15 @@ public class PlayerStartConditions {
|
|||||||
public final int getStartingLife() {
|
public final int getStartingLife() {
|
||||||
return startingLife;
|
return startingLife;
|
||||||
}
|
}
|
||||||
public final Iterable<Card> getCardsOnBattlefield() {
|
public final Iterable<Card> getCardsOnBattlefield(Player p) {
|
||||||
return cardsOnBattlefield == null ? null : cardsOnBattlefield.get();
|
return cardsOnBattlefield == null ? null : cardsOnBattlefield.apply(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setStartingLife(int startingLife) {
|
public final void setStartingLife(int startingLife) {
|
||||||
this.startingLife = startingLife;
|
this.startingLife = startingLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setCardsOnBattlefield(Supplier<Iterable<Card>> cardsOnTable) {
|
public final void setCardsOnBattlefield(Function<Player, Iterable<Card>> cardsOnTable) {
|
||||||
this.cardsOnBattlefield = cardsOnTable;
|
this.cardsOnBattlefield = cardsOnTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ public final class BoosterDraft implements IBoosterDraft {
|
|||||||
final List<Card> forAi = new ArrayList<Card>();
|
final List<Card> forAi = new ArrayList<Card>();
|
||||||
final List<CardPrinted> booster = this.pack.get((iHumansBooster + i) % this.pack.size());
|
final List<CardPrinted> booster = this.pack.get((iHumansBooster + i) % this.pack.size());
|
||||||
for (final CardPrinted cr : booster) {
|
for (final CardPrinted cr : booster) {
|
||||||
forAi.add(cr.toForgeCard());
|
forAi.add(cr.getMatchingForgeCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
final CardPrinted aiPick = this.draftAI.choose(booster, iPlayer++);
|
final CardPrinted aiPick = this.draftAI.choose(booster, iPlayer++);
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import forge.Card;
|
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,7 +193,6 @@ public class CardListViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SelListener implements ListSelectionListener {
|
private class SelListener implements ListSelectionListener {
|
||||||
private Card[] cache = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(final ListSelectionEvent e) {
|
public void valueChanged(final ListSelectionEvent e) {
|
||||||
@@ -202,20 +200,12 @@ public class CardListViewer {
|
|||||||
// (String) jList.getSelectedValue();
|
// (String) jList.getSelectedValue();
|
||||||
if ((row >= 0) && (row < CardListViewer.this.list.size())) {
|
if ((row >= 0) && (row < CardListViewer.this.list.size())) {
|
||||||
final CardPrinted cp = CardListViewer.this.list.get(row);
|
final CardPrinted cp = CardListViewer.this.list.get(row);
|
||||||
this.ensureCacheHas(row, cp);
|
CardListViewer.this.detail.setCard(cp.getMatchingForgeCard());
|
||||||
CardListViewer.this.detail.setCard(this.cache[row]);
|
|
||||||
CardListViewer.this.picture.setCard(cp);
|
CardListViewer.this.picture.setCard(cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureCacheHas(final int row, final CardPrinted cp) {
|
|
||||||
if (this.cache == null) {
|
|
||||||
this.cache = new Card[CardListViewer.this.list.size()];
|
|
||||||
}
|
|
||||||
if (null == this.cache[row]) {
|
|
||||||
this.cache[row] = cp.toForgeCard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Card getCard() {
|
public Card getCard() {
|
||||||
if ((this.card == null) && (this.inventoryItem != null) && (this.inventoryItem instanceof CardPrinted)) {
|
if ((this.card == null) && this.inventoryItem instanceof CardPrinted) {
|
||||||
this.card = ((CardPrinted) this.inventoryItem).toForgeCard();
|
this.card = ((CardPrinted) this.inventoryItem).getMatchingForgeCard();
|
||||||
}
|
}
|
||||||
return this.card;
|
return this.card;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class DualListBox<T> extends FPanel {
|
|||||||
} else if (obj instanceof SpellAbility) {
|
} else if (obj instanceof SpellAbility) {
|
||||||
card = ((SpellAbility) obj).getSourceCard();
|
card = ((SpellAbility) obj).getSourceCard();
|
||||||
} else if (obj instanceof CardPrinted) {
|
} else if (obj instanceof CardPrinted) {
|
||||||
card = ((CardPrinted) obj).toForgeCard();
|
card = ((CardPrinted) obj).getMatchingForgeCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiUtils.clearPanelSelections();
|
GuiUtils.clearPanelSelections();
|
||||||
|
|||||||
@@ -187,17 +187,14 @@ public final class EditorTableModel<T extends InventoryItem> extends AbstractTab
|
|||||||
final int row = table.getSelectedRow();
|
final int row = table.getSelectedRow();
|
||||||
if (row != -1) {
|
if (row != -1) {
|
||||||
final T cp = this.rowToCard(row).getKey();
|
final T cp = this.rowToCard(row).getKey();
|
||||||
final Card card2;
|
|
||||||
if (cp instanceof CardPrinted) {
|
if (cp instanceof CardPrinted) {
|
||||||
card2 = ((CardPrinted) cp).toForgeCard();
|
CDeckEditorUI.SINGLETON_INSTANCE.setCard(((CardPrinted) cp).getMatchingForgeCard());
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCard(card2);
|
|
||||||
}
|
}
|
||||||
else if (cp != null) {
|
else if (cp != null) {
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCard(cp);
|
CDeckEditorUI.SINGLETON_INSTANCE.setCard(cp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
card2 = null;
|
CDeckEditorUI.SINGLETON_INSTANCE.setCard((Card)null);
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCard(card2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public enum VProbabilities implements IVDoc<CProbabilities> {
|
|||||||
if (name2.length() > name1.length()) { continue; }
|
if (name2.length() > name1.length()) { continue; }
|
||||||
|
|
||||||
if (name2.equals(name1.substring(0, name2.length()))) {
|
if (name2.equals(name1.substring(0, name2.length()))) {
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCard(c.toForgeCard());
|
CDeckEditorUI.SINGLETON_INSTANCE.setCard(c.getMatchingForgeCard());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ import javax.swing.SwingWorker;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardEdition;
|
import forge.card.CardEdition;
|
||||||
@@ -22,6 +21,7 @@ import forge.game.GameType;
|
|||||||
import forge.game.MatchStartHelper;
|
import forge.game.MatchStartHelper;
|
||||||
import forge.game.PlayerStartConditions;
|
import forge.game.PlayerStartConditions;
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerType;
|
import forge.game.player.PlayerType;
|
||||||
import forge.gui.GuiChoose;
|
import forge.gui.GuiChoose;
|
||||||
import forge.gui.SOverlayUtils;
|
import forge.gui.SOverlayUtils;
|
||||||
@@ -387,10 +387,10 @@ public class SSubmenuQuestUtil {
|
|||||||
humanStart.setStartingLife(qData.getAssets().getLife(qData.getMode()) + extraLifeHuman);
|
humanStart.setStartingLife(qData.getAssets().getLife(qData.getMode()) + extraLifeHuman);
|
||||||
aiStart.setStartingLife(lifeAI);
|
aiStart.setStartingLife(lifeAI);
|
||||||
|
|
||||||
humanStart.setCardsOnBattlefield(new Supplier<Iterable<Card>>() {
|
humanStart.setCardsOnBattlefield(new Function<Player, Iterable<Card>>() {
|
||||||
@Override public Iterable<Card> get() { return QuestUtil.getHumanStartingCards(qData, event); } });
|
@Override public Iterable<Card> apply(Player p) { return QuestUtil.getHumanStartingCards(qData, event, p); } });
|
||||||
aiStart.setCardsOnBattlefield(new Supplier<Iterable<Card>>() {
|
aiStart.setCardsOnBattlefield(new Function<Player, Iterable<Card>>() {
|
||||||
@Override public Iterable<Card> get() { return QuestUtil.getComputerStartingCards(event); } });
|
@Override public Iterable<Card> apply(Player p) { return QuestUtil.getComputerStartingCards(event, p); } });
|
||||||
} // End isFantasy
|
} // End isFantasy
|
||||||
|
|
||||||
MatchStartHelper msh = new MatchStartHelper();
|
MatchStartHelper msh = new MatchStartHelper();
|
||||||
|
|||||||
@@ -131,9 +131,8 @@ public enum VSubmenuVanguard implements IVSubmenu<CSubmenuVanguard> {
|
|||||||
int index = avatarLists.indexOf(arg0.getSource());
|
int index = avatarLists.indexOf(arg0.getSource());
|
||||||
Object obj = avatarLists.get(index).getSelectedValue();
|
Object obj = avatarLists.get(index).getSelectedValue();
|
||||||
|
|
||||||
if (!(obj instanceof String)) {
|
if (obj instanceof CardPrinted) {
|
||||||
|
cdpAvatarDetails.get(index).setCard(((CardPrinted) obj).getMatchingForgeCard());
|
||||||
cdpAvatarDetails.get(index).setCard(((CardPrinted) obj).toForgeCard());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import javax.swing.event.ListSelectionEvent;
|
|||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import forge.Card;
|
|
||||||
import forge.gui.CardDetailPanel;
|
import forge.gui.CardDetailPanel;
|
||||||
import forge.gui.CardPicturePanel;
|
import forge.gui.CardPicturePanel;
|
||||||
import forge.gui.toolbox.FList;
|
import forge.gui.toolbox.FList;
|
||||||
@@ -98,28 +97,16 @@ public class QuestWinLoseCardViewer extends FPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SelListener implements ListSelectionListener {
|
private class SelListener implements ListSelectionListener {
|
||||||
private Card[] cache = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(final ListSelectionEvent e) {
|
public void valueChanged(final ListSelectionEvent e) {
|
||||||
final int row = QuestWinLoseCardViewer.this.jList.getSelectedIndex();
|
final int row = QuestWinLoseCardViewer.this.jList.getSelectedIndex();
|
||||||
// (String) jList.getSelectedValue();
|
// (String) jList.getSelectedValue();
|
||||||
if ((row >= 0) && (row < QuestWinLoseCardViewer.this.list.size())) {
|
if ((row >= 0) && (row < QuestWinLoseCardViewer.this.list.size())) {
|
||||||
final CardPrinted cp = QuestWinLoseCardViewer.this.list.get(row);
|
final CardPrinted cp = QuestWinLoseCardViewer.this.list.get(row);
|
||||||
this.ensureCacheHas(row, cp);
|
QuestWinLoseCardViewer.this.detail.setCard(cp.getMatchingForgeCard());
|
||||||
QuestWinLoseCardViewer.this.detail.setCard(this.cache[row]);
|
|
||||||
QuestWinLoseCardViewer.this.picture.setCard(cp);
|
QuestWinLoseCardViewer.this.picture.setCard(cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureCacheHas(final int row, final CardPrinted cp) {
|
|
||||||
if (this.cache == null) {
|
|
||||||
this.cache = new Card[QuestWinLoseCardViewer.this.list.size()];
|
|
||||||
}
|
|
||||||
if (null == this.cache[row]) {
|
|
||||||
this.cache[row] = cp.toForgeCard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import forge.Card;
|
|
||||||
import forge.gui.CardDetailPanel;
|
import forge.gui.CardDetailPanel;
|
||||||
import forge.gui.CardPicturePanel;
|
import forge.gui.CardPicturePanel;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
@@ -87,28 +86,17 @@ public class CardViewer extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SelListener implements ListSelectionListener {
|
private class SelListener implements ListSelectionListener {
|
||||||
private Card[] cache = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(final ListSelectionEvent e) {
|
public void valueChanged(final ListSelectionEvent e) {
|
||||||
final int row = CardViewer.this.jList.getSelectedIndex();
|
final int row = CardViewer.this.jList.getSelectedIndex();
|
||||||
// (String) jList.getSelectedValue();
|
// (String) jList.getSelectedValue();
|
||||||
if ((row >= 0) && (row < CardViewer.this.list.size())) {
|
if ((row >= 0) && (row < CardViewer.this.list.size())) {
|
||||||
final CardPrinted cp = CardViewer.this.list.get(row);
|
final CardPrinted cp = CardViewer.this.list.get(row);
|
||||||
this.ensureCacheHas(row, cp);
|
CardViewer.this.detail.setCard(cp.getMatchingForgeCard());
|
||||||
CardViewer.this.detail.setCard(this.cache[row]);
|
|
||||||
CardViewer.this.picture.setCard(cp);
|
CardViewer.this.picture.setCard(cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureCacheHas(final int row, final CardPrinted cp) {
|
|
||||||
if (this.cache == null) {
|
|
||||||
this.cache = new Card[CardViewer.this.list.size()];
|
|
||||||
}
|
|
||||||
if (null == this.cache[row]) {
|
|
||||||
this.cache[row] = cp.toForgeCard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
package forge.item;
|
package forge.item;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
@@ -295,8 +297,14 @@ public final class CardPrinted implements Comparable<CardPrinted>, InventoryItem
|
|||||||
*
|
*
|
||||||
* @return the card
|
* @return the card
|
||||||
*/
|
*/
|
||||||
public Card toForgeCard() {
|
private static final Map<CardPrinted, Card> cp2card = new HashMap<CardPrinted, Card>();
|
||||||
return toForgeCard(null);
|
public Card getMatchingForgeCard() {
|
||||||
|
Card res = cp2card.get(this);
|
||||||
|
if (null == res) {
|
||||||
|
res = toForgeCard(null);
|
||||||
|
cp2card.put(this, res);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package forge.quest;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
|
||||||
import forge.card.cardfactory.CardFactory;
|
import forge.card.cardfactory.CardFactory;
|
||||||
|
import forge.game.player.Player;
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.quest.bazaar.QuestPetController;
|
import forge.quest.bazaar.QuestPetController;
|
||||||
|
|
||||||
@@ -61,11 +62,11 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.QuestEvent} object.
|
* a {@link forge.quest.QuestEvent} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static List<Card> getComputerStartingCards(final QuestEvent qe) {
|
public static List<Card> getComputerStartingCards(final QuestEvent qe, Player ai) {
|
||||||
final List<Card> list = new ArrayList<Card>();
|
final List<Card> list = new ArrayList<Card>();
|
||||||
|
|
||||||
for (final String s : qe.getAiExtraCards()) {
|
for (final String s : qe.getAiExtraCards()) {
|
||||||
list.add(QuestUtil.readExtraCard(s));
|
list.add(QuestUtil.readExtraCard(s, ai));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
@@ -116,10 +117,10 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.QuestEvent} object.
|
* a {@link forge.quest.QuestEvent} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static List<Card> getHumanStartingCards(final QuestController qc, final QuestEvent qe) {
|
public static List<Card> getHumanStartingCards(final QuestController qc, final QuestEvent qe, final Player human) {
|
||||||
final List<Card> list = QuestUtil.getHumanStartingCards(qc);
|
final List<Card> list = QuestUtil.getHumanStartingCards(qc);
|
||||||
for (final String s : qe.getHumanExtraCards()) {
|
for (final String s : qe.getHumanExtraCards()) {
|
||||||
list.add(QuestUtil.readExtraCard(s));
|
list.add(QuestUtil.readExtraCard(s, human));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -168,17 +169,16 @@ public class QuestUtil {
|
|||||||
* the owner
|
* the owner
|
||||||
* @return the card
|
* @return the card
|
||||||
*/
|
*/
|
||||||
public static Card readExtraCard(final String name) {
|
public static Card readExtraCard(final String name, Player owner) {
|
||||||
// Token card creation
|
// Token card creation
|
||||||
Card tempcard;
|
Card tempcard;
|
||||||
if (name.startsWith("TOKEN")) {
|
if (name.startsWith("TOKEN")) {
|
||||||
tempcard = QuestUtil.createToken(name);
|
tempcard = QuestUtil.createToken(name);
|
||||||
|
tempcard.setOwner(owner);
|
||||||
|
return tempcard;
|
||||||
}
|
}
|
||||||
// Standard card creation
|
// Standard card creation
|
||||||
else {
|
return CardDb.instance().getCard(name, true).toForgeCard(owner);
|
||||||
tempcard = CardDb.instance().getCard(name, true).toForgeCard();
|
|
||||||
}
|
|
||||||
return tempcard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // QuestUtil
|
} // QuestUtil
|
||||||
|
|||||||
Reference in New Issue
Block a user