15/06/2010, 07:14
|
| | Fecha de Ingreso: noviembre-2009
Mensajes: 76
Antigüedad: 15 años, 1 mes Puntos: 2 | |
Respuesta: Ayuda Juego Browser floten3.php parte 2
Código:
{//info
$missiontype = array(
1 => 'Atacar',
3 => 'Transporte',
4 => 'Despliegue',
5 => 'Destruir',
6 => 'Espionaje',
8 => 'Recojer',
9 => 'Negociar',
);
$speed = array(
10 => 100,
9 => 90,
8 => 80,
7 => 70,
6 => 60,
5 => 50,
4 => 40,
3 => 30,
2 => 20,
1 => 10,
);
}
if(!$g){$g = $planetrow['galaxy'];}
if(!$s){$s = $planetrow['system'];}
if(!$p){$p = $planetrow['planet'];}
if(!$t){$t = $planetrow['planet_type'];}
/*
UUURRRRGGGGGG!!!!
*/
//en caso de que no exista el tipo de planeta destino
if(!$_POST['planettype']){message('Debes elegir el tipo de destino.'."Error");}
//para las coordenadas del planeta destino
if(!$_POST['galaxy']){$error++;$errorlist .= 'Debes elegir la Ciudad destino.';}
if(!$_POST['system']){$error++;$errorlist .= 'Debes elegir el Estado destino.';}
if(!$_POST['planet']){$error++;$errorlist .= 'Debes elegir el distrito destino.';}
//Para comprobar de que la flota que se envia, sea la misma del planeta
if($_POST['thisgalaxy'] != $planetrow['galaxy']|$_POST['thissystem'] != $planetrow['system']|$_POST['thisplanet'] != $planetrow['planet']|$_POST['thisplanettype'] != $planetrow['planet_type']){message('...',"WTF!");}
//Se comprueba de que se tengan los recursos.
/*
Ahora se debe obtener la lista de naves, para agregarlas a la array
Solo un megaloop comprobando si esta la nave, y cuantas.
*/
/* $pquery = str_replace("'","^",$pquery);
$query = "`query`='{$pquery}',";
doquery("INSERT INTO {{table}} SET
$query
`fleet_owner`='{$user['id']}',
`fleet_amount`='{$fleet['amount']}',
`fleet_array`='{$fleet['fleetlist']}'"
,'flota');
*/
if(!isset($flota)){message("Gemi Sec.","Error");}
if (($_POST['thisgalaxy'] - $_POST['galaxy']) != 0){
$dista = abs($_POST['thisgalaxy'] - $_POST['galaxy']) * 20000;
}
elseif (($_POST['thissystem'] - $_POST['system']) != 0){
$dista = abs($_POST['thissystem'] - $_POST['system']) * 95 + 2700;
}
elseif (($_POST['thisplanet'] - $_POST['planet']) != 0){
$dista = abs($_POST['thisplanet'] - $_POST['planet']) * 5 + 1000;
} else {
$dista = 5;
}
$fleet['fly_time'] = round(35000 / $_POST['speed'] * sqrt($dista * 10 / $_POST['speedallsmin'] )) / ($game_config['fleet_speed']/2500);
$fleet['start_time'] = round(35000 / $_POST['speed'] * sqrt($dista * 10 / $_POST['speedallsmin'] )) / ($game_config['fleet_speed']/2500) + time();
$fleet['end_time'] = 2*(round(35000 / $_POST['speed'] * sqrt($dista * 10 / $_POST['speedallsmin'] )) / ($game_config['fleet_speed']/2500) ) + time();
$consumption = 0;
$pojemosc = 0;
$ilosc_floty = 0;
$fleet_array="";
$pquery="";
foreach($flota as $a =>$b){
$shipSpeed = $pricelist[$a]["speed"];
$spd = 35000 / ($fleet['fly_time'] * ($game_config['fleet_speed']/2500) - 10) * sqrt($dista * 10 / $shipSpeed);
$basicConsumption = $pricelist[$a]["consumption"] * $b ;
$spidq = (($spd/10) + 1) * (($spd/10) + 1);
$consumption = $consumption + $basicConsumption * $dista / 35000 * $spidq;
// echo "dista: ".$dista." spd: ".$spd." spidq: ".$spidq." consumption: ".$basicConsumption." sumcons: ".$consumption."\n";
$pojemosc = $pojemosc + $pricelist[$a]["capacity"]*$b;
$ilosc_floty = $ilosc_floty + $b;
$fleet_array .= $a.",".$b.";";
$pquery .= $resource[$a]." = ".$resource[$a]." - ".$b." , ";
}
$consumption = round($consumption) + 1;
//echo $consumption."\n";
//die();
if($_POST['resource1'] > $planetrow['metal']|$_POST['resource2'] > $planetrow['crystal']|$_POST['resource3'] > ($planetrow['deuterium'] - $consumption)){
message("Error.","Error");
}
if(($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3']) > ($pojemosc - $consumption)){
message("Error.:".(($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3']) - ($pojemosc - $consumption)),"Error");
}
//$fleetlist contiene la lista de flotas, Esta se colocara en una row
//dentro de la sql
doquery("INSERT INTO {{table}} SET
`fleet_owner`='{$user['id']}',
`fleet_mission`='{$_POST['mission']}',
`fleet_amount`='{$ilosc_floty}',
`fleet_array`='{$fleet_array}',
`fleet_start_time`= '{$fleet['start_time']}',
`fleet_start_galaxy`='{$_POST['thisgalaxy']}',
`fleet_start_system`='{$_POST['thissystem']}',
`fleet_start_planet`='{$_POST['thisplanet']}',
`fleet_start_type`='{$_POST['planettype']}',
`fleet_end_time`='{$fleet['end_time']}',
`fleet_end_galaxy`='{$_POST['galaxy']}',
`fleet_end_system`='{$_POST['system']}',
`fleet_end_planet`='{$_POST['planet']}',
`fleet_end_type`='{$_POST['thisplanettype']}',
`fleet_resource_metal` = '{$_POST['resource1']}',
`fleet_resource_crystal` = '{$_POST['resource2']}',
`fleet_resource_deuterium` = '{$_POST['resource3']}',
`fleet_ofiara`='{$enemyrow['id_owner']}'",'fleets');
if ($_POST['resource1'] < 1){
$transport["metal"] = 0;
} else {
$transport["metal"] = $_POST['resource1'];
}
if ($_POST['resource2'] < 1){
$transport["crystal"] = 0;
} else {
$transport["crystal"] = $_POST['resource2'];
}
if ($_POST['resource3'] < 1){
$transport["deuterium"] = 0 + $consumption;
} else {
$transport["deuterium"] = $_POST['resource3'] + $consumption;
}
$planetrow["metal"] = $planetrow["metal"] - $transport["metal"];
$planetrow["crystal"] = $planetrow["crystal"] - $transport["crystal"];
$planetrow["deuterium"] = $planetrow["deuterium"] - $transport["deuterium"];
$query = "UPDATE {{table}} SET
metal=metal - '{$transport["metal"]}',
crystal=crystal - '{$transport["crystal"]}',
deuterium=deuterium - '{$transport["deuterium"]}',
$pquery
id_owner='{$planetrow['id_owner']}'
WHERE id={$planetrow['id']}";
doquery($query,"planets");
//ahora se deven quitar las naves correspondientes
//o mejor dicho. actualizar el row del planet
//$missiontype corresponde al tipo de accion a tomar.
$page = '<table border="0" cellpadding="0" cellspacing="1" width="519"><br>';
$page .= '<tr height="20"><td class="c" colspan="2">';
$page .= '<span class="success">Detalles:</span>';
$page .= '</td></tr>';
$misja = $missiontype[$_POST['mission']] ;
$page .= "<tr height=20><th>Mision</th><th>{$misja}</th></tr>";
$page .= "<tr height=20><th>Distancia</th><th>{$dista}</th></tr>";
$page .= "<tr height=20><th>Velocidad</th><th>".$_POST['speedallsmin']."</th></tr>";
$page .= "<tr height=20><th>Consumo Recursos</th><th>{$consumption}</th></tr>";
$page .= "<tr height=20><th>Comienzo</th><th>{$_POST['thisgalaxy']}:{$_POST['thissystem']}:{$_POST['thisplanet']}</th></tr>";
$page .= "<tr height=20><th>Objetivo.</th><th>{$_POST['galaxy']}:{$_POST['system']}:{$_POST['planet']}</th></tr>";
$page .= "<tr height=20><th>Llegada</th><th>";
//hora de lleada
$page .= date("M D d H:i:s",$fleet['start_time']).'</th></tr>';
$page .= '<tr height="20"><th>Volver</th><th>';
//Hora de vuelta
$page .= date("M D d H:i:s",$fleet['end_time']).'</th></tr>';
$page .= '<tr height="20"><td class="c" colspan="2">Grupo</td></tr>';
$page .= '</table>';
display($page,'Flotas');
?>
|