Chance that clicking the random hats button produces a set of equal hats
authorWuzzy <almikes@aol.com>
Sat, 23 Sep 2017 09:35:45 +0200
changeset 12502 f4b0e164a0d5
parent 12501 92c597704e57
child 12503 7442bb330d38
Chance that clicking the random hats button produces a set of equal hats
QTfrontend/ui/page/pageeditteam.cpp
QTfrontend/util/namegen.cpp
QTfrontend/util/namegen.h
--- a/QTfrontend/ui/page/pageeditteam.cpp	Sat Sep 23 09:12:35 2017 +0200
+++ b/QTfrontend/ui/page/pageeditteam.cpp	Sat Sep 23 09:35:45 2017 +0200
@@ -488,7 +488,7 @@
 void PageEditTeam::setRandomHats()
 {
     HWTeam team = data();
-    HWNamegen::teamRandomEverything(team, HWNamegen::rtmHats);
+    HWNamegen::teamRandomHats(team);
     loadTeam(team);
 }
 
--- a/QTfrontend/util/namegen.cpp	Sat Sep 23 09:12:35 2017 +0200
+++ b/QTfrontend/util/namegen.cpp	Sat Sep 23 09:35:45 2017 +0200
@@ -101,10 +101,6 @@
             hh.Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())];
             team.setHedgehog(i,hh);
         }
-        else if (mode == HWNamegen::rtmHats)
-        {
-            HWNamegen::teamRandomHat(team,i);
-        }
 
         // there is a chance that this hog has the same hat as the previous one
         // let's reuse the hat-specific dict in this case
@@ -121,6 +117,24 @@
 
 }
 
+// Set random hats for entire team
+void HWNamegen::teamRandomHats(HWTeam & team, bool withDLC)
+{
+    // 50% chance that all hogs are set to the same hat.
+    // 50% chance that each hog gets a random head individually.
+
+    bool sameHogs = (rand()%2) == 0;
+    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
+    {
+        HWHog hh = team.hedgehog(i);
+        if (sameHogs and i > 0)
+            hh.Hat = team.hedgehog(i-1).Hat;
+        else
+            hh.Hat = getRandomHat(withDLC);
+        team.setHedgehog(i, hh);
+    }
+}
+
 void HWNamegen::teamRandomHat(HWTeam & team, const int HedgehogNumber, bool withDLC)
 {
     HWHog hh = team.hedgehog(HedgehogNumber);
--- a/QTfrontend/util/namegen.h	Sat Sep 23 09:12:35 2017 +0200
+++ b/QTfrontend/util/namegen.h	Sat Sep 23 09:35:45 2017 +0200
@@ -32,7 +32,6 @@
         {
             rtmEverything = 0,
             rtmHogNames = 1,
-            rtmHats = 2
         };
 
         static void teamRandomTeamName(HWTeam & team);
@@ -40,6 +39,7 @@
         static void teamRandomFort(HWTeam & team, bool withDLC = true);
         static void teamRandomFlag(HWTeam & team, bool withDLC = true);
         static void teamRandomVoice(HWTeam & team, bool withDLC = true);
+        static void teamRandomHats(HWTeam & team, bool withDLC = true);
         static void teamRandomHat(HWTeam & team, const int HedgehogNumber, bool withDLC = true);
         static void teamRandomHogName(HWTeam & team, const int HedgehogNumber);
         static void teamRandomEverything(HWTeam & team, const enum RandomTeamMode mode);