Exemplo n.º 1
0
    def _clean(self):
        result = {}

        move_if_present(result, self.data, 'location_loader')
        move_if_present(result, self.data, 'player')
        move_if_present(result, self.data, 'targets')

        set_if_present(result, 'conditions', self._get_conditions())
        set_if_present(result, 'objects', self._get_objects())

        return result
    def test_set_if_present(self):
        dst = {}

        set_if_present(dst, 'foo', 1)
        set_if_present(dst, 'bar', None)
        set_if_present(dst, 'baz', [])

        self.assertEquals(dst, {'foo': 1})
    def test_set_if_present(self):
        dst = {}

        set_if_present(dst, 'foo', 1)
        set_if_present(dst, 'bar', None)
        set_if_present(dst, 'baz', [])

        self.assertEquals(dst, {'foo': 1})
Exemplo n.º 4
0
    def _get_aircrafts(self, aircrafts_count):
        results = []

        for i in range(aircrafts_count):
            info = {
                'index': i,
                'has_markings': self._has_markings(i),
                'skill': self._get_skill(i),
            }
            set_if_present(info, 'aircraft_skin', self._get_skin('skin', i))
            set_if_present(info, 'nose_art', self._get_skin('nose_art', i))
            set_if_present(info, 'pilot_skin', self._get_skin('pilot', i))
            set_if_present(info, 'spawn_object', self._get_spawn_object_id(i))
            results.append(info)

        return results
Exemplo n.º 5
0
    def _get_aircrafts(self, aircrafts_count):
        results = []

        for i in range(aircrafts_count):
            info = {
                'index': i,
                'has_markings': self._has_markings(i),
                'skill': self._get_skill(i),
            }
            set_if_present(info, 'aircraft_skin', self._get_skin('skin', i))
            set_if_present(info, 'nose_art', self._get_skin('nose_art', i))
            set_if_present(info, 'pilot_skin', self._get_skin('pilot', i))
            set_if_present(info, 'spawn_object', self._get_spawn_object_id(i))
            results.append(info)

        return results
Exemplo n.º 6
0
    def _get_objects(self):
        result = {}

        set_if_present(result, 'moving_units', self._get_moving_units())
        set_if_present(result, 'flights', self._get_flights())
        set_if_present(result, 'home_bases', self._get_home_bases())

        move_if_present(result, self.data, 'stationary')
        move_if_present(result, self.data, 'buildings')
        move_if_present(result, self.data, 'cameras')
        move_if_present(result, self.data, 'markers')
        move_if_present(result, self.data, 'rockets')

        return result
Exemplo n.º 7
0
    def _get_conditions(self):
        result = {}

        set_if_present(result, 'time_info', self._get_time_info())
        set_if_present(result, 'meteorology', self._get_meteorology())
        set_if_present(result, 'scouting', self._get_scouting())

        move_if_present(result, self.data, 'respawn_time')

        if 'conditions' in self.data:
            conditions = self.data['conditions']

            move_if_present(result, conditions, 'radar')
            move_if_present(result, conditions, 'communication')
            move_if_present(result, conditions, 'home_bases')
            move_if_present(result, conditions,
                            'crater_visibility_muptipliers')

        return result