Example #1
0
function CreateOneMoonRecord($Galaxy, $System, $Planet, $Owner, $MoonID, $MoonName, $Chance)
{
    global $lang;
    $PlanetName = "";
    $QryGetMoonPlanetData = "SELECT * FROM {{table}} ";
    $QryGetMoonPlanetData .= "WHERE ";
    $QryGetMoonPlanetData .= "`galaxy` = '" . $Galaxy . "' AND ";
    $QryGetMoonPlanetData .= "`system` = '" . $System . "' AND ";
    $QryGetMoonPlanetData .= "`planet` = '" . $Planet . "';";
    $MoonPlanet = doquery($QryGetMoonPlanetData, 'planets', true);
    $QryGetMoonGalaxyData = "SELECT * FROM {{table}} ";
    $QryGetMoonGalaxyData .= "WHERE ";
    $QryGetMoonGalaxyData .= "`galaxy` = '" . $Galaxy . "' AND ";
    $QryGetMoonGalaxyData .= "`system` = '" . $System . "' AND ";
    $QryGetMoonGalaxyData .= "`planet` = '" . $Planet . "';";
    $MoonGalaxy = doquery($QryGetMoonGalaxyData, 'galaxy', true);
    if ($MoonGalaxy['id_luna'] == 0) {
        if ($MoonPlanet['id'] != 0) {
            $SizeMin = zround(pow(3 * $Chance + 10, 0.5) * 1000);
            $SizeMax = zround(pow(3 * $Chance + 20, 0.5) * 1000);
            $PlanetName = $MoonPlanet['name'];
            $maxtemp = $MoonPlanet['temp_max'] - rand(10, 45);
            $mintemp = $MoonPlanet['temp_min'] - rand(10, 45);
            $size = rand($SizeMin, $SizeMax);
            $QryInsertMoonInLunas = "INSERT INTO {{table}} SET ";
            $QryInsertMoonInLunas .= "`name` = '" . ($MoonName == '' ? $lang['sys_moon'] : $MoonName) . "', ";
            $QryInsertMoonInLunas .= "`galaxy` = '" . $Galaxy . "', ";
            $QryInsertMoonInLunas .= "`system` = '" . $System . "', ";
            $QryInsertMoonInLunas .= "`lunapos` = '" . $Planet . "', ";
            $QryInsertMoonInLunas .= "`id_owner` = '" . $Owner . "', ";
            $QryInsertMoonInLunas .= "`temp_max` = '" . $maxtemp . "', ";
            $QryInsertMoonInLunas .= "`temp_min` = '" . $mintemp . "', ";
            $QryInsertMoonInLunas .= "`diameter` = '" . $size . "', ";
            $QryInsertMoonInLunas .= "`id_luna` = '" . $MoonID . "';";
            doquery($QryInsertMoonInLunas, 'lunas');
            $QryGetMoonIdFromLunas = "SELECT * FROM {{table}} ";
            $QryGetMoonIdFromLunas .= "WHERE ";
            $QryGetMoonIdFromLunas .= "`galaxy` = '" . $Galaxy . "' AND ";
            $QryGetMoonIdFromLunas .= "`system` = '" . $System . "' AND ";
            $QryGetMoonIdFromLunas .= "`lunapos` = '" . $Planet . "';";
            $lunarow = doquery($QryGetMoonIdFromLunas, 'lunas', true);
            $QryUpdateMoonInGalaxy = "UPDATE {{table}} SET ";
            $QryUpdateMoonInGalaxy .= "`id_luna` = '" . $lunarow['id'] . "', ";
            $QryUpdateMoonInGalaxy .= "`luna` = '0' ";
            $QryUpdateMoonInGalaxy .= "WHERE ";
            $QryUpdateMoonInGalaxy .= "`galaxy` = '" . $Galaxy . "' AND ";
            $QryUpdateMoonInGalaxy .= "`system` = '" . $System . "' AND ";
            $QryUpdateMoonInGalaxy .= "`planet` = '" . $Planet . "';";
            doquery($QryUpdateMoonInGalaxy, 'galaxy');
            $QryInsertMoonInPlanet = "INSERT INTO {{table}} SET ";
            $QryInsertMoonInPlanet .= "`name` = '" . $lang['sys_moon'] . "', ";
            $QryInsertMoonInPlanet .= "`id_owner` = '" . $Owner . "', ";
            $QryInsertMoonInPlanet .= "`galaxy` = '" . $Galaxy . "', ";
            $QryInsertMoonInPlanet .= "`system` = '" . $System . "', ";
            $QryInsertMoonInPlanet .= "`planet` = '" . $Planet . "', ";
            $QryInsertMoonInPlanet .= "`last_update` = '" . time() . "', ";
            $QryInsertMoonInPlanet .= "`planet_type` = '3', ";
            $QryInsertMoonInPlanet .= "`image` = 'mond', ";
            $QryInsertMoonInPlanet .= "`diameter` = '" . $size . "', ";
            $QryInsertMoonInPlanet .= "`field_max` = '1', ";
            $QryInsertMoonInPlanet .= "`temp_min` = '" . $maxtemp . "', ";
            $QryInsertMoonInPlanet .= "`temp_max` = '" . $mintemp . "', ";
            $QryInsertMoonInPlanet .= "`metal` = '0', ";
            $QryInsertMoonInPlanet .= "`metal_perhour` = '0', ";
            $QryInsertMoonInPlanet .= "`metal_max` = '" . BASE_STORAGE_SIZE . "', ";
            $QryInsertMoonInPlanet .= "`crystal` = '0', ";
            $QryInsertMoonInPlanet .= "`crystal_perhour` = '0', ";
            $QryInsertMoonInPlanet .= "`crystal_max` = '" . BASE_STORAGE_SIZE . "', ";
            $QryInsertMoonInPlanet .= "`deuterium` = '0', ";
            $QryInsertMoonInPlanet .= "`deuterium_perhour` = '0', ";
            $QryInsertMoonInPlanet .= "`deuterium_max` = '" . BASE_STORAGE_SIZE . "';";
            doquery($QryInsertMoonInPlanet, 'planets');
        }
    }
    return $PlanetName;
}
Example #2
0
function BuildRessourcePage($CurrentUser, $CurrentPlanet)
{
    global $pricelist, $lang, $ProdGrid, $resource, $reslist, $game_config, $_POST;
    includeLang('resources');
    if ($user['urlaubs_modus'] == 1) {
        message($lang['Vacation_mode'], $lang['Error'], "overview.php", 1);
    }
    $RessBodyTPL = gettemplate('resources');
    $RessRowTPL = gettemplate('resources_row');
    // Si c'est une lune ... pas de ressources produites
    if ($CurrentPlanet['planet_type'] == 3) {
        $game_config['metal_basic_income'] = 0;
        $game_config['crystal_basic_income'] = 0;
        $game_config['deuterium_basic_income'] = 0;
    }
    $ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
    $SubQry = "";
    if ($_POST) {
        foreach ($_POST as $Field => $Value) {
            $FieldName = $Field . "_porcent";
            if (isset($CurrentPlanet[$FieldName])) {
                if (!in_array($Value, $ValidList['percent'])) {
                    header("Location: overview.php");
                    exit;
                }
                $Value = $Value / 10;
                $CurrentPlanet[$FieldName] = $Value;
                $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'";
            }
        }
    }
    $parse = $lang;
    $parse['production_level'] = 100;
    if ($CurrentPlanet['energy_max'] == 0 && abs($CurrentPlanet['energy_used']) <= 0) {
        $post_porcent = 0;
    } elseif ($CurrentPlanet['energy_max'] == 0) {
        $post_porcent = 0;
    } elseif ($CurrentPlanet['energy_max'] > 0 && $CurrentPlanet['energy_used'] + $CurrentPlanet['energy_max'] < 0) {
        $post_porcent = $CurrentPlanet['energy_max'] / abs($CurrentPlanet['energy_used']) * 100;
    } else {
        $post_porcent = 100;
    }
    if ($post_porcent > 100) {
        $post_porcent = 100;
    }
    // -------------------------------------------------------------------------------------------------------
    // Mise a jour de l'espace de stockage
    $CurrentPlanet['metal_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[22]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    $CurrentPlanet['crystal_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[23]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    $CurrentPlanet['deuterium_max'] = floor(BASE_STORAGE_SIZE * pow(1.5, $CurrentPlanet[$resource[24]])) * (1 + $CurrentUser['rpg_stockeur'] * 0.5);
    // -------------------------------------------------------------------------------------------------------
    $parse['resource_row'] = "";
    $CurrentPlanet['metal_perhour'] = 0;
    $CurrentPlanet['crystal_perhour'] = 0;
    $CurrentPlanet['deuterium_perhour'] = 0;
    $CurrentPlanet['energy_max'] = 0;
    $CurrentPlanet['energy_used'] = 0;
    $CurrentPlanet['deuterium_used'] = 0;
    $energy_tech_bonus = 0;
    $energy_offi = 0;
    $metal_offi = 0;
    $crystal_offi = 0;
    $deuterium_offi = 0;
    $BuildTemp = $CurrentPlanet['temp_max'];
    foreach ($reslist['prod'] as $ProdID) {
        if ($CurrentPlanet[$resource[$ProdID]] > 0 && isset($ProdGrid[$ProdID])) {
            $BuildLevelFactor = $CurrentPlanet[$resource[$ProdID] . "_porcent"];
            $BuildLevel = $CurrentPlanet[$resource[$ProdID]];
            $metal = eval($ProdGrid[$ProdID]['formule']['metal']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05);
            $metal_offi += eval($ProdGrid[$ProdID]['formule']['metal']) * $game_config['resource_multiplier'] * ($CurrentUser['rpg_geologue'] * 0.05);
            $crystal = eval($ProdGrid[$ProdID]['formule']['crystal']) * $game_config['resource_multiplier'] * (1 + $CurrentUser['rpg_geologue'] * 0.05);
            $crystal_offi += eval($ProdGrid[$ProdID]['formule']['crystal']) * $game_config['resource_multiplier'] * ($CurrentUser['rpg_geologue'] * 0.05);
            $deuterium = eval($ProdGrid[$ProdID]['formule']['deuterium']) * $game_config['resource_multiplier'];
            $energy = eval($ProdGrid[$ProdID]['formule']['energy']);
            if ($energy > 0) {
                $energy_offi += $energy * ($CurrentUser['rpg_ingenieur'] * 0.05);
                $energy_tech_bonus += $energy * ($CurrentUser['energy_tech'] * 0.01);
                $energy *= 1 + ($CurrentUser['rpg_ingenieur'] * 0.05 + $CurrentUser['energy_tech'] * 0.01);
                $CurrentPlanet['energy_max'] += $energy;
            } else {
                $CurrentPlanet['energy_used'] += $energy;
            }
            $CurrentPlanet['metal_perhour'] += $metal;
            $CurrentPlanet['crystal_perhour'] += $crystal;
            if ($deuterium < 0) {
                $CurrentPlanet['deuterium_used'] = $deuterium;
            } else {
                $deuterium_offi += $deuterium * ($CurrentUser['rpg_geologue'] * 0.05);
                $deuterium *= 1 + $CurrentUser['rpg_geologue'] * 0.05;
                $CurrentPlanet['deuterium_perhour'] += $deuterium;
                $deuterium *= 0.01 * $post_porcent;
            }
            $metal = $metal * 0.01 * $post_porcent;
            $crystal = $crystal * 0.01 * $post_porcent;
            $Field = $resource[$ProdID] . "_porcent";
            $CurrRow = array();
            $CurrRow['name'] = $resource[$ProdID];
            $CurrRow['porcent'] = $CurrentPlanet[$Field];
            for ($Option = 10; $Option >= 0; $Option--) {
                $OptValue = $Option * 10;
                if ($Option == $CurrRow['porcent']) {
                    $OptSelected = " selected=selected";
                } else {
                    $OptSelected = "";
                }
                $CurrRow['option'] .= "<option value=\"" . $OptValue . "\"" . $OptSelected . ">" . $OptValue . "%</option>";
            }
            $CurrRow['type'] = $lang['tech'][$ProdID];
            $CurrRow['level'] = $ProdID > 200 ? $lang['quantity'] : $lang['level'];
            $CurrRow['level_type'] = $CurrentPlanet[$resource[$ProdID]];
            $CurrRow['metal_type'] = colorNumber(pretty_number(floor($metal)));
            $CurrRow['crystal_type'] = colorNumber(pretty_number(floor($crystal)));
            $CurrRow['deuterium_type'] = colorNumber(pretty_number(zround($deuterium)));
            $CurrRow['energy_type'] = colorNumber(pretty_number(zround($energy)));
            $parse['resource_row'] .= parsetemplate($RessRowTPL, $CurrRow);
        }
    }
    $parse['Production_of_resources_in_the_planet'] = str_replace('%s', $CurrentPlanet['name'], $lang['Production_of_resources_in_the_planet']);
    if ($CurrentPlanet['energy_max'] == 0 && abs($CurrentPlanet['energy_used']) >= 0) {
        $parse['production_level'] = 0;
    } elseif ($CurrentPlanet['energy_max'] > 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
        $parse['production_level'] = $CurrentPlanet['energy_max'] / abs($CurrentPlanet['energy_used']) * 100;
    } elseif ($CurrentPlanet['energy_max'] == 0 && abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) {
        $parse['production_level'] = 0;
    } else {
        $parse['production_level'] = 100;
    }
    if ($parse['production_level'] > 100) {
        $parse['production_level'] = 100;
    }
    $parse['metal_basic_income'] = $game_config['metal_basic_income'] * $game_config['resource_multiplier'];
    $parse['crystal_basic_income'] = $game_config['crystal_basic_income'] * $game_config['resource_multiplier'];
    $parse['deuterium_basic_income'] = $game_config['deuterium_basic_income'] * $game_config['resource_multiplier'];
    $parse['energy_basic_income'] = $game_config['energy_basic_income'] * $game_config['resource_multiplier'];
    if ($CurrentUser['energy_tech'] > 0) {
        $parse['energy_tech_bonus'] = '(+<font color="yellow">' . pretty_number(zround($energy_tech_bonus)) . '</font>)';
    } else {
        $parse['energy_tech_bonus'] = '<font color="yellow">-</font>';
    }
    if ($CurrentUser['rpg_geologue'] > 0) {
        $parse['metal_offi_bonus'] = '(+<font color="yellow">' . pretty_number(zround($metal_offi)) . '</font>)';
        $parse['crystal_offi_bonus'] = '(+<font color="yellow">' . pretty_number(zround($crystal_offi)) . '</font>)';
        $parse['deuterium_offi_bonus'] = '(+<font color="yellow">' . pretty_number(zround($deuterium_offi)) . '</font>)';
    } else {
        $parse['metal_offi_bonus'] = '<font color="yellow">-</font>';
        $parse['crystal_offi_bonus'] = '<font color="yellow">-</font>';
        $parse['deuterium_offi_bonus'] = '<font color="yellow">-</font>';
    }
    if ($CurrentUser['rpg_ingenieur'] > 0) {
        $parse['energy_offi_bonus'] = '(+<font color="yellow">' . pretty_number(zround($energy_offi)) . '</font>)';
    } else {
        $parse['energy_offi_bonus'] = '<font color="yellow">-</font>';
    }
    if ($CurrentPlanet['metal_max'] < $CurrentPlanet['metal']) {
        $parse['metal_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['metal_max'] = "<font color=\"#00ff00\">";
    }
    $parse['metal_max'] .= pretty_number($CurrentPlanet['metal_max'] / 1000) . " " . $lang['k'] . "</font>";
    if ($CurrentPlanet['crystal_max'] < $CurrentPlanet['crystal']) {
        $parse['crystal_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['crystal_max'] = "<font color=\"#00ff00\">";
    }
    $parse['crystal_max'] .= pretty_number($CurrentPlanet['crystal_max'] / 1000) . " " . $lang['k'] . "</font>";
    if ($CurrentPlanet['deuterium_max'] < $CurrentPlanet['deuterium']) {
        $parse['deuterium_max'] = "<font color=\"#ff0000\">";
    } else {
        $parse['deuterium_max'] = "<font color=\"#00ff00\">";
    }
    $parse['deuterium_max'] .= pretty_number($CurrentPlanet['deuterium_max'] / 1000) . " " . $lang['k'] . "</font>";
    $parse['metal_total'] = colorNumber(pretty_number(floor($CurrentPlanet['metal_perhour'] * 0.01 * $parse['production_level'] + $parse['metal_basic_income'])));
    $parse['crystal_total'] = colorNumber(pretty_number(floor($CurrentPlanet['crystal_perhour'] * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'])));
    $parse['deuterium_total'] = colorNumber(pretty_number(zround($CurrentPlanet['deuterium_perhour'] * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] + $CurrentPlanet['deuterium_used'])));
    $parse['energy_total'] = colorNumber(pretty_number(zround($CurrentPlanet['energy_max'] + $parse['energy_basic_income'] + $CurrentPlanet['energy_used'])));
    $value['daily_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24);
    $value['weekly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 7);
    $value['monthly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 30);
    $value['daily_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24);
    $value['weekly_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 7);
    $value['monthly_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 30);
    $value['daily_deuterium'] = zround($CurrentPlanet['deuterium_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 + $CurrentPlanet['deuterium_used'] * 24);
    $value['weekly_deuterium'] = zround($CurrentPlanet['deuterium_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 7 + $CurrentPlanet['deuterium_used'] * 24 * 7);
    $value['monthly_deuterium'] = zround($CurrentPlanet['deuterium_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 30 + $CurrentPlanet['deuterium_used'] * 24 * 30);
    $parse['daily_metal'] = colorNumber(pretty_number($value['daily_metal']));
    $parse['weekly_metal'] = colorNumber(pretty_number($value['weekly_metal']));
    $parse['monthly_metal'] = colorNumber(pretty_number($value['monthly_metal']));
    $parse['daily_crystal'] = colorNumber(pretty_number($value['daily_crystal']));
    $parse['weekly_crystal'] = colorNumber(pretty_number($value['weekly_crystal']));
    $parse['monthly_crystal'] = colorNumber(pretty_number($value['monthly_crystal']));
    $parse['daily_deuterium'] = colorNumber(pretty_number($value['daily_deuterium']));
    $parse['weekly_deuterium'] = colorNumber(pretty_number($value['weekly_deuterium']));
    $parse['monthly_deuterium'] = colorNumber(pretty_number($value['monthly_deuterium']));
    $parse['metal_storage'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100) . $lang['o/o'];
    $parse['crystal_storage'] = floor($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100) . $lang['o/o'];
    $parse['deuterium_storage'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100) . $lang['o/o'];
    $parse['metal_storage_bar'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100 * 2.5);
    $parse['crystal_storage_bar'] = floor($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100 * 2.5);
    $parse['deuterium_storage_bar'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100 * 2.5);
    if ($parse['metal_storage_bar'] > 100 * 2.5) {
        $parse['metal_storage_bar'] = 250;
        $parse['metal_storage_barcolor'] = '#C00000';
    } elseif ($parse['metal_storage_bar'] > 80 * 2.5) {
        $parse['metal_storage_barcolor'] = '#C0C000';
    } else {
        $parse['metal_storage_barcolor'] = '#00C000';
    }
    if ($parse['crystal_storage_bar'] > 100 * 2.5) {
        $parse['crystal_storage_bar'] = 250;
        $parse['crystal_storage_barcolor'] = '#C00000';
    } elseif ($parse['crystal_storage_bar'] > 80 * 2.5) {
        $parse['crystal_storage_barcolor'] = '#C0C000';
    } else {
        $parse['crystal_storage_barcolor'] = '#00C000';
    }
    if ($parse['deuterium_storage_bar'] > 100 * 2.5) {
        $parse['deuterium_storage_bar'] = 250;
        $parse['deuterium_storage_barcolor'] = '#C00000';
    } elseif ($parse['deuterium_storage_bar'] > 80 * 2.5) {
        $parse['deuterium_storage_barcolor'] = '#C0C000';
    } else {
        $parse['deuterium_storage_barcolor'] = '#00C000';
    }
    $parse['production_level_bar'] = $parse['production_level'] * 2.5;
    $parse['production_level'] = "{$parse['production_level']}%";
    $parse['production_level_barcolor'] = '#00ff00';
    $QryUpdatePlanet = "UPDATE {{table}} SET ";
    $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "' ";
    $QryUpdatePlanet .= $SubQry;
    $QryUpdatePlanet .= "WHERE ";
    $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';";
    doquery($QryUpdatePlanet, 'planets');
    // Ship and deffend produktion calculate script
    // new writen and fixed by Mori for Xnova 2009 (Team Rocket)
    ////////////////Fleets////////////////
    $c = 202;
    //value from first ship from table
    $m = 218;
    //end and last ship
    while ($c <= $m) {
        $Spm = $pricelist[$c]['metal'];
        // Met. price from ship $c
        $Spc = $pricelist[$c]['crystal'];
        // crys. price from ship $c
        $Spd = $pricelist[$c]['deuterium'];
        // Deut. price from ship $c
        $Xdprom = @floor($value['daily_metal'] / $Spm);
        $Xdproc = @floor($value['daily_crystal'] / $Spc);
        $Xdprod = @floor($value['daily_deuterium'] / $Spd);
        $Xwprom = @floor($value['weekly_metal'] / $Spm);
        $Xwproc = @floor($value['weekly_crystal'] / $Spc);
        $Xwprod = @floor($value['weekly_deuterium'] / $Spd);
        $Xmprom = @floor($value['monthly_metal'] / $Spm);
        $Xmproc = @floor($value['monthly_crystal'] / $Spc);
        $Xmprod = @floor($value['monthly_deuterium'] / $Spd);
        if ($Spm > 0 and $Spc == 0 and $Spd == 0) {
            $xsd = $Xdprom;
            $xsw = $Xwprom;
            $xsm = $Xmprom;
        } elseif ($Spm == 0 and $Spc > 0 and $Spd == 0) {
            $xsd = $Xdproc;
            $xsw = $Xwproc;
            $xsm = $Xmproc;
        } elseif ($Spm > 0 and $Spc > 0 and $Spd == 0) {
            $xmind = min($Xdprom, $Xdproc);
            $xminw = min($Xwprom, $Xwproc);
            $xminm = min($Xmprom, $Xmproc);
            $xsd = $xmind;
            $xsw = $xminw;
            $xsm = $xminm;
        } elseif ($Spm > 0 and $Spc > 0 and $Spd > 0) {
            $xmind = min($Xdprom, $Xdproc, $Xdprod);
            $xminw = min($Xwprom, $Xwproc, $Xwprod);
            $xminm = min($Xmprom, $Xmproc, $Xmprod);
            $xsd = $xmind;
            $xsw = $xminw;
            $xsm = $xminm;
        } elseif ($Spm == 0 and $Spc > 0 and $Spd > 0) {
            $xmind = min($Xdproc, $Xdprod);
            $xminw = min($Xwproc, $Xwprod);
            $xminm = min($Xmproc, $Xmprod);
            $xsd = $xmind;
            $xsw = $xminw;
            $xsm = $xminm;
        } else {
            $xsd = '<font color=red>0</font>';
            $xsw = '<font color=red>0</font>';
            $xsm = '<font color=red>0</font>';
        }
        if ($xsd < 0 or $xsw < 0 or $xsm < 0) {
            $xsd = 0;
            $xsw = 0;
            $xsm = 0;
        }
        $parse['predu_fleet'] .= "<tr>";
        $parse['predu_fleet'] .= "<th>" . $lang['tech'][$c] . "</th>";
        $parse['predu_fleet'] .= "<th>" . $xsd . "</th>";
        $parse['predu_fleet'] .= "<th>" . $xsw . "</th>";
        $parse['predu_fleet'] .= "<th>" . $xsm . "</th>";
        $parse['predu_fleet'] .= "</tr>";
        $c++;
    }
    ////////////////Deffends////////////////
    $c = 401;
    //targed from first deffend fro table
    $m = 503;
    //end and last deffend
    while ($c <= $m) {
        $Spm = $pricelist[$c]['metal'];
        // Met. price from deffend $c
        $Spc = $pricelist[$c]['crystal'];
        // crys. price from deffend $c
        $Spd = $pricelist[$c]['deuterium'];
        // Deut. price from deffend $c
        $Xdprom = @floor($value['daily_metal'] / $Spm);
        $Xdproc = @floor($value['daily_crystal'] / $Spc);
        $Xdprod = @floor($value['daily_deuterium'] / $Spd);
        $Xwprom = @floor($value['weekly_metal'] / $Spm);
        $Xwproc = @floor($value['weekly_crystal'] / $Spc);
        $Xwprod = @floor($value['weekly_deuterium'] / $Spd);
        $Xmprom = @floor($value['monthly_metal'] / $Spm);
        $Xmproc = @floor($value['monthly_crystal'] / $Spc);
        $Xmprod = @floor($value['monthly_deuterium'] / $Spd);
        if ($Spm > 0 and $Spc == 0 and $Spd == 0) {
            $xsd = $Xdprom;
            $xsw = $Xwprom;
            $xsm = $Xmprom;
        } elseif ($Spm == 0 and $Spc > 0 && $Spd == 0) {
            $xsd = $Xdproc;
            $xsw = $Xwproc;
            $xsm = $Xmproc;
        } elseif ($Spm > 0 and $Spc > 0 and $Spd == 0) {
            $xmind = min($Xdprom, $Xdproc);
            $xminw = min($Xwprom, $Xwproc);
            $xminm = min($Xmprom, $Xmproc);
            $xsd = $xmind;
            $xsw = $xminw;
            $xsm = $xminm;
        } elseif ($Spm > 0 and $Spc > 0 and $Spd > 0) {
            $xmind = min($Xdprom, $Xdproc, $Xdprod);
            $xminw = min($Xwprom, $Xwproc, $Xwprod);
            $xminm = min($Xmprom, $Xmproc, $Xmprod);
            $xsd = $xmind;
            $xsw = $xminw;
            $xsm = $xminm;
        } elseif ($Spm == 0 and $Spc > 0 and $Spd > 0) {
            $xmind = min($Xdproc, $Xdprod);
            $xminw = min($Xwproc, $Xwprod);
            $xminm = min($Xmproc, $Xmprod);
            $xsd = $xmind;
            $xsw = $xminw;
            $xsm = $xminm;
        } else {
            $xsd = '<font color=red>0</font>';
            $xsw = '<font color=red>0</font>';
            $xsm = '<font color=red>0</font>';
        }
        if ($xsd < 0 or $xsw < 0 or $xsm < 0) {
            $xsd = 0;
            $xsw = 0;
            $xsm = 0;
        }
        $parse['predu_def'] .= "<tr>";
        $parse['predu_def'] .= "<th>" . $lang['tech'][$c] . "</th>";
        $parse['predu_def'] .= "<th>" . $xsd . "</th>";
        $parse['predu_def'] .= "<th>" . $xsw . "</th>";
        $parse['predu_def'] .= "<th>" . $xsm . "</th>";
        $parse['predu_def'] .= "</tr>";
        if ($c == 408) {
            $c = 502;
        } else {
            $c++;
        }
    }
    $page = parsetemplate($RessBodyTPL, $parse);
    return $page;
}
Example #3
0
function MissionCaseAttack($FleetRow)
{
    global $user, $phpEx, $rocketnova_root_path, $pricelist, $lang, $resource, $CombatCaps;
    if ($FleetRow['fleet_start_time'] <= time()) {
        if ($FleetRow['fleet_mess'] == 0) {
            if (!isset($CombatCaps[202]['sd'])) {
                message("<font color=\"red\">" . $lang['sys_no_vars'] . "</font>", $lang['sys_error'], "fleet." . $phpEx, 2);
            }
            $QryTargetPlanet = "SELECT * FROM {{table}} ";
            $QryTargetPlanet .= "WHERE ";
            $QryTargetPlanet .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND ";
            $QryTargetPlanet .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND ";
            $QryTargetPlanet .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' AND ";
            $QryTargetPlanet .= "`planet_type` = '" . $FleetRow['fleet_end_type'] . "';";
            $TargetPlanet = doquery($QryTargetPlanet, 'planets', true);
            $TargetUserID = $TargetPlanet['id_owner'];
            $QryTargetUser = "******";
            $QryTargetUser .= "WHERE ";
            $QryTargetUser .= "`id` = '" . $TargetUserID . "';";
            $TargetUser = doquery($QryTargetUser, 'users', true);
            // Planeten aktualisieren und erneut auslesen
            // =============================================================================
            $update = PlanetResourceUpdate($TargetUser, $TargetPlanet, time());
            $TargetPlanet = doquery($QryTargetPlanet, 'planets', true);
            $TargetUser = doquery($QryTargetUser, 'users', true);
            // =============================================================================
            $QryCurrentUser = "******";
            $QryCurrentUser .= "WHERE ";
            $QryCurrentUser .= "`id` = '" . $FleetRow['fleet_owner'] . "';";
            $CurrentUser = doquery($QryCurrentUser, 'users', true);
            $CurrentUserID = $CurrentUser['id'];
            $QryTargetTech = "SELECT ";
            $QryTargetTech .= "`military_tech`, `defence_tech`, `shield_tech` ";
            $QryTargetTech .= "FROM {{table}} ";
            $QryTargetTech .= "WHERE ";
            $QryTargetTech .= "`id` = '" . $TargetUserID . "';";
            $TargetTechno = doquery($QryTargetTech, 'users', true);
            $QryCurrentTech = "SELECT ";
            $QryCurrentTech .= "`military_tech`, `defence_tech`, `shield_tech` ";
            $QryCurrentTech .= "FROM {{table}} ";
            $QryCurrentTech .= "WHERE ";
            $QryCurrentTech .= "`id` = '" . $CurrentUserID . "';";
            $CurrentTechno = doquery($QryCurrentTech, 'users', true);
            for ($SetItem = 200; $SetItem < 500; $SetItem++) {
                if ($TargetPlanet[$resource[$SetItem]] > 0) {
                    $TargetSet[$SetItem]['count'] = $TargetPlanet[$resource[$SetItem]];
                }
            }
            $TheFleet = explode(";", $FleetRow['fleet_array']);
            foreach ($TheFleet as $a => $b) {
                if ($b != '') {
                    $a = explode(",", $b);
                    $CurrentSet[$a[0]]['count'] = $a[1];
                }
            }
            include_once $rocketnova_root_path . 'includes/ataki.' . $phpEx;
            // Calcul de la duree de traitement (initialisation)
            $mtime = microtime();
            $mtime = explode(" ", $mtime);
            $mtime = $mtime[1] + $mtime[0];
            $starttime = $mtime;
            $walka = walka($CurrentSet, $TargetSet, $CurrentTechno, $TargetTechno);
            // Calcul de la duree de traitement (calcul)
            $mtime = microtime();
            $mtime = explode(" ", $mtime);
            $mtime = $mtime[1] + $mtime[0];
            $endtime = $mtime;
            $totaltime = $endtime - $starttime;
            // Ce qu'il reste de l'attaquant
            $CurrentSet = $walka["atakujacy"];
            // Ce qu'il reste de l'attaqué
            $TargetSet = $walka["wrog"];
            // Le resultat de la bataille
            $FleetResult = $walka["wygrana"];
            // Rapport long (rapport de bataille detaillé)
            $dane_do_rw = $walka["dane_do_rw"];
            // Rapport court (cdr + unitées perdues)
            $zlom = $walka["zlom"];
            $FleetArray = "";
            $FleetAmount = 0;
            $FleetStorage = 0;
            foreach ($CurrentSet as $Ship => $Count) {
                $FleetStorage += $pricelist[$Ship]["capacity"] * $Count['count'];
                $FleetArray .= $Ship . "," . $Count['count'] . ";";
                $FleetAmount += $Count['count'];
            }
            // Au cas ou le p'tit rigolo qu'a envoyé la flotte y avait mis des ressources ...
            // Rechnet die einzelnen resourcen vom Laderaum ab was die Flotte beim Start mitgenommen hat
            $FleetStorage -= $FleetRow["fleet_resource_metal"];
            $FleetStorage -= $FleetRow["fleet_resource_crystal"];
            $FleetStorage -= $FleetRow["fleet_resource_deuterium"];
            $TargetPlanetUpd = "";
            if (!is_null($TargetSet)) {
                foreach ($TargetSet as $Ship => $Count) {
                    $TargetPlanetUpd .= "`" . $resource[$Ship] . "` = '" . $Count['count'] . "', ";
                }
            }
            // Beute_math v0.3 edit by Mori for Xnova anfang
            $Mining['metal'] = 0;
            $Mining['crystal'] = 0;
            $Mining['deuter'] = 0;
            if ($FleetResult == "a") {
                if ($FleetStorage > 0) {
                    $metal = floor($TargetPlanet['metal'] / 2);
                    $crystal = floor($TargetPlanet['crystal'] / 2);
                    $deuter = floor($TargetPlanet["deuterium"] / 2);
                    if ($FleetStorage >= $metal + $crystal + $deuter) {
                        $Mining['metal'] = $metal;
                        $Mining['crystal'] = $crystal;
                        $Mining['deuter'] = $deuter;
                    } elseif ($FleetStorage / 3 >= $metal) {
                        $Mining['metal'] = $metal;
                        $FleetStorage -= $metal;
                        if ($FleetStorage / 2 >= $crystal) {
                            $Mining['crystal'] = $crystal;
                            $Mining['deuter'] = $FleetStorage - $crystal;
                        } elseif ($FleetStorage / 2 >= $deuter) {
                            $Mining['deuter'] = $deuter;
                            $Mining['crystal'] = $FleetStorage - $deuter;
                        } else {
                            $Mining['crystal'] = $FleetStorage / 2;
                            $FleetStorage -= round($FleetStorage / 2);
                            $Mining['deuter'] = $FleetStorage;
                        }
                    } elseif ($FleetStorage / 3 >= $crystal) {
                        $Mining['crystal'] = $crystal;
                        $FleetStorage -= $crystal;
                        if ($FleetStorage / 2 >= $metal) {
                            $Mining['metal'] = $metal;
                            $Mining['deuter'] = $FleetStorage - $metal;
                        } elseif ($FleetStorage / 2 >= $deuter) {
                            $Mining['deuter'] = $deuter;
                            $Mining['metal'] = $FleetStorage - $deuter;
                        } else {
                            $Mining['metal'] = $FleetStorage / 2;
                            $FleetStorage -= round($FleetStorage / 2);
                            $Mining['deuter'] = $FleetStorage;
                        }
                    } elseif ($FleetStorage / 3 >= $deuter) {
                        $Mining['deuter'] = $deuter;
                        $FleetStorage -= $deuter;
                        if ($FleetStorage / 2 >= $metal) {
                            $Mining['metal'] = $metal;
                            $Mining['crystal'] = $FleetStorage - $metal;
                        } elseif ($FleetStorage / 2 >= $crystal) {
                            $Mining['crystal'] = $crystal;
                            $Mining['metal'] = $FleetStorage - $crystal;
                        } else {
                            $Mining['metal'] = $FleetStorage / 2;
                            $FleetStorage -= round($FleetStorage / 2);
                            $Mining['crystal'] = $FleetStorage;
                        }
                    } else {
                        $Mining['crystal'] = $FleetStorage / 3;
                        $FleetStorage -= round($FleetStorage / 3);
                        $Mining['metal'] = $FleetStorage / 2;
                        $FleetStorage -= round($FleetStorage / 2);
                        $Mining['deuter'] = $FleetStorage;
                    }
                }
            }
            $Mining['metal'] = round($Mining['metal']);
            $Mining['crystal'] = round($Mining['crystal']);
            $Mining['deuter'] = round($Mining['deuter']);
            // Beute_math ende
            // Mise a jour de l'enregistrement de la planete attaquée
            $QryUpdateTarget = "UPDATE {{table}} SET ";
            $QryUpdateTarget .= $TargetPlanetUpd;
            $QryUpdateTarget .= "`metal` = `metal` - '" . $Mining['metal'] . "', ";
            $QryUpdateTarget .= "`crystal` = `crystal` - '" . $Mining['crystal'] . "', ";
            $QryUpdateTarget .= "`deuterium` = `deuterium` - '" . $Mining['deuter'] . "' ";
            $QryUpdateTarget .= "WHERE ";
            $QryUpdateTarget .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND ";
            $QryUpdateTarget .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND ";
            $QryUpdateTarget .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' AND ";
            $QryUpdateTarget .= "`planet_type` = '" . $FleetRow['fleet_end_type'] . "' ";
            $QryUpdateTarget .= "LIMIT 1;";
            doquery($QryUpdateTarget, 'planets');
            // Mise a jour du champ de ruine devant la planete attaquée
            $QryUpdateGalaxy = "UPDATE {{table}} SET ";
            $QryUpdateGalaxy .= "`metal` = `metal` + '" . $zlom['metal'] . "', ";
            $QryUpdateGalaxy .= "`crystal` = `crystal` + '" . $zlom['crystal'] . "' ";
            $QryUpdateGalaxy .= "WHERE ";
            $QryUpdateGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND ";
            $QryUpdateGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND ";
            $QryUpdateGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' ";
            $QryUpdateGalaxy .= "LIMIT 1;";
            doquery($QryUpdateGalaxy, 'galaxy');
            // Là on va discuter le bout de gras pour voir s'il y a moyen d'avoir une Lune !
            $FleetDebris = $zlom['metal'] + $zlom['crystal'];
            $StrAttackerUnits = sprintf($lang['sys_attacker_lostunits'], $zlom["atakujacy"]);
            $StrDefenderUnits = sprintf($lang['sys_defender_lostunits'], $zlom["wrog"]);
            $StrRuins = sprintf($lang['sys_gcdrunits'], $zlom["metal"], $lang['Metal'], $zlom['crystal'], $lang['Crystal']);
            // mod TOP KB
            $strunitsgesamt = $zlom["atakujacy"] + $zlom["wrog"];
            $user1lostunits = $zlom["atakujacy"];
            $user1shotunits = $zlom["wrog"];
            $user2lostunits = $zlom["wrog"];
            $user2shotunits = $zlom["atakujacy"];
            $strtruemmerfeld = $zlom["metal"] + $zlom["crystal"];
            $strtruemmermetal = $zlom["metal"];
            $strtruemmercrystal = $zlom["crystal"];
            // mod TOP KB
            $DebrisField = $StrAttackerUnits . "<br />" . $StrDefenderUnits . "<br />" . $StrRuins;
            $MoonChance = zround($FleetDebris / 100000);
            if ($MoonChance > 20) {
                $MoonChance = 20;
            }
            if ($MoonChance < 1) {
                $UserChance = 0;
                $ChanceMoon = "";
            } elseif ($MoonChance >= 1) {
                $UserChance = mt_rand(1, 100);
                $ChanceMoon = sprintf($lang['sys_moonproba'], $MoonChance);
            }
            if ($UserChance > 0 and $UserChance <= $MoonChance and $galenemyrow['id_luna'] == 0) {
                $TargetPlanetName = CreateOneMoonRecord($FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet'], $TargetUserID, $FleetRow['fleet_start_time'], '', $MoonChance);
                $GottenMoon = sprintf($lang['sys_moonbuilt'], $TargetPlanetName, $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']);
            } elseif ($UserChance = 0 or $UserChance > $MoonChance) {
                $GottenMoon = "";
            }
            $AttackDate = date("r", $FleetRow["fleet_start_time"]);
            $title = sprintf($lang['sys_attack_title'], $AttackDate);
            $raport = "<center><table><tr><td>" . $title . "<br />";
            $zniszczony = false;
            $a_zestrzelona = 0;
            $AttackTechon['A'] = $CurrentTechno["military_tech"] * 10;
            $AttackTechon['B'] = $CurrentTechno["defence_tech"] * 10;
            $AttackTechon['C'] = $CurrentTechno["shield_tech"] * 10;
            $AttackerData = sprintf($lang['sys_attack_attacker_pos'], $CurrentUser["username"], $FleetRow['fleet_start_galaxy'], $FleetRow['fleet_start_system'], $FleetRow['fleet_start_planet']);
            $AttackerTech = sprintf($lang['sys_attack_techologies'], $AttackTechon['A'], $AttackTechon['B'], $AttackTechon['C']);
            $DefendTechon['A'] = $TargetTechno["military_tech"] * 10;
            $DefendTechon['B'] = $TargetTechno["defence_tech"] * 10;
            $DefendTechon['C'] = $TargetTechno["shield_tech"] * 10;
            $DefenderData = sprintf($lang['sys_attack_defender_pos'], $TargetUser["username"], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']);
            $DefenderTech = sprintf($lang['sys_attack_techologies'], $DefendTechon['A'], $DefendTechon['B'], $DefendTechon['C']);
            // mod TOP KB
            $angreifer = $CurrentUser["username"];
            $defender = $TargetUser["username"];
            // mod TOP KB
            foreach ($dane_do_rw as $a => $b) {
                $raport .= "<table border=1 width=100%><tr><th><br /><center>" . $AttackerData . "<br />" . $AttackerTech . "<table border=1>";
                if ($b["atakujacy"]['count'] > 0) {
                    $raport1 = "<tr><th>" . $lang['sys_ship_type'] . "</th>";
                    $raport2 = "<tr><th>" . $lang['sys_ship_count'] . "</th>";
                    $raport3 = "<tr><th>" . $lang['sys_ship_weapon'] . "</th>";
                    $raport4 = "<tr><th>" . $lang['sys_ship_shield'] . "</th>";
                    $raport5 = "<tr><th>" . $lang['sys_ship_armour'] . "</th>";
                    foreach ($b["atakujacy"] as $Ship => $Data) {
                        if (is_numeric($Ship)) {
                            if ($Data['count'] > 0) {
                                $raport1 .= "<th>" . $lang["tech_rc"][$Ship] . "</th>";
                                $raport2 .= "<th>" . $Data['count'] . "</th>";
                                $raport3 .= "<th>" . round($Data["atak"] / $Data['count']) . "</th>";
                                $raport4 .= "<th>" . round($Data["tarcza"] / $Data['count']) . "</th>";
                                $raport5 .= "<th>" . round($Data["obrona"] / $Data['count']) . "</th>";
                            }
                        }
                    }
                    $raport1 .= "</tr>";
                    $raport2 .= "</tr>";
                    $raport3 .= "</tr>";
                    $raport4 .= "</tr>";
                    $raport5 .= "</tr>";
                    $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5;
                } else {
                    if ($a == 2) {
                        $a_zestrzelona = 1;
                    }
                    $zniszczony = true;
                    $raport .= "<br />" . $lang['sys_destroyed'];
                }
                $raport .= "</table></center></th></tr></table>";
                $raport .= "<table border=1 width=100%><tr><th><br /><center>" . $DefenderData . "<br />" . $DefenderTech . "<table border=1>";
                if ($b["wrog"]['count'] > 0) {
                    $raport1 = "<tr><th>" . $lang['sys_ship_type'] . "</th>";
                    $raport2 = "<tr><th>" . $lang['sys_ship_count'] . "</th>";
                    $raport3 = "<tr><th>" . $lang['sys_ship_weapon'] . "</th>";
                    $raport4 = "<tr><th>" . $lang['sys_ship_shield'] . "</th>";
                    $raport5 = "<tr><th>" . $lang['sys_ship_armour'] . "</th>";
                    foreach ($b["wrog"] as $Ship => $Data) {
                        if (is_numeric($Ship)) {
                            if ($Data['count'] > 0) {
                                $raport1 .= "<th>" . $lang["tech_rc"][$Ship] . "</th>";
                                $raport2 .= "<th>" . $Data['count'] . "</th>";
                                $raport3 .= "<th>" . round($Data["atak"] / $Data['count']) . "</th>";
                                $raport4 .= "<th>" . round($Data["tarcza"] / $Data['count']) . "</th>";
                                $raport5 .= "<th>" . round($Data["obrona"] / $Data['count']) . "</th>";
                            }
                        }
                    }
                    $raport1 .= "</tr>";
                    $raport2 .= "</tr>";
                    $raport3 .= "</tr>";
                    $raport4 .= "</tr>";
                    $raport5 .= "</tr>";
                    $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5;
                } else {
                    $zniszczony = true;
                    $raport .= "<br />" . $lang['sys_destroyed'];
                }
                $raport .= "</table></center></th></tr></table>";
                if ($zniszczony == false and !($a == 8)) {
                    $AttackWaveStat = sprintf($lang['sys_attack_attack_wave'], floor($b["atakujacy"]["atak"]), floor($b["wrog"]["tarcza"]));
                    $DefendWavaStat = sprintf($lang['sys_attack_defend_wave'], floor($b["wrog"]["atak"]), floor($b["atakujacy"]["tarcza"]));
                    $raport .= "<br /><center>" . $AttackWaveStat . "<br />" . $DefendWavaStat . "</center>";
                }
            }
            switch ($FleetResult) {
                case "a":
                    $Pillage = sprintf($lang['sys_stealed_ressources'], $Mining['metal'], $lang['metal'], $Mining['crystal'], $lang['crystal'], $Mining['deuter'], $lang['Deuterium']);
                    $raport .= $lang['sys_attacker_won'] . "<br />" . $Pillage . "<br />";
                    $raport .= $DebrisField . "<br />";
                    $raport .= $ChanceMoon . "<br />";
                    $raport .= $GottenMoon . "<br />";
                    break;
                case "r":
                    $raport .= $lang['sys_both_won'] . "<br />";
                    $raport .= $DebrisField . "<br />";
                    $raport .= $ChanceMoon . "<br />";
                    $raport .= $GottenMoon . "<br />";
                    break;
                case "w":
                    $raport .= $lang['sys_defender_won'] . "<br />";
                    $raport .= $DebrisField . "<br />";
                    $raport .= $ChanceMoon . "<br />";
                    $raport .= $GottenMoon . "<br />";
                    doquery("DELETE FROM {{table}} WHERE `fleet_id` = '" . $FleetRow["fleet_id"] . "';", 'fleets');
                    break;
                default:
                    break;
            }
            $SimMessage = sprintf($lang['sys_rapport_build_time'], $totaltime);
            $raport .= $SimMessage . "</table>";
            $dpath = !$user["dpath"] ? DEFAULT_SKINPATH : $user["dpath"];
            $rid = md5($raport);
            $QryInsertRapport = "INSERT INTO {{table}} SET ";
            $QryInsertRapport .= "`time` = UNIX_TIMESTAMP(), ";
            $QryInsertRapport .= "`id_owner1` = '" . $FleetRow['fleet_owner'] . "', ";
            $QryInsertRapport .= "`id_owner2` = '" . $TargetUserID . "', ";
            $QryInsertRapport .= "`rid` = '" . $rid . "', ";
            $QryInsertRapport .= "`a_zestrzelona` = '" . $a_zestrzelona . "', ";
            $QryInsertRapport .= "`raport` = '" . addslashes($raport) . "';";
            doquery($QryInsertRapport, 'rw');
            // mod TOP KB
            $dpath = !$user["dpath"] ? DEFAULT_SKINPATH : $user["dpath"];
            $rid = md5($raport);
            $QryInserttopkb = "INSERT INTO {{table}} SET ";
            $QryInserttopkb .= "`time` = UNIX_TIMESTAMP(), ";
            $QryInserttopkb .= "`id_owner1` = '" . $FleetRow['fleet_owner'] . "', ";
            $QryInserttopkb .= "`angreifer` = '" . $angreifer . "', ";
            $QryInserttopkb .= "`id_owner2` = '" . $TargetUserID . "', ";
            $QryInserttopkb .= "`defender` = '" . $defender . "', ";
            $QryInserttopkb .= "`gesamtunits` = '" . $strunitsgesamt . "', ";
            $QryInserttopkb .= "`gesamttruemmer` = '" . $strtruemmerfeld . "', ";
            $QryInserttopkb .= "`rid` = '" . $rid . "', ";
            $QryInserttopkb .= "`a_zestrzelona` = '" . $a_zestrzelona . "', ";
            $QryInserttopkb .= "`raport` = '" . addslashes($raport) . "',";
            $QryInserttopkb .= "`fleetresult` = '" . $FleetResult . "';";
            doquery("LOCK TABLE {{table}} WRITE", 'topkb');
            doquery($QryInserttopkb, 'topkb');
            doquery("UNLOCK TABLES", '');
            $user1stat = $FleetRow['fleet_owner'];
            $user2stat = $TargetUserID;
            // mod TOP KB
            // Colorisation du résumé de rapport pour l'attaquant
            $raport = "<a href # OnClick=\"f( 'rw.php?raport=" . $rid . "', '');\" >";
            $raport .= "<center>";
            if ($FleetResult == "a") {
                $raport .= "<font color=\"green\">";
            } elseif ($FleetResult == "r") {
                $raport .= "<font color=\"orange\">";
            } elseif ($FleetResult == "w") {
                $raport .= "<font color=\"red\">";
            }
            $raport .= $lang['sys_mess_attack_report'] . " [" . $FleetRow['fleet_end_galaxy'] . ":" . $FleetRow['fleet_end_system'] . ":" . $FleetRow['fleet_end_planet'] . "] </font></a><br /><br />";
            $raport .= "<font color=\"red\">" . $lang['sys_perte_attaquant'] . ": " . $zlom["atakujacy"] . "</font>";
            $raport .= "<font color=\"green\">   " . $lang['sys_perte_defenseur'] . ":" . $zlom["wrog"] . "</font><br />";
            $raport .= $lang['sys_gain'] . " " . $lang['Metal'] . ":<font color=\"#adaead\">" . $Mining['metal'] . "</font>   " . $lang['Crystal'] . ":<font color=\"#ef51ef\">" . $Mining['crystal'] . "</font>   " . $lang['Deuterium'] . ":<font color=\"#f77542\">" . $Mining['deuter'] . "</font><br />";
            $raport .= $lang['sys_debris'] . " " . $lang['Metal'] . ":<font color=\"#adaead\">" . $zlom['metal'] . "</font>   " . $lang['Crystal'] . ":<font color=\"#ef51ef\">" . $zlom['crystal'] . "</font><br /></center>";
            $Mining['metal'] = $Mining['metal'] + $FleetRow["fleet_resource_metal"];
            $Mining['crystal'] = $Mining['crystal'] + $FleetRow["fleet_resource_crystal"];
            $Mining['deuter'] = $Mining['deuter'] + $FleetRow["fleet_resource_deuterium"];
            $QryUpdateFleet = "UPDATE {{table}} SET ";
            $QryUpdateFleet .= "`fleet_amount` = '" . $FleetAmount . "', ";
            $QryUpdateFleet .= "`fleet_array` = '" . $FleetArray . "', ";
            $QryUpdateFleet .= "`fleet_mess` = '1', ";
            $QryUpdateFleet .= "`fleet_resource_metal` = '" . $Mining['metal'] . "', ";
            $QryUpdateFleet .= "`fleet_resource_crystal` = '" . $Mining['crystal'] . "', ";
            $QryUpdateFleet .= "`fleet_resource_deuterium` = '" . $Mining['deuter'] . "' ";
            $QryUpdateFleet .= "WHERE fleet_id = '" . $FleetRow['fleet_id'] . "' ";
            $QryUpdateFleet .= "LIMIT 1 ;";
            doquery($QryUpdateFleet, 'fleets');
            SendSimpleMessage($CurrentUserID, '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport);
            // Ajout d'un point au compteur de raids
            $RaidsTotal = $CurrentUser['raids'] + 1;
            if ($FleetResult == "a") {
                $RaidsWin = $CurrentUser['raidswin'] + 1;
                $QryUpdateRaidsCompteur = "UPDATE {{table}} SET ";
                $QryUpdateRaidsCompteur .= "`raidswin` ='" . $RaidsWin . "', ";
                $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' ";
                $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' ";
                $QryUpdateRaidsCompteur .= "LIMIT 1 ;";
                doquery($QryUpdateRaidsCompteur, 'users');
            } elseif ($FleetResult == "r" || $FleetResult == "w") {
                $RaidsLoose = $CurrentUser['raidsloose'] + 1;
                $QryUpdateRaidsCompteur = "UPDATE {{table}} SET ";
                $QryUpdateRaidsCompteur .= "`raidsloose` ='" . $RaidsLoose . "', ";
                $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' ";
                $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' ";
                $QryUpdateRaidsCompteur .= "LIMIT 1 ;";
                doquery($QryUpdateRaidsCompteur, 'users');
            }
            // Colorisation du résumé de rapport pour l'attaquant
            $raport2 = "<a href # OnClick=\"f( 'rw.php?raport=" . $rid . "', '');\" >";
            $raport2 .= "<center>";
            if ($FleetResult == "w") {
                $raport2 .= "<font color=\"green\">";
            } elseif ($FleetResult == "r") {
                $raport2 .= "<font color=\"orange\">";
            } elseif ($FleetResult == "a") {
                $raport2 .= "<font color=\"red\">";
            }
            $raport2 .= $lang['sys_mess_attack_report'] . " [" . $FleetRow['fleet_end_galaxy'] . ":" . $FleetRow['fleet_end_system'] . ":" . $FleetRow['fleet_end_planet'] . "] </font></a><br /><br />";
            SendSimpleMessage($TargetUserID, '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport2);
        }
        // Updaten Spieler Datenbank
        $user1 = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $user1stat . "';", 'users');
        while ($user1data = mysql_fetch_assoc($user1)) {
            $strtruemmermetaluser1 = $strtruemmermetal + $user1data['kbmetal'];
            $strtruemmercrystaluser1 = $strtruemmercrystal + $user1data['kbcrystal'];
            $user1lostunits = $user1lostunits + $user1data['lostunits'];
            $user1shotunits = $user1shotunits + $user1data['desunits'];
            $user1wons = $user1data['wons'];
            $user1loos = $user1data['loos'];
            $user1draws = $user1data['draws'];
        }
        $user2 = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $user2stat . "';", 'users');
        while ($user2data = mysql_fetch_assoc($user2)) {
            $strtruemmermetaluser2 = $strtruemmermetal + $user2data['kbmetal'];
            $strtruemmercrystaluser2 = $strtruemmercrystal + $user2data['kbcrystal'];
            $user2lostunits = $user2lostunits + $user2data['lostunits'];
            $user2shotunits = $user2shotunits + $user2data['desunits'];
            $user2wons = $user2data['wons'];
            $user2loos = $user2data['loos'];
            $user2draws = $user2data['draws'];
        }
        if ($FleetResult == "a") {
            $user1wons++;
            $user2loos++;
        } elseif ($FleetResult == "r") {
            $user1draws++;
            $user2draws++;
        } elseif ($FleetResult == "w") {
            $user1loos++;
            $user2wons++;
        }
        //Update Angreifer Truemerfeld, Kampfergebniss und Units
        $userstat = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $user1stat . "';", 'users');
        while ($userwrite = mysql_fetch_assoc($userstat)) {
            $QryUpdateuserstat = "UPDATE {{table}} SET ";
            $QryUpdateuserstat .= "`wons` = '" . $user1wons . "', ";
            $QryUpdateuserstat .= "`loos` = '" . $user1loos . "', ";
            $QryUpdateuserstat .= "`draws` = '" . $user1draws . "', ";
            $QryUpdateuserstat .= "`kbmetal` = '" . $strtruemmermetaluser1 . "', ";
            $QryUpdateuserstat .= "`kbcrystal` = '" . $strtruemmercrystaluser1 . "', ";
            $QryUpdateuserstat .= "`lostunits` = '" . $user1lostunits . "', ";
            $QryUpdateuserstat .= "`desunits` = '" . $user1shotunits . "' ";
            $QryUpdateuserstat .= "WHERE ";
            $QryUpdateuserstat .= "`id` = '" . $user1stat . "';";
            doquery($QryUpdateuserstat, 'users');
            //Update Verteidiger Truemerfeld, Kampfergebniss und Units
            $QryUpdateuserstat = "UPDATE {{table}} SET ";
            $QryUpdateuserstat .= "`wons` = '" . $user2wons . "', ";
            $QryUpdateuserstat .= "`loos` = '" . $user2loos . "', ";
            $QryUpdateuserstat .= "`draws` = '" . $user2draws . "', ";
            $QryUpdateuserstat .= "`kbmetal` = '" . $strtruemmermetaluser2 . "', ";
            $QryUpdateuserstat .= "`kbcrystal` = '" . $strtruemmercrystaluser2 . "', ";
            $QryUpdateuserstat .= "`lostunits` = '" . $user2lostunits . "', ";
            $QryUpdateuserstat .= "`desunits` = '" . $user2shotunits . "' ";
            $QryUpdateuserstat .= "WHERE ";
            $QryUpdateuserstat .= "`id` = '" . $user2stat . "';";
            doquery($QryUpdateuserstat, 'users');
        }
        // Ende schreiben in datenbank
        // Retour de flotte (s'il en reste)
        $fquery = "";
        if ($FleetRow['fleet_end_time'] <= time()) {
            $Message = sprintf($lang['sys_tran_mess_angriffback'], $TargetName, GetTargetAdressLink($FleetRow, ''), pretty_number($FleetRow['fleet_resource_metal']), $lang['Metal'], pretty_number($FleetRow['fleet_resource_crystal']), $lang['Crystal'], pretty_number($FleetRow['fleet_resource_deuterium']), $lang['Deuterium']);
            SendSimpleMessage($FleetRow['fleet_owner'], '', $FleetRow['fleet_end_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_fleetback'], $Message);
            if (!is_null($CurrentSet)) {
                foreach ($CurrentSet as $Ship => $Count) {
                    $fquery .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` + '" . $Count['count'] . "', ";
                }
            } else {
                $fleet = explode(";", $FleetRow['fleet_array']);
                foreach ($fleet as $a => $b) {
                    if ($b != '') {
                        $a = explode(",", $b);
                        $fquery .= "{$resource[$a[0]]}={$resource[$a[0]]} + {$a[1]}, \n";
                    }
                }
            }
            doquery("DELETE FROM {{table}} WHERE `fleet_id` = " . $FleetRow["fleet_id"], 'fleets');
            if (!($FleetResult == "w")) {
                $QryUpdatePlanet = "UPDATE {{table}} SET ";
                $QryUpdatePlanet .= $fquery;
                $QryUpdatePlanet .= "`metal` = `metal` + " . $FleetRow['fleet_resource_metal'] . ", ";
                $QryUpdatePlanet .= "`crystal` = `crystal` + " . $FleetRow['fleet_resource_crystal'] . ", ";
                $QryUpdatePlanet .= "`deuterium` = `deuterium` + " . $FleetRow['fleet_resource_deuterium'] . " ";
                $QryUpdatePlanet .= "WHERE ";
                $QryUpdatePlanet .= "`galaxy` = " . $FleetRow['fleet_start_galaxy'] . " AND ";
                $QryUpdatePlanet .= "`system` = " . $FleetRow['fleet_start_system'] . " AND ";
                $QryUpdatePlanet .= "`planet` = " . $FleetRow['fleet_start_planet'] . " AND ";
                $QryUpdatePlanet .= "`planet_type` = " . $FleetRow['fleet_start_type'] . " LIMIT 1 ;";
                doquery($QryUpdatePlanet, 'planets');
            }
        }
    }
}