Prevent there being a possible crash when winning a quest match

This commit is contained in:
drdev
2014-07-17 04:10:43 +00:00
parent fd839c81ec
commit ed7f3e54a0

View File

@@ -71,24 +71,20 @@ public class QuestAchievements {
* Adds the win. * Adds the win.
*/ */
public void addWin() { // changes getRank() public void addWin() { // changes getRank()
win++;
winstreakCurrent++;
this.win++; if (drafts != null && currentDraft != -1) {
this.winstreakCurrent++; drafts.get(currentDraft).addWin();
for (QuestEventDraft draft : drafts) {
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,7 +210,7 @@ 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() {
@@ -220,7 +218,6 @@ public class QuestAchievements {
} }
public void generateDrafts() { public void generateDrafts() {
if (drafts == null) { if (drafts == null) {
drafts = new QuestEventDraftContainer(); drafts = new QuestEventDraftContainer();
draftsToGenerate = 1; draftsToGenerate = 1;
@@ -248,7 +245,6 @@ public class QuestAchievements {
} }
FModel.getQuest().save(); FModel.getQuest().save();
} }
public void addDraftToken() { public void addDraftToken() {
@@ -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,7 +301,6 @@ public class QuestAchievements {
fourthPlaceDraftFinishes++; fourthPlaceDraftFinishes++;
break; break;
} }
} }
public int getDraftTokens() { public int getDraftTokens() {
@@ -322,5 +314,4 @@ public class QuestAchievements {
FModel.getQuest().save(); FModel.getQuest().save();
} }
} }
} }