Handle END and GOTO footers
This commit is contained in:
parent
106786279f
commit
f3d3bd2cd1
@ -3,7 +3,7 @@ START
|
||||
One day Dane took a really big shit.
|
||||
Dane: "Wow, that was a really big shit"
|
||||
|
||||
1) Don't die [NEXT]
|
||||
GOTO NEXT
|
||||
|
||||
NEXT
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "storybook.h"
|
||||
|
||||
@ -24,7 +25,7 @@ int main(int argc, const char *argv[]) {
|
||||
sb.Find("START");
|
||||
sb.Play();
|
||||
|
||||
while (!sb.IsEnded()) {
|
||||
while (!sb.IsEnded) {
|
||||
sb.Play();
|
||||
}
|
||||
|
||||
@ -50,8 +51,18 @@ void Storybook::Find(const char* id) {
|
||||
|
||||
void Storybook::Play() {
|
||||
printf(current->body);
|
||||
}
|
||||
|
||||
bool Storybook::IsEnded() {
|
||||
return true; // TODO
|
||||
switch (current->footer.type) {
|
||||
case FooterType::End:
|
||||
printf("The End.");
|
||||
IsEnded = true;
|
||||
break;
|
||||
case FooterType::Goto:
|
||||
Find(current->footer.link);
|
||||
printf("Press ENTER to continue...");
|
||||
std::cin.get();
|
||||
break;
|
||||
default:
|
||||
IsEnded = true; // TODO
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
Storybook(FILE* fin);
|
||||
void Find(const char*);
|
||||
void Play();
|
||||
bool IsEnded();
|
||||
bool IsEnded = false;
|
||||
};
|
||||
|
||||
#endif /* STORYBOOK_H */
|
||||
|
Loading…
Reference in New Issue
Block a user