equal
deleted
inserted
replaced
38 { |
38 { |
39 } |
39 } |
40 |
40 |
41 |
41 |
42 |
42 |
43 void HWNamegen::TeamRandomName(HWTeam*& team, const int &i) |
43 void HWNamegen::TeamRandomName(HWTeam*& team, const int HedgehogNumber) |
44 { |
44 { |
45 RandomNameByHat(team,i); |
45 RandomNameByHat(team, HedgehogNumber); |
46 } |
46 } |
47 |
47 |
48 void HWNamegen::TeamRandomNames(HWTeam*& team, const bool changeteamname) |
48 void HWNamegen::TeamRandomNames(HWTeam*& team, const bool changeteamname) |
49 { |
49 { |
50 if ((TypesHatnames.size() > 0) && TypesAvliable){ |
50 if ((TypesHatnames.size() > 0) && TypesAvliable){ |
53 |
53 |
54 if (changeteamname){ |
54 if (changeteamname){ |
55 if (TypesTeamnames[kind].size() > 0){ |
55 if (TypesTeamnames[kind].size() > 0){ |
56 team->TeamName = TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]; |
56 team->TeamName = TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]; |
57 } |
57 } |
58 team->Grave = "Simple"; // Todo: make it semi-random |
58 team->Grave = GetRandomGrave(); |
59 team->Fort = "Island"; // Todo: make it semi-random |
59 team->Fort = GetRandomFort(); |
60 team->Voicepack = "Default"; |
60 team->Voicepack = "Default"; |
61 } |
61 } |
62 |
62 |
|
63 //give each hedgehog a random name: |
|
64 //TODO: load the dictionary only once! (right now it's loaded once for each hedgehog) |
63 for(int i = 0; i < 8; i++) |
65 for(int i = 0; i < 8; i++) |
64 { |
66 { |
65 if ((TypesHatnames[kind].size()) > 0){ |
67 if ((TypesHatnames[kind].size()) > 0){ |
66 team->Hedgehogs[i].Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
68 team->Hedgehogs[i].Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
67 } |
69 } |
71 } |
73 } |
72 |
74 |
73 } |
75 } |
74 |
76 |
75 |
77 |
76 void HWNamegen::RandomNameByHat(HWTeam*& team, const int &i) |
78 void HWNamegen::RandomNameByHat(HWTeam*& team, const int HedgehogNumber) |
77 { |
79 { |
78 QStringList Dictionaries; |
80 QStringList Dictionaries; |
79 HatCfgLoad(team->Hedgehogs[i].Hat,Dictionaries); |
81 HatCfgLoad(team->Hedgehogs[HedgehogNumber].Hat,Dictionaries); |
80 |
82 |
81 QStringList Dictionary; |
83 QStringList Dictionary; |
82 DictLoad(Dictionaries[rand()%(Dictionaries.size())],Dictionary); |
84 DictLoad(Dictionaries[rand()%(Dictionaries.size())],Dictionary); |
83 |
85 |
84 team->Hedgehogs[i].Name = Dictionary[rand()%(Dictionary.size())]; |
86 team->Hedgehogs[HedgehogNumber].Name = Dictionary[rand()%(Dictionary.size())]; |
85 } |
87 } |
86 |
88 |
87 void HWNamegen::DictLoad(const QString filename, QStringList &list) |
89 void HWNamegen::DictLoad(const QString filename, QStringList &list) |
88 { |
90 { |
89 list.clear(); |
91 list.clear(); |
162 TypesAvliable = TRUE; |
164 TypesAvliable = TRUE; |
163 return; |
165 return; |
164 } |
166 } |
165 |
167 |
166 |
168 |
|
169 |
|
170 QString HWNamegen::GetRandomGrave() |
|
171 { |
|
172 QStringList Graves; |
|
173 |
|
174 //list all available Graves |
|
175 QDir tmpdir; |
|
176 tmpdir.cd(datadir->absolutePath()); |
|
177 tmpdir.cd("Graphics/Graves"); |
|
178 tmpdir.setFilter(QDir::Files); |
|
179 Graves.append(tmpdir.entryList(QStringList("*.png")).replaceInStrings(QRegExp("^(.*)\\.png"), "\\1")); |
|
180 |
|
181 if(Graves.size()==0) |
|
182 { |
|
183 //do some serious error handling |
|
184 return "Error"; |
|
185 } |
|
186 |
|
187 //pick a random grave |
|
188 return Graves[rand()%(Graves.size())]; |
|
189 } |
|
190 |
|
191 QString HWNamegen::GetRandomFort() |
|
192 { |
|
193 QStringList Forts; |
|
194 |
|
195 //list all available Forts |
|
196 QDir tmpdir; |
|
197 tmpdir.cd(datadir->absolutePath()); |
|
198 tmpdir.cd("Forts"); |
|
199 tmpdir.setFilter(QDir::Files); |
|
200 Forts.append(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
|
201 |
|
202 if(Forts.size()==0) |
|
203 { |
|
204 //do some serious error handling |
|
205 return "Error"; |
|
206 } |
|
207 |
|
208 //pick a random fort |
|
209 return Forts[rand()%(Forts.size())]; |
|
210 } |