QTfrontend/util/namegen.cpp
changeset 12244 45c83c88ac4b
parent 11888 618d99523933
child 12245 5206f9a803d1
equal deleted inserted replaced
12243:8a6a40f2e3dc 12244:45c83c88ac4b
    31 
    31 
    32 QList<QStringList> HWNamegen::TypesTeamnames;
    32 QList<QStringList> HWNamegen::TypesTeamnames;
    33 QList<QStringList> HWNamegen::TypesHatnames;
    33 QList<QStringList> HWNamegen::TypesHatnames;
    34 bool HWNamegen::typesAvailable = false;
    34 bool HWNamegen::typesAvailable = false;
    35 
    35 
    36 
    36 void HWNamegen::teamRandomFlag(HWTeam & team)
    37 void HWNamegen::teamRandomNames(HWTeam & team, const bool changeteamname)
    37 {
       
    38     team.setFlag(getRandomFlag());
       
    39 }
       
    40 
       
    41 void HWNamegen::teamRandomVoice(HWTeam & team)
       
    42 {
       
    43     team.setVoicepack(getRandomVoice());
       
    44 }
       
    45 
       
    46 void HWNamegen::teamRandomGrave(HWTeam & team)
       
    47 {
       
    48     team.setGrave(getRandomGrave());
       
    49 }
       
    50 
       
    51 void HWNamegen::teamRandomFort(HWTeam & team)
       
    52 {
       
    53     team.setFort(getRandomFort());
       
    54 }
       
    55 
       
    56 void HWNamegen::teamRandomEverything(HWTeam & team, const bool changeteamname)
    38 {
    57 {
    39     // load types if not already loaded
    58     // load types if not already loaded
    40     if (!typesAvailable)
    59     if (!typesAvailable)
    41         if (!loadTypes())
    60         if (!loadTypes())
    42             return; // abort if loading failed
    61             return; // abort if loading failed
    85             dicts = dictsForHat(team.hedgehog(i).Hat);
   104             dicts = dictsForHat(team.hedgehog(i).Hat);
    86             dict  = dictContents(dicts[rand()%(dicts.size())]);
   105             dict  = dictContents(dicts[rand()%(dicts.size())]);
    87         }
   106         }
    88 
   107 
    89         // give each hedgehog a random name
   108         // give each hedgehog a random name
    90         HWNamegen::teamRandomName(team,i,dict);
   109         HWNamegen::teamRandomHogName(team,i,dict);
    91     }
   110     }
    92 
   111 
    93 }
   112 }
    94 
   113 
    95 void HWNamegen::teamRandomName(HWTeam & team, const int HedgehogNumber)
   114 void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber)
    96 {
   115 {
    97     QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat);
   116     QStringList dicts = dictsForHat(team.hedgehog(HedgehogNumber).Hat);
    98 
   117 
    99     QStringList dict = dictContents(dicts[rand()%(dicts.size())]);
   118     QStringList dict = dictContents(dicts[rand()%(dicts.size())]);
   100 
   119 
   101     teamRandomName(team, HedgehogNumber, dict);
   120     teamRandomHogName(team, HedgehogNumber, dict);
   102 }
   121 }
   103 
   122 
   104 void HWNamegen::teamRandomName(HWTeam & team, const int HedgehogNumber, const QStringList & dict)
   123 void HWNamegen::teamRandomHogName(HWTeam & team, const int HedgehogNumber, const QStringList & dict)
   105 {
   124 {
   106     QStringList namesDict = dict;
   125     QStringList namesDict = dict;
   107 
   126 
   108     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
   127     for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
   109     {
   128     {