- else:
- with open(self.io.save_file, 'r') as f:
- lines = f.readlines()
- for i in range(len(lines)):
- line = lines[i]
- print("FILE INPUT LINE %5s: %s" % (i, line), end='')
- self.io.handle_input(line, god_mode=True)
+
+ def register_task(self, task):
+ prefix = 'Task_'
+ if not task.__name__.startswith(prefix):
+ raise GameError('illegal task object name: %s' % task.__name__)
+ task_name = task.__name__[len(prefix):]
+ self.tasks[task_name] = task
+
+ def read_savefile(self):
+ if os.path.exists(self.io.save_file):
+ with open(self.io.save_file, 'r') as f:
+ lines = f.readlines()
+ for i in range(len(lines)):
+ line = lines[i]
+ print("FILE INPUT LINE %5s: %s" % (i, line), end='')
+ self.io.handle_input(line, god_mode=True)