75 // the hat will influence which names the hogs get |
75 // the hat will influence which names the hogs get |
76 int kind = (rand()%(TypesHatnames.size())); |
76 int kind = (rand()%(TypesHatnames.size())); |
77 |
77 |
78 // pick team name based on hat |
78 // pick team name based on hat |
79 if (mode == HWNamegen::rtmEverything) |
79 if (mode == HWNamegen::rtmEverything) |
80 { |
80 { team.setName(getRandomTeamName(kind)); |
81 team.setName(getRandomTeamName(kind)); |
|
82 team.setGrave(getRandomGrave()); |
81 team.setGrave(getRandomGrave()); |
83 team.setFort(getRandomFort()); |
82 team.setFort(getRandomFort()); |
84 team.setFlag(getRandomFlag()); |
83 team.setFlag(getRandomFlag()); |
85 team.setVoicepack(getRandomVoice()); |
84 team.setVoicepack(getRandomVoice()); |
86 } |
85 } |
87 |
86 |
88 QStringList dicts; |
87 QStringList dicts; |
89 QStringList dict; |
88 QStringList dict; |
90 |
89 |
91 if ((TypesHatnames[kind].size()) <= 0) |
90 if ((mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) && (TypesHatnames[kind].size()) <= 0) |
92 { |
91 { |
93 dicts = dictsForHat(team.hedgehog(0).Hat); |
92 dicts = dictsForHat(team.hedgehog(0).Hat); |
94 dict = dictContents(dicts[rand()%(dicts.size())]); |
93 dict = dictContents(dicts[rand()%(dicts.size())]); |
95 } |
94 } |
96 |
95 |
97 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
96 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
98 { |
97 { |
99 if (((TypesHatnames[kind].size()) > 0) && (mode == HWNamegen::rtmEverything || mode == HWNamegen::rtmHats)) |
98 if (mode == HWNamegen::rtmEverything && (TypesHatnames[kind].size()) > 0) |
100 { |
99 { |
101 HWHog hh = team.hedgehog(i); |
100 HWHog hh = team.hedgehog(i); |
102 hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
101 hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
103 team.setHedgehog(i,hh); |
102 team.setHedgehog(i,hh); |
104 } |
103 } |
|
104 else if (mode == HWNamegen::rtmHats) |
|
105 { |
|
106 HWNamegen::teamRandomHat(team,i); |
|
107 } |
|
108 |
105 // there is a chance that this hog has the same hat as the previous one |
109 // there is a chance that this hog has the same hat as the previous one |
106 // let's reuse the hat-specific dict in this case |
110 // let's reuse the hat-specific dict in this case |
107 if ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)) |
111 if ( (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) && ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat))) |
108 { |
112 { |
109 dicts = dictsForHat(team.hedgehog(i).Hat); |
113 dicts = dictsForHat(team.hedgehog(i).Hat); |
110 dict = dictContents(dicts[rand()%(dicts.size())]); |
114 dict = dictContents(dicts[rand()%(dicts.size())]); |
111 } |
115 } |
112 |
116 |
113 // give each hedgehog a random name |
117 // give each hedgehog a random name |
114 if (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) |
118 if (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) |
115 HWNamegen::teamRandomHogName(team,i,dict); |
119 HWNamegen::teamRandomHogName(team,i,dict); |
116 } |
120 } |
117 |
121 |
|
122 } |
|
123 |
|
124 void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, bool withDLC) |
|
125 { |
|
126 HWHog hh = team.hedgehog(HedgehogNumber); |
|
127 |
|
128 hh.Hat = getRandomHat(withDLC); |
|
129 |
|
130 team.setHedgehog(HedgehogNumber, hh); |
|
131 } |
|
132 |
|
133 void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, const QStringList & dict) |
|
134 { |
|
135 HWHog hh = team.hedgehog(HedgehogNumber); |
|
136 |
|
137 hh.Name = dict[rand()%(dict.size())]; |
|
138 |
|
139 team.setHedgehog(HedgehogNumber, hh); |
118 } |
140 } |
119 |
141 |
120 void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber) |
142 void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber) |
121 { |
143 { |
122 QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat); |
144 QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat); |