mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Added a way to implement persistent challenges by adding Persistent=true to the challenge deck metadata. Persistent challenges do not disappear if a player lost the match (and thus stay until the player wins).
This commit is contained in:
@@ -69,6 +69,9 @@ public class QuestEventChallenge extends QuestEvent {
|
|||||||
/** The ai extra cards. */
|
/** The ai extra cards. */
|
||||||
private List<String> aiExtraCards = new ArrayList<String>();
|
private List<String> aiExtraCards = new ArrayList<String>();
|
||||||
|
|
||||||
|
/** If persistent, the challenge does not disappear if the player fails it. */
|
||||||
|
private boolean persistent = false;
|
||||||
|
|
||||||
private Deck humanDeck = null;
|
private Deck humanDeck = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -208,6 +211,25 @@ public class QuestEventChallenge extends QuestEvent {
|
|||||||
this.repeatable = repeatable0;
|
this.repeatable = repeatable0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is persistent.
|
||||||
|
*
|
||||||
|
* @return the persistent
|
||||||
|
*/
|
||||||
|
public boolean isPersistent() {
|
||||||
|
return this.persistent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the persistent.
|
||||||
|
*
|
||||||
|
* @param persistent0
|
||||||
|
* the repeatable to set
|
||||||
|
*/
|
||||||
|
public void setPersistent(final boolean persistent0) {
|
||||||
|
this.persistent = persistent0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ai life.
|
* Gets the ai life.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -187,12 +187,14 @@ public class QuestWinLoseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qEvent instanceof QuestEventChallenge) {
|
if (qEvent instanceof QuestEventChallenge) {
|
||||||
final String id = ((QuestEventChallenge) qEvent).getId();
|
if (wonMatch || (!((QuestEventChallenge)qEvent).isPersistent())) {
|
||||||
qData.getAchievements().getCurrentChallenges().remove(id);
|
final String id = ((QuestEventChallenge) qEvent).getId();
|
||||||
qData.getAchievements().addLockedChallenge(id);
|
qData.getAchievements().getCurrentChallenges().remove(id);
|
||||||
|
qData.getAchievements().addLockedChallenge(id);
|
||||||
|
|
||||||
// Increment challenge counter to limit challenges available
|
// Increment challenge counter to limit challenges available
|
||||||
qData.getAchievements().addChallengesPlayed();
|
qData.getAchievements().addChallengesPlayed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qData.setCurrentEvent(null);
|
qData.setCurrentEvent(null);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class QuestChallengeReader extends StorageReaderFolder<QuestEventChalleng
|
|||||||
qc.setId(sectionQuest.get("ID", "-1"));
|
qc.setId(sectionQuest.get("ID", "-1"));
|
||||||
qc.setOpponent(sectionQuest.get("OpponentName"));
|
qc.setOpponent(sectionQuest.get("OpponentName"));
|
||||||
qc.setRepeatable(sectionQuest.getBoolean("Repeat", false));
|
qc.setRepeatable(sectionQuest.getBoolean("Repeat", false));
|
||||||
|
qc.setPersistent(sectionQuest.getBoolean("Persistent", false));
|
||||||
qc.setAiLife(sectionQuest.getInt("AILife", 25));
|
qc.setAiLife(sectionQuest.getInt("AILife", 25));
|
||||||
qc.setWinsReqd(sectionQuest.getInt("Wins", 20));
|
qc.setWinsReqd(sectionQuest.getInt("Wins", 20));
|
||||||
qc.setCreditsReward(sectionQuest.getInt("Credit Reward", 100));
|
qc.setCreditsReward(sectionQuest.getInt("Credit Reward", 100));
|
||||||
|
|||||||
Reference in New Issue
Block a user