Example #1
0
def dict_to_location_object(location_object_info):
    """Converts a dict or str to a LocationObject

    :type location_object_info: dict | str
    """

    if type(location_object_info) == str:
        location_object = list_to_dict(
            all_locations_objects)[location_object_info]
    else:
        location_object = location_object_info

    npcs = list_to_dict(all_npcs)
    weapons = list_to_dict(all_weapons)

    name = location_object["Name"]

    if name in npcs:
        contained_object = dict_to_npc(name)
    elif name in weapons:
        contained_object = dict_to_weapon(name)
    else:
        raise Exception(name + " is not in weapons or npcs")

    return \
        LocationObject(
            contained_object,
            location_object["Probability"],
            location_object["Fraction"],
            location_object["Max"],
        )
Example #2
0
def dict_to_location(location_info):
    """Converts a dict or str to a Location

    :type location_info: dict | str
    """

    if type(location_info) == str:
        _location = list_to_dict(all_locations)[location_info]
    else:
        _location = location_info

    npcs = []
    for npc in _location["NPCs"]:
        npcs.append(dict_to_location_object(npc))

    _weapons = []
    for _weapon in _location["Weapons"]:
        _weapons.append(dict_to_location_object(_weapon))

    return \
        Location(
            _location["Name"],
            _location["Probability"],
            _location["Treasure"],
            _weapons,
            npcs,
            _location["Description"],
            _location["Attributes"]
        )
Example #3
0
def dict_to_npc(npc_info):
    """Converts a dict or str to a NPC

    :type npc_info: dict | str
    """

    if type(npc_info) == str:
        npc = list_to_dict(all_npcs)[npc_info]
    else:
        npc = npc_info

    _attacks = []
    for _attack in npc["Attacks"]:
        _attacks.append(dict_to_attack(_attack))

    _weapons = []
    for _weapon in npc["Weapons"]:
        _weapons.append(dict_to_weapon(_weapon))

    return \
        NPC(
            npc["Name"],
            None,
            npc["Health"],
            npc["Aggressiveness"],
            _attacks,
            _weapons,
            npc["Description"],
            npc["Attributes"]
        )
Example #4
0
def dict_to_attack(attack_info):
    """Converts a dict or str to an Attack

    :type attack_info: dict | str | Attack
    """

    if type(attack_info) == str:
        # Attack name given, get dict from all_attacks
        _attack = list_to_dict(all_attacks)[attack_info]
    else:
        _attack = attack_info

    if not "Ammo" in _attack:
        ammo = 0
    else:
        ammo = _attack["Ammo"]
    return \
        Attack(
            _attack["Name"],
            _attack["Past Tense"],
            _attack["Choice Probability"],
            _attack["Hit Probability"],
            _attack["Cooldown"],
            _attack["Damages"],
            _attack["Effect Probabilities"],
            _attack["Effectiveness"],
            _attack["Attributes"],
            ammo,
        )
Example #5
0
def dict_to_weapon(weapon_info):
    """Converts a dict or str to a Weapon

    :type weapon_info: dict | str
    """

    if type(weapon_info) == str:
        _weapon = list_to_dict(all_weapons)[weapon_info]
    else:
        _weapon = weapon_info

    _attacks = []
    for _attack in _weapon["Attacks"]:
        _attacks.append(dict_to_attack(_attack))

    return \
        Weapon(
            _weapon["Name"],
            _attacks,
            _weapon["Attributes"],
            _weapon["Description"]
        )
Example #6
0
            _location["Probability"],
            _location["Treasure"],
            _weapons,
            npcs,
            _location["Description"],
            _location["Attributes"]
        )


all_attacks = get_value("game_objects", "attacks")
all_weapons = get_value("game_objects", "weapons")
all_npcs = get_value("game_objects", "npcs")
all_locations_objects = get_value("game_objects", "location objects")
all_locations = get_value("game_objects", "locations")

ambrosia = dict_to_weapon(list_to_dict(all_weapons)["Ambrosia"])
treasure = dict_to_weapon(list_to_dict(all_weapons)["Treasure"])
bestiary = dict_to_weapon(list_to_dict(all_weapons)["Bestiary"])
anthology = dict_to_weapon(list_to_dict(all_weapons)["Herbal-Anthology"])
cook_book = dict_to_weapon(list_to_dict(all_weapons)["Cook-Book"])
dagger = dict_to_weapon(list_to_dict(all_weapons)["Dagger"])
atlas = dict_to_weapon(list_to_dict(all_weapons)["Atlas"])
cooked_meal = dict_to_weapon(list_to_dict(all_weapons)["Cooked-Meal"])
hrunting = dict_to_weapon(list_to_dict(all_weapons)["Hrunting"])
hrothgars_gift = dict_to_weapon(list_to_dict(all_weapons)["Hrothgar's-Gift"])
finely_cooked_meal = dict_to_weapon(
    list_to_dict(all_weapons)["Finely-Cooked-Meal"])
mead = dict_to_weapon(list_to_dict(all_weapons)["Mead"])
gold_ingot = dict_to_weapon(list_to_dict(all_weapons)["Gold-Ingot"])
adamantine_blade = dict_to_weapon(
    list_to_dict(all_weapons)["Adamantine-Blade"])