mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Prevent there being a possible crash when winning a quest match
This commit is contained in:
@@ -71,24 +71,20 @@ public class QuestAchievements {
|
|||||||
* Adds the win.
|
* Adds the win.
|
||||||
*/
|
*/
|
||||||
public void addWin() { // changes getRank()
|
public void addWin() { // changes getRank()
|
||||||
|
win++;
|
||||||
this.win++;
|
winstreakCurrent++;
|
||||||
this.winstreakCurrent++;
|
|
||||||
|
if (drafts != null && currentDraft != -1) {
|
||||||
for (QuestEventDraft draft : drafts) {
|
drafts.get(currentDraft).addWin();
|
||||||
if (!(currentDraft != -1 && drafts.get(currentDraft) == draft)) {
|
|
||||||
draft.addWin();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (win % 5 == 0) {
|
if (win % 5 == 0) {
|
||||||
draftsToGenerate++;
|
draftsToGenerate++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.winstreakCurrent > this.winstreakBest) {
|
if (winstreakCurrent > winstreakBest) {
|
||||||
this.winstreakBest = this.winstreakCurrent;
|
winstreakBest = winstreakCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Challenge performance
|
// Challenge performance
|
||||||
@@ -98,14 +94,14 @@ public class QuestAchievements {
|
|||||||
* @return the challenges played
|
* @return the challenges played
|
||||||
*/
|
*/
|
||||||
public int getChallengesPlayed() {
|
public int getChallengesPlayed() {
|
||||||
return this.challengesPlayed;
|
return challengesPlayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the challenges played.
|
* Adds the challenges played.
|
||||||
*/
|
*/
|
||||||
public void addChallengesPlayed() {
|
public void addChallengesPlayed() {
|
||||||
this.challengesPlayed++;
|
challengesPlayed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +110,7 @@ public class QuestAchievements {
|
|||||||
* @return List<Integer>
|
* @return List<Integer>
|
||||||
*/
|
*/
|
||||||
public List<String> getLockedChallenges() {
|
public List<String> getLockedChallenges() {
|
||||||
return this.completedChallenges;
|
return completedChallenges;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,7 +123,7 @@ public class QuestAchievements {
|
|||||||
* the i
|
* the i
|
||||||
*/
|
*/
|
||||||
public void addLockedChallenge(final String i) {
|
public void addLockedChallenge(final String i) {
|
||||||
this.completedChallenges.add(i);
|
completedChallenges.add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,11 +132,11 @@ public class QuestAchievements {
|
|||||||
* @return List<Integer>
|
* @return List<Integer>
|
||||||
*/
|
*/
|
||||||
public List<String> getCurrentChallenges() {
|
public List<String> getCurrentChallenges() {
|
||||||
if (this.currentChallenges == null) {
|
if (currentChallenges == null) {
|
||||||
this.currentChallenges = new ArrayList<String>();
|
currentChallenges = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.currentChallenges;
|
return currentChallenges;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -149,16 +145,17 @@ public class QuestAchievements {
|
|||||||
* @param lst0 List<Integer>
|
* @param lst0 List<Integer>
|
||||||
*/
|
*/
|
||||||
public void setCurrentChallenges(final List<String> lst0) {
|
public void setCurrentChallenges(final List<String> lst0) {
|
||||||
this.currentChallenges = lst0;
|
currentChallenges = lst0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the lost.
|
* Adds the lost.
|
||||||
*/
|
*/
|
||||||
public void addLost() {
|
public void addLost() {
|
||||||
this.lost++;
|
lost++;
|
||||||
this.winstreakCurrent = 0;
|
winstreakCurrent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Level, read-only ( note: it increments in addWin() )
|
// Level, read-only ( note: it increments in addWin() )
|
||||||
/**
|
/**
|
||||||
* Gets the level.
|
* Gets the level.
|
||||||
@@ -167,8 +164,9 @@ public class QuestAchievements {
|
|||||||
*/
|
*/
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
final int winsToLvlUp = FModel.getQuestPreferences().getPrefInt(DifficultyPrefs.WINS_RANKUP, difficulty);
|
final int winsToLvlUp = FModel.getQuestPreferences().getPrefInt(DifficultyPrefs.WINS_RANKUP, difficulty);
|
||||||
return this.win / winsToLvlUp;
|
return win / winsToLvlUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wins & Losses
|
// Wins & Losses
|
||||||
/**
|
/**
|
||||||
* Gets the lost.
|
* Gets the lost.
|
||||||
@@ -176,7 +174,7 @@ public class QuestAchievements {
|
|||||||
* @return the lost
|
* @return the lost
|
||||||
*/
|
*/
|
||||||
public int getLost() {
|
public int getLost() {
|
||||||
return this.lost;
|
return lost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,20 +210,19 @@ public class QuestAchievements {
|
|||||||
* @return the difficulty index
|
* @return the difficulty index
|
||||||
*/
|
*/
|
||||||
public int getDifficulty() {
|
public int getDifficulty() {
|
||||||
return this.difficulty;
|
return difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestEventDraftContainer getDraftEvents() {
|
public QuestEventDraftContainer getDraftEvents() {
|
||||||
return drafts;
|
return drafts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateDrafts() {
|
public void generateDrafts() {
|
||||||
|
|
||||||
if (drafts == null) {
|
if (drafts == null) {
|
||||||
drafts = new QuestEventDraftContainer();
|
drafts = new QuestEventDraftContainer();
|
||||||
draftsToGenerate = 1;
|
draftsToGenerate = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuestEventDraft toRemove = null;
|
QuestEventDraft toRemove = null;
|
||||||
for (QuestEventDraft draft : drafts) {
|
for (QuestEventDraft draft : drafts) {
|
||||||
if (draft.getAge() <= 0
|
if (draft.getAge() <= 0
|
||||||
@@ -234,11 +231,11 @@ public class QuestAchievements {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toRemove != null) {
|
if (toRemove != null) {
|
||||||
drafts.remove(toRemove);
|
drafts.remove(toRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < draftsToGenerate; i++) {
|
for (int i = 0; i < draftsToGenerate; i++) {
|
||||||
QuestEventDraft draft = QuestEventDraft.getRandomDraftOrNull(FModel.getQuest());
|
QuestEventDraft draft = QuestEventDraft.getRandomDraftOrNull(FModel.getQuest());
|
||||||
if (draft != null) {
|
if (draft != null) {
|
||||||
@@ -246,19 +243,18 @@ public class QuestAchievements {
|
|||||||
draftsToGenerate--;
|
draftsToGenerate--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FModel.getQuest().save();
|
FModel.getQuest().save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDraftToken() {
|
public void addDraftToken() {
|
||||||
draftTokens++;
|
draftTokens++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentDraft(final QuestEventDraft draft) {
|
public void setCurrentDraft(final QuestEventDraft draft) {
|
||||||
currentDraft = drafts.indexOf(draft);
|
currentDraft = drafts.indexOf(draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestEventDraft getCurrentDraft() {
|
public QuestEventDraft getCurrentDraft() {
|
||||||
if (drafts == null || drafts.size() == 0) {
|
if (drafts == null || drafts.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
@@ -276,7 +272,6 @@ public class QuestAchievements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getWinsForPlace(final int place) {
|
public int getWinsForPlace(final int place) {
|
||||||
|
|
||||||
switch (place) {
|
switch (place) {
|
||||||
case 1:
|
case 1:
|
||||||
return firstPlaceDraftFinishes;
|
return firstPlaceDraftFinishes;
|
||||||
@@ -289,11 +284,9 @@ public class QuestAchievements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDraftFinish(final int place) {
|
private void addDraftFinish(final int place) {
|
||||||
|
|
||||||
switch (place) {
|
switch (place) {
|
||||||
case 1:
|
case 1:
|
||||||
firstPlaceDraftFinishes++;
|
firstPlaceDraftFinishes++;
|
||||||
@@ -308,13 +301,12 @@ public class QuestAchievements {
|
|||||||
fourthPlaceDraftFinishes++;
|
fourthPlaceDraftFinishes++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDraftTokens() {
|
public int getDraftTokens() {
|
||||||
return draftTokens;
|
return draftTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spendDraftToken() {
|
public void spendDraftToken() {
|
||||||
if (draftTokens > 0) {
|
if (draftTokens > 0) {
|
||||||
draftTokens--;
|
draftTokens--;
|
||||||
@@ -322,5 +314,4 @@ public class QuestAchievements {
|
|||||||
FModel.getQuest().save();
|
FModel.getQuest().save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user