def parse_line(self, line):
     oid, pos_x, pos_y, belligerent = line.split()
     self.data.append(FrontMarker(
         id=oid,
         belligerent=to_belligerent(belligerent),
         pos=Point2D(pos_x, pos_y),
     ))
Пример #2
0
 def parse_line(self, line):
     pos_x, pos_y, pos_z, belligerent = line.split()
     self.data.append(
         StaticCamera(
             belligerent=to_belligerent(belligerent),
             pos=Point3D(pos_x, pos_y, pos_z),
         ))
 def parse_line(self, line):
     params = line.split()
     oid, building_object, belligerent = params[:3]
     pos_x, pos_y, rotation_angle = params[3:]
     code = building_object.split('$')[1]
     self.data.append(Building(
         id=oid,
         belligerent=to_belligerent(belligerent),
         code=code,
         pos=Point2D(pos_x, pos_y),
         rotation_angle=to_angle(rotation_angle),
     ))
 def parse_line(self, line):
     params = line.split()
     oid, building_object, belligerent = params[:3]
     pos_x, pos_y, rotation_angle = params[3:]
     code = building_object.split('$')[1]
     self.data.append(
         Building(
             id=oid,
             belligerent=to_belligerent(belligerent),
             code=code,
             pos=Point2D(pos_x, pos_y),
             rotation_angle=to_angle(rotation_angle),
         ))
Пример #5
0
    def parse_line(self, line):
        (
            belligerent, the_range, pos_x, pos_y, has_parachutes,
            air_spawn_height, air_spawn_speed, air_spawn_heading, max_pilots,
            radar_min_height, radar_max_height, radar_range, air_spawn_always,
            enable_aircraft_limits, aircraft_limits_consider_lost,
            disable_spawning, friction_enabled, friction_value,
            aircraft_limits_consider_stationary, show_default_icon,
            air_spawn_if_deck_is_full, spawn_in_stationary,
            return_to_start_position
        ) = line.split()

        self.data.append({
            'range': int(the_range),
            'belligerent': to_belligerent(belligerent),
            'show_default_icon': to_bool(show_default_icon),
            'friction': {
                'enabled': to_bool(friction_enabled),
                'value': float(friction_value),
            },
            'spawning': {
                'enabled': not to_bool(disable_spawning),
                'with_parachutes': to_bool(has_parachutes),
                'max_pilots': int(max_pilots),
                'in_stationary': {
                    'enabled': to_bool(spawn_in_stationary),
                    'return_to_start_position': to_bool(return_to_start_position),
                },
                'in_air': {
                    'height': int(air_spawn_height),
                    'speed': int(air_spawn_speed),
                    'heading': int(air_spawn_heading),
                    'conditions': {
                        'always': to_bool(air_spawn_always),
                        'if_deck_is_full': to_bool(air_spawn_if_deck_is_full),
                    },
                },
                'aircraft_limitations': {
                    'enabled': to_bool(enable_aircraft_limits),
                    'consider_lost': to_bool(aircraft_limits_consider_lost),
                    'consider_stationary': to_bool(aircraft_limits_consider_stationary),
                },
            },
            'radar': {
                'range': int(radar_range),
                'min_height': int(radar_min_height),
                'max_height': int(radar_max_height),
            },
            'pos': Point2D(pos_x, pos_y),
        })
Пример #6
0
    def parse_line(self, line):
        params = line.split()

        oid, code, belligerent = params[0:3]
        pos = params[3:5]
        rotation_angle, delay, count, period = params[5:9]
        destination = params[9:]

        self.data.append(
            Rocket(id=oid,
                   code=code,
                   belligerent=to_belligerent(belligerent),
                   pos=Point2D(*pos),
                   rotation_angle=to_angle(rotation_angle),
                   delay=float(delay),
                   count=int(count),
                   period=float(period),
                   destination=Point2D(*destination) if destination else None))
Пример #7
0
    def parse_line(self, line):
        params = line.split()

        oid, code, belligerent = params[0:3]
        pos = params[3:5]
        rotation_angle, delay, count, period = params[5:9]
        destination = params[9:]

        self.data.append(Rocket(
            id=oid,
            code=code,
            belligerent=to_belligerent(belligerent),
            pos=Point2D(*pos),
            rotation_angle=to_angle(rotation_angle),
            delay=float(delay),
            count=int(count),
            period=float(period),
            destination=Point2D(*destination) if destination else None
        ))
Пример #8
0
    def parse_line(self, line):
        params = line.split()
        (uid, type__code, belligerent), params = params[0:3], params[3:]

        type_code, unit_code = type__code.split('.')
        unit_type = self._get_unit_type(type_code)

        unit = {
            'id': uid,
            'code': unit_code,
            'type': unit_type,
            'belligerent': to_belligerent(belligerent),
        }
        if params:
            hibernation, skill, recharge_time = params
            unit.update({
                'hibernation': int(hibernation),
                'skill': to_skill(skill),
                'recharge_time': float(recharge_time),
            })
        self.data.append(unit)
Пример #9
0
    def parse_line(self, line):
        params = line.split()
        (uid, type__code, belligerent), params = params[0:3], params[3:]

        type_code, unit_code = type__code.split('.')
        unit_type = self._get_unit_type(type_code)

        unit = {
            'id': uid,
            'code': unit_code,
            'type': unit_type,
            'belligerent': to_belligerent(belligerent),
        }
        if params:
            hibernation, skill, recharge_time = params
            unit.update({
                'hibernation': int(hibernation),
                'skill': to_skill(skill),
                'recharge_time': float(recharge_time),
            })
        self.data.append(unit)
Пример #10
0
 def clean(self):
     """
     Redefines base method. See :meth:`SectionParser.clean` for
     semantics.
     """
     weather_conditions = int(self.data['CloudType'])
     return {
         'location_loader': self.data['MAP'],
         'time': {
             'value': to_time(self.data['TIME']),
             'is_fixed': 'TIMECONSTANT' in self.data,
         },
         'weather_conditions': Conditions.get_by_value(weather_conditions),
         'cloud_base': int(float(self.data['CloudHeight'])),
         'player': {
             'belligerent': to_belligerent(self.data['army']),
             'flight_id': self.data.get('player'),
             'aircraft_index': int(self.data['playerNum']),
             'fixed_weapons': 'WEAPONSCONSTANT' in self.data,
         },
     }
Пример #11
0
 def clean(self):
     """
     Redefines base method. See :meth:`SectionParser.clean` for
     semantics.
     """
     weather_conditions = int(self.data['CloudType'])
     return {
         'location_loader': self.data['MAP'],
         'time': {
             'value': to_time(self.data['TIME']),
             'is_fixed': 'TIMECONSTANT' in self.data,
         },
         'weather_conditions': Conditions.get_by_value(weather_conditions),
         'cloud_base': int(float(self.data['CloudHeight'])),
         'player': {
             'belligerent': to_belligerent(self.data['army']),
             'flight_id': self.data.get('player'),
             'aircraft_index': int(self.data['playerNum']),
             'fixed_weapons': 'WEAPONSCONSTANT' in self.data,
         },
     }
    def parse_line(self, line):
        params = line.split()

        oid, object_name, belligerent = params[0], params[1], params[2]
        pos = params[3:5]
        rotation_angle = params[5]
        params = params[6:]

        unit_type = self._get_type(object_name)
        info = {
            'id': oid,
            'belligerent': to_belligerent(belligerent),
            'code': self._get_code(object_name),
            'pos': Point2D(*pos),
            'rotation_angle': to_angle(rotation_angle),
            'type': unit_type,
        }

        subparser = self.__subparsers.get(unit_type)
        if subparser:
            info.update(subparser(params))

        structure_class = structure_class_by_unit_type(unit_type)
        self.data.append(structure_class(**info))
    def parse_line(self, line):
        params = line.split()

        oid, object_name, belligerent = params[0], params[1], params[2]
        pos = params[3:5]
        rotation_angle = params[5]
        params = params[6:]

        unit_type = self._get_type(object_name)
        info = {
            'id': oid,
            'belligerent': to_belligerent(belligerent),
            'code': self._get_code(object_name),
            'pos': Point2D(*pos),
            'rotation_angle': to_angle(rotation_angle),
            'type': unit_type,
        }

        subparser = self.__subparsers.get(unit_type)
        if subparser:
            info.update(subparser(params))

        structure_class = structure_class_by_unit_type(unit_type)
        self.data.append(structure_class(**info))
 def parse_line(self, line):
     pos_x, pos_y, pos_z, belligerent = line.split()
     self.data.append(StaticCamera(
         belligerent=to_belligerent(belligerent),
         pos=Point3D(pos_x, pos_y, pos_z),
     ))
Пример #15
0
 def test_to_belligerent(self):
     self.assertEqual(to_belligerent('0'), Belligerents.none)
     self.assertEqual(to_belligerent('1'), Belligerents.red)
     self.assertEqual(to_belligerent('2'), Belligerents.blue)