about summary refs log tree commit diff stats
path: root/Source/Randomizer.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-10-30 21:58:46 -0700
committerjbzdarkid <jbzdarkid@gmail.com>2018-10-30 21:58:46 -0700
commit3557f0ba80942397a9d963208695b4fa80290cb0 (patch)
treed754d0f1b56ca10c133804639882d12d6686f7ec /Source/Randomizer.cpp
parente66a408e38849107a3d35a317ff6f2b23dcaeead (diff)
downloadwitness-tutorializer-3557f0ba80942397a9d963208695b4fa80290cb0.tar.gz
witness-tutorializer-3557f0ba80942397a9d963208695b4fa80290cb0.tar.bz2
witness-tutorializer-3557f0ba80942397a9d963208695b4fa80290cb0.zip
Infinite amounts of cleanup
Diffstat (limited to 'Source/Randomizer.cpp')
-rw-r--r--Source/Randomizer.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 83f5571..9622601 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp
@@ -4,21 +4,21 @@
4 * Swamp <-> symmetry has non-invisible background 4 * Swamp <-> symmetry has non-invisible background
5 * Tutorial sounds don't always play 5 * Tutorial sounds don't always play
6 * FEATURES: 6 * FEATURES:
7 * Prevent re-randomization (?) 7 * Clear "Randomized" button after short delay
8 * Clear "Randomized" state on NG (?) -- Or on a short delay
9 * Randomize audio logs -- Hard, seem to be unloaded some times? 8 * Randomize audio logs -- Hard, seem to be unloaded some times?
10 * Swap sounds in jungle (along with panels) -- maybe impossible 9 * Swap sounds in jungle (along with panels) -- maybe impossible
11 * Make orange 7 (all of oranges?) hard. Like big = hard. 10 * Make orange 7 (all of oranges?) hard. Like big = hard.
12 * Start the game if it isn't running? 11 * Start the game if it isn't running?
13 * Stop swapping colors in desert 12 * Stop swapping colors in desert
13 * Allow users to enter seed after randomly generating seed (aka detect user input in the text box)
14*/ 14*/
15#include "Memory.h" 15#include "Memory.h"
16#include "Randomizer.h" 16#include "Randomizer.h"
17#include "Panels.h" 17#include "Panels.h"
18#include "Random.h"
18#include <string> 19#include <string>
19#include <iostream> 20#include <iostream>
20#include <numeric> 21#include <numeric>
21#include <chrono>
22 22
23template <class T> 23template <class T>
24int find(const std::vector<T> &data, T search, size_t startIndex = 0) { 24int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
@@ -29,8 +29,16 @@ int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
29 exit(-1); 29 exit(-1);
30} 30}
31 31
32void Randomizer::Randomize() 32short Randomizer::Randomize(int seed)
33{ 33{
34 short metadata = _core.ReadMetadata();
35 if (metadata & 0x1) {
36 // Already randomized -- exit.
37 return metadata;
38 }
39 _core.WriteMetadata(metadata | 0x1);
40 Random::SetSeed(seed);
41
34 // Content swaps -- must happen before squarePanels 42 // Content swaps -- must happen before squarePanels
35 _core.Randomize(upDownPanels, SWAP_LINES); 43 _core.Randomize(upDownPanels, SWAP_LINES);
36 _core.Randomize(leftForwardRightPanels, SWAP_LINES); 44 _core.Randomize(leftForwardRightPanels, SWAP_LINES);
@@ -53,6 +61,7 @@ void Randomizer::Randomize()
53 RandomizeMountain(); 61 RandomizeMountain();
54 // RandomizeChallenge(); 62 // RandomizeChallenge();
55 // RandomizeAudioLogs(); 63 // RandomizeAudioLogs();
64 return metadata;
56} 65}
57 66
58void Randomizer::AdjustSpeed() { 67void Randomizer::AdjustSpeed() {