aboutsummaryrefslogtreecommitdiff
path: root/People.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'People.cpp')
-rw-r--r--People.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/People.cpp b/People.cpp
index 39d44db..d11434d 100644
--- a/People.cpp
+++ b/People.cpp
@@ -1,6 +1,8 @@
#include <algorithm>
+#include <memory>
#include "People.h"
+#include "ArtistData.h"
#include "util.h"
using namespace std;
@@ -50,3 +52,21 @@ void People::update(bool tick) {
}
}
+Memories People::save() {
+ Memories data;
+ for (Artist * artist : this->artists) {
+ data.push_back(make_unique<ArtistDataMemento>(artist->data));
+ }
+ return data;
+}
+
+void People::restore(const Memories & memories) {
+ this->artists.clear();
+ this->artist_count = 0;
+ for (const unique_ptr<Memento> & memory : memories) {
+ auto data = dynamic_cast<ArtistDataMemento *>(memory.get());
+ if (data == nullptr) continue;
+ this->add_artist(data->data);
+ }
+}
+