24 #include <QSettings> |
24 #include <QSettings> |
25 |
25 |
26 #include "team.h" |
26 #include "team.h" |
27 #include "hwform.h" |
27 #include "hwform.h" |
28 #include "pageeditteam.h" |
28 #include "pageeditteam.h" |
29 #include "hwconsts.h" |
|
30 #include "hats.h" |
29 #include "hats.h" |
31 |
30 |
32 HWTeam::HWTeam(const QString & teamname) : |
31 HWTeam::HWTeam(const QString & teamname) : |
33 difficulty(0), |
32 m_difficulty(0), |
34 numHedgehogs(4), |
33 m_numHedgehogs(4), |
35 m_isNetTeam(false) |
34 m_isNetTeam(false) |
36 { |
35 { |
37 TeamName = teamname; |
36 m_name = teamname; |
38 OldTeamName = TeamName; |
37 OldTeamName = m_name; |
39 for (int i = 0; i < 8; i++) |
38 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
40 { |
39 { |
41 Hedgehogs[i].Name = (QLineEdit::tr("hedgehog %1").arg(i+1)); |
40 m_hedgehogs[i].Name = (QLineEdit::tr("hedgehog %1").arg(i+1)); |
42 Hedgehogs[i].Hat = "NoHat"; |
41 m_hedgehogs[i].Hat = "NoHat"; |
43 } |
42 } |
44 Grave = "Statue"; |
43 m_grave = "Statue"; |
45 Fort = "Plane"; |
44 m_fort = "Plane"; |
46 Voicepack = "Default"; |
45 m_voicepack = "Default"; |
47 Flag = "hedgewars"; |
46 m_flag = "hedgewars"; |
48 for(int i = 0; i < BINDS_NUMBER; i++) |
47 for(int i = 0; i < BINDS_NUMBER; i++) |
49 { |
48 { |
50 binds[i].action = cbinds[i].action; |
49 binds[i].action = cbinds[i].action; |
51 binds[i].strbind = cbinds[i].strbind; |
50 binds[i].strbind = cbinds[i].strbind; |
52 } |
51 } |
53 Rounds = 0; |
52 m_rounds = 0; |
54 Wins = 0; |
53 m_wins = 0; |
55 CampaignProgress = 0; |
54 m_campaignProgress = 0; |
56 } |
55 } |
57 |
56 |
58 HWTeam::HWTeam(const QStringList& strLst) : |
57 HWTeam::HWTeam(const QStringList& strLst) : |
59 numHedgehogs(4), |
58 m_numHedgehogs(4), |
60 m_isNetTeam(true) |
59 m_isNetTeam(true) |
61 { |
60 { |
62 // net teams are configured from QStringList |
61 // net teams are configured from QStringList |
63 if(strLst.size() != 23) throw HWTeamConstructException(); |
62 if(strLst.size() != 23) throw HWTeamConstructException(); |
64 TeamName = strLst[0]; |
63 m_name = strLst[0]; |
65 Grave = strLst[1]; |
64 m_grave = strLst[1]; |
66 Fort = strLst[2]; |
65 m_fort = strLst[2]; |
67 Voicepack = strLst[3]; |
66 m_voicepack = strLst[3]; |
68 Flag = strLst[4]; |
67 m_flag = strLst[4]; |
69 Owner = strLst[5]; |
68 m_owner = strLst[5]; |
70 difficulty = strLst[6].toUInt(); |
69 m_difficulty = strLst[6].toUInt(); |
71 for(int i = 0; i < 8; i++) |
70 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
72 { |
71 { |
73 Hedgehogs[i].Name=strLst[i * 2 + 7]; |
72 m_hedgehogs[i].Name=strLst[i * 2 + 7]; |
74 Hedgehogs[i].Hat=strLst[i * 2 + 8]; |
73 m_hedgehogs[i].Hat=strLst[i * 2 + 8]; |
75 // Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat |
74 // Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat |
76 // Checking net teams is probably pointless, but can't hurt. |
75 // Checking net teams is probably pointless, but can't hurt. |
77 if (Hedgehogs[i].Hat.isEmpty()) Hedgehogs[i].Hat = "NoHat"; |
76 if (m_hedgehogs[i].Hat.isEmpty()) m_hedgehogs[i].Hat = "NoHat"; |
78 } |
77 } |
79 Rounds = 0; |
78 m_rounds = 0; |
80 Wins = 0; |
79 m_wins = 0; |
81 CampaignProgress = 0; |
80 m_campaignProgress = 0; |
82 } |
81 } |
83 |
82 |
84 HWTeam::HWTeam() : |
83 HWTeam::HWTeam() : |
85 difficulty(0), |
84 m_difficulty(0), |
86 numHedgehogs(4), |
85 m_numHedgehogs(4), |
87 m_isNetTeam(false) |
86 m_isNetTeam(false) |
88 { |
87 { |
89 TeamName = QString("Team"); |
88 m_name = QString("Team"); |
90 for (int i = 0; i < 8; i++) |
89 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
91 { |
90 { |
92 Hedgehogs[i].Name.sprintf("hedgehog %d", i); |
91 m_hedgehogs[i].Name.sprintf("hedgehog %d", i); |
93 Hedgehogs[i].Hat = "NoHat"; |
92 m_hedgehogs[i].Hat = "NoHat"; |
94 } |
93 } |
95 |
94 |
96 Grave = QString("Simple"); // default |
95 m_grave = QString("Simple"); // default |
97 Fort = QString("Island"); // default |
96 m_fort = QString("Island"); // default |
98 Voicepack = "Default"; |
97 m_voicepack = "Default"; |
99 Flag = "hedgewars"; |
98 m_flag = "hedgewars"; |
100 |
99 |
101 for(int i = 0; i < BINDS_NUMBER; i++) |
100 for(int i = 0; i < BINDS_NUMBER; i++) |
102 { |
101 { |
103 binds[i].action = cbinds[i].action; |
102 binds[i].action = cbinds[i].action; |
104 binds[i].strbind = cbinds[i].strbind; |
103 binds[i].strbind = cbinds[i].strbind; |
105 } |
104 } |
106 Rounds = 0; |
105 m_rounds = 0; |
107 Wins = 0; |
106 m_wins = 0; |
108 CampaignProgress = 0; |
107 m_campaignProgress = 0; |
109 } |
108 } |
110 |
109 |
111 |
110 |
112 bool HWTeam::LoadFromFile() |
111 bool HWTeam::loadFromFile() |
113 { |
112 { |
114 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt", QSettings::IniFormat, 0); |
113 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + m_name + ".hwt", QSettings::IniFormat, 0); |
115 teamfile.setIniCodec("UTF-8"); |
114 teamfile.setIniCodec("UTF-8"); |
116 TeamName = teamfile.value("Team/Name", TeamName).toString(); |
115 m_name = teamfile.value("Team/Name", m_name).toString(); |
117 Grave = teamfile.value("Team/Grave", "Statue").toString(); |
116 m_grave = teamfile.value("Team/Grave", "Statue").toString(); |
118 Fort = teamfile.value("Team/Fort", "Plane").toString(); |
117 m_fort = teamfile.value("Team/Fort", "Plane").toString(); |
119 Voicepack = teamfile.value("Team/Voicepack", "Default").toString(); |
118 m_voicepack = teamfile.value("Team/Voicepack", "Default").toString(); |
120 Flag = teamfile.value("Team/Flag", "hedgewars").toString(); |
119 m_flag = teamfile.value("Team/Flag", "hedgewars").toString(); |
121 difficulty = teamfile.value("Team/Difficulty", 0).toInt(); |
120 m_difficulty = teamfile.value("Team/Difficulty", 0).toInt(); |
122 Rounds = teamfile.value("Team/Rounds", 0).toInt(); |
121 m_rounds = teamfile.value("Team/Rounds", 0).toInt(); |
123 Wins = teamfile.value("Team/Wins", 0).toInt(); |
122 m_wins = teamfile.value("Team/Wins", 0).toInt(); |
124 CampaignProgress = teamfile.value("Team/CampaignProgress", 0).toInt(); |
123 m_campaignProgress = teamfile.value("Team/CampaignProgress", 0).toInt(); |
125 for(int i = 0; i < 8; i++) |
124 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
126 { |
125 { |
127 QString hh = QString("Hedgehog%1/").arg(i); |
126 QString hh = QString("Hedgehog%1/").arg(i); |
128 Hedgehogs[i].Name = teamfile.value(hh + "Name", QString("hedgehog %1").arg(i+1)).toString(); |
127 m_hedgehogs[i].Name = teamfile.value(hh + "Name", QString("hedgehog %1").arg(i+1)).toString(); |
129 Hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString(); |
128 m_hedgehogs[i].Hat = teamfile.value(hh + "Hat", "NoHat").toString(); |
130 Hedgehogs[i].Rounds = teamfile.value(hh + "Rounds", 0).toInt(); |
129 m_hedgehogs[i].Rounds = teamfile.value(hh + "Rounds", 0).toInt(); |
131 Hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt(); |
130 m_hedgehogs[i].Kills = teamfile.value(hh + "Kills", 0).toInt(); |
132 Hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt(); |
131 m_hedgehogs[i].Deaths = teamfile.value(hh + "Deaths", 0).toInt(); |
133 Hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt(); |
132 m_hedgehogs[i].Suicides = teamfile.value(hh + "Suicides", 0).toInt(); |
134 } |
133 } |
135 for(int i = 0; i < BINDS_NUMBER; i++) |
134 for(int i = 0; i < BINDS_NUMBER; i++) |
136 binds[i].strbind = teamfile.value(QString("Binds/%1").arg(binds[i].action), cbinds[i].strbind).toString(); |
135 binds[i].strbind = teamfile.value(QString("Binds/%1").arg(binds[i].action), cbinds[i].strbind).toString(); |
137 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
136 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
138 if(achievements[i][0][0]) |
137 if(achievements[i][0][0]) |
140 else |
139 else |
141 break; |
140 break; |
142 return true; |
141 return true; |
143 } |
142 } |
144 |
143 |
145 bool HWTeam::FileExists() |
144 bool HWTeam::fileExists() |
146 { |
145 { |
147 QFile f(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt"); |
146 QFile f(cfgdir->absolutePath() + "/Teams/" + m_name + ".hwt"); |
148 return f.exists(); |
147 return f.exists(); |
149 } |
148 } |
150 |
149 |
151 bool HWTeam::DeleteFile() |
150 bool HWTeam::deleteFile() |
152 { |
151 { |
153 if(m_isNetTeam) |
152 if(m_isNetTeam) |
154 return false; |
153 return false; |
155 QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt"); |
154 QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + m_name + ".hwt"); |
156 cfgfile.remove(); |
155 cfgfile.remove(); |
157 return true; |
156 return true; |
158 } |
157 } |
159 |
158 |
160 bool HWTeam::SaveToFile() |
159 bool HWTeam::saveToFile() |
161 { |
160 { |
162 if (OldTeamName != TeamName) |
161 if (OldTeamName != m_name) |
163 { |
162 { |
164 QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + OldTeamName + ".hwt"); |
163 QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + OldTeamName + ".hwt"); |
165 cfgfile.remove(); |
164 cfgfile.remove(); |
166 OldTeamName = TeamName; |
165 OldTeamName = m_name; |
167 } |
166 } |
168 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt", QSettings::IniFormat, 0); |
167 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + m_name + ".hwt", QSettings::IniFormat, 0); |
169 teamfile.setIniCodec("UTF-8"); |
168 teamfile.setIniCodec("UTF-8"); |
170 teamfile.setValue("Team/Name", TeamName); |
169 teamfile.setValue("Team/Name", m_name); |
171 teamfile.setValue("Team/Grave", Grave); |
170 teamfile.setValue("Team/Grave", m_grave); |
172 teamfile.setValue("Team/Fort", Fort); |
171 teamfile.setValue("Team/Fort", m_fort); |
173 teamfile.setValue("Team/Voicepack", Voicepack); |
172 teamfile.setValue("Team/Voicepack", m_voicepack); |
174 teamfile.setValue("Team/Flag", Flag); |
173 teamfile.setValue("Team/Flag", m_flag); |
175 teamfile.setValue("Team/Difficulty", difficulty); |
174 teamfile.setValue("Team/Difficulty", m_difficulty); |
176 teamfile.setValue("Team/Rounds", Rounds); |
175 teamfile.setValue("Team/Rounds", m_rounds); |
177 teamfile.setValue("Team/Wins", Wins); |
176 teamfile.setValue("Team/Wins", m_wins); |
178 teamfile.setValue("Team/CampaignProgress", CampaignProgress); |
177 teamfile.setValue("Team/CampaignProgress", m_campaignProgress); |
179 for(int i = 0; i < 8; i++) |
178 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
180 { |
179 { |
181 QString hh = QString("Hedgehog%1/").arg(i); |
180 QString hh = QString("Hedgehog%1/").arg(i); |
182 teamfile.setValue(hh + "Name", Hedgehogs[i].Name); |
181 teamfile.setValue(hh + "Name", m_hedgehogs[i].Name); |
183 teamfile.setValue(hh + "Hat", Hedgehogs[i].Hat); |
182 teamfile.setValue(hh + "Hat", m_hedgehogs[i].Hat); |
184 teamfile.setValue(hh + "Rounds", Hedgehogs[i].Rounds); |
183 teamfile.setValue(hh + "Rounds", m_hedgehogs[i].Rounds); |
185 teamfile.setValue(hh + "Kills", Hedgehogs[i].Kills); |
184 teamfile.setValue(hh + "Kills", m_hedgehogs[i].Kills); |
186 teamfile.setValue(hh + "Deaths", Hedgehogs[i].Deaths); |
185 teamfile.setValue(hh + "Deaths", m_hedgehogs[i].Deaths); |
187 teamfile.setValue(hh + "Suicides", Hedgehogs[i].Suicides); |
186 teamfile.setValue(hh + "Suicides", m_hedgehogs[i].Suicides); |
188 } |
187 } |
189 for(int i = 0; i < BINDS_NUMBER; i++) |
188 for(int i = 0; i < BINDS_NUMBER; i++) |
190 teamfile.setValue(QString("Binds/%1").arg(binds[i].action), binds[i].strbind); |
189 teamfile.setValue(QString("Binds/%1").arg(binds[i].action), binds[i].strbind); |
191 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
190 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
192 if(achievements[i][0][0]) |
191 if(achievements[i][0][0]) |
196 return true; |
195 return true; |
197 } |
196 } |
198 |
197 |
199 void HWTeam::SetToPage(HWForm * hwform) |
198 void HWTeam::SetToPage(HWForm * hwform) |
200 { |
199 { |
201 hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName); |
200 hwform->ui.pageEditTeam->TeamNameEdit->setText(m_name); |
202 hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty); |
201 hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(m_difficulty); |
203 for(int i = 0; i < 8; i++) |
202 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
204 { |
203 { |
205 hwform->ui.pageEditTeam->HHNameEdit[i]->setText(Hedgehogs[i].Name); |
204 hwform->ui.pageEditTeam->HHNameEdit[i]->setText(m_hedgehogs[i].Name); |
206 if (Hedgehogs[i].Hat.startsWith("Reserved")) |
205 if (m_hedgehogs[i].Hat.startsWith("Reserved")) |
207 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData("Reserved "+Hedgehogs[i].Hat.remove(0,40), Qt::DisplayRole)); |
206 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData("Reserved "+m_hedgehogs[i].Hat.remove(0,40), Qt::DisplayRole)); |
208 else |
207 else |
209 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(Hedgehogs[i].Hat, Qt::DisplayRole)); |
208 hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(m_hedgehogs[i].Hat, Qt::DisplayRole)); |
210 } |
209 } |
211 hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave)); |
210 hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(m_grave)); |
212 hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findData(Flag)); |
211 hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findData(m_flag)); |
213 |
212 |
214 hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort)); |
213 hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(m_fort)); |
215 hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(Voicepack)); |
214 hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(m_voicepack)); |
216 //hwform->ui.pageEditTeam->CBFort_activated(Fort); |
215 //hwform->ui.pageEditTeam->CBFort_activated(Fort); |
217 |
216 |
218 for(int i = 0; i < BINDS_NUMBER; i++) |
217 for(int i = 0; i < BINDS_NUMBER; i++) |
219 { |
218 { |
220 hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findData(binds[i].strbind)); |
219 hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findData(binds[i].strbind)); |
221 } |
220 } |
222 } |
221 } |
223 |
222 |
224 void HWTeam::GetFromPage(HWForm * hwform) |
223 void HWTeam::GetFromPage(HWForm * hwform) |
225 { |
224 { |
226 TeamName = hwform->ui.pageEditTeam->TeamNameEdit->text(); |
225 m_name = hwform->ui.pageEditTeam->TeamNameEdit->text(); |
227 difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex(); |
226 m_difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex(); |
228 for(int i = 0; i < 8; i++) |
227 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
229 { |
228 { |
230 Hedgehogs[i].Name = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); |
229 m_hedgehogs[i].Name = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); |
231 if (hwform->ui.pageEditTeam->HHHats[i]->currentText().startsWith("Reserved")) |
230 if (hwform->ui.pageEditTeam->HHHats[i]->currentText().startsWith("Reserved")) |
232 Hedgehogs[i].Hat = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9); |
231 m_hedgehogs[i].Hat = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9); |
233 else |
232 else |
234 Hedgehogs[i].Hat = hwform->ui.pageEditTeam->HHHats[i]->currentText(); |
233 m_hedgehogs[i].Hat = hwform->ui.pageEditTeam->HHHats[i]->currentText(); |
235 } |
234 } |
236 |
235 |
237 Grave = hwform->ui.pageEditTeam->CBGrave->currentText(); |
236 m_grave = hwform->ui.pageEditTeam->CBGrave->currentText(); |
238 Fort = hwform->ui.pageEditTeam->CBFort->currentText(); |
237 m_fort = hwform->ui.pageEditTeam->CBFort->currentText(); |
239 Voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText(); |
238 m_voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText(); |
240 Flag = hwform->ui.pageEditTeam->CBFlag->itemData(hwform->ui.pageEditTeam->CBFlag->currentIndex()).toString(); |
239 m_flag = hwform->ui.pageEditTeam->CBFlag->itemData(hwform->ui.pageEditTeam->CBFlag->currentIndex()).toString(); |
241 for(int i = 0; i < BINDS_NUMBER; i++) |
240 for(int i = 0; i < BINDS_NUMBER; i++) |
242 { |
241 { |
243 binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString(); |
242 binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString(); |
244 } |
243 } |
245 } |
244 } |
246 |
245 |
247 QStringList HWTeam::TeamGameConfig(quint32 InitHealth) const |
246 QStringList HWTeam::teamGameConfig(quint32 InitHealth) const |
248 { |
247 { |
249 QStringList sl; |
248 QStringList sl; |
250 if (m_isNetTeam) |
249 if (m_isNetTeam) |
251 { |
250 { |
252 sl.push_back(QString("eaddteam %3 %1 %2").arg(teamColor.rgb() & 0xffffff).arg(TeamName).arg(QString(QCryptographicHash::hash(Owner.toLatin1(), QCryptographicHash::Md5).toHex()))); |
251 sl.push_back(QString("eaddteam %3 %1 %2").arg(m_color.rgb() & 0xffffff).arg(m_name).arg(QString(QCryptographicHash::hash(m_owner.toLatin1(), QCryptographicHash::Md5).toHex()))); |
253 sl.push_back("erdriven"); |
252 sl.push_back("erdriven"); |
254 } |
253 } |
255 else sl.push_back(QString("eaddteam %3 %1 %2").arg(teamColor.rgb() & 0xffffff).arg(TeamName).arg(playerHash)); |
254 else sl.push_back(QString("eaddteam %3 %1 %2").arg(m_color.rgb() & 0xffffff).arg(m_name).arg(playerHash)); |
256 |
255 |
257 sl.push_back(QString("egrave " + Grave)); |
256 sl.push_back(QString("egrave " + m_grave)); |
258 sl.push_back(QString("efort " + Fort)); |
257 sl.push_back(QString("efort " + m_fort)); |
259 sl.push_back(QString("evoicepack " + Voicepack)); |
258 sl.push_back(QString("evoicepack " + m_voicepack)); |
260 sl.push_back(QString("eflag " + Flag)); |
259 sl.push_back(QString("eflag " + m_flag)); |
261 |
260 |
262 if (!m_isNetTeam) |
261 if (!m_isNetTeam) |
263 for(int i = 0; i < BINDS_NUMBER; i++) |
262 for(int i = 0; i < BINDS_NUMBER; i++) |
264 if(!binds[i].strbind.isEmpty()) |
263 if(!binds[i].strbind.isEmpty()) |
265 sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action)); |
264 sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action)); |
266 |
265 |
267 for (int t = 0; t < numHedgehogs; t++) |
266 for (int t = 0; t < m_numHedgehogs; t++) |
268 { |
267 { |
269 sl.push_back(QString("eaddhh %1 %2 %3") |
268 sl.push_back(QString("eaddhh %1 %2 %3") |
270 .arg(QString::number(difficulty), |
269 .arg(QString::number(m_difficulty), |
271 QString::number(InitHealth), |
270 QString::number(InitHealth), |
272 Hedgehogs[t].Name)); |
271 m_hedgehogs[t].Name)); |
273 sl.push_back(QString("ehat %1") |
272 sl.push_back(QString("ehat %1") |
274 .arg(Hedgehogs[t].Hat)); |
273 .arg(m_hedgehogs[t].Hat)); |
275 } |
274 } |
276 return sl; |
275 return sl; |
277 } |
276 } |
278 |
277 |
279 bool HWTeam::isNetTeam() const |
278 bool HWTeam::isNetTeam() const |
281 return m_isNetTeam; |
280 return m_isNetTeam; |
282 } |
281 } |
283 |
282 |
284 |
283 |
285 bool HWTeam::operator==(const HWTeam& t1) const { |
284 bool HWTeam::operator==(const HWTeam& t1) const { |
286 return TeamName==t1.TeamName; |
285 return m_name==t1.m_name; |
287 } |
286 } |
288 |
287 |
289 bool HWTeam::operator<(const HWTeam& t1) const { |
288 bool HWTeam::operator<(const HWTeam& t1) const { |
290 return TeamName<t1.TeamName; // if names are equal - test if it is net team |
289 return m_name<t1.m_name; // if names are equal - test if it is net team |
291 } |
290 } |
292 |
291 |
293 |
292 |
|
293 //// Methods for member inspection+modification //// |
|
294 |
|
295 |
|
296 // name |
|
297 QString HWTeam::name() const { return m_name; } |
|
298 void HWTeam::setName(const QString & name) { m_name = name; } |
|
299 |
|
300 // single hedgehog |
|
301 const HWHog & HWTeam::hedgehog(unsigned int idx) const { return m_hedgehogs[idx]; } |
|
302 void HWTeam::setHedgehog(unsigned int idx, const HWHog & hh) { m_hedgehogs[idx] = hh; } |
|
303 |
|
304 // owner |
|
305 QString HWTeam::owner() const { return m_owner; } |
|
306 |
|
307 |
|
308 |
|
309 // difficulty |
|
310 unsigned int HWTeam::difficulty() const { return m_difficulty; } |
|
311 void HWTeam::setDifficulty(unsigned int level) { m_difficulty = level; } |
|
312 |
|
313 // color |
|
314 QColor HWTeam::color() const { return m_color; } |
|
315 void HWTeam::setColor(const QColor & color) { m_color = color; } |
|
316 |
|
317 |
|
318 |
|
319 // flag |
|
320 void HWTeam::setFlag(const QString & flag) { m_flag = flag; } |
|
321 QString HWTeam::flag() const { return m_flag; } |
|
322 |
|
323 // fort |
|
324 void HWTeam::setFort(const QString & fort) { m_fort = fort; } |
|
325 QString HWTeam::fort() const { return m_fort; } |
|
326 |
|
327 // grave |
|
328 void HWTeam::setGrave(const QString & grave) { m_grave = grave; } |
|
329 QString HWTeam::grave() const { return m_grave; } |
|
330 |
|
331 // voicepack - getter/setter |
|
332 void HWTeam::setVoicepack(const QString & voicepack) { m_voicepack = voicepack; } |
|
333 QString HWTeam::voicepack() const { return m_voicepack; } |
|
334 |
|
335 |
|
336 // campaignProgress - getter |
|
337 unsigned int HWTeam::campaignProgress() const { return m_campaignProgress; }; |
|
338 |
|
339 // amount of hedgehogs |
|
340 unsigned char HWTeam::numHedgehogs() const { return m_numHedgehogs; } |
|
341 void HWTeam::setNumHedgehogs(unsigned char num) { m_numHedgehogs = num; } |
|
342 |
|
343 |
|
344 |
|
345 // rounds+wins - incrementors |
|
346 void HWTeam::incRounds() { m_rounds++; } |
|
347 void HWTeam::incWins() { m_wins++; } |
|
348 |