Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > PHP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 19-05-2010
CniL CniL is offline
Miembro
 
Registrado: may 2010
Posts: 10
Poder: 0
CniL Va por buen camino
Juego de las Puertas

Una vez con la intención de comprobar una teoría matemática... cree un juego de una puerta, basada en premios a base de un juego MMORPG (por eso los banderines que tienen que ver con el juego)

Pero para compartir la idea, les dejo el código a ver si alguien arma algo con esto algún día.

h t t p : // w w w.filosofadas.hostoi.com/juegopuerta/juegopuerta.php

Código PHP:
<?php 
//ESTA COMPROBACIÓN ES PARA REVISAR IPs (de modo tal en el inicio no se repitiesen el plato)
if(!$_POST['post'] && !$_POST['post2'])
{
mysql_connect("HOSTSERVER","USER","PASS") or die(mysql_error());
mysql_select_db("DATABASE")or die(mysql_error());
$ipsa=getRealIpAddr();
$correcta=rand(1,3);
$datedate("Y-m-d");
$abierto="abierto";
$adip=rand(0,99999);
$ipsa3="$ipsa"."$adip";
$insert mysql_query("INSERT INTO door VALUES ('','$abierto','$ipsa3','$correcta','','','','','1','','','$date')") or die(mysql_error());
?>
// ACÁ ELIMINE LA TABLA DEL INICIO PARA PODER INGRESAR EL CÓDIGO
<?php 

//puerta00, puerta01, puerta02 envía primera elección, ip, nick, puertacorrecta, eleccioncorrecta 1 incorrecta 2.

}
elseif(
$_POST['post'])
{
mysql_connect("HOSTSERVER","USER","PASS") or die(mysql_error());
mysql_select_db("DATABASE")or die(mysql_error());
$correcta=$_POST['c'];
$respuesta=$_POST['r'];
$ipsa=$_POST['i'];
$estado=0;
$rec mysql_query("SELECT * FROM door WHERE ip='$ipsa'") or die(mysql_error());
if ((
mysql_num_rows($rec))==0)
    die(
"Te falta el paso anterior");
$fila mysql_fetch_assoc($rec);
$pri $fila['pri'];
$seg $fila['seg'];
if(
$pri==|| $seg==1)
    die(
"ya habias pasado por esta parte antes");
//

if($correcta==$respuesta)
$estado=1;

if(
$correcta==1)
{
    if(
$estado==0)
    {
        if(
$respuesta==2)
            
$abrir=3;
        else
            
$abrir=2;
    }

    else
        
$abrir=rand(2,3);
}

if(
$correcta==2)
{
    if(
$estado==0)
    {
        if(
$respuesta==1)
            
$abrir=3;
        else
            
$abrir=1;
    }
    else
    {
        
$abrir=rand(1,2);
        if(
$abrir==2);
            
$abrir=3;
    }
}

if(
$correcta==3)
{
    if(
$estado==0)
    {
        if(
$respuesta==2)
            
$abrir=1;
        else
            
$abrir=2;
    }
    else
        
$abrir=rand(1,2);
}
$update mysql_query("UPDATE `DATABASE`.`door` SET `respuesta1` = '" $respuesta "',`abrir` = '" $abrir "',`seg` = '1' WHERE `door`.`ip` ='" $ipsa "' LIMIT 1");
//---------------------Linea separadora
?>
<table border="0" cellpadding="0" cellspacing="0" width="800">
<!-- fwtable fwsrc="Sin título" fwbase="juegopuerta.gif" fwstyle="Dreamweaver" fwdocid = "1882347419" fwnested="0" -->
  <tr>
   <td><img src="spacer.gif" width="63" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="16" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="10" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="42" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="57" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="70" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="48" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="56" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="53" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="60" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="49" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="55" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="55" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="59" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="22" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="11" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="74" height="1" border="0" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="1" border="0" alt="" /></td>
  </tr>

  <tr>
   <td colspan="17"><img name="juegopuerta_r1_c1" src="juegopuerta_r1_c1.gif" width="800" height="36" border="0" id="juegopuerta_r1_c1" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="36" border="0" alt="" /></td>
  </tr>
  <tr>
   <td rowspan="6" colspan="2"><img name="juegopuerta_r2_c1" src="juegopuerta_r2_c1.gif" width="79" height="456" border="0" id="juegopuerta_r2_c1" alt="" /></td>
   <td colspan="14"><?php echo" Has elegido la puerta número $respuesta. Aún puedes cambiar de opinión. "?></td>
   <td rowspan="8"><img name="juegopuerta_r2_c17" src="juegopuerta_r2_c17.gif" width="74" height="564" border="0" id="juegopuerta_r2_c17" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="59" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="14"><img name="juegopuerta_r3_c3" src="juegopuerta_r3_c3.gif" width="647" height="19" border="0" id="juegopuerta_r3_c3" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="19" border="0" alt="" /></td>
  </tr>
  <tr>
   <td rowspan="2" colspan="2"><img name="juegopuerta_r4_c3" src="juegopuerta_r4_c3.gif" width="52" height="82" border="0" id="juegopuerta_r4_c3" alt="" /></td>
   <td><img name="juegopuerta_r4_c5" src="juegopuerta_r4_c5.gif" width="57" height="46" border="0" id="juegopuerta_r4_c5" alt="" /></td>
   <td rowspan="2" colspan="3"><img name="juegopuerta_r4_c6" src="juegopuerta_r4_c6.gif" width="174" height="82" border="0" id="juegopuerta_r4_c6" alt="" /></td>
   <td><img name="juegopuerta_r4_c9" src="juegopuerta_r4_c9.gif" width="53" height="46" border="0" id="juegopuerta_r4_c9" alt="" /></td>
   <td rowspan="2" colspan="3"><img name="juegopuerta_r4_c10" src="juegopuerta_r4_c10.gif" width="164" height="82" border="0" id="juegopuerta_r4_c10" alt="" /></td>
   <td><img name="juegopuerta_r4_c13" src="juegopuerta_r4_c13.gif" width="55" height="46" border="0" id="juegopuerta_r4_c13" alt="" /></td>
   <td rowspan="2" colspan="3"><img name="juegopuerta_r4_c14" src="juegopuerta_r4_c14.gif" width="92" height="82" border="0" id="juegopuerta_r4_c14" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="46" border="0" alt="" /></td>
  </tr>
  <tr>
   <td><img name="juegopuerta_r5_c5" src="juegopuerta_r5_c5.gif" width="57" height="36" border="0" id="juegopuerta_r5_c5" alt="" /></td>
   <td><img name="juegopuerta_r5_c9" src="juegopuerta_r5_c9.gif" width="53" height="36" border="0" id="juegopuerta_r5_c9" alt="" /></td>
   <td><img name="juegopuerta_r5_c13" src="juegopuerta_r5_c13.gif" width="55" height="36" border="0" id="juegopuerta_r5_c13" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="36" border="0" alt="" /></td>
  </tr>
  <tr>
   <td rowspan="2"><img name="juegopuerta_r6_c3" src="juegopuerta_r6_c3.gif" width="10" height="296" border="0" id="juegopuerta_r6_c3" alt="" /></td>
   <td colspan="3"><?php
    
if($abrir==1)
{
?>
<img name="juegopuerta_r6_c12" src="juegopuerta_r6_c12.gif" width="169" height="251" border="0" id="juegopuerta_r6_c12" alt="" /></td>
   <td rowspan="2"><img name="juegopuerta_r6_c7" src="juegopuerta_r6_c7.gif" width="48" height="296" border="0" id="juegopuerta_r6_c7" alt="" /></td>
   <td colspan="3">
<?php
}
else
{
?>
<form name="form1" method="post" action="">
  <input name="i" type="hidden" value="<?php echo"$ipsa?>">
  <input name="ro" type="hidden" value="<?php echo"$respuesta?>">
  <input name="c" type="hidden" value="<?php echo"$correcta?>">
  <input name="r" type="hidden" id="1" value="1">
  <input type="image" name="post2" id="post" value="submit" src="juegopuerta_r6_c4.gif">
</form></td>
   <td rowspan="2"><img name="juegopuerta_r6_c7" src="juegopuerta_r6_c7.gif" width="48" height="296" border="0" id="juegopuerta_r6_c7" alt="" /></td>
   <td colspan="3">
<?php
}
if(
$abrir==2)
{
?>
<img name="juegopuerta_r6_c12" src="juegopuerta_r6_c12.gif" width="169" height="251" border="0" id="juegopuerta_r6_c12" alt="" /></td>
   <td rowspan="2"><img name="juegopuerta_r6_c7" src="juegopuerta_r6_c7.gif" width="48" height="296" border="0" id="juegopuerta_r6_c7" alt="" /></td>
   <td colspan="3">
<?php
}
else
{
?>
<form name="form2" method="post" action="">
  <input name="i" type="hidden" value="<?php echo"$ipsa?>">
  <input name="ro" type="hidden" value="<?php echo"$respuesta?>">
  <input name="c" type="hidden" value="<?php echo"$correcta?>">
  <input name="r" type="hidden" id="2" value="2">
  <input type="image" name="post2" id="post" value="submit" src="juegopuerta_r6_c4.gif">
</form></td>
   <td rowspan="2"><img name="juegopuerta_r6_c11" src="juegopuerta_r6_c11.gif" width="49" height="296" border="0" id="juegopuerta_r6_c11" alt="" /></td>
   <td colspan="3">
<?php
}
if(
$abrir==3)
{
?>
<img name="juegopuerta_r6_c12" src="juegopuerta_r6_c12.gif" width="169" height="251" border="0" id="juegopuerta_r6_c12" alt="" /></td>
   <td rowspan="2" colspan="2"><img name="juegopuerta_r6_c15" src="juegopuerta_r6_c15.gif" width="33" height="296" border="0" id="juegopuerta_r6_c15" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="251" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="3"><img name="juegopuerta_r7_c4" src="juegopuerta_r7_c4.gif" width="169" height="45" border="0" id="juegopuerta_r7_c4" alt="" /></td>
   <td colspan="3"><img name="juegopuerta_r7_c8" src="juegopuerta_r7_c8.gif" width="169" height="45" border="0" id="juegopuerta_r7_c8" alt="" /></td>
   <td colspan="3"><img name="juegopuerta_r7_c12" src="juegopuerta_r7_c12.gif" width="169" height="45" border="0" id="juegopuerta_r7_c12" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="45" border="0" alt="" /></td>
  </tr>
  <tr>
   <td rowspan="2"><img name="juegopuerta_r8_c1" src="juegopuerta_r8_c1.gif" width="63" height="108" border="0" id="juegopuerta_r8_c1" alt="" /></td>
   <td colspan="14">Como vés en esa puerta hay un Stem, eligé la puerta que quieras, ya sea la misma anterior o la otra puerta.</td>
   <td rowspan="2"><img name="juegopuerta_r8_c16" src="juegopuerta_r8_c16.gif" width="11" height="108" border="0" id="juegopuerta_r8_c16" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="84" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="14"><img name="juegopuerta_r9_c2" src="juegopuerta_r9_c2.gif" width="652" height="24" border="0" id="juegopuerta_r9_c2" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="24" border="0" alt="" /></td>
  </tr>
</table>
<?php
}
else
{
?>
<form name="form3" method="post" action="">
  <input name="i" type="hidden" value="<?php echo"$ipsa?>">
  <input name="ro" type="hidden" value="<?php echo"$respuesta?>">
  <input name="c" type="hidden" value="<?php echo"$correcta?>">
  <input name="r" type="hidden" id="3" value="3">
  <input type="image" name="post2" id="post" value="submit" src="juegopuerta_r6_c4.gif">
</form></td>
   <td rowspan="2" colspan="2"><img name="juegopuerta_r6_c15" src="juegopuerta_r6_c15.gif" width="33" height="296" border="0" id="juegopuerta_r6_c15" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="251" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="3"><img name="juegopuerta_r7_c4" src="juegopuerta_r7_c4.gif" width="169" height="45" border="0" id="juegopuerta_r7_c4" alt="" /></td>
   <td colspan="3"><img name="juegopuerta_r7_c8" src="juegopuerta_r7_c8.gif" width="169" height="45" border="0" id="juegopuerta_r7_c8" alt="" /></td>
   <td colspan="3"><img name="juegopuerta_r7_c12" src="juegopuerta_r7_c12.gif" width="169" height="45" border="0" id="juegopuerta_r7_c12" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="45" border="0" alt="" /></td>
  </tr>
  <tr>
   <td rowspan="2"><img name="juegopuerta_r8_c1" src="juegopuerta_r8_c1.gif" width="63" height="108" border="0" id="juegopuerta_r8_c1" alt="" /></td>
   <td colspan="14">Como vés en esa puerta hay un Stem, eligé la puerta que quieras, ya sea la misma anterior o la otra puerta.</td>
   <td rowspan="2"><img name="juegopuerta_r8_c16" src="juegopuerta_r8_c16.gif" width="11" height="108" border="0" id="juegopuerta_r8_c16" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="84" border="0" alt="" /></td>
  </tr>
  <tr>
   <td colspan="14"><img name="juegopuerta_r9_c2" src="juegopuerta_r9_c2.gif" width="652" height="24" border="0" id="juegopuerta_r9_c2" alt="" /></td>
   <td><img src="spacer.gif" width="1" height="24" border="0" alt="" /></td>
  </tr>
</table>
<?php 
}
//si eligío la puerta correcta, hace un azar entre las 2 puertas incorrectas, y muestra que hay 1 stem.  Le dá a elegir si cambia de puerta a la otra incorrecta, mantiene la misma opción.

//si eligio la puerta incorrecta, abre la otra puerta incorrecta. Le dá a elegir si cambia de puerta a la otra incorrecta, mantiene la misma opción.

//envía "0 si cambio la puerta y 1 si la mantuvo"
}
elseif(
$_POST['post2'])
{
mysql_connect("HOSTSERVER","USER","PASS") or die(mysql_error());
mysql_select_db("DATABASE")or die(mysql_error());
$respuesta=$_POST['r'];
$respuestaori=$_POST['ro'];
$correcta=$_POST['c'];;
$ipsa=$_POST['i'];
$rec mysql_query("SELECT * FROM door WHERE ip='$ipsa'") or die(mysql_error());
if ((
mysql_num_rows($rec))==0)
die(
"Te falta el paso anterior");
$fila mysql_fetch_assoc($rec);
$pri=$fila['pri'];
$seg=$fila['seg'];
$ter=$fila['ter'];
if(
$pri==|| $seg==|| $ter==1)
die(
"ya habias pasado por esta parte antes");
if(
$respuesta==$correcta)
{
    echo
"</br><b><h1>FELICITACIONES!!, GANASTE '1m de Adena en l2.cl'</h1></b>.";
    if(
$respuesta==$respuestaori)
    {
    echo
"</br>La seguridad en tí mismo, te ha dado frutos.";
    
$valor=1;
    }
    else
    {
    echo
"</br>Es bueno detenerse a pensar 2 veces las cosas.  Y se acá se ha demostrado";
    
$valor=2;
    }
    echo
"</br> Contactame In-Game para entregarte la adena.";
    
?>
    <img name="adena" src="adena.gif" width="57" height="36" border="0" id="adena" alt="adena" />
    <?php
}
else
{
    echo 
"</br> <b>Lo siento has perdido.</b>";
    if(
$respuesta==$respuestaori)
    {
    echo
" </br>Pese a ser seguro de ti mismo al mantener tu respuesta, esta vez debiste pensarlos 2 veces.";
    
$valor=3;
    }
    else
    {
    echo
"</br>Deberías ser un poco más seguro de tí mismo y haber mantenido la respuesta.";
    
$valor=0;
    }
    
?>
    <img name="adena" src="juegopuerta_r6_c12.gif" width="57" height="36" border="0" id="adena" alt="stem" />
    <?php
}
$update mysql_query("UPDATE `a3359133_bdoor`.`door` SET `respuesta2` = '" $respuesta "',`valor` = '" $valor "',`ter` = '1' WHERE `door`.`ip` ='" $ipsa "' LIMIT 1");

//si su elección era correcta y la cambió, entonces pierde y marca un 0
//si su eleeción era correcta y la mantuvo, entonces gana y marca un 1
//si su elección era incorrecta y la cambió, entonces gana y marca un 2
//si su elección era incorrecta y la mantuvo, entonces pierde y marca un 3
echo"</br>Muchas gracias por Participar en la experiencia del JUEGO DE LA PUERTA. </br>";
}


function 
getRealIpAddr()
{
    if (!empty(
$_SERVER['HTTP_CLIENT_IP']))   //comproba la ip compartida a internet
    
{
      
$ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty(
$_SERVER['HTTP_X_FORWARDED_FOR']))   //comprobando si pasa por un proxy
    
{
      
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      
$ip=$_SERVER['REMOTE_ADDR'];
    }
    return 
$ip;
}
?>
Responder Con Cita
  #2  
Antiguo 19-05-2010
CniL CniL is offline
Miembro
 
Registrado: may 2010
Posts: 10
Poder: 0
CniL Va por buen camino
La página la puse con espacio ya que aún no me permite escribir enlaces.
Responder Con Cita
  #3  
Antiguo 20-05-2010
CniL CniL is offline
Miembro
 
Registrado: may 2010
Posts: 10
Poder: 0
CniL Va por buen camino
ht tp:// w w w.filosofadas.hostoi.com/juegopuerta/resultados.php

Resultados de el total de juegos y elecciones
Responder Con Cita
  #4  
Antiguo 25-05-2010
Avatar de Ñuño Martínez
Ñuño Martínez Ñuño Martínez is offline
Moderador
 
Registrado: jul 2006
Ubicación: Ciudad Catedral, Españistán
Posts: 6.000
Poder: 25
Ñuño Martínez Tiene un aura espectacularÑuño Martínez Tiene un aura espectacular
Esta teoría de cambiar o no cambiar la respuesta la he leído en alguna parte. Los resultados son curiosos.

Lo de los enlaces, ten paciencia, que ya llegará.
__________________
Proyectos actuales --> Allegro 5 Pascal ¡y Delphi!|MinGRo Game Engine
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
A las puertas del cielo jcarteagaf Humor 0 03-07-2008 18:53:09
Guillermo Puertas se gradua en Hardware. marcoszorrilla La Taberna 1 26-03-2007 22:00:15
Guille Puertas en directo. marcoszorrilla La Taberna 0 03-10-2006 21:21:53
La Guerra Fria a las puertas??? Sasuke_Cub Debates 8 27-12-2005 02:54:14
FireFox 1.5 a las puertas!!!!! Sasuke_Cub Noticias 15 05-12-2005 11:43:53


La franja horaria es GMT +2. Ahora son las 15:24:41.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi