Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # I have a MapGame with abstract .spawn_players method, MapGame_FreeForAll(MapGame) and MapGame_TeamBased(MapGame)
- class MapGame(BaseGame):
- stage_groups = {
- 'game-start': ["spawn-players"],
- 'game-end': ["send-some-message", "destroy"],
- }
- # I'll skip send-some-message and destroy stages as they're unrelated
- @stage('spawn-players')
- def spawn_players(self):
- raise NotImplementedError
- class MapGame_FreeForAll(MapGame):
- @stage('spawn-players')
- def spawn_players(self):
- spawnpoints = list(self.spawnpoints)
- for player in self.players:
- teleport_to_spawnpoint(spawnpoints.pop(0))
- class MapGame_TeamBased(MapGame):
- @stage('spawn-players')
- def spawn_players(self):
- spawnpoints_team1 = list(self.spawnpoints_team1)
- spawnpoints_team2 = list(self.spawnpoints_team2)
- for player in self.players_team1:
- teleport_to_spawnpoint(spawnpoints_team1.pop(0))
- for player in self.players_team2:
- teleport_to_spawnpoint(spawnpoints_team2.pop(0))
- # Then I have a SurvivalGame_FreeForAll and SurvivalGame_TeamBased that inherit from SurvivalGame
- class SurvivalGame_FreeForAll(SurvivalGame):
- pass
- # Some methods specific to SurvivalGame_FreeForAll
- class SurvivalGame_TeamBased(SurvivalGame):
- pass
- # Some methods specific to SurvivalGame_TeamBased
- # And here goes SurvivalGame itself
- # Now to the funny part - survival games require setting damage hooks - that's another stage
- class SurvivalGame(??????????????): # I'll skip inheritance for this class
- stage_groups = {
- 'game-start': ["spawn-players", "setup-damage-hooks"] # Note how game-start stage is altered,
- # but the stage_groups dict still retains
- # original "game-end" stage untouched
- }
- @stage('setup-damage-hooks')
- def setup_damage_hooks(self):
- for player in self.player:
- setup_damage_hook(player)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement