def save(self): l = self.level s = os.path.normcase( os.path.join(os.environ["APPDATA"], self.save_file)) with open(s, 'wb') as f: pickle.dump(self.seed, f, pickle.HIGHEST_PROTOCOL) pickle.dump(self.where, f, pickle.HIGHEST_PROTOCOL) self.last_level_seed = l.seed pickle.dump(self.last_level_seed, f, pickle.HIGHEST_PROTOCOL) l.save(f) mm.con("Game saved @ level {} to {}".format(str(l), s))
def load(self): s = os.path.normcase( os.path.join(os.environ["APPDATA"], self.save_file)) with open(s, 'rb') as f: mm.log("Game loading from {}".format(s)) self.seed = pickle.load(f) self.where = pickle.load(f) self.last_level_seed = pickle.load(f) self.load_level(self.last_level_seed) mm.log("Game loaded @ level {} to {}".format(str(self.level), s)) mm.con("Loaded previously saved game") if self.version != self.__class__.class_version: self.upgrade()
def save(self): l = self.level s = os.path.normcase( os.path.join(os.environ["APPDATA"], self.save_file)) with open(s, 'wb') as f: pickle.dump(self.seed, f, pickle.HIGHEST_PROTOCOL) pickle.dump(self.sdl_delay, f, pickle.HIGHEST_PROTOCOL) pickle.dump(self.where, f, pickle.HIGHEST_PROTOCOL) pickle.dump(self.move_count, f, pickle.HIGHEST_PROTOCOL) pickle.dump(self.moves_per_day, f, pickle.HIGHEST_PROTOCOL) pickle.dump(self.level_stack, f, pickle.HIGHEST_PROTOCOL) self.last_level_seed = l.seed pickle.dump(self.last_level_seed, f, pickle.HIGHEST_PROTOCOL) l.save(f) mm.con("Game saved @ chunk {0} to {1}".format(str(l), s))
def load(self): s = os.path.normcase(os.path.join(os.environ["APPDATA"], self.save_file)) with open(s, 'rb') as f: mm.log("Game loading from {0}".format(s)) self.seed = pickle.load(f) self.sdl_delay = pickle.load(f) self.where = pickle.load(f) self.move_count = pickle.load(f) self.moves_per_day = pickle.load(f) self.level_stack = pickle.load(f) self.last_level_seed = pickle.load(f) self.load_level(self.last_level_seed) mm.log("Game loaded @ chunk {0} to {1}".format(str(self.level), s)) mm.con("Loaded previously saved game") if self.version != self.__class__.class_version: self.upgrade()
def con(self, msg): mm.con("Level {0}: {1}".format(str(self), msg))
def die(self, msg): mm.con("".join(traceback.format_stack())) mm.die("p_wid {}: ERROR: {}".format(self.name, msg))
def hook_new_game(): mm.con("New game hook") game.game_new()
def wid_tp_grid_on_m_over(w, x, y, button): mm.con("o") return True
def con(self, msg): mm.con("Thing {0}: {1}".format(str(self), msg))
def hello(): mm.con("%%fg=yellow$" + " _____ __ __") mm.con("%%fg=yellow$" + " / \\ | \\ | \\") mm.con( "%%fg=yellow$" + "| $$$$$\\ ____ __ __ _____ _| $$_ ____ | $$ ____ ____ ____" ) mm.con( "%%fg=yellow$" + "| $$ \\$$ / \\ | \\ | \\ / \\| $$ \\ | \\ | $$ / \\ / \\ / \\" ) mm.con( "%%fg=yellow$" + "| $$ | $$$$\\| $$ | $$| $$$$$ \\$$$$$$ \\$$$$\\| $$| $$$$\\| $$$$\\| $$$$\\" ) mm.con( "%%fg=yellow$" + "| $$ __ | $$ \\$$| $$ | $$ \\$$ \\ | $$ __ / $$| $$| $$ $$| $$ $$| $$ \\$$" ) mm.con( "%%fg=yellow$" + "| $$_/ \\| $$ | $$_/ $$ _\\$$$$\\ | $$| \\| $$$$$| $$| $$$$$$| $$$$$$| $$" ) mm.con( "%%fg=yellow$" + " \\$$ $$| $$ \\$$ $$| $$ \\$$ $$ \\$$ $$| $$ \\$$ \\ \\$$ \\| $$" ) mm.con( "%%fg=yellow$" + " \\$$$$$ \\$$ _\\$$$$$$ \\$$$$$ \\$$$$ \\$$$$$ \\$$ \\$$$$$ \\$$$$$ \\$$" ) mm.con("%%fg=yellow$" + " | \\_| $$") mm.con("%%fg=yellow$" + " \\$$ $$") mm.con("%%fg=yellow$" + " \\$$$$$") mm.con("%%fg=green$Version " + mm.VERSION + "%%fg=reset$") mm.con(" ") mm.con("Press %%fg=red$<tab>%%fg=reset$ to complete commands.") mm.con("Press %%fg=red$?%%fg=reset$ to show command options.") mm.con("You can also enter raw python code here.")
def die(self, msg): mm.con("".join(traceback.format_stack())) mm.die("Chunk {0}: ERROR: {1}".format(str(self), msg))
def con(self, msg): mm.con("Chunk {0}: {1}".format(str(self), msg))
def die(self, msg): mm.con("".join(traceback.format_stack())) mm.die("p_wid {0}: ERROR: {1}".format(self.name, msg))
def con(self, msg): mm.con("p_wid {0}: {1}".format(str(self), msg))
def err(self, msg): mm.con("".join(traceback.format_stack())) mm.err("Level {0}: ERROR: {1}".format(self, msg))
def die(self, msg): mm.con("".join(traceback.format_stack())) mm.die("Level {0}: FATAL ERROR: {1}".format(self, msg))
def con(self, msg): mm.con("Level {}: {}".format(str(self), msg))
def hook_destroy_game(): mm.con("Destroy game hook") if game.g is not None: game.g.destroy()
def err(self, msg): mm.con("".join(traceback.format_stack())) mm.err("Level {}: ERROR: {}".format(self, msg))
def wid_tp_grid_on_m_down_close(w, x, y, button): mm.con("TODO") return True
def die(self, msg): mm.con("".join(traceback.format_stack())) mm.die("Level {}: FATAL ERROR: {}".format(self, msg))
def con(self, msg): mm.con("p_wid {}: {}".format(str(self), msg))