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. */
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -208,6 +211,25 @@ public class QuestEventChallenge extends QuestEvent {
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -187,6 +187,7 @@ public class QuestWinLoseController {
|
||||
}
|
||||
|
||||
if (qEvent instanceof QuestEventChallenge) {
|
||||
if (wonMatch || (!((QuestEventChallenge)qEvent).isPersistent())) {
|
||||
final String id = ((QuestEventChallenge) qEvent).getId();
|
||||
qData.getAchievements().getCurrentChallenges().remove(id);
|
||||
qData.getAchievements().addLockedChallenge(id);
|
||||
@@ -194,6 +195,7 @@ public class QuestWinLoseController {
|
||||
// Increment challenge counter to limit challenges available
|
||||
qData.getAchievements().addChallengesPlayed();
|
||||
}
|
||||
}
|
||||
|
||||
qData.setCurrentEvent(null);
|
||||
qData.save();
|
||||
|
||||
@@ -32,6 +32,7 @@ public class QuestChallengeReader extends StorageReaderFolder<QuestEventChalleng
|
||||
qc.setId(sectionQuest.get("ID", "-1"));
|
||||
qc.setOpponent(sectionQuest.get("OpponentName"));
|
||||
qc.setRepeatable(sectionQuest.getBoolean("Repeat", false));
|
||||
qc.setPersistent(sectionQuest.getBoolean("Persistent", false));
|
||||
qc.setAiLife(sectionQuest.getInt("AILife", 25));
|
||||
qc.setWinsReqd(sectionQuest.getInt("Wins", 20));
|
||||
qc.setCreditsReward(sectionQuest.getInt("Credit Reward", 100));
|
||||
|
||||
Reference in New Issue
Block a user