Este es el codigo:
Cita:
<?
// REQUIRE de Verificación de login e Inicio de Session
require ("aut_verifica.inc.php");
// Datos de conexion a la Base de datos (BBDD)
$hostname = "localhost"; //URL del Servidor
$username = "root"; //USER del Servidor
$password = ""; //PASS del USER del Servidor
$dbName = "arch"; //Nombre de la BBDD
$nick = $_SESSION['mago_login'];
// Conexion Persistente a la BBDD
$db = mysql_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");
mysql_select_db($dbName,$db) or DIE("Table unavailable");
// Extracción de los datos pertinentes
$cons1 = "select mago.id_mago, mago.nick, mago.magia, mago.turnos, mago.oro, mago.tierra, mago.fortalezas, mago.idioma from mago where (mago.nick like '$nick')";
$cons1 = mysql_query($cons1,$db);
$res1 = mysql_fetch_array($cons1);
include ("variables.php");
$TIERRAS = $res1[5];
$TURNOS = $res1[3];
echo $TIERRAS;
echo $TURNOS;
// liberamos la memoria usada por la consulta, ya que tenemos estos datos en el Array.
mysql_free_result($cons1);
// cerramos la Base de dtos.
//mysql_close($db);
$error = 0;
/*
if ($texplorer > $TURNOS){$texplorer = 0; $error = 1;}
*/
for ($i=0; $i<$texplorer; $i++)
{
$TIERRAS = round($TIERRAS + ((3001-$TIERRAS)/100));
if ($TIERRAS > 3001)
{
$texplorer = $i; $error = 2;
}
// Calculando el Mana
if (((round($NODOS/$TIERRAS*10000))/100) < 11) {$PoderA = $NODOS*10;}
else {$PoderA = floor((($NODOS - (round($TIERRAS/10))) * 10) * (1 - floor($NODOS/$TIERRAS*100)/100)) + $TIERRAS;}
$PoderA = $PoderA - ($BARRERAS * $mantenimiento["barreras"]["mana"]);
// Calculando la Población
$PuebloA = floor((($PUEBLOS - (round($GRANJAS/10))) * 10) * (1 - floor($PUEBLOS/$GRANJAS*100)/100)) + $GRANJAS;
// Calculando el Oro
$ORO = floor(1.3*$PuebloA);
// Costes en Oro por MANTENIMIENTO
$ORO = $ORO - ($GRANJAS * $mantenimiento["granjas"]["oro"]);
$ORO = $ORO - ($PUEBLOS * $mantenimiento["pueblos"]["oro"]);
$ORO = $ORO - ($TALLERES * $mantenimiento["talleres"]["oro"]);
$ORO = $ORO - ($BARRACAS * $mantenimiento["barracas"]["oro"]);
$ORO = $ORO - ($GREMIOS * $mantenimiento["gremios"]["oro"]);
$ORO = $ORO - ($NODOS * $mantenimiento["nodos"]["oro"]);
$ORO = $ORO - ($FORTALEZAS * $mantenimiento["fortalezas"]["oro"]);
}
$TURNOS = $TURNOS - $texplorer;
// Conexion Persistente a la BBDD
//$db2 = mysql_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");
//mysql_select_db($dbName,$db2) or DIE("Table unavailable");
$texto = "datos al final del explorar: ";
echo $TURNOS;
echo $TIERRAS;
$sql = "insert into mago (turnos, tierra, poder, pueblos, oro) values ($TURNOS, $TIERRAS, $PODER, $PUEBLOS, $ORO)";
$result2 = mysql_query($sql);
// cerramos la Base de dtos.
//mysql_close($db2);
?>
<html>
<head>
<title>-- EXPLORAR EN NUEVA TERRA --</title>
</head>
<body>
<form method="POST" action="explorar.php?<? echo SID ?>">
<table align="center" border="0">
<tr>
<td>Turnos a Explorar: </td>
<td><input type="text" name="texplorer" size="4"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Explorar" name="B1" style="font-family: Arial Narrow; font-size: 8pt"></td>
</tr>
</table>
</form>
<a href="menu.php?<? echo SID ?>">volver</a>
<?
if ($error == 1){echo "La cantidad de turnos ha explorar supera los turnos disponibles.";}
elseif ($error == 2){echo "Ha alcanzado el límite de tierras ha explorar.";}
else {echo "La cantidad de tierras exploradas es ahora de $TIERRAS acres.";}
?>
</body>
</html>
// REQUIRE de Verificación de login e Inicio de Session
require ("aut_verifica.inc.php");
// Datos de conexion a la Base de datos (BBDD)
$hostname = "localhost"; //URL del Servidor
$username = "root"; //USER del Servidor
$password = ""; //PASS del USER del Servidor
$dbName = "arch"; //Nombre de la BBDD
$nick = $_SESSION['mago_login'];
// Conexion Persistente a la BBDD
$db = mysql_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");
mysql_select_db($dbName,$db) or DIE("Table unavailable");
// Extracción de los datos pertinentes
$cons1 = "select mago.id_mago, mago.nick, mago.magia, mago.turnos, mago.oro, mago.tierra, mago.fortalezas, mago.idioma from mago where (mago.nick like '$nick')";
$cons1 = mysql_query($cons1,$db);
$res1 = mysql_fetch_array($cons1);
include ("variables.php");
$TIERRAS = $res1[5];
$TURNOS = $res1[3];
echo $TIERRAS;
echo $TURNOS;
// liberamos la memoria usada por la consulta, ya que tenemos estos datos en el Array.
mysql_free_result($cons1);
// cerramos la Base de dtos.
//mysql_close($db);
$error = 0;
/*
if ($texplorer > $TURNOS){$texplorer = 0; $error = 1;}
*/
for ($i=0; $i<$texplorer; $i++)
{
$TIERRAS = round($TIERRAS + ((3001-$TIERRAS)/100));
if ($TIERRAS > 3001)
{
$texplorer = $i; $error = 2;
}
// Calculando el Mana
if (((round($NODOS/$TIERRAS*10000))/100) < 11) {$PoderA = $NODOS*10;}
else {$PoderA = floor((($NODOS - (round($TIERRAS/10))) * 10) * (1 - floor($NODOS/$TIERRAS*100)/100)) + $TIERRAS;}
$PoderA = $PoderA - ($BARRERAS * $mantenimiento["barreras"]["mana"]);
// Calculando la Población
$PuebloA = floor((($PUEBLOS - (round($GRANJAS/10))) * 10) * (1 - floor($PUEBLOS/$GRANJAS*100)/100)) + $GRANJAS;
// Calculando el Oro
$ORO = floor(1.3*$PuebloA);
// Costes en Oro por MANTENIMIENTO
$ORO = $ORO - ($GRANJAS * $mantenimiento["granjas"]["oro"]);
$ORO = $ORO - ($PUEBLOS * $mantenimiento["pueblos"]["oro"]);
$ORO = $ORO - ($TALLERES * $mantenimiento["talleres"]["oro"]);
$ORO = $ORO - ($BARRACAS * $mantenimiento["barracas"]["oro"]);
$ORO = $ORO - ($GREMIOS * $mantenimiento["gremios"]["oro"]);
$ORO = $ORO - ($NODOS * $mantenimiento["nodos"]["oro"]);
$ORO = $ORO - ($FORTALEZAS * $mantenimiento["fortalezas"]["oro"]);
}
$TURNOS = $TURNOS - $texplorer;
// Conexion Persistente a la BBDD
//$db2 = mysql_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");
//mysql_select_db($dbName,$db2) or DIE("Table unavailable");
$texto = "datos al final del explorar: ";
echo $TURNOS;
echo $TIERRAS;
$sql = "insert into mago (turnos, tierra, poder, pueblos, oro) values ($TURNOS, $TIERRAS, $PODER, $PUEBLOS, $ORO)";
$result2 = mysql_query($sql);
// cerramos la Base de dtos.
//mysql_close($db2);
?>
<html>
<head>
<title>-- EXPLORAR EN NUEVA TERRA --</title>
</head>
<body>
<form method="POST" action="explorar.php?<? echo SID ?>">
<table align="center" border="0">
<tr>
<td>Turnos a Explorar: </td>
<td><input type="text" name="texplorer" size="4"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Explorar" name="B1" style="font-family: Arial Narrow; font-size: 8pt"></td>
</tr>
</table>
</form>
<a href="menu.php?<? echo SID ?>">volver</a>
<?
if ($error == 1){echo "La cantidad de turnos ha explorar supera los turnos disponibles.";}
elseif ($error == 2){echo "Ha alcanzado el límite de tierras ha explorar.";}
else {echo "La cantidad de tierras exploradas es ahora de $TIERRAS acres.";}
?>
</body>
</html>