44 } |
44 } |
45 |
45 |
46 return teamfile; |
46 return teamfile; |
47 } |
47 } |
48 |
48 |
|
49 /** |
|
50 Returns true if the specified mission has been completed |
|
51 campaignName: Name of the campaign in question |
|
52 missionInList: QComboBox index of the mission as selected in the mission widget |
|
53 teamName: Name of the playing team |
|
54 */ |
|
55 bool isMissionWon(QString & campaignName, int missionInList, QString & teamName) |
|
56 { |
|
57 QSettings* teamfile = getCampTeamFile(campaignName, teamName); |
|
58 int progress = teamfile->value("Campaign " + campaignName + "/Progress", 0).toInt(); |
|
59 int unlockedMissions = teamfile->value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
|
60 if(progress>0 and unlockedMissions==0) |
|
61 { |
|
62 return progress > (progress - missionInList); |
|
63 } |
|
64 else if(unlockedMissions>0) |
|
65 { |
|
66 int fileMissionId = missionInList + 1; |
|
67 int actualMissionId = teamfile->value(QString("Campaign %1/Mission%2").arg(campaignName, QString::number(fileMissionId)), false).toInt(); |
|
68 return teamfile->value(QString("Campaign %1/Mission%2Won").arg(campaignName, QString::number(actualMissionId)), false).toBool(); |
|
69 } |
|
70 else |
|
71 return false; |
|
72 } |
|
73 |
|
74 /** Returns true if the campaign has been won by the team */ |
49 bool isCampWon(QString & campaignName, QString & teamName) |
75 bool isCampWon(QString & campaignName, QString & teamName) |
50 { |
76 { |
51 QSettings* teamfile = getCampTeamFile(campaignName, teamName); |
77 QSettings* teamfile = getCampTeamFile(campaignName, teamName); |
52 bool won = teamfile->value("Campaign " + campaignName + "/Won", false).toBool(); |
78 bool won = teamfile->value("Campaign " + campaignName + "/Won", false).toBool(); |
53 return won; |
79 return won; |