mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fixed re-updating bug of cards in play at beginning of round during quest.
This commit is contained in:
@@ -31,7 +31,6 @@ import forge.item.CardPrinted;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants.LANG.GameAction.GAMEACTION_TEXT;
|
||||
import forge.quest.gui.QuestWinLoseHandler;
|
||||
import forge.quest.gui.main.QuestChallenge;
|
||||
import forge.quest.gui.main.QuestEvent;
|
||||
import forge.view.swing.WinLoseFrame;
|
||||
|
||||
@@ -1125,13 +1124,6 @@ public class GameAction {
|
||||
AllZone.getComputerPlayer().setLife(computerLife, null);
|
||||
AllZone.getHumanPlayer().setLife(humanLife, null);
|
||||
|
||||
if (qe != null && qe instanceof QuestChallenge){
|
||||
QuestChallenge challenge = (QuestChallenge)qe;
|
||||
if (challenge.getEventType().equals("challenge")) {
|
||||
computer.addAll(forge.quest.data.QuestUtil.getComputerStartingCards(AllZone.getQuestData(), AllZone.getQuestEvent()));
|
||||
}
|
||||
}
|
||||
|
||||
for (Card c : human) {
|
||||
for (Trigger trig : c.getTriggers()) {
|
||||
AllZone.getTriggerHandler().registerTrigger(trig);
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.Player;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.BoosterUtils;
|
||||
import forge.item.CardPrinted;
|
||||
@@ -31,7 +34,7 @@ public class QuestUtil {
|
||||
|
||||
/**
|
||||
* <p>getComputerStartingCards.</p>
|
||||
* Returns extra AI cards in play at start of event.
|
||||
* Returns new card instances of extra AI cards in play at start of event.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @param qe a {@link forge.quest.gui.main.QuestEvent} object.
|
||||
@@ -40,9 +43,14 @@ public class QuestUtil {
|
||||
public static CardList getComputerStartingCards(final QuestData qd, QuestEvent qe) {
|
||||
CardList list = new CardList();
|
||||
|
||||
if (qe.getEventType().equals("challenge")) {
|
||||
list.addAll(((QuestChallenge)qe).getAIExtraCards());
|
||||
if(qe.getEventType().equals("challenge")) {
|
||||
List<String> extras = ((QuestChallenge)qe).getAIExtraCards();
|
||||
|
||||
for(String s : extras) {
|
||||
list.add(readExtraCard(s, AllZone.getComputerPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -69,7 +77,8 @@ public class QuestUtil {
|
||||
|
||||
/**
|
||||
* <p>getHumanStartingCards.</p>
|
||||
* Returns extra human cards, including current plant/pet configuration,
|
||||
* Returns new card instances of extra human cards,
|
||||
* including current plant/pet configuration,
|
||||
* and cards in play at start of quest.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
@@ -79,8 +88,12 @@ public class QuestUtil {
|
||||
public static CardList getHumanStartingCards(final QuestData qd, QuestEvent qe) {
|
||||
CardList list = getHumanStartingCards(qd);
|
||||
|
||||
if (qe.getEventType().equals("challenge")) {
|
||||
list.addAll(((QuestChallenge)qe).getHumanExtraCards());
|
||||
if(qe.getEventType().equals("challenge")) {
|
||||
List<String> extras = ((QuestChallenge)qe).getHumanExtraCards();
|
||||
|
||||
for(String s : extras) {
|
||||
list.add(readExtraCard(s, AllZone.getHumanPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -164,4 +177,29 @@ public class QuestUtil {
|
||||
return BoosterUtils.generateCards(qty, rar, col);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>readExtraCard.</p>
|
||||
* Creates single card for a string read from unique event properties.
|
||||
*
|
||||
* @param name
|
||||
* @param owner
|
||||
* @return
|
||||
*/
|
||||
public static Card readExtraCard(String name, Player owner) {
|
||||
// Token card creation
|
||||
Card tempcard;
|
||||
if(name.startsWith("TOKEN")) {
|
||||
tempcard = QuestUtil.createToken(name);
|
||||
tempcard.addController(owner);
|
||||
tempcard.setOwner(owner);
|
||||
}
|
||||
// Standard card creation
|
||||
else {
|
||||
tempcard = AllZone.getCardFactory().getCard(name, owner);
|
||||
tempcard.setCurSetCode(tempcard.getMostRecentSet());
|
||||
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
|
||||
}
|
||||
return tempcard;
|
||||
}
|
||||
|
||||
} //QuestUtil
|
||||
|
||||
@@ -7,6 +7,7 @@ import forge.gui.GuiUtils;
|
||||
import forge.gui.deckeditor.DeckEditorShop;
|
||||
import forge.gui.deckeditor.DeckEditorQuest;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.quest.data.QuestUtil;
|
||||
import forge.quest.data.item.QuestItemZeppelin;
|
||||
import forge.quest.gui.main.QuestDuel;
|
||||
import forge.quest.gui.main.QuestDuelPanel;
|
||||
@@ -706,8 +707,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
QuestDuel selectedDuel = (QuestDuel)selectedOpponent.getEvent();
|
||||
AllZone.setQuestEvent(selectedDuel);
|
||||
|
||||
AllZone.getGameAction().newGame(humanDeck, computer, forge.quest.data.QuestUtil.getHumanStartingCards(questData),
|
||||
new CardList(), questData.getLife(), 20, null);
|
||||
AllZone.getGameAction().newGame(humanDeck, computer,
|
||||
QuestUtil.getHumanStartingCards(questData),
|
||||
QuestUtil.getComputerStartingCards(questData),
|
||||
questData.getLife(), 20, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -730,7 +733,8 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
}
|
||||
|
||||
AllZone.getGameAction().newGame(humanDeck, computer,
|
||||
forge.quest.data.QuestUtil.getHumanStartingCards(questData, selectedChallenge), new CardList(),
|
||||
QuestUtil.getHumanStartingCards(questData, selectedChallenge),
|
||||
QuestUtil.getComputerStartingCards(questData, selectedChallenge),
|
||||
questData.getLife() + extraLife, selectedChallenge.getAILife(), selectedChallenge);
|
||||
|
||||
}
|
||||
|
||||
@@ -82,8 +82,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
}
|
||||
|
||||
CardList humanList = QuestUtil.getHumanStartingCards(model.qData, model.qEvent);
|
||||
CardList computerList = new CardList();
|
||||
|
||||
CardList computerList = QuestUtil.getComputerStartingCards(model.qData, model.qEvent);
|
||||
|
||||
int humanLife = model.qData.getLife() + extraLife;
|
||||
int computerLife = 20;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package forge.quest.gui.main;
|
||||
|
||||
import forge.CardList;
|
||||
import forge.item.CardPrinted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,8 +23,8 @@ public class QuestChallenge extends QuestEvent {
|
||||
public int winsReqd = 20;
|
||||
|
||||
// Other cards used in assignment: starting, and reward.
|
||||
public CardList humanExtraCards = new CardList();
|
||||
public CardList aiExtraCards = new CardList();
|
||||
public List<String> humanExtraCards = new ArrayList<String>();
|
||||
public List<String> aiExtraCards = new ArrayList<String>();
|
||||
public List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
|
||||
|
||||
public QuestChallenge() {
|
||||
@@ -94,7 +92,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final CardList getAIExtraCards() {
|
||||
public final List<String> getAIExtraCards() {
|
||||
return aiExtraCards;
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final CardList getHumanExtraCards() {
|
||||
public final List<String> getHumanExtraCards() {
|
||||
return humanExtraCards;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package forge.quest.gui.main;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.CardList;
|
||||
import forge.CardUtil;
|
||||
import forge.FileUtil;
|
||||
import forge.Player;
|
||||
import forge.deck.DeckManager;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
@@ -141,10 +137,10 @@ public class QuestEventManager {
|
||||
// Human extra card list assembled here.
|
||||
else if(key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
|
||||
String[] names = value.split("\\|");
|
||||
CardList templist = new CardList();
|
||||
List<String> templist = new ArrayList<String>();
|
||||
|
||||
for(String n : names) {
|
||||
templist.add(readExtraCard(n, AllZone.getHumanPlayer()));
|
||||
templist.add(n);
|
||||
}
|
||||
|
||||
qc.humanExtraCards = templist;
|
||||
@@ -152,10 +148,10 @@ public class QuestEventManager {
|
||||
// AI extra card list assembled here.
|
||||
else if(key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
|
||||
String[] names = value.split("\\|");
|
||||
CardList templist = new CardList();
|
||||
List<String> templist = new ArrayList<String>();
|
||||
|
||||
for(String n : names) {
|
||||
templist.add(readExtraCard(n, AllZone.getComputerPlayer()));
|
||||
templist.add(n);
|
||||
}
|
||||
|
||||
qc.aiExtraCards = templist;
|
||||
@@ -168,32 +164,6 @@ public class QuestEventManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>readExtraCard.</p>
|
||||
* Creates single card for a string read from unique event properties.
|
||||
*
|
||||
* @param name
|
||||
* @param owner
|
||||
* @return
|
||||
*/
|
||||
private Card readExtraCard(String name, Player owner) {
|
||||
// Token card creation
|
||||
Card tempcard;
|
||||
if(name.startsWith("TOKEN")) {
|
||||
tempcard = QuestUtil.createToken(name);
|
||||
tempcard.addController(owner);
|
||||
tempcard.setOwner(owner);
|
||||
}
|
||||
// Standard card creation
|
||||
else {
|
||||
tempcard = AllZone.getCardFactory().getCard(name, owner);
|
||||
tempcard.setCurSetCode(tempcard.getMostRecentSet());
|
||||
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
|
||||
}
|
||||
return tempcard;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>assembleEventMetadata.</p>
|
||||
* Handler for metadata contained in event files.
|
||||
|
||||
Reference in New Issue
Block a user