QTfrontend/util/namegen.cpp
changeset 12502 f4b0e164a0d5
parent 12501 92c597704e57
child 12505 82c75a317d48
equal deleted inserted replaced
12501:92c597704e57 12502:f4b0e164a0d5
    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         else if (mode == HWNamegen::rtmHats)
       
   105         {
       
   106             HWNamegen::teamRandomHat(team,i);
       
   107         }
       
   108 
   104 
   109         // there is a chance that this hog has the same hat as the previous one
   105         // there is a chance that this hog has the same hat as the previous one
   110         // let's reuse the hat-specific dict in this case
   106         // let's reuse the hat-specific dict in this case
   111         if ( (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) && ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)))
   107         if ( (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything) && ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)))
   112         {
   108         {
   117         // give each hedgehog a random name
   113         // give each hedgehog a random name
   118         if (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything)
   114         if (mode == HWNamegen::rtmHogNames || mode == HWNamegen::rtmEverything)
   119             HWNamegen::teamRandomHogName(team,i,dict);
   115             HWNamegen::teamRandomHogName(team,i,dict);
   120     }
   116     }
   121 
   117 
       
   118 }
       
   119 
       
   120 // Set random hats for entire team
       
   121 void HWNamegen::teamRandomHats(HWTeam & team, bool withDLC)
       
   122 {
       
   123     // 50% chance that all hogs are set to the same hat.
       
   124     // 50% chance that each hog gets a random head individually.
       
   125 
       
   126     bool sameHogs = (rand()%2) == 0;
       
   127     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
       
   128     {
       
   129         HWHog hh = team.hedgehog(i);
       
   130         if (sameHogs and i > 0)
       
   131             hh.Hat = team.hedgehog(i-1).Hat;
       
   132         else
       
   133             hh.Hat = getRandomHat(withDLC);
       
   134         team.setHedgehog(i, hh);
       
   135     }
   122 }
   136 }
   123 
   137 
   124 void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, bool withDLC)
   138 void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, bool withDLC)
   125 {
   139 {
   126     HWHog hh = team.hedgehog(HedgehogNumber);
   140     HWHog hh = team.hedgehog(HedgehogNumber);