def gen_new(path):
    change = False
    json_data = load_json(path)
    if json_data is None:
        return None
    for jo in json_data:
        # We only want JsonObjects
        if type(jo) is str:
            continue
        if (
            type(jo.get("volume")) != str
            and jo.get("volume")
            and jo.get("type") not in ["sound_effect", "speech"]
        ):
            volume = jo["volume"]
            volume *= 250
            if volume > 10000 and volume % 1000 == 0:
                jo["volume"] = str(volume // 1000) + " L"
            else:
                jo["volume"] = str(volume) + " ml"
            change = True
        if jo.get("barrel_length"):
            if type(jo["barrel_length"]) == int:
                barrel_length = jo["barrel_length"]
                barrel_length *= 250
                jo["barrel_volume"] = str(barrel_length) + " ml"
            elif type(jo["barrel_length"]) == str:
                jo["barrel_volume"] = jo["barrel_length"]
            del jo["barrel_length"]
            change = True

    return json_data if change else None
def gen_new(path):
    change = False
    json_data = load_json(path)
    if json_data is None:
        return None
    for jo in json_data:
        # We only want JsonObjects
        if type(jo) is str:
            continue
        # And only if they have coverage
        if not jo.get("covers"):
            continue
        joc = []
        for bodypart in jo["covers"]:
            if bodypart.endswith("_EITHER"):
                bodypart = bodypart[:-7]
                jo["sided"] = True
                bodypart = bodypart + "s"
            if bodypart == "ARMS":
                joc.append("arm_l")
                joc.append("arm_r")
            elif bodypart == "EYES":
                joc.append("eyes")
            elif bodypart in ["FEET", "FOOTS"]:
                joc.append("foot_l")
                joc.append("foot_r")
            elif bodypart == "HANDS":
                joc.append("hand_l")
                joc.append("hand_r")
            elif bodypart == "HEAD":
                joc.append("head")
            elif bodypart == "LEGS":
                joc.append("leg_l")
                joc.append("leg_r")
            elif bodypart == "MOUTH":
                joc.append("mouth")
            elif bodypart == "TORSO":
                joc.append("torso")
            else:
                joc.append(bodypart)
        if jo["covers"] == joc:
            continue
        jo["covers"] = joc
        change = True

    return json_data if change else None
def gen_new(path):
    change = False
    json_data = load_json(path)
    if json_data is None:
        return None
    for jo in json_data:
        # We only want JsonObjects
        if type(jo) is str:
            continue
        if type(jo.get("price")) is int:
            jo = convert_price(jo, "price")
            change = True

        if type(jo.get("price_postapoc")) is int:
            jo = convert_price(jo, "price_postapoc")
            change = True

    return json_data if change else None
def gen_new(path):
    change = False
    json_data = load_json(path)
    if json_data is None:
        return None
    for jo in json_data:
        # We only want JsonObjects
        if type(jo) is str:
            continue
        if type(jo.get("material")) == str:
            material = jo["material"]
            jo["material"] = [material]
            change = True
        if type(jo.get("ammo")) == str and jo.get("type") == "ammo":
            ammo = jo["ammo"]
            jo["ammo"] = [ammo]
            change = True

    return json_data if change else None
コード例 #5
0
def gen_new(path):
    change = False
    json_data = load_json(path)
    if json_data is None:
        return None
    for jo in json_data:
        # We only want JsonObjects
        if type(jo) is str:
            continue
        # And only if they have weight
        if not jo.get("weight"):
            continue
        # Mapgen uses the wrong type of weight, so we exclude it.
        elif jo.get("type") in ["mapgen", "overmap_terrain", "mod_tileset"]:
            continue
        # We're only looking for integers.
        elif isinstance(jo.get("weight"), int):
            weight = jo["weight"]
            jo["weight"] = str(weight) + " g"
            change = True

    return json_data if change else None
コード例 #6
0
def gen_new(path):
    change = False
    json_data = load_json(path)
    if json_data is None:
        return None
    for jo in json_data:
        # We only want JsonObjects
        if type(jo) is str:
            continue

        # These need no conversion.
        if type(jo.get("time")) == str:
            continue

        # It has to have time.
        if not jo.get("time"):
            continue

        if jo.get("type") == "construction":
            # Convert time to minutes.
            jo["time"] = str(jo["time"]) + " m"
            change = True

        elif jo.get("type") == "recipe":
            # Convert time from turns to seconds, then minutes.
            # Loses the remainder.
            turns = jo["time"]
            turns //= 100
            if turns % 60 == 0:
                turns //= 60
                jo["time"] = str(turns) + " m"
            else:
                jo["time"] = str(turns) + " s"
            change = True

    return json_data if change else None
コード例 #7
0
def gen_new(path):
    change = False
    json_data = load_json(path)
    if json_data is None:
        return None
    for jo in json_data:
        # We only want JsonObjects
        if type(jo) is str:
            continue
        if not jo.get("name"):
            continue
        if type(jo["name"]) == dict:
            continue
        if jo.get("type") not in [
                "AMMO",
                "ARMOR",
                "BATTERY",
                "bionic",
                "BIONIC_ITEM",
                "BIONIC_ITEM",
                "BOOK",
                "COMESTIBLE",
                "ENGINE",
                "fault",
                "GENERIC",
                "GUN",
                "GUNMOD",
                "item_action",
                "ITEM_CATEGORY",
                "MAGAZINE",
                "map_extra",
                "martial_art",
                "mission_definition",
                "MONSTER",
                "mutation",
                "npc_class",
                "PET_ARMOR",
                "proficiency",
                "skill",
                "TOOL",
                "TOOL_ARMOR",
                "tool_quality",
                "TOOLMOD",
                "vehicle_part",
                "vehicle_part_category",
                "vitamin",
                "WHEEL",
                "SPELL",
        ]:
            continue
        if jo.get("name_plural"):
            if jo["name"] == jo["name_plural"]:
                name_obj = {"str_sp": jo["name"]}
            else:
                name_obj = {"str": jo["name"], "str_pl": jo["name_plural"]}
            jo["name"] = name_obj
            del jo["name_plural"]
            change = True
        else:
            name_obj = {"str": jo["name"]}
            jo["name"] = name_obj
            change = True

    return json_data if change else None