def get_screen(console, screen_data):
    display_string, _options = '', {}
    equipment_id, character_id, page_num = screen_data.split('#')
    page_num = int(page_num)
    equipment_id = int(equipment_id)
    character = Refs.gc.get_char_by_id(character_id)
    outfit = character.get_outfit()

    display_string += '\n\t'
    display_string += get_equipment_box(EQUIPMENT_CATEGORIES[equipment_id], outfit.items[equipment_id - WEAPON], 1).replace('\n', '\n\t')

    items = Refs.gc.get_equipment(equipment_id)

    _options = {'0': BACK}
    if outfit.items[equipment_id - WEAPON] is not None:
        display_string += f'\n\t{OPT_C}1:{END_OPT_C} Unequip {outfit.items[equipment_id - WEAPON].get_name()}\n'
        _options['1'] = f'confirm{CHANGE_EQUIP_ITEM}:{equipment_id}#{character_id}#0#none#none'

    display_string += '\n'

    fail = '\tYou have no matching equipment.\n'
    ip_text, ip_options = item_page_list(2, f'{CHANGE_EQUIP_ITEM}:{equipment_id}#{character_id}', page_num, items, fail, '', get_equipment_item, page_num_first=False, size_check=2)

    display_string += ip_text
    _options.update(ip_options)

    if outfit.items[equipment_id - WEAPON] is not None:
        display_string += f'\n\t{OPT_C}0:{END_OPT_C} Keep Item\n'
    else:
        display_string += f'\n\t{OPT_C}0:{END_OPT_C} Back\n'
    return display_string, _options
Beispiel #2
0
def get_screen(console, screen_data):
    console.header_callback = None
    display_text = ''

    page_num, key, item_id = screen_data.split('#', 2)
    page_num = int(page_num)

    inventory = Refs.gc.get_inventory()
    item_list = inventory.get_metadata_items(key)

    current_item = None
    if item_id != 'none':
        for index in range(len(item_list)):
            if item_list[index].get_full_id() == item_id:
                current_item = item_list.pop(index)
                break

    fail = '\n\tYou have no items in your inventory.'
    option_index = 1
    _options = {'0': BACK}
    if current_item is not None:
        display_text += f'\n\tCurrent selected: {current_item.get_name()}\n\t\tDurability: {current_item.get_current_durability()} / {current_item.get_durability()}\n\t{OPT_C}1:{END_OPT_C} Deselect\n'
        _options['1'] = f'set#{page_num}#{key}#none'
        option_index += 1

    ip_text, ip_options = item_page_list(option_index, f'set#{page_num}#{key}',
                                         page_num, item_list, fail, '',
                                         get_inventory_select_item)

    _options.update(ip_options)
    display_text += ip_text

    display_text += f'\n\n\t{OPT_C}0:{END_OPT_C} back\n'
    return display_text, _options
def get_screen(console, screen_data):
    console.header_callback = get_town_header
    _options = {'0': BACK}

    screen_data_options = screen_data.split('#')
    recipe = Refs.gc['recipes'][screen_data_options[0]]
    equipment = Refs.gc['equipment'][recipe.get_output_id()]
    material_index = int(screen_data_options[-1])
    current_material_id = screen_data_options[material_index + 1]
    current_material = None
    if current_material_id != 'none':
        current_material = Refs.gc['materials'][current_material_id]

    display_text = '\n\tWhich material would you like to use?'

    if current_material is None:
        display_text += '\n\n\tCurrent Material: None\n'
    else:
        display_text += f'\n\n\tCurrent Material: {current_material.get_name()}\n'

    if equipment.is_weapon():
        material_index = max(0, material_index - 2)
    material_type = list(recipe.get_ingredients())[material_index]
    print(list(recipe.get_ingredients()),
          list(recipe.get_ingredients().keys()))
    count = recipe.get_ingredients()[material_type]
    if equipment.is_weapon() and int(screen_data_options[-1]) in [1, 2]:
        count *= 0.2

    materials = []
    inventory = Refs.gc.get_inventory()
    if material_type == 'hard':
        for material in Refs.gc['materials'].values():
            if material.is_hard() and inventory.get_item_count(
                    material.get_processed_id()) > count:
                materials.append(material)
    elif material_type == 'soft':
        for material in Refs.gc['materials'].values():
            if material.is_soft() and inventory.get_item_count(
                    material.get_processed_id()) > count:
                materials.append(material)
    elif material_type == 'wood':
        for material in Refs.gc['materials'].values():
            if material.is_wood() and inventory.get_item_count(
                    material.get_processed_id()) > count:
                materials.append(material)

    fail = '\n\tYou do not have any available materials.\n'
    item_func = lambda item, option_index, current, page_name, page_num: get_equipment_material(
        equipment.is_weapon(), item, option_index, current, page_name, page_num
    )
    ip_text, ip_options = item_page_list(1, CRAFT_EQUIPMENT_MATERIAL, 0,
                                         materials, fail, '', item_func)
    display_text += ip_text
    _options.update(ip_options)
    display_text += f'\n\n\t{OPT_C}0:{END_OPT_C} Back\n'
    return display_text, _options
Beispiel #4
0
def get_screen(console, screen_data):
    console.header_callback = get_town_header
    item_list = Refs.gc.get_housing_options()

    page_num = int(screen_data)

    fail = '\n\tYou cannot buy any housing.'

    ip_text, ip_options = item_page_list(1, HOUSING_BROWSE, page_num, item_list, fail, '', get_housing_string)

    _options = {'0': BACK}
    _options.update(ip_options)
    display_text = ip_text + f'\n\n\t{OPT_C}0:{END_OPT_C} back\n'
    return display_text, _options
def get_screen(console, screen_data):
    console.header_callback = get_town_header
    item_list = Refs.gc.get_inventory().get_items()

    page_num = int(screen_data)

    fail = '\n\tYou have no items in your inventory.'

    ip_text, ip_options = item_page_list(1, INVENTORY, page_num, item_list,
                                         fail, '', get_inventory_item)

    _options = {'0': BACK}
    _options.update(ip_options)
    display_text = ip_text + f'\n\n\t{OPT_C}0:{END_OPT_C} back\n'
    return display_text, _options
def get_screen(console, screen_data):
    console.header_callback = None
    item_list = list(Refs.gc.get_floor_data().get_gained_items().keys())
    item_list += Refs.gc.get_potions()

    page_num = int(screen_data)

    fail = '\n\tYou have no items in your inventory.'

    ip_text, ip_options = item_page_list(1, INVENTORY_BATTLE, page_num, item_list, fail, '', get_inventory_battle_item)

    _options = {'0': BACK}
    _options.update(ip_options)
    display_text = ip_text

    inventory = Refs.gc.get_inventory()
    pickaxe = inventory.get_current_pickaxe()
    shovel = inventory.get_current_shovel()
    harvesting_knife = inventory.get_current_harvesting_knife()
    option_index = len(_options)

    if pickaxe is None:
        display_text += f'\n\n\t{OPT_C}{option_index}:{END_OPT_C} Current Pickaxe: None'
        _options[str(option_index)] = f'{INVENTORY_BATTLE_SELECT}:0#pickaxe#none'
    else:
        display_text += f'\n\n\t{OPT_C}{option_index}:{END_OPT_C} Current Pickaxe: {pickaxe.get_name()}'
        _options[str(option_index)] = f'{INVENTORY_BATTLE_SELECT}:0#pickaxe#{pickaxe.get_full_id()}'
    option_index += 1

    if shovel is None:
        display_text += f'\n\t{OPT_C}{option_index}:{END_OPT_C} Current Shovel: None'
        _options[str(option_index)] = f'{INVENTORY_BATTLE_SELECT}:0#shovel#none'
    else:
        display_text += f'\n\t{OPT_C}{option_index}:{END_OPT_C} Current Shovel: {shovel.get_name()}'
        _options[str(option_index)] = f'{INVENTORY_BATTLE_SELECT}:0#shovel#{shovel.get_full_id()}'
    option_index += 1
    if harvesting_knife is None:
        display_text += f'\n\t{OPT_C}{option_index}:{END_OPT_C} Current Harvesting Knife: None'
        _options[str(option_index)] = f'{INVENTORY_BATTLE_SELECT}:0#harvesting_knife#none'
    else:
        display_text += f'\n\t{OPT_C}{option_index}:{END_OPT_C} Current Harvesting Knife: {harvesting_knife.get_name()}'
        _options[str(option_index)] = f'{INVENTORY_BATTLE_SELECT}:0#harvesting_knife#{harvesting_knife.get_full_id()}'

    display_text += f'\n\n\t{OPT_C}0:{END_OPT_C} back\n'
    return display_text, _options
Beispiel #7
0
def get_screen(console, screen_data):
    console.header_callback = get_town_header
    page_num = int(screen_data)
    display_text = '\n\tWhat type of finished alloy would you like to make?\n'

    recipes = Refs.gc.get_alloy_recipes()

    fail = '\n\tThere is nothing that you can craft.'

    item_func = lambda item, option_index, current, page_name, page_num: get_craft_item(
        item, option_index, current, f'{CRAFT_ITEM_MULTIPLE}', page_num)
    ip_text, ip_options = item_page_list(1, CRAFTING_ALLOYS, page_num, recipes,
                                         fail, '', item_func)

    _options = {'0': BACK}
    _options.update(ip_options)
    display_text += ip_text + f'\n\n\t{OPT_C}0:{END_OPT_C} back\n'
    return display_text, _options
Beispiel #8
0
def get_screen(console, screen_data):
    console.header_callback = get_town_header
    display_text = '\n\tWhat type of equipment would you like to make?\n'

    recipes = Refs.gc.get_equipment_recipes()

    page_num = int(screen_data)

    fail = '\n\tThere is nothing that you can craft.'

    item_func = lambda item, option_index, current, page_name, page_num: get_craft_equipment_item(
        item, option_index, current, CRAFT_EQUIPMENT, page_num)
    ip_text, ip_options = item_page_list(1, CRAFTING_EQUIPMENT, page_num,
                                         recipes, fail, '', item_func)

    _options = {'0': BACK}
    _options.update(ip_options)
    display_text += ip_text + f'\n\n\t{OPT_C}0:{END_OPT_C} back\n'
    return display_text, _options
Beispiel #9
0
def get_screen(console, screen_data):
    console.header_callback = get_town_header
    display_text = '\n\t'
    _options = {'0': BACK}

    print(screen_data)

    pages = {
        'main': [
            'general', 'dungeon_materials', 'ingredients', 'potions_medicines',
            'equipment', 'home_supplies', 'other'
        ],
        'general': ['floor_maps'],
        'equipment': ['tools', 'weapons', 'armors'],
        'tools': [],
        'weapons': [],
        'armors': [],
        'dungeon_materials': [],
        'magic_stones': [],
        'monster_drops': [],
        'raw_materials': [],
        'processed_materials': [],
        'ingredients': [],
        'potions_medicines': [],
        'floor_maps': [
            f'floor_{floor_id}' for floor_id in range(
                1,
                min(len(Refs.gc['floors']), Refs.gc.get_lowest_floor()) + 1)
        ]
    }

    # Header display options
    headers = {
        'main':
        'Welcome to the Guild Shopping District where you can find anything you need!\n\t',
        'general':
        'Welcome to the General shop! Your premier provider of useful goods.\n\t',
        'floor_maps':
        'Welcome to the map shop! As an extension of the guild, we have all the latest maps available!\n\t',
        'equipment': 'Welcome to the equipment district!\n\t'
    }

    # Sub header display options
    sub_headers = {
        'main': 'Where you you like to browse today?\n',
        'equipment': 'What form of equipment are you looking for?\n',
        'tools': 'What kind of tool are you looking for?\n',
        'weapons': 'What kind of weapon are you looking for?\n',
        'armors': 'What kind of armor are you looking for?\n',
        'general': 'What would you like to purchase?\n',
        'floor_maps': 'Which floor are you interested in?\n',
        'dungeon_materials': 'Which type of transaction would you like?\n'
    }

    # The Names to display for page links
    page_to_string = {
        'general': 'General Goods',
        'dungeon_materials': 'Dungeon Materials',
        'ingredients': 'Ingredients',
        'potions_medicines': 'Potions & Medicines',
        'equipment': 'Equipment',
        'tools': 'Tools',
        'weapons': 'Weapons',
        'armors': 'Armor',
        'home_supplies': 'Home Supplies',
        'other': 'Other',
        'floor_maps': 'Floor Maps',
        'monster_drops': 'Monster Drop',
        'magic_stones': 'Magic Stone',
        'raw_materials': 'Raw Material',
        'processed_materials': 'Processed Material'
    }

    # Sub categories that should have a Buy and Sell option listed
    bspages = {
        'dungeon_materials': [
            'magic_stones', 'monster_drops', 'raw_materials',
            'processed_materials'
        ]
    }

    item_lists = {
        'general': Refs.gc.get_shop_items,
        'ingredients': lambda category: Refs.gc.get_ingredients(),
        'magic_stones': lambda category: Refs.gc.get_magic_stone_types(),
        'monster_drops': lambda category: Refs.gc.get_monster_drop_types(),
        'raw_materials': lambda category: Refs.gc.get_raw_materials(),
        'processed_materials':
        lambda category: Refs.gc.get_processed_materials()
    }

    if '#' in screen_data:
        page, page_data = screen_data.split('#', 1)
    else:
        page = screen_data
        page_data = ''
    header, sub_header, sub_text, option_index, sub_options = '', '', '', 1, {}

    if page == 'floor_maps':
        for floor_id in range(
                1,
                min(len(Refs.gc['floors']), Refs.gc.get_lowest_floor()) + 1):
            page_to_string[f'floor_{floor_id}'] = f'Floor {floor_id}'
    elif page.startswith('floor'):
        pages[page] = []
        headers[page] = 'Which map type are you interested in?\n'
        item_lists[page] = Refs.gc.get_shop_items

    if page in ['equipment', 'tools', 'weapons', 'armors']:
        for item_id, equipment_class in Refs.gc['equipment'].items():
            equipment_category = EQUIPMENT_TYPES[
                equipment_class.get_type()].lower() + 's'
            pages[equipment_category].append(item_id)
            page_to_string[item_id] = equipment_class.get_name()
            item_lists[item_id] = None
    elif page in Refs.gc['equipment']:
        list_links = {
            'tools':
            lambda category, page_name=page: Refs.gc.get_store_tools(page_name
                                                                     ),
            'weapons':
            lambda category, page_name=page: Refs.gc.get_store_weapons(
                page_name),
            'armors':
            lambda category, page_name=page: Refs.gc.get_store_armor(page_name)
        }
        equipment_class = Refs.gc['equipment'][page]
        equipment_category = EQUIPMENT_TYPES[
            equipment_class.get_type()].lower() + 's'
        pages[page] = []
        headers[
            page] = f'What kind of {equipment_class.get_name()} are you interested in?\n\n'
        item_lists[page] = list_links[equipment_category]

    texts = {
        'sell_start': 'Which of your {0}s would you like to sell?\n',
        'sell_fail': '\n\tYou do not have any {0}s that you can sell.',
        'sell_current': 'Current going price',
        'sell_future': 'You will get',
        'buy_start': 'What type of {0} would you like to buy?\n',
        'buy_fail':
        '\n\tNo items are available to purchase',  # \n\tYou are not eligible to purchase any floor maps.\n\tYou must visit the floor before you can purchase a map for it.
        'buy_current': 'Current price',
        'buy_future': 'This will cost'
    }

    page_list = pages[page]
    # Get sub pages that go on this page; Can be on pages w/ lists too
    if page in headers:
        header = headers[page]
    if page in sub_headers:
        sub_header = sub_headers[page]
    for page_link in page_list:
        sub_text += f'\n\t{OPT_C}{option_index}:{END_OPT_C} {page_to_string[page_link]}'
        if page_link in item_lists.keys():
            sub_options[str(option_index)] = (f'{SHOP_MAIN}:{page_link}#0',
                                              True)
        else:
            sub_options[str(option_index)] = (f'{SHOP_MAIN}:{page_link}', True)
        option_index += 1

    bstype = None
    if page_data.startswith('buy') or page_data.startswith('sell'):
        if '#' in page_data:
            bstype, page_data = page_data.split('#', 1)
        else:
            bstype = page_data
            page_data = ''

    page_num = None
    if page in item_lists:
        if '#' in page_data:
            page_num, page_data = page_data.split('#', 1)
        else:
            page_num = page_data
            page_data = ''
        page_num = int(page_num)

    if page in bspages:
        ip_text, ip_options = bspage_list(bspages[page], f'{SHOP_MAIN}:{page}',
                                          page_to_string)

        sub_text += ip_text
        for number, option in ip_options.items():
            sub_options[number] = (option, True)

        if sub_text != '':
            sub_text += '\n'

    if page_data == '' and page_num is not None:
        item_list = item_lists[page](page)

        if bstype == 'sell':
            item_list = Refs.gc.get_owned_items(item_list)

        if bstype == 'buy':
            sub_header = texts['buy_start'].format(page_to_string[page])
            ip_text, ip_options = item_page_list(option_index,
                                                 f'{SHOP_MAIN}:{page}#buy',
                                                 page_num,
                                                 item_list,
                                                 texts['buy_fail'],
                                                 texts['buy_current'],
                                                 get_item_string,
                                                 page_num_first=False)
        elif bstype == 'sell':
            sub_header = texts['sell_start'].format(page_to_string[page])
            ip_text, ip_options = item_page_list(option_index,
                                                 f'{SHOP_MAIN}:{page}#sell',
                                                 page_num,
                                                 item_list,
                                                 texts['sell_fail'].format(
                                                     page_to_string[page]),
                                                 texts['sell_current'],
                                                 get_item_string,
                                                 page_num_first=False)
        else:
            ip_text, ip_options = item_page_list(option_index,
                                                 f'{SHOP_MAIN}:{page}',
                                                 page_num,
                                                 item_list,
                                                 texts['buy_fail'],
                                                 texts['buy_current'],
                                                 get_item_string,
                                                 page_num_first=False)

        # Add to current page
        sub_text += ip_text
        for number, option in ip_options.items():
            if 'confirm' not in option:
                sub_options[number] = (option, len(option.split('#')) > 3)
            else:
                sub_options[number] = option
    elif page_data != '':
        item_id, item_count = page_data.split('#')
        if bstype:
            sub_header = texts[f'{bstype}_start'].format(
                Refs.gc.find_item(item_id).get_name())
            sub_text, sub_options = item_transaction(
                item_count, item_id, f'{SHOP_MAIN}:{page}#{bstype}#{page_num}',
                texts[f'{bstype}_current'], texts[f'{bstype}_future'])
        else:
            sub_text, sub_options = item_transaction(
                item_count, item_id, f'{SHOP_MAIN}:{page}#{page_num}',
                texts[f'buy_current'], texts[f'buy_future'])
        for number, option in sub_options.items():
            if 'confirm' not in option:
                sub_options[number] = (option, False)

    display_text += header
    display_text += sub_header
    display_text += sub_text
    _options.update(sub_options)

    if page == 'main':
        display_text += f'\n\n\t{OPT_C}0:{END_OPT_C} Leave the market\n'
    else:
        display_text += f'\n\n\t{OPT_C}0:{END_OPT_C} back\n'
    print(_options)
    return display_text, _options