HTML - Generala PHP y HTML

 
Vista:

Generala PHP y HTML

Publicado por Tomás (2 intervenciones) el 05/07/2015 21:48:45
Hola,
Necesito hacer una generala en html y php, me vendría bien algo de ayuda o una mano.
Hasta ahora tengo esto:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<html>
    <head>
        <title>
            Generala
        </title>
    </head>
    <?php
    $rand1=mt_rand(1,6);
    $rand2=mt_rand(1,6);
    $rand3=mt_rand(1,6);
    $rand4=mt_rand(1,6);
    $rand5=mt_rand(1,6);
    $aleatorio=array("0","$rand1","$rand2","$rand3","$rand4","$rand5");
    $tirar=isset($_REQUEST['tirar'])?$_REQUEST['tirar']:NULL;
    $anotar=isset($_REQUEST['anotar'])?$_REQUEST['anotar']:NULL;
    if ($tirar=="tiro"){$rand=mt_rand(1,5);}else{$rand="0";};
    if ($anotar=="anote"){;}else{;};
    ?>
    <body>
        <center>
        <form action="index.php" method="post">
            <table>
                <tr>
                    <td>
                        <table>
                        <?php for($i=1;$i<=5;$i++){ ?>
                        <tr>
                            <td>
                                <?php if($rand=="0") {?>
                                <input type="image" name="dado.<?php echo $i ?>" value="<?php echo $i ?>" src="img/<?php echo $i ?>.jpg" width="60" height="60">
                                <input type="checkbox">
                                <?php }else{?>
                                <input type="image" name="dado.<?php echo $aleatorio[$i] ?>" value="<?php echo $aleatorio[$i] ?>" src="img/<?php echo $aleatorio[$i] ?>.jpg" width="60" height="60">
                                <input type="checkbox">
                                <?php } ?>
                            </td>
                        </tr>
                        <?php } ?>
                        </table>
                    </td>
                    <td>
                        <table border="1">
                        <tr>
                            <td>
 
                            </td>
                            <td>
                                Jugador
                            </td>
                        </tr>
                        <?php for($e=1;$e<=12;$e++){ ?>
                        <tr>
                            <td>
                                <input type="image"  name="anotador" value="<?php echo $e?>" src="img/<?php echo $e?>n.jpg" width="60" height="30">
                            </td>
                            <td>
                                <input type="text" size="5">
                            </td>
                        </tr>
                        <?php } ?>
                        </table>
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>
                        <input type="hidden" name="tirar" value="<?php echo $tirar ?>">
                        <button type="submit" name="tirar" style='width:150px; height:50px' value="tiro">Tirar</button>
                    </td>
                    <td>
                        <input type="hidden" name="anotar" value="<?php echo $anotar ?>">
                        <button type="submit" name="anotar" style='width:150px; height:50px' value="anote">Anotar</button>
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

Lo que faltaría es el funcionamiento en cuanto a la cantidad de tiros, que cuando checkeas un dado no se tire y todo lo que sea para anotar automáticamente. Apreciaría mucho la ayuda.

Espero su respuesta.Muchas Gracias,
Tomás.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 1.144
Oro
Ha mantenido su posición en HTML (en relación al último mes)
Gráfica de HTML

Generala PHP y HTML

Publicado por xve (1543 intervenciones) el 06/07/2015 09:26:45
Hola Tomas, que es una "generala"?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Generala PHP y HTML

Publicado por Tomás (2 intervenciones) el 07/07/2015 23:48:52
Es un juego de dados
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Generala PHP y HTML

Publicado por Ignacio (8 intervenciones) el 08/07/2015 14:22:08
Hola Tomás, no conocía el juego generala, pero he visto algunos vídeos en youtube y he encontrado este: Video juego generala, el cual da una idea bastante clara de la mecánica del juego.

Tal y como tu planteas el programa, utilizando PHP así a pelo, tendrías que recargar la página completa por cada tiro, haciendo que se tenga que volver a calcular todos los valores de la partida ¿para remediar esto no crees que deberías usar JavaScript o AJAX y así modificar cada valor individualmente cuando le toque, sin tener que modificar todos a la vez por cada tiro (refresco de la página)?

¿Los valores se guardan en alguna base de datos una vez acabada la partida?

¿Esto es un trabajo o es para aprender por tu cuenta?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar