예제 #1
0
def spec_parse_cost(value):
    spec.validate_must_be_list(value)
    if len(value) != 3:  # pragma: no cover
        raise ValueError(
            "Cost must have exactly 3 values (CPU, money, time), got %d items (value: %s)"
            % (len(value), repr(value)))
    return [int(x) for x in value]
예제 #2
0
파일: base.py 프로젝트: mchac1/singularity
def parse_detect_chance(parsed_value):
    validate_must_be_list(parsed_value)
    chance_dict = {}

    for chance_str in parsed_value:
        key, value = chance_str.split(":")
        chance_dict[key] = int(value)

    return chance_dict
예제 #3
0
파일: item.py 프로젝트: LFL077/singularity
def convert_item_qualities(raw_value):
    validate_must_be_list(raw_value)
 
    if len(raw_value) % 2 == 1:
        raise ValueError("item quality list must have pair elements, got %d (value: %s)"  
                         % (len(raw_value), repr(raw_value)))
 
    # Create a dict from the list with impair as string key and pair as integer value
    return {key: int(value) for key, value in zip(*[iter(raw_value)]*2)}
예제 #4
0
def position_data_parser(raw_value):
    validate_must_be_list(raw_value)
    abs = False
    if len(raw_value) == 3:
        if raw_value[0] != 'absolute':
            raise ValueError('First element for a 3-element position data must be "absolute", got: %s' % raw_value[0])
        abs = True
        _, x, y = raw_value
    elif len(raw_value) == 2:
        x, y = raw_value
    else:
        raise ValueError("Location position data must be exactly 2 or 3 elements")
    return abs, int(x) / -100., int(y) / -100.