コード例 #1
0
 $item_add_power = intval($HTTP_POST_VARS['item_add_power']);
 $item_mp_use = intval($HTTP_POST_VARS['item_mp_use']);
 $item_element = intval($HTTP_POST_VARS['element_weap_list']);
 $item_element_str = intval($HTTP_POST_VARS['item_element_str']);
 $item_element_same = intval($HTTP_POST_VARS['item_element_same']);
 $item_element_weak = intval($HTTP_POST_VARS['item_element_weak']);
 $item_weight = intval($HTTP_POST_VARS['item_weight']);
 $item_max_skill = intval($HTTP_POST_VARS['item_max_skill']);
 if ($item_name == '' || !$item_power || !$item_duration) {
     message_die(MESSAGE, $lang['Fields_empty']);
 }
 if ($item_price == '') {
     // If no price is defined , let's calculate the real item price
     $adr_general = adr_get_general_config();
     // Get the base and modifier price
     $adr_quality_price = adr_get_item_quality($item_quality, price);
     $adr_type_price = adr_get_item_type($item_type, price);
     // First define the base price
     $item_price = $adr_type_price;
     // Then apply the quality modifier
     $item_price = $item_price * ($adr_quality_price / 100);
     // And now the power - it's a little more complicated
     $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price;
     // Apply the duration penalty
     $item_price = abs($item_price / ($item_duration_max / $item_duration));
     // Finally let's use a non decimal value & add 10 %
     $item_price = ceil($item_price * 1.1);
 }
 $sql = "INSERT INTO " . ADR_BEGGAR_DONATIONS . "\r\n\t\t\t\t( item_id , item_owner_id , item_chance , item_type_use , item_name , item_desc , item_icon , item_price , item_quality , item_duration , item_duration_max , item_power , item_add_power , item_mp_use , item_weight , item_max_skill , item_element , item_element_str_dmg , item_element_same_dmg , item_element_weak_dmg )\r\n\t\t\t\tVALUES ( {$item_id} , 1 , {$item_chance} , {$item_type} , '" . str_replace("\\'", "''", $item_name) . "', '" . str_replace("\\'", "''", $item_desc) . "' , '" . str_replace("\\'", "''", $item_icon) . "' , {$item_price} , {$item_quality} , {$item_duration} , {$item_duration_max} , {$item_power} , {$item_add_power} , {$item_mp_use} , {$item_weight} , {$item_max_skill} , {$item_element} , {$item_element_str} , {$item_element_same} , {$item_element_weak} )";
 $result = $db->sql_query($sql);
 if (!$result) {
コード例 #2
0
     // First define the base price
     $item_price = $adr_type_price;
     // Then apply the quality modifier
     $item_price = $item_price * ($adr_quality_price / 100);
     // And now the power - it's a little more complicated
     $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price;
     // Apply the duration penalty
     $item_price = abs($item_price / ($item_duration_max / $item_duration));
     // Finally let's use a non decimal value & add 10 %
     $item_price = ceil($item_price * 1.1);
 }
 if ($recipe_price == '') {
     // If no price is defined , let's calculate the real item price
     $adr_general = adr_get_general_config();
     // Get the base and modifier price
     $adr_quality_price = adr_get_item_quality($recipe_quality, price);
     $adr_type_price = adr_get_item_type($recipe_type, price);
     // First define the base price
     $recipe_price = $adr_type_price;
     // Then apply the quality modifier
     $recipe_price = $recipe_price * ($adr_quality_price / 100);
     // And now the power - it's a little more complicated
     $recipe_price = $recipe_power > 1 ? $recipe_price + $recipe_price * (($recipe_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $recipe_price;
     // Apply the duration penalty
     $recipe_price = abs($recipe_price / ($recipe_duration_max / $recipe_duration));
     // Finally let's use a non decimal value & add 10 %
     $recipe_price = ceil($recipe_price * 1.1);
 }
 //recipe_items_req
 $recipe_items_req_list = array();
 $recipe_items_req_list = $HTTP_POST_VARS['recipe_items_req'];
コード例 #3
0
ファイル: adr_TownMap_forge.php プロジェクト: Nekrofage/FJR
     $tools = $db->sql_fetchrowset($result);
     $tool_list = '<select name="item_tool">';
     $tool_list .= '<option value = "0" >' . $lang['Adr_forge_mining_no_tool'] . '</option>';
     for ($i = 0; $i < count($tools); $i++) {
         $tool_list .= '<option value = "' . $tools[$i]['item_id'] . '" >' . adr_get_lang($tools[$i]['item_name']) . ' ( ' . $lang['Adr_items_power'] . ' : ' . $tools[$i]['item_power'] . ' - ' . $lang['Adr_items_duration'] . ' : ' . $tools[$i]['item_duration'] . ' )' . '</option>';
     }
     $tool_list .= '</select>';
     $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\tWHERE item_owner_id = {$user_id}\r\n\t\t\t\tAND item_quality < 5 \r\n\t\t\t\tAND item_in_shop = 0\r\n\t\t\t\tAND item_in_warehouse = 0\r\n\t\t\t\tAND item_duration > 0\r\n\t\t\t\tAND item_type_use IN ( 1 , 2 ) ";
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not check user items', "", __LINE__, __FILE__, $sql);
     }
     $items = $db->sql_fetchrowset($result);
     $items_list = '<select name="item_to_repair">';
     $items_list .= '<option value = "0" >' . $lang['Adr_forge_repair_no_item'] . '</option>';
     for ($i = 0; $i < count($items); $i++) {
         $items_list .= '<option value = "' . $items[$i]['item_id'] . '" >' . adr_get_lang($items[$i]['item_name']) . ' ( ' . $lang['Adr_items_power'] . ' : ' . $items[$i]['item_power'] . ' - ' . $lang['Adr_items_quality'] . ' : ' . adr_get_item_quality($items[$i]['item_quality'], simple) . ' - ' . $lang['Adr_items_type_use'] . ' : ' . adr_get_item_type($items[$i]['item_type_use'], simple) . ')' . '</option>';
     }
     $items_list .= '</select>';
     $template->assign_vars(array('ITEMS_LIST' => $items_list, 'TOOL_LIST' => $tool_list, 'L_SELECT_TOOL' => $lang['Adr_forge_mining_select_tool'], 'L_SELECT_ITEMS' => $lang['Adr_forge_stone_select_item'], 'L_GO_REPAIR' => $lang['Adr_forge_stone_go'], 'L_STONE_EXPLAIN' => $lang['Adr_forge_stone_explain']));
     break;
 case 'stone_action':
     $tool = intval($HTTP_POST_VARS['item_tool']);
     $item_to_repair = intval($HTTP_POST_VARS['item_to_repair']);
     // No tool , no repair
     if (!$tool) {
         adr_previous(Adr_forge_stone_tool_needed, adr_TownMap_forge, "mode=stone");
     }
     // No item to repair ?
     if (!$item_to_repair) {
         adr_previous(Adr_forge_stone_item_to_repair_needed, adr_TownMap_forge, "mode=stone");
     }
コード例 #4
0
ファイル: adr_shops.php プロジェクト: ZerGabriel/adr-rpg
     $shop_name = isset($_POST['shop_name']) ? trim($_POST['shop_name']) : trim($_GET['shop_name']);
     $shop_desc = isset($_POST['shop_desc']) ? trim($_POST['shop_desc']) : trim($_GET['shop_desc']);
     $shop_id = !empty($_POST['shop_id']) ? $_POST['shop_id'] : $_GET['shop_id'];
     if (!$shop_name) {
         message_die(MESSAGE, $lang['Fields_empty']);
     }
     $sql = "UPDATE " . ADR_SHOPS_TABLE . " \n\t\t\t\tSET  shop_name = '" . str_replace("\\'", "''", $shop_name) . "',\n\t\t\t\t     shop_desc = '" . str_replace("\\'", "''", $shop_desc) . "'\n\t\t\t\tWHERE shop_id = {$shop_id}\n\t\t\t\tAND shop_owner_id = {$user_id} ";
     $result = $db->sql_query($sql);
     if (!$result) {
         message_die(GENERAL_ERROR, "Couldn't insert new shop", "", __LINE__, __FILE__, $sql);
     }
     adr_previous(Adr_users_shops_edited_success, adr_shops, "?mode=see_shop&amp;shop_id=" . $shop_id . "");
     break;
 case 'search_item':
     $template->assign_block_vars('search_item', array());
     $template->assign_vars(array('ITEM_TYPE' => adr_get_item_type(0, search), 'ITEM_QUALITY' => adr_get_item_quality(0, search), 'L_POINTS' => get_reward_name(), 'L_ITEM_QUALITY' => $lang['Adr_items_quality'], 'L_ITEM_TYPE' => $lang['Adr_items_type_use'], 'L_ITEM_QUALITY_LEAST' => $lang['Adr_items_type_least'], 'L_ITEM_POWER_LEAST' => $lang['Adr_items_power_least'], 'L_ITEM_DURATION_LEAST' => $lang['Adr_items_duration_least'], 'L_ITEM_PRICE_MAX' => $lang['Adr_items_price_max'], 'L_SEARCH_ITEM_CRITERA' => $lang['Adr_items_search_criteria'], 'L_SUBMIT' => $lang['Submit']));
     break;
 case 'search_item_results':
     $template->assign_block_vars('search_item_results', array());
     $item_quality = intval($_POST['item_quality']) - 1;
     $item_power_least = intval($_POST['item_power_least']) - 1;
     $item_duration_least = intval($_POST['item_duration_least']) - 1;
     $item_type = intval($_POST['item_type_use']);
     $item_price_max = intval($_POST['item_price_max']);
     // Check user input for errors
     $item_quality = $item_quality < '0' ? intval(0) : $item_quality;
     $item_power_least = $item_power_least < '0' ? intval(0) : $item_power_least;
     $item_duration_least = $item_duration_least < '0' ? intval(0) : $item_duration_least;
     $search_type_sql = $item_type > '0' ? 'AND item_type_use = ' . $item_type : '';
     $search_price_sql = $item_price_max > '0' ? 'AND item_price < ' . $item_price_max : '';
     //         $sql = "SELECT i.*, s.*, q.item_quality_lang, t.item_type_lang FROM " . ADR_SHOPS_ITEMS_TABLE . " i, " . ADR_SHOPS_TABLE . " s
コード例 #5
0
function adr_get_item_real_price($item_id, $user_id)
{
    global $db;
    // Fix the values
    $item_id = intval($item_id);
    $user_id = intval($user_id);
    $adr_general = adr_get_general_config();
    $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_id = {$item_id} \n\t\tAND item_owner_id = {$user_id} ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, "Couldn't query item infos", "", __LINE__, __FILE__, $sql);
    }
    $row = $db->sql_fetchrow($result);
    // Once again , let's protect us about malicious users ...
    if (!is_numeric($row['item_type_use'])) {
        message_die(GENERAL_ERROR, "This item doesn't exist");
    }
    $item_type = $row['item_type_use'];
    $item_quality = $row['item_quality'];
    $item_duration = $row['item_duration'];
    $item_duration_max = $row['item_duration_max'];
    $item_power = $row['item_power'];
    // Get the base and modifier price
    $adr_quality_price = adr_get_item_quality($item_quality, price);
    $adr_type_price = adr_get_item_type($item_type, price);
    // First define the base price
    $item_price = $adr_type_price;
    // Apply the sell back penalty
    $item_price = $row['item_sell_back_percentage'] * $item_price / 100;
    // Then apply the quality modifier
    $item_price = $item_price * ($adr_quality_price / 100);
    // And now the power - it's a little more complicated
    $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price;
    // Apply the duration penalty
    $item_price = abs($item_price / ($item_duration_max / $item_duration));
    // Finally let's use a non decimal value
    $item_price = ceil($item_price);
    return $item_price;
}
コード例 #6
0
function adr_use_skill_mining($user_id, $tool)
{
    global $db;
    $user_id = intval($user_id);
    $tool = intval($tool);
    $new_item_id = 0;
    $adr_general = adr_get_general_config();
    // START skill limit check
    $sql = " SELECT character_skill_limit FROM " . ADR_CHARACTERS_TABLE . "\n\t\t\tWHERE character_id = {$user_id} ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not query skill limit value', '', __LINE__, __FILE__, $sql);
    }
    $limit_check = $db->sql_fetchrow($result);
    if ($adr_general['Adr_character_limit_enable'] != 0 && $limit_check['character_skill_limit'] < 1) {
        adr_previous(Adr_skill_limit, adr_town, '');
    }
    // END skill limit check
    $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\tWHERE item_in_shop = 0 \n\t\tAND item_owner_id = {$user_id} \n\t\tAND item_id = {$tool} ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not query tool informations', '', __LINE__, __FILE__, $sql);
    }
    $item = $db->sql_fetchrow($result);
    if ($item['item_duration'] < 0) {
        adr_previous(Adr_forge_mining_broken, adr_forge, "mode=mining");
    }
    // Alter the tool
    adr_use_item($tool, $user_id);
    $adr_general = adr_get_general_config();
    $adr_user = adr_get_user_infos($user_id);
    $skill_data = adr_get_skill_data(1);
    $user_chance = $adr_user['character_skill_mining'] * $skill_data['skill_chance'];
    $user_chance = $user_chance > 100 ? 100 : $user_chance;
    $rand = rand(0, 100);
    if ($user_chance > $rand) {
        $modif = $item['item_quality'] > 3 ? $item['item_quality'] - 3 : 0;
        $modif = $modif + ($item['item_power'] - 1);
        $happiness = rand($modif, 10);
        $new_item_type = $happiness > 8 ? 2 : 1;
        // Make the new id for the item
        $sql = "SELECT item_id FROM " . ADR_SHOPS_ITEMS_TABLE . "\n\t\t\tWHERE item_owner_id = {$user_id}\n\t\t\tORDER BY item_id \n\t\t\tDESC LIMIT 1";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql);
        }
        $data = $db->sql_fetchrow($result);
        $new_item_id = $data['item_id'] + 1;
        $item_type = $new_item_type;
        $item_name = $new_item_type == 1 ? 'Adr_item_ore' : 'Adr_items_diamond';
        $item_desc = $new_item_type == 1 ? 'Adr_item_ore_desc' : 'Adr_items_diamond_desc';
        $item_icon = $new_item_type == 1 ? 'ore.gif' : 'diamond.gif';
        $item_quality = rand(1, 6);
        $item_duration = rand(1, 3);
        $item_power = rand(1, 3);
        adr_skill_limit($user_id);
        // Generate the item price
        $adr_quality_price = adr_get_item_quality($item_quality, price);
        $adr_type_price = adr_get_item_type($item_type, price);
        $item_price = $adr_type_price;
        $item_price = $item_price * ($adr_quality_price / 100);
        $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price;
        $item_price = ceil($item_price);
        $sql = "INSERT INTO " . ADR_SHOPS_ITEMS_TABLE . " \n\t\t\t( item_id , item_owner_id , item_type_use , item_name , item_desc , item_icon , item_price , item_quality , item_duration, item_duration_max , item_power )\n\t\t\tVALUES ( {$new_item_id} , {$user_id} , {$item_type} , '" . str_replace("\\'", "''", $item_name) . "', '" . str_replace("\\'", "''", $item_desc) . "' , '" . str_replace("\\'", "''", $item_icon) . "' , {$item_price} , {$item_quality} , {$item_duration}, {$item_duration} , {$item_power} )";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, "Couldn't insert new item", "", __LINE__, __FILE__, $sql);
        }
        // Increases the success uses of this skill and increase level if needed
        if ($adr_user['character_skill_mining_uses'] + 1 >= $skill_data['skill_req']) {
            $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\t\t\tSET character_skill_mining_uses = 0 , \n\t\t\t\t\tcharacter_skill_mining = character_skill_mining + 1\n\t\t\t\tWHERE character_id = {$user_id} ";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, 'Could not obtain skill information', "", __LINE__, __FILE__, $sql);
            }
        } else {
            $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\n\t\t\t\tSET character_skill_mining_uses = character_skill_mining_uses + 1\n\t\t\t\tWHERE character_id = {$user_id} ";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql);
            }
        }
    }
    return $new_item_id;
}
コード例 #7
0
} else {
    $mode = "";
}
if ($mode != "") {
    switch ($mode) {
        case 'add_store':
            adr_template_file('admin/config_adr_store_cats_edit_body.tpl');
            $template->assign_block_vars('add', array());
            $s_hidden_fields = '<input type="hidden" name="mode" value="savenew_store" /><input type="hidden" name="store_type" value="' . $item_type . '" />';
            $sql = "SELECT * FROM " . ADR_STORES_TABLE;
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, 'Could not obtain elements information', "", __LINE__, __FILE__, $sql);
            }
            $items = $db->sql_fetchrowset($result);
            $template->assign_vars(array("ITEM_QUALITY" => adr_get_item_quality($items['item_quality'], 'list'), "ITEM_TYPE" => adr_get_item_type($items['item_type_use'], 'list'), "L_POINTS" => $board_config['points_name'], "L_CLOSED" => $lang['Adr_store_status_closed'], "L_OPEN" => $lang['Adr_store_status_open'], "L_NORMAL" => $lang['Adr_store_sales_off'], "L_SALE" => $lang['Adr_store_sales_on'], "L_ALL" => $lang['Adr_store_auth_all'], "L_ADMIN" => $lang['Adr_store_auth_admin'], "L_NAME_EXPLAIN" => $lang['Adr_races_name_explain'], "L_ITEMS_TITLE" => $lang['Adr_shops_item_add_title'], "L_ITEMS_EXPLAIN" => $lang['Adr_shops_item_add_title_explain'], "L_ITEM_NAME" => $lang['Adr_shops_categories_item_name'], "L_ITEM_DESC" => $lang['Adr_shops_categories_item_desc'], "L_ITEM_STATUS" => $lang['Adr_store_status'], "L_ITEM_SALES" => $lang['Adr_store_sales'], "L_ITEM_AUTH" => $lang['Adr_store_auth'], "L_ITEM_VIEW" => $lang['Adr_store_view'], "L_NAME" => $lang['Adr_races_name'], "L_DESC" => $lang['Adr_races_desc'], "L_ACTION" => $lang['Action'], "L_ITEMS" => $lang['Adr_shops_categories_items'], "L_EDIT" => $lang['Edit'], "L_DELETE" => $lang['Delete'], "L_ITEM_IMG" => $lang['Adr_races_image'], "L_ITEM_PRICE" => $lang['Adr_items_price'], "L_ITEM_PRICE_EXPLAIN" => $lang['Adr_items_price_explain'], "L_IMG" => $lang['Adr_races_image'], "L_IMG_EXPLAIN" => $lang['Adr_items_image_explain'], "L_SUBMIT" => $lang['Submit'], "S_ITEMS_ACTION" => append_sid("admin_adr_store_cats.{$phpEx}"), "S_HIDDEN_FIELDS" => $s_hidden_fields));
            $template->pparse("body");
            break;
        case 'delete_store':
            $store_id = !empty($_POST['store_id']) ? intval($_POST['store_id']) : intval($_GET['store_id']);
            $sql = "DELETE FROM " . ADR_STORES_TABLE . "\n\t\t\t\tWHERE store_id = " . $store_id . "\n\t\t\t\tAND store_owner_id = 1 ";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, "Couldn't delete item", "", __LINE__, __FILE__, $sql);
            }
            adr_previous(Adr_store_cats_successful_deleted, admin_adr_store_cats, '');
            break;
        case 'edit_store':
            $store_id = !empty($_POST['store_id']) ? intval($_POST['store_id']) : intval($_GET['store_id']);
            adr_template_file('admin/config_adr_store_cats_edit_body.tpl');
            $template->assign_block_vars('edit', array());
コード例 #8
0
function adr_use_skill($user_id, $tool, $recipe_item_id, $skill_id, $type)
{
    global $db;
    $user_id = intval($user_id);
    $item_id = intval($item_id);
    $tool = intval($tool);
    $recipe_item_id = intval($recipe_item_id);
    $new_item_id = 0;
    $adr_general = adr_get_general_config();
    $adr_user = adr_get_user_infos($user_id);
    $skill_data = adr_get_skill_data($skill_id);
    $current_file = 'adr_' . $type;
    $character_skill = 'character_skill_' . $type;
    $character_skill_uses = 'character_skill_' . $type . '_uses';
    // START skill limit check
    if ($adr_general['Adr_character_limit_enable'] != 0 && $adr_user['character_skill_limit'] < 1) {
        adr_previous(Adr_skill_limit, $current_file, "mode=view&known_recipes={$recipe_item_id}");
    }
    // END skill limit check
    $sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\tWHERE item_in_shop = 0 \r\n\t\tAND item_owner_id = {$user_id} \r\n\t\tAND item_id = {$tool} ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Could not query tool informations', '', __LINE__, __FILE__, $sql);
    }
    $item = $db->sql_fetchrow($result);
    // get the information of the item that will be crafted
    //get original recipe information
    $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\tWHERE item_owner_id = 1\r\n\t\tAND item_original_recipe_id = {$recipe_item_id}\r\n\t\t";
    $result = $db->sql_query($sql);
    if (!$result) {
        message_die(GENERAL_ERROR, 'Could not obtain owners recipes information', "", __LINE__, __FILE__, $sql);
    }
    $original_recipe = $db->sql_fetchrow($result);
    //get original (up-to-date) recipe info now
    $sql_recipe = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\tWHERE item_id = " . $original_recipe['item_recipe_linked_item'] . "\r\n\t\tAND item_owner_id = 1\r\n\t\t";
    $result_recipe = $db->sql_query($sql_recipe);
    if (!$result_recipe) {
        message_die(GENERAL_ERROR, "Couldn't select recipe info", "", __LINE__, __FILE__, $sql_recipe);
    }
    $crafted_item = $db->sql_fetchrow($result_recipe);
    if ($item['item_duration'] < 0) {
        adr_previous(Adr_forge_broken, $current_file, "mode=view&known_recipes={$recipe_item_id}");
    }
    // Alter the tool
    adr_use_item($tool, $user_id);
    //roll
    $difference = intval($adr_user['character_skill_' . $type . ''] - $original_recipe['item_power']);
    $impossible_loose_bonus = 0;
    switch (TRUE) {
        case $difference < -9:
            $modifier = '-100%';
            $lose_roll = 100;
            $impossible_loose_bonus = 1;
            break;
            //Impossible
        //Impossible
        case $difference >= -9 && $difference < -6:
            $modifier = '-80%';
            $lose_roll = 80;
            $item_quality = rand(1, 2);
            break;
            //Very Hard
        //Very Hard
        case $difference >= -6 && $difference < -4:
            $modifier = '-60%';
            $lose_roll = 60;
            $item_quality = rand(1, 3);
            break;
            //Hard
        //Hard
        case $difference >= -4 && $difference < -2:
            $modifier = '-40%';
            $lose_roll = 40;
            $item_quality = rand(1, 4);
            break;
            //Normal
        //Normal
        case $difference >= -2 && $difference < 0:
            $modifier = '-20%';
            $lose_roll = 20;
            $item_quality = rand(1, 5);
            break;
            //Easy
        //Easy
        case $difference >= 0:
            $modifier = '-1%';
            $lose_roll = 5;
            $item_quality = rand(1, 6);
            break;
            //Very Easy
    }
    $user_chance = rand(0, $adr_user['character_skill_' . $type . ''] * 100);
    $user_chance = $user_chance + floor($user_chance * $modifier / 100);
    $loose_chance = rand($impossible_loose_bonus, $adr_user['character_skill_' . $type . ''] * $lose_roll);
    /*
    echo $modifier." : modifier<br>";
    echo $difference." : difference<br>";
    echo $user_chance." : user chance<br>";
    echo $loose_chance." : loose_chance<br>";
    */
    // loose a needed item if the rolled dice is bad
    $items_req = explode(':', $crafted_item['item_brewing_items_req']);
    if ($user_chance < $loose_chance) {
        for ($i = 0; $i < count($items_req); $i++) {
            $switch = !($i % 2) ? $get_info = 1 : ($get_info = 0);
            if ($get_info == 1) {
                $req_list .= $req_list == '' ? $items_req[$i] : ':' . $items_req[$i];
            }
        }
        $req_list = explode(':', $req_list);
        $random = rand(0, count($req_list) - 1);
        $sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\tWHERE item_id = '" . $req_list[$random] . "'\r\n\t\t\t\tAND item_owner_id = 1\r\n\t\t\t\t";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, 'Could not obtain items information', "", __LINE__, __FILE__, $sql);
        }
        $req_item = $db->sql_fetchrow($result);
        $req_item_name = str_replace("'", "\\'", $req_item['item_name']);
        //delete item from inventory
        $sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_in_shop = 0\r\n\t\t\tAND item_in_warehouse = 0\r\n\t\t\tAND item_owner_id = {$user_id}\r\n\t\t\tAND item_name = '" . $req_item_name . "'\r\n\t\t\tLIMIT 1\r\n\t\t\t";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, 'Could not delete item', "", __LINE__, __FILE__, $sql);
        }
        $new_item_id = 'You lost a <br><br><center>' . adr_get_lang($req_item['item_name']) . '<br><img src="./adr/images/items/' . $req_item['item_icon'] . '"></center><br>during your attempt to cook this food!';
    } elseif ($user_chance > $loose_chance) {
        $sql = "UPDATE " . ADR_CHARACTERS_TABLE . "\r\n\t\t\tSET character_xp = character_xp + 3 \r\n\t\t\tWHERE character_id = {$user_id} ";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, 'Could not update characters xp', "", __LINE__, __FILE__, $sql);
        }
        for ($i = 0; $i < count($items_req); $i++) {
            $switch = !($i % 2) ? $check_item = 0 : ($check_item = 1);
            if ($check_item == 1) {
                //get item info
                $sql_info = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\t\twhere item_id = " . $items_req[$i - 1];
                $result_info = $db->sql_query($sql_info);
                if (!$result_info) {
                    message_die(GENERAL_ERROR, 'Could not obtain items information', "", __LINE__, __FILE__, $sql_info);
                }
                $item_info = $db->sql_fetchrow($result_info);
                $req_item_name = str_replace("'", "\\'", $item_info['item_name']);
                echo $rew_item_name . "<br>";
                //delete item from inventory
                $sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\t\t\tWHERE item_in_shop = 0\r\n\t\t\t\t\tAND item_in_warehouse = 0\r\n\t\t\t\t\tAND item_owner_id = {$user_id}\r\n\t\t\t\t\tAND item_name = '" . $req_item_name . "'\r\n\t\t\t\t\tLIMIT " . $items_req[$i] . "\r\n\t\t\t\t\t";
                $result = $db->sql_query($sql);
                if (!$result) {
                    message_die(GENERAL_ERROR, 'Could not delete item', "", __LINE__, __FILE__, $sql);
                }
            }
        }
        // Make the new id for the item
        $sql = "SELECT item_id FROM " . ADR_SHOPS_ITEMS_TABLE . "\r\n\t\t\tWHERE item_owner_id = {$user_id}\r\n\t\t\tORDER BY item_id \r\n\t\t\tDESC LIMIT 1";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, 'Could not obtain item information', "", __LINE__, __FILE__, $sql);
        }
        $data = $db->sql_fetchrow($result);
        $new_item_id = $data['item_id'] + 1;
        $item_name = $crafted_item['item_name'];
        $item_type = $crafted_item['item_type_use'];
        $item_desc = 'Crafted by ' . $adr_user['character_name'] . '';
        $item_icon = $crafted_item['item_icon'];
        $item_duration = $crafted_item['item_duration'];
        $item_duration_max = $crafted_item['item_duration_max'];
        $item_power = $crafted_item['item_power'];
        $item_add_power = $crafted_item['item_add_power'];
        $item_mp_use = $crafted_item['item_mp_use'];
        $item_element = $crafted_item['item_element'];
        $item_element_str_dmg = $crafted_item['item_element_str_dmg'];
        $item_element_same_dmg = $crafted_item['item_element_same_dmg'];
        $item_element_weak_dmg = $crafted_item['item_element_weak_dmg'];
        $item_max_skill = $crafted_item['item_max_skill'];
        $item_weight = $crafted_item['item_weight'];
        $item_brewing_items_req = $crafted_item['item_brewing_items_req'];
        $item_effect = $crafted_item['item_effect'];
        adr_skill_limit($user_id);
        // Generate the item price
        $adr_quality_price = adr_get_item_quality($item_quality, price);
        $adr_type_price = adr_get_item_type($item_type, price);
        $item_price = $adr_type_price;
        $item_price = $item_price * ($adr_quality_price / 100);
        $item_price = $item_power > 1 ? $item_price + $item_price * (($item_power - 1) * ($adr_general['item_modifier_power'] - 100) / 100) : $item_price;
        $item_price = ceil($item_price);
        $sql = "INSERT INTO " . ADR_SHOPS_ITEMS_TABLE . " ( item_id , item_owner_id , item_type_use , item_name , item_desc , item_icon , item_price , item_quality , \r\n\t\t\t\titem_duration , item_duration_max , item_power ,  item_add_power , item_mp_use , item_element , item_element_str_dmg , \r\n\t\t\t\titem_element_same_dmg , item_element_weak_dmg , item_max_skill  , item_weight, item_brewing_items_req, item_effect ) \r\n\t\t\t\tVALUES ( {$new_item_id} , {$user_id} , {$item_type} , '" . str_replace("\\'", "''", $item_name) . "', '" . str_replace("\\'", "''", $item_desc) . "' , \r\n\t\t\t\t'" . str_replace("\\'", "''", $item_icon) . "' , {$item_price} , {$item_quality} , {$item_duration} , {$item_duration_max} , {$item_power} , \r\n\t\t\t\t{$item_add_power} , {$item_mp_use} , {$item_element} , {$item_element_str_dmg} , {$item_element_same_dmg} , {$item_element_weak_dmg} , {$item_max_skill} , {$item_weight}, '" . $item_brewing_items_req . "', '" . $item_effect . "')";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, "Couldn't insert new item", "", __LINE__, __FILE__, $sql);
        }
        // Increases the success uses of this skill and increase level if needed
        if ($adr_user['character_skill_' . $type . '_uses'] + 1 >= $skill_data['skill_req']) {
            $sql = "UPDATE " . ADR_CHARACTERS_TABLE . " \r\n\t\t      SET {$character_skill_uses} = 0 , \r\n\t\t          {$character_skill} = {$character_skill} + 1 \r\n\t\t      WHERE character_id = {$user_id} ";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, 'Could not update skill information', "", __LINE__, __FILE__, $sql);
            }
        } else {
            $sql = "UPDATE " . ADR_CHARACTERS_TABLE . " \r\n\t\t      SET {$character_skill_uses} = {$character_skill_uses} + 1 \r\n\t\t      WHERE character_id = {$user_id} ";
            $result = $db->sql_query($sql);
            if (!$result) {
                message_die(GENERAL_ERROR, 'Could not update item information', "", __LINE__, __FILE__, $sql);
            }
        }
    }
    return $new_item_id;
}