58 void HWNamegen::teamRandomFort(HWTeam & team) |
58 void HWNamegen::teamRandomFort(HWTeam & team) |
59 { |
59 { |
60 team.setFort(getRandomFort()); |
60 team.setFort(getRandomFort()); |
61 } |
61 } |
62 |
62 |
63 void HWNamegen::teamRandomEverything(HWTeam & team, const bool changeteamname) |
63 void HWNamegen::teamRandomEverything(HWTeam & team, const RandomTeamMode mode) |
64 { |
64 { |
65 // load types if not already loaded |
65 // load types if not already loaded |
66 if (!typesAvailable) |
66 if (!typesAvailable) |
67 if (!loadTypes()) |
67 if (!loadTypes()) |
68 return; // abort if loading failed |
68 return; // abort if loading failed |
73 |
73 |
74 // the hat will influence which names the hogs get |
74 // the hat will influence which names the hogs get |
75 int kind = (rand()%(TypesHatnames.size())); |
75 int kind = (rand()%(TypesHatnames.size())); |
76 |
76 |
77 // pick team name based on hat |
77 // pick team name based on hat |
78 if (changeteamname) |
78 if (mode == HWNamegen::rtmEverything) |
79 { |
79 { |
80 team.setName(getRandomTeamName(kind)); |
80 team.setName(getRandomTeamName(kind)); |
81 team.setGrave(getRandomGrave()); |
81 team.setGrave(getRandomGrave()); |
82 team.setFort(getRandomFort()); |
82 team.setFort(getRandomFort()); |
83 team.setFlag(getRandomFlag()); |
83 team.setFlag(getRandomFlag()); |
93 dict = dictContents(dicts[rand()%(dicts.size())]); |
93 dict = dictContents(dicts[rand()%(dicts.size())]); |
94 } |
94 } |
95 |
95 |
96 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
96 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
97 { |
97 { |
98 if ((TypesHatnames[kind].size()) > 0) |
98 if (((TypesHatnames[kind].size()) > 0) && (mode == HWNamegen::rtmEverything || mode == HWNamegen::rtmHats)) |
99 { |
99 { |
100 HWHog hh = team.hedgehog(i); |
100 HWHog hh = team.hedgehog(i); |
101 hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
101 hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; |
102 team.setHedgehog(i,hh); |
102 team.setHedgehog(i,hh); |
103 } |
103 } |
104 |
|
105 // there is a chance that this hog has the same hat as the previous one |
104 // 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 |
105 // let's reuse the hat-specific dict in this case |
107 if ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)) |
106 if ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)) |
108 { |
107 { |
109 dicts = dictsForHat(team.hedgehog(i).Hat); |
108 dicts = dictsForHat(team.hedgehog(i).Hat); |
110 dict = dictContents(dicts[rand()%(dicts.size())]); |
109 dict = dictContents(dicts[rand()%(dicts.size())]); |
111 } |
110 } |
112 |
111 |
113 // give each hedgehog a random name |
112 // give each hedgehog a random name |
114 HWNamegen::teamRandomHogName(team,i,dict); |
113 if (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) |
|
114 HWNamegen::teamRandomHogName(team,i,dict); |
115 } |
115 } |
116 |
116 |
117 } |
117 } |
118 |
118 |
119 void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber) |
119 void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber) |