示例#1
0
function Module_JSON($db)
{
    $card_id = Functions::Post_Int('card_id');
    $normal = Functions::Post_Int('normal');
    $gold = Functions::Post_Int('gold');
    if (!Functions::Card_Load_Id($db, $card_id, $card)) {
        return JSON_Response_Error('#Error#', 'Failed to load card');
    }
    if ($normal < 0 or !is_int($normal)) {
        return JSON_Response_Error('#Error#', 'Invalid normal value');
    }
    if ($gold < 0 or !is_int($gold)) {
        return JSON_Response_Error('#Error#', 'Invalid normal value');
    }
    if ($card['rarity'] == 'Legendary') {
        $card['normal'] = $normal > 1 ? 1 : $normal;
        $card['gold'] = $gold > 1 ? 1 : $gold;
    } else {
        $card['normal'] = $normal > 2 ? 2 : $normal;
        $card['gold'] = $gold > 2 ? 2 : $gold;
    }
    if (!Functions::Card_Update($db, $card)) {
        return JSON_Response_Global_Error();
    }
    return JSON_Response_Success();
}
示例#2
0
function Module_JSON($db)
{
    $dust_am = Functions::Post_Int('dust_am');
    $dust_de = Functions::Post_Int('dust_de');
    $gold = Functions::Post_Int('gold');
    if (!Functions::Account_Load($db, $account)) {
        return JSON_Response_Error('#Error#', 'Failed to load account');
    }
    $account['dust_am'] = $dust_am;
    $account['dust_de'] = $dust_de;
    $account['gold'] = $gold;
    if (!Functions::Account_Update($db, $account)) {
        return JSON_Response_Global_Error();
    }
    return JSON_Response_Success();
}
示例#3
0
function Module_JSON($db)
{
    $common = Functions::Post_Int('common');
    $c_gold = Functions::Post_Int('c_gold');
    $rare = Functions::Post_Int('rare');
    $r_gold = Functions::Post_Int('r_gold');
    $epic = Functions::Post_Int('epic');
    $e_gold = Functions::Post_Int('e_gold');
    $legend = Functions::Post_Int('legend');
    $l_gold = Functions::Post_Int('l_gold');
    if (!Functions::Pack_Load($db, $packs)) {
        return JSON_Response_Error('#Error#', 'Failed to load pack data');
    }
    $packs['common'] = $packs['common'] + $common;
    $packs['c_gold'] = $packs['c_gold'] + $c_gold;
    $packs['rare'] = $packs['rare'] + $rare;
    $packs['r_gold'] = $packs['r_gold'] + $r_gold;
    $packs['epic'] = $packs['epic'] + $epic;
    $packs['e_gold'] = $packs['e_gold'] + $e_gold;
    $packs['legend'] = $packs['legend'] + $legend;
    $packs['l_gold'] = $packs['l_gold'] + $l_gold;
    $packs['opened']++;
    if ($common + $c_gold + $rare + $r_gold + $epic + $e_gold + $legend + $l_gold != 5) {
        return JSON_Response_Error('#Error#', 'Not a valid pack');
    }
    if (!Functions::Pack_Update($db, $packs)) {
        return JSON_Response_Global_Error();
    }
    //Update account pack info (perhaps should be in packs)
    if (!Functions::Account_Load($db, $account)) {
        return JSON_Response_Error('#Error#', 'Failed to load account');
    }
    if ($legend + $l_gold != 0) {
        $account['last_l'] = 0;
    } else {
        $account['last_l']++;
    }
    if ($epic + $e_gold != 0) {
        $account['last_e'] = 0;
    } else {
        $account['last_e']++;
    }
    if (!Functions::Account_Update($db, $account)) {
        return JSON_Response_Global_Error();
    }
    return JSON_Response_Success();
}
示例#4
0
function Module_JSON($db)
{
    $opponent = Functions::Post('opponent');
    $win = Functions::Post_Int('win');
    $coin = Functions::Post_Int('coin');
    if (!Functions::ArenaRun_Load_Active($db, $arena_run)) {
        return JSON_Response_Error('#Error#', 'Failed to load active arena');
    }
    $arena_match['arena_id'] = $arena_run['id'];
    $arena_match['opponent'] = $opponent;
    $arena_match['win'] = $win;
    $arena_match['coin'] = $coin;
    if (!Functions::ArenaMatch_Validate($arena_match)) {
        return JSON_Response_Global_Error();
    }
    return JSON_Response_Success();
}
示例#5
0
function Update_Item(&$db, $type, $date_input, $employee_id, $hours, $description, $billable, $custom_rate)
{
    $item_id = Functions::Post_Int('item_id');
    if (!Functions::Item_Load($db, $item_id, $loaded_item)) {
        return JSON_Response_Error('#Error#', 'Item could not be found');
    }
    $item['id'] = $loaded_item['id'];
    $item['rp_id'] = $loaded_item['rp_id'];
    $item['date'] = date('Y-m-d', strtotime($date_input));
    $item['type'] = $type;
    $item['hours'] = $hours;
    $item['employee_id'] = $employee_id;
    $item['description'] = $description;
    $item['billable'] = $billable;
    $item['custom_rate'] = $custom_rate;
    if (!Functions::Item_Update($db, $item)) {
        return JSON_Response_Global_Error();
    }
    return JSON_Response_Success(array('real_id' => $item_id));
}