예제 #1
0
    def build_new(self):
        logger.info("Build New")
        self.allunits = []
        self.factions = {}
        self.allreinforcements = {}
        self.prefabs = []
        self.objective = None
        self.phase_music = None
        self.map = None
        self.game_constants = Counter()
        self.game_constants['level'] = 0
        self.game_constants['money'] = 0
        self.convoy = []
        self.play_time = 0
        self.support = Support.Support_Graph(
            'Data/support_nodes.txt',
            'Data/support_edges.txt') if cf.CONSTANTS['support'] else None
        self.unlocked_lore = []
        self.statistics = []
        self.market_items = set()

        self.sweep()
        self.generic()

        # Turn tutorial mode off if the difficulty does not start with a tutorial
        if not int(self.mode['tutorial']):
            cf.OPTIONS['Display Hints'] = 0
예제 #2
0
    def build_new(self):
        logger.info("Build New")
        self.allunits = []
        self.groups = {}
        self.allreinforcements = {}
        self.prefabs = []
        self.objective = None
        self.map = None
        self.counters = {}
        self.counters['level'] = 0
        self.convoy = []
        self.counters['money'] = 0
        self.play_time = 0
        self.game_constants = []
        self.support = Support.Support_Graph(
            'Data/support_nodes.txt',
            'Data/support_edges.txt') if cf.CONSTANTS['support'] else None
        self.modify_stats = cf.read_growths_file()
        self.unlocked_lore = []
        self.statistics = []
        self.market_items = set()

        self.sweep()
        self.generic()
예제 #3
0
    def load(self, load_info):
        logger.info("Load")
        # Rebuild gameStateObj
        self.allunits = [
            UnitObject.UnitObject(info) for info in load_info['allunits']
        ]
        self.factions = load_info['factions'] if 'factions' in load_info else (
            load_info['groups'] if 'groups' in load_info else {})
        self.allreinforcements = load_info['allreinforcements']
        self.prefabs = load_info['prefabs']
        self.triggers = load_info.get('triggers', dict())
        map_info = load_info['map']
        self.playtime = load_info['playtime']
        self.convoy = [
            ItemMethods.deserialize(item_dict)
            for item_dict in load_info['convoy']
        ]
        self.convoy = [item for item in self.convoy if item]
        self.turncount = load_info['turncount']
        self.game_constants = load_info['game_constants']
        self.level_constants = load_info['level_constants']
        self.objective = CustomObjects.Objective.deserialize(
            load_info['objective']) if load_info['objective'] else None
        self.phase_music = CustomObjects.PhaseMusic.deserialize(
            load_info['phase_music']) if load_info['phase_music'] else None
        support_dict = load_info['support']
        self.talk_options = load_info['talk_options']
        self.base_conversations = load_info['base_conversations']
        self.stateMachine = StateMachine.StateMachine(
            load_info['state_list'][0], load_info['state_list'][1])
        self.statistics = load_info['statistics']
        # self.message = [Dialogue.Dialogue_Scene(scene) for scene in load_info['message']]
        self.message = []
        self.unlocked_lore = load_info['unlocked_lore']
        self.market_items = load_info.get('market_items', set())
        self.mode = load_info.get('mode', self.default_mode())

        # Map
        self.map = SaveLoad.create_map('Data/Level' +
                                       str(self.game_constants['level']))
        if map_info:
            self.map.replay_commands(map_info['command_list'],
                                     self.game_constants['level'])
            self.map.command_list = map_info['command_list']
            for position, current_hp in map_info['HP']:
                self.map.tiles[position].set_hp(current_hp)

        # Statuses
        for index, info in enumerate(load_info['allunits']):
            for s_dict in info['status_effects']:
                if isinstance(s_dict, dict):
                    StatusObject.deserialize(s_dict, self.allunits[index],
                                             self)
                else:
                    self.allunits[index].status_effects.append(s_dict)

        # Support
        if cf.CONSTANTS['support']:
            self.support = Support.Support_Graph('Data/support_nodes.txt',
                                                 'Data/support_edges.txt')
            self.support.deserialize(support_dict)
        else:
            self.support = None

        # Set up blitting surface
        if self.map:
            mapSurfWidth = self.map.width * GC.TILEWIDTH
            mapSurfHeight = self.map.height * GC.TILEHEIGHT
            self.mapSurf = Engine.create_surface((mapSurfWidth, mapSurfHeight))

            self.grid_manager = AStar.Grid_Manager(self.map)
            self.boundary_manager = CustomObjects.BoundaryManager(self.map)

            for unit in self.allunits:
                if unit.position:
                    self.grid_manager.set_unit_node(unit.position, unit)

        self.generic()
        if 'phase_info' in load_info:
            self.phase.current, self.phase.previous = load_info['phase_info']