# HG changeset patch # User Wuzzy # Date 1506152145 -7200 # Node ID f4b0e164a0d52a729e5a07ae352f9cea9ceaf778 # Parent 92c597704e578a969e76518dc5a8d5ce5a8b97a7 Chance that clicking the random hats button produces a set of equal hats diff -r 92c597704e57 -r f4b0e164a0d5 QTfrontend/ui/page/pageeditteam.cpp --- 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); } diff -r 92c597704e57 -r f4b0e164a0d5 QTfrontend/util/namegen.cpp --- 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); diff -r 92c597704e57 -r f4b0e164a0d5 QTfrontend/util/namegen.h --- 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);