Handle END and GOTO footers
This commit is contained in:
		@@ -3,7 +3,7 @@ START
 | 
				
			|||||||
One day Dane took a really big shit.
 | 
					One day Dane took a really big shit.
 | 
				
			||||||
Dane: "Wow, that was a really big shit"
 | 
					Dane: "Wow, that was a really big shit"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1) Don't die [NEXT]
 | 
					GOTO NEXT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NEXT
 | 
					NEXT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
#include <cstdlib>
 | 
					#include <cstdlib>
 | 
				
			||||||
#include <cstring>
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "storybook.h"
 | 
					#include "storybook.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -24,7 +25,7 @@ int main(int argc, const char *argv[]) {
 | 
				
			|||||||
  sb.Find("START");
 | 
					  sb.Find("START");
 | 
				
			||||||
  sb.Play();
 | 
					  sb.Play();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while (!sb.IsEnded()) {
 | 
					  while (!sb.IsEnded) {
 | 
				
			||||||
    sb.Play();
 | 
					    sb.Play();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,8 +51,18 @@ void Storybook::Find(const char* id) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Storybook::Play() {
 | 
					void Storybook::Play() {
 | 
				
			||||||
  printf(current->body);
 | 
					  printf(current->body);
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Storybook::IsEnded() {
 | 
					  switch (current->footer.type) {
 | 
				
			||||||
  return true; // TODO
 | 
					  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);
 | 
					  Storybook(FILE* fin);
 | 
				
			||||||
  void Find(const char*);
 | 
					  void Find(const char*);
 | 
				
			||||||
  void Play();
 | 
					  void Play();
 | 
				
			||||||
  bool IsEnded();
 | 
					  bool IsEnded = false;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* STORYBOOK_H */
 | 
					#endif /* STORYBOOK_H */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user