- 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:
Agetian
2016-08-27 14:12:48 +00:00
parent 8405b967ca
commit 34c11c6b46
3 changed files with 30 additions and 5 deletions

View File

@@ -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.
*

View File

@@ -187,12 +187,14 @@ public class QuestWinLoseController {
}
if (qEvent instanceof QuestEventChallenge) {
final String id = ((QuestEventChallenge) qEvent).getId();
qData.getAchievements().getCurrentChallenges().remove(id);
qData.getAchievements().addLockedChallenge(id);
if (wonMatch || (!((QuestEventChallenge)qEvent).isPersistent())) {
final String id = ((QuestEventChallenge) qEvent).getId();
qData.getAchievements().getCurrentChallenges().remove(id);
qData.getAchievements().addLockedChallenge(id);
// Increment challenge counter to limit challenges available
qData.getAchievements().addChallengesPlayed();
// Increment challenge counter to limit challenges available
qData.getAchievements().addChallengesPlayed();
}
}
qData.setCurrentEvent(null);

View File

@@ -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));