Exemplo n.º 1
0
def admin_creationKit_add():
    if not is_admin():
        return not_admin_redirect()

    slot_names = select_query.select_slot_names()
    rarity_names = select_query.select_rarity_names()
    effect_names = select_query.select_effect_names()

    return render_template('admin/add_item.html',
                           slots=slot_names,
                           rarities=rarity_names,
                           effects=effect_names,
                           header_text=get_current_username())
Exemplo n.º 2
0
def get_item_list(item_slot):
    field_names = ("Item_ID", "Item_Name", "Item_Picture", "Rarities_Color")
    query_result = select_query.select_item_fields_from_item_slot(
        item_slot, field_names)

    # TODO: handle if query_result is none

    item_list = []

    for item in query_result:
        item_data = {}
        for key in field_names:
            item_data[key] = item[key]

        item_list.append(item_data)

    slot_name = select_query.select_slot_names(item_slot)["Slots_Name"]

    output = {'slot_name': slot_name, 'items': item_list}

    return jsonify(output)
Exemplo n.º 3
0
def admin_creationKit():
    if not is_admin():
        return not_admin_redirect()

    items = select_query.select_items()
    buckets = {}
    slot_name_query_result = select_query.select_slot_names()

    for sn in slot_name_query_result:
        buckets[sn["Slots_Name"]] = []

    for i in items:
        item_data = {
            'Item_Name': shorten_string(i['Item_Name'], 13),
            'Item_ID': i['Item_ID']
        }
        buckets[i["Slots_Name"]].append(item_data)

    return render_template('admin/items.html',
                           buckets=buckets,
                           header_text=get_current_username())
Exemplo n.º 4
0
def get_current_equiped_items(char_id, item_slot):
    user_id = session["user_id"]
    if not check_if_user_has_character(user_id, char_id):
        if is_admin():
            user_id = get_user_id_from_char_id(char_id)
            if user_id < 0:
                return jsonify(current_value="Err")

    characters = select_query.select_char_fields(user_id, char_id)

    if characters is None:
        return redirect(url_for('character.character_select'))

    slot_name = select_query.select_slot_names(item_slot)["Slots_Name"]

    multiple = {'Weapon': 4, 'Ring': 2, 'Item': 2, 'Trinket': 2}

    r = 1
    slots = []

    if slot_name in multiple.keys():
        r = int(multiple[slot_name])
        for i in range(r):
            field_name = "Character_" + slot_name + str(i + 1)
            slots.append(field_name)
    else:
        slots.append("Character_" + slot_name)

    item_ids = select_query.select_char_fields(user_id, char_id, tuple(slots))

    field_names = ['Item_ID', 'Item_Name', 'Item_Picture', 'Rarities_Color']

    item_list = []

    item_defaults = {
        'Ring': {
            'item_name': 'Ring',
            'picture': 'Ring.png'
        },
        'Item': {
            'item_name': 'Item',
            'picture': 'Item.png'
        },
        'Trinket': {
            'item_name': 'Trinket',
            'picture': 'Trinket.png'
        }
    }

    for i in range(r):
        temp_dict = {}

        temp_dict['Item_ID'] = -1

        if slot_name == 'Weapon':
            if i % 2 == 1:
                temp_dict['Item_Name'] = 'Off Hand '
                temp_dict['Item_Picture'] = 'Off_Hand.png'
            else:
                temp_dict['Item_Name'] = 'Main Hand '
                temp_dict['Item_Picture'] = 'Main_Hand.png'
            temp_dict['Item_Name'] += str(math.ceil((i + 1) / 2))
        else:
            temp_dict['Item_Name'] = item_defaults[slot_name]['item_name']
            temp_dict['Item_Picture'] = item_defaults[slot_name]['picture']

        temp_dict['Rarities_Color'] = '#606060'

        item_list.append(temp_dict)

    count = 0
    for i in item_ids:
        join_str = "INNER JOIN Rarities ON Rarities.Rarities_ID=Items.Rarity_ID"
        item_data_result = select_query.select(tuple(field_names), "Items",
                                               False, "WHERE Item_ID=?", (i, ),
                                               (join_str, ))

        if item_data_result is None:
            count += 1
            continue

        temp_data = {}
        for name in field_names:
            temp_data[name] = item_data_result[name]

        item_list[count] = temp_data
        count += 1

    slot_name = select_query.select_slot_names(item_slot)['Slots_Name']

    output = {'slot_name': slot_name, 'items': item_list, 'num_of_slots': r}

    return jsonify(output)
Exemplo n.º 5
0
def admin_creationKit_edit(item_id):
    if not is_admin():
        return not_admin_redirect()

    slot_names = select_query.select_slot_names()
    rarity_names = select_query.select_rarity_names()
    effect_names = select_query.select_effect_names()

    item_query_result = select_query.select_items(item_id)

    if item_query_result is None:
        Logger().error("Failed to get item data for item_id: " + str(item_id))
        item_query_result = {
            'Item_Description': 'null',
            'Item_Name': 'null',
            'Item_Picture': 'no_image.png',
            'Rarities_Name': 'null',
            'Rarities_Color': 'white',
            #'Item_Slot' : 'null',
            'Item_Weight': 'null',
            'Item_Str_Bonus': 0,
            'Item_Dex_Bonus': 0,
            'Item_Con_Bonus': 0,
            'Item_Int_Bonus': 0,
            'Item_Wis_Bonus': 0,
            'Item_Cha_Bonus': 0,
            'Item_Attack_Bonus': 0,
            #'Item_Initiative_Bonus' : 0,
            'Item_Health_Bonus': 0,
            'Item_Damage_Num_Of_Dices': 0,
            'Item_Damage_Num_Of_Dice_Sides': 0,
            'Item_AC_Bonus': 0
        }

    item_effect1 = 'None'
    item_effect2 = 'None'
    item_slots_name = ''

    if item_query_result is not None:
        # Check if item has an effect on it
        if item_query_result['Item_Effect1'] is not None and item_query_result[
                'Item_Effect1'] > 0:
            item_effect1 = select_query.select_effect_names(
                item_query_result['Item_Effect1'])['Effect_Name']

        if item_query_result['Item_Effect2'] is not None and item_query_result[
                'Item_Effect2'] > 0:
            item_effect2 = select_query.select_effect_names(
                item_query_result['Item_Effect2'])['Effect_Name']

        if item_query_result['Item_Slot'] is not None and item_query_result[
                'Item_Slot'] > 0:
            item_slots_name = select_query.select_slot_names(
                item_query_result['Item_Slot'])['Slots_Name']

    return render_template('admin/edit_item.html',
                           items=item_query_result,
                           slots=slot_names,
                           rarities=rarity_names,
                           effects=effect_names,
                           effect1_name=item_effect1,
                           effect2_name=item_effect2,
                           item_id=item_id,
                           item_slots_name=item_slots_name,
                           header_text=get_current_username())