salve a tutti,
non so quanti di voi conoscono il travian, il browser game. Beh ho creato un tool per quel gioco per calcolare la distanza fra due villaggi e il tempo impiegato a percorrerla. il codice è questo
codice:
<form action="#" method="post">            <b>INSERISCI LE COORDINATE DEL VILLAGGIO DI PARTENZA</b><br>
                        X: <input type="text" name="x1" size="4"> Y: <input type="text" name="y1" size="4"><br>
                        <b>INSERISCI LE COORDINATE DEL VILLAGGIO DI ARRIVO</b><br>
                        X: <input type="text" name="x2" size="4"> Y: <input type="text" name="y2" size="4"><br>
                        <b>INSERISCI IL VALORE DELLA VELOCITA' DELLA TRUPPA PIU LENTA</b><br>
                        <input type="text" name="vel" size="3"> caselle/ora<br>
                        (per dubbi consulta la <a href="tabella.JPG">tabella delle velocita'</a>)<br>
                        <b>INSERISCI IL BONUS DATO DALL' ARTEFATTO (SE PRESENTE)</b><br>
                        <input type="text" name="arte" size="4">%<br>
                        <b>INSERISCI IL LIVELLO DELL' ARENA (SE PRESENTE)</b><br>
                        <input type="text" name="arena" size="3"><br>                                                                                          
                        <b>INSERISCI IL BONUS DATO DALL' ACCESSORIO STIVALI DELL EROE (SE PRESENTI)</b><br>
                        <input type="text" name="scarpe" size="3">%<br>   
                        <b>INSERISCI IL BONUS DATO DAGLI ACCESSORI STENDARDO/BANDIERA DELL' EROE (SE L'EFFETTO E' VALIDO)</b><br>
                        <input type="text" name="acc" size="3">%<br>
                        <input type="submit" value="Calcola"><br>
            </form>     
            <hr>
                        <?
                         $x1=$_POST['x1'];
                         $y1=$_POST['y1'];
                         $x2=$_POST['x2'];
                         $y2=$_POST['y2'];
                         $vel=$_POST['vel'];
                         $arte=$_POST['arte'];
                         $arena=$_POST['arena'];
                         $scarpe=$_POST['scarpe'];
                         $acc=$_POST['acc'];
                         $a=pow($x1-$x2, 2);
                         $b=pow($y1-$y2, 2);
                         $c=$a+$b;
                         $tot=sqrt($c);
                         $tot1=bcsqrt($c, 1);
                         if(empty($arte))
                          {
                           $arte=0;
                          }
                         if(empty($arena))
                          {
                           $arte=0;
                          }
                         if(empty($scarpe))
                          { 
                           $scarpe=0;
                          }
                         if(empty($acc))
                          {
                           $acc=0;
                          }                       
                         if($tot <= 20)
                          {
                           $d=($acc/100)+1;
                           $e=($arte/100);
                           $vell=$vel*$d*$e;                           
                          }
                         else
                          {
                           $d=($acc/100)+1;
                           $e=($arte/100);
                           $f=($arena/10)+1;
                           $g=($scarpe/100)+1;
                           $vell=$vel*$d*$e*$f*$g;
                          }
                        $h=$tot/$vel;
                        $ora=floor($h);
                        $i=$h-$ora;
                        $l=$i*60;
                        $min=floor($l);
                        $m=$l-$min;
                        $n=$m*60;
                        $sec=round($n, 0);
            if(empty($x1) Or empty($x2) Or empty($y1) Or empty($y2))
            {
             echo "<p><b>Coordinate mancanti</b></p>";
            }
            else
            {
             if(empty($vel))
             {
             echo"<p><b>Inserisci la velocita'</b></p>";
             }
             else
             {
                          echo "<p><b>La distanza tra i due villaggi e' di $tot1 caselle</b></p>";
                          echo "<p><b>Il tempo impiegato secondo i parametri indicati e' $ora h: $min m: $sec s</b></p>";        
                         }
                        }    
                        ?><br>
ora, inserendo le coordinate e la velocità nessun problema ma se vado a inserire un bonus, che per esempio raddoppia la velocità, il tempo non si dimezza.
per quanto l'abbia guardato, non riesco a trovare l'errore.
potreste darmi una mano? grazie in anticipo
P.S. se volete farvi un'idea più precisa il tool è questo http://www.journeycalculator.altervista.it