3
3
#include < algorithm>
4
4
#include < vector>
5
5
#include < random>
6
+ #include < fstream>
6
7
7
8
int main ()
8
9
{
@@ -28,7 +29,7 @@ int main()
28
29
29
30
int searchLine = 0 ;
30
31
31
- // auto rng = std::minstd_rand0{} ;
32
+ std::string saveList ;
32
33
33
34
// ------------------------------------------------------------------------------- DELIMITOR ------------------------------------------------------------------------------------------------//
34
35
@@ -38,9 +39,15 @@ int main()
38
39
Tools::Log (" Enter the Seed you wish to use!" , Tools::Colour::Red);
39
40
40
41
std::getline (std::cin, seedString);
42
+
43
+ for (int i = 0 ; i < seedString.size (); i++)
44
+ {
45
+ seedString.at (i) = towupper (seedString.at (i));
46
+ }
47
+
41
48
std::seed_seq seed (seedString.begin (), seedString.end ());
42
49
43
- std::minstd_rand0 generator (seed);
50
+ std::default_random_engine rng (seed);
44
51
45
52
Tools::Log (" Now, name everyone who's participating as a secret santa! Write 'end' to finish the list." , Tools::Colour::Red);
46
53
@@ -57,14 +64,29 @@ int main()
57
64
58
65
if (santa == " END" )
59
66
{
60
- std::shuffle (std::begin (giftReceiver), std::end (giftReceiver), generator ());
67
+ std::shuffle (std::begin (giftReceiver), std::end (giftReceiver), rng);
68
+
69
+ for (int i = 0 ; i < secretSanta.size (); i++)
70
+ {
71
+ saveList += secretSanta.at (i) + " \n " ;
72
+ }
73
+
74
+ auto save = " Seed: " + seedString + " \n\n Santas: \n " + saveList;
75
+
76
+ std::ofstream saveFile (" ../Seed/SantaListSeed.txt" );
77
+
78
+ saveFile << save;
79
+
80
+ saveFile.close ();
61
81
62
82
isListEnded = true ;
63
83
}
64
84
65
- secretSanta.push_back (santa);
66
- giftReceiver.push_back (santa);
67
-
85
+ else
86
+ {
87
+ secretSanta.push_back (santa);
88
+ giftReceiver.push_back (santa);
89
+ }
68
90
69
91
}
70
92
@@ -86,7 +108,7 @@ int main()
86
108
// Reshuffle if its still the same name.
87
109
if (name == giftReceiver.at (searchLine))
88
110
{
89
- std::shuffle (std::begin (giftReceiver), std::end (giftReceiver), generator () );
111
+ std::shuffle (std::begin (giftReceiver), std::end (giftReceiver), rng );
90
112
}
91
113
92
114
else
@@ -99,7 +121,7 @@ int main()
99
121
receiverName.at (i) = tolower (receiverName.at (i));
100
122
}
101
123
102
- std::string message = " You gotta gift: " + receiverName + " !" ;
124
+ std::string message = " You gotta gift " + receiverName + " !" ;
103
125
104
126
Tools::Log (message, Tools::Colour::Red);
105
127
isSearchEnded = true ;
0 commit comments