示例#1
0
def read_database(
    major_items_data: Dict,
    ammo_data: Dict,
) -> ItemDatabase:
    """

    :param major_items_data:
    :param ammo_data:
    :return:
    """
    major_items = {
        name: MajorItem.from_json(name, value)
        for name, value in major_items_data["items"].items()
    }

    ammo = {
        name: Ammo.from_json(name, value)
        for name, value in ammo_data.items()
    }

    default_items = {
        ItemCategory(category_name):
        tuple(major_items[item_name] for item_name in value)
        for category_name, value in major_items_data["default_items"].items()
    }

    return ItemDatabase(major_items, ammo, default_items)
示例#2
0
def read_database(database_data: Dict, game: RandovaniaGame) -> ItemDatabase:
    """
    :param database_data:
    :param game:
    :return:
    """
    migrations.migrate_current(database_data)

    item_categories = {
        name: ItemCategory.from_json(name, value)
        for name, value in database_data["item_categories"].items()
    }

    major_items = {
        name: MajorItem.from_json(name, value, game, item_categories)
        for name, value in database_data["items"].items()
    }

    ammo = {
        name: Ammo.from_json(name, value, game, item_categories)
        for name, value in database_data["ammo"].items()
    }

    default_items = {
        item_categories[category_name]:
        tuple(major_items[item_name] for item_name in value)
        for category_name, value in database_data["default_items"].items()
    }

    return ItemDatabase(item_categories, major_items, ammo, default_items)
示例#3
0
def read_database(major_items_data: Dict,
                  ammo_data: Dict,
                  ) -> ItemDatabase:
    """

    :param major_items_data:
    :param ammo_data:
    :return:
    """
    major_items = {
        name: MajorItem.from_json(name, value)
        for name, value in major_items_data.items()
    }

    ammo = {
        name: Ammo.from_json(name, value)
        for name, value in ammo_data.items()
    }

    return ItemDatabase(major_items, ammo)