def save(self, db): """Saves the current game to the specified db. @param db: DbReader object of the db the game is saved to.""" super(World, self).save(db) if isinstance(self.map_name, list): db("INSERT INTO metadata VALUES(?, ?)", 'random_island_sequence', ' '.join(self.map_name)) else: # the map name has to be simplified because the absolute paths won't be transferable between machines simplified_name = self.map_name if self.map_name.startswith(PATHS.USER_MAPS_DIR): simplified_name = 'USER_MAPS_DIR:' + simplified_name[len(PATHS.USER_MAPS_DIR):] db("INSERT INTO metadata VALUES(?, ?)", 'map_name', simplified_name) for island in self.islands: island.save(db) for player in self.players: player.save(db) if self.trader is not None: self.trader.save(db) if self.pirate is not None: self.pirate.save(db) for unit in self.ships + self.ground_units: unit.save(db) for bullet in self.bullets: bullet.save(db) self.diplomacy.save(db) Weapon.save_attacks(db) self.disaster_manager.save(db)
def save(self, db): """Saves the current game to the specified db. @param db: DbReader object of the db the game is saved to.""" super().save(db) if isinstance(self.map_name, list): db("INSERT INTO metadata VALUES(?, ?)", 'random_island_sequence', ' '.join(self.map_name)) else: # the map name has to be simplified because the absolute paths won't be transferable between machines simplified_name = self.map_name if self.map_name.startswith(PATHS.USER_MAPS_DIR): simplified_name = 'USER_MAPS_DIR:' + simplified_name[ len(PATHS.USER_MAPS_DIR):] db("INSERT INTO metadata VALUES(?, ?)", 'map_name', simplified_name) for island in self.islands: island.save(db) for player in self.players: player.save(db) if self.trader is not None: self.trader.save(db) if self.pirate is not None: self.pirate.save(db) for unit in self.ships + self.ground_units: unit.save(db) self.diplomacy.save(db) Weapon.save_attacks(db) self.disaster_manager.save(db)
def save(self, db): """Saves the current game to the specified db. @param db: DbReader object of the db the game is saved to.""" super(World, self).save(db) if isinstance(self.map_name, list): db("INSERT INTO metadata VALUES(?, ?)", 'random_island_sequence', ' '.join(self.map_name)) else: db("INSERT INTO metadata VALUES(?, ?)", 'map_name', self.map_name) for island in self.islands: island.save(db) for player in self.players: player.save(db) if self.trader is not None: self.trader.save(db) if self.pirate is not None: self.pirate.save(db) for unit in self.ships + self.ground_units: unit.save(db) for bullet in self.bullets: bullet.save(db) self.diplomacy.save(db) Weapon.save_attacks(db) self.disaster_manager.save(db)
def save(self, db): """Saves the current game to the specified db. @param db: DbReader object of the db the game is saved to.""" super(World, self).save(db) for name, value in self.properties.iteritems(): db("INSERT INTO map_properties (name, value) VALUES (?, ?)", name, json.dumps(value)) for island in self.islands: island.save(db) for player in self.players: player.save(db) if self.trader is not None: self.trader.save(db) if self.pirate is not None: self.pirate.save(db) for unit in self.ships + self.ground_units: unit.save(db) for bullet in self.bullets: bullet.save(db) self.diplomacy.save(db) Weapon.save_attacks(db) self.disaster_manager.save(db)
def save(self, db): """Saves the current game to the specified db. @param db: DbReader object of the db the game is saved to.""" super(World, self).save(db) if isinstance(self.map_name, list): db("INSERT INTO metadata VALUES(?, ?)", 'random_island_sequence', ' '.join(self.map_name)) else: db("INSERT INTO metadata VALUES(?, ?)", 'map_name', self.map_name) for island in self.islands: island.save(db) for player in self.players: player.save(db) if self.trader is not None: self.trader.save(db) if self.pirate is not None: self.pirate.save(db) for unit in self.ships + self.ground_units: unit.save(db) for bullet in self.bullets: bullet.save(db) self.diplomacy.save(db) Weapon.save_attacks(db) self.disaster_manager.save(db)