Hallo zusammen
Ic könnte bei einem java script ein wenig hilfe gebrauchen. Java kann ich überhaupt nicht. Aber Vieleicht einer von euch.
Undzwar habe ich das Problem das ich das die schiffe trozdem immer nur 100% fliegen wähle ich 30% aus fliegen Sie trozdem auf 100%. Kann mir da vieleicht jemand helfen? Da ich kein Java kann wüsste ich nichteinmal wo ich da anfangen müsste.
Hier mal der Code
Alles anzeigen
Hier noch der dazugehörige php code
Alles anzeigen
Auf 100 % stimmen die zeiten so gut wie überein
Gruss
Dragon
Ic könnte bei einem java script ein wenig hilfe gebrauchen. Java kann ich überhaupt nicht. Aber Vieleicht einer von euch.
Undzwar habe ich das Problem das ich das die schiffe trozdem immer nur 100% fliegen wähle ich 30% aus fliegen Sie trozdem auf 100%. Kann mir da vieleicht jemand helfen? Da ich kein Java kann wüsste ich nichteinmal wo ich da anfangen müsste.
Hier mal der Code
Quellcode
- <html>
- <head>
- <meta name="generator" content="HTML Tidy, see www.w3.org">
- <title></title>
- <link rel="stylesheet" type="text/css" href="n/gw.css">
- <meta http-equiv="content-type" content=
- "text/html; charset=ISO-8859-1">
- </head>
- <body text="#FFFFFF" onload="y()" bgcolor="black">
- <center>
- <br>
- {include file="res_bar.thtml"}
- <br>
- <form action="flotten.php" method="post" name="aa">
- <input type="hidden" name="x" value="2">
- <input type="hidden" name="sprit" value="0">
- <input type="hidden" name="load" value="{$fleet.load}">
- <input type="hidden" name="h2need" value="{$fleet.h2need}">
- <input type="hidden" name="entf" value="0">
- {foreach from=$ships item=ship}
- <input type="hidden" name="c{$ship.id}" value="{$ship.count}">
- {/foreach}
- <table width="519">
- <tr>
- <td class="c" colspan="2">Flotte verschicken</td>
- </tr>
- {if $err}
- <tr>
- </tr>
- <tr>
- <th colspan=2><font color=red>{$err}</font></th>
- </tr>
- <tr>
- <td>
- <br>
- </td>
- </tr>
- {/if}
- <tr>
- <th>Ziel</th>
- <th>
- <input size="5" maxlength="3" onkeyup="y()" type="text" name="ft1" value="{$startcoords.gal}"> :
- <input size="5" maxlength="3" onkeyup="y()" type="text" name="ft2" value="{$startcoords.sys}"> :
- <input size="5" maxlength="3" onkeyup="y()" type="text" name="ft3" value="{$startcoords.plan}">
- </th>
- </tr>
- <tr>
- <th>Geschwindigkeit</th>
- <th>
- <select name="s" size="1" onchange="y()">
- <option selected value="10">
- 100%
- </option>
- <option value="9">
- 90%
- </option>
- <option value="8">
- 80%
- </option>
- <option value="7">
- 70%
- </option>
- <option value="6">
- 60%
- </option>
- <option value="5">
- 50%
- </option>
- <option value="4">
- 40%
- </option>
- <option value="3">
- 30%
- </option>
- <option value="2">
- 20%
- </option>
- <option value="1">
- 10%
- </option>
- </select>
- </th>
- </tr>
- <tr>
- <th>Entfernung</th>
- <th>
- <div id="w">
- -
- </div>
- </th>
- </tr>
- <tr>
- <th>Dauer (eine Strecke)</th>
- <th>
- <div id="t">
- -
- </div>
- </th>
- </tr>
- <tr>
- <th>Wasserstoffverbrauch</th>
- <th>
- <div id="z">
- -
- </div>
- </th>
- </tr>
- <tr>
- <th>Max. Geschwindigkeit</th>
- <th>{$fleet.maxspeed}</th>
- </tr>
- <tr>
- <th>Ladekapazität</th>
- <th>{$fleet.load} Einheiten</th>
- </tr>
- <tr>
- <th colspan="2">{*<input type="submit" name="cha" value=
- "Zur Auswahl">*}<input type="submit" value="Weiter" name=
- "dr"></th>
- </tr>
- </table>
- {literal}
- <script type="text/javascript">
- function tp(ac)
- {
- ei=ac+"";
- au="";
- while(ei.length>3)
- {
- au="."+ei.substring(ei.length-3,ei.length)+au;
- ei=ei.substring(0,ei.length-3);
- }
- au=ei+au;
- return au;
- }
- function y()
- {
- a=document.getElementsByName("ft1")[0].value;
- b=document.getElementsByName("ft2")[0].value;
- c=document.getElementsByName("ft3")[0].value;
- p=document.getElementsByName("s")[0].value;
- m=0;
- h=0;
- d="-";
- en="";
- if(a!={/literal}{$startcoords.gal}{literal})
- {
- d=Math.abs((a-{/literal}{$startcoords.gal}{literal})*263000);
- }
- else if(b!={/literal}{$startcoords.sys}{literal})
- {
- d=Math.abs((b-{/literal}{$startcoords.sys}{literal})*1340);
- }
- else if(c!={/literal}{$startcoords.plan}{literal})
- {
- d=1000+Math.abs((c-{/literal}{$startcoords.plan}{literal})*1000);
- }
- if(a<1|a>255|b<1|b>999|c<0|c>12)
- {
- d="-";
- }
- e=Math.round({/literal}{$fleet.h2need}{literal}*d/35000*((p/10)+1)*((p/10)+1))+1;
- s=Math.round(35000/p*Math.sqrt(d*10/{/literal}{$fleet.maxspeed}{literal}));
- if(s>59)
- {
- m=Math.floor(s/60);
- s=s-m*60;
- }
- if(m>59)
- {
- h=Math.floor(m/60);
- m=m-h*60;
- }
- if(s<10)
- {
- s="0"+s;
- }
- if(m<10)
- {
- m="0"+m;
- }
- u="00FF";
- if(e>{/literal}{$fleet.h2max}{literal})
- {
- u="FF00";
- }
- if(e>1)
- {
- en="en";
- }
- if(d=="-")
- {
- document.aa.entf.value=0;
- document.getElementById("w").innerHTML=d;
- document.getElementById("t").innerHTML=d;
- document.getElementById("z").innerHTML=d;
- document.aa.sprit.value=0;
- }
- else
- {
- document.aa.entf.value=d;
- document.getElementById("w").innerHTML=tp(d)+".000 km";
- document.getElementById("t").innerHTML=tp(h)+":"+m+":"+s;
- document.getElementById("z").innerHTML="<font color="+u+"00>"+tp(e)+" Einheit"+en+"<\/font>";
- document.aa.sprit.value=e;
- }
- }
- </script>
- {/literal}
- </form>
- <br>
- <a href="sim.php?u=y&a10=6">Zum Simulator</a>
- </center>
- </body>
- </html>
Hier noch der dazugehörige php code
Quellcode
- // flotten geschwindigkeit
- function formula_transfer($fcoords, $tcoords, $speed, $h2need)
- {
- global $CONFIG;
- $a = $tcoords['gal'];
- $b = $tcoords['sys'];
- $c = $tcoords['plan'];
- $p = 100;
- $d = -1;
- $en = "";
- $fa = $fcoords['gal'];
- $fb = $fcoords['sys'];
- $fc = $fcoords['plan'];
- $a2 = $CONFIG["planets"]["max_gal"];
- $b2 = $CONFIG["planets"]["max_sys"];
- $c2 = $CONFIG["planets"]["max_plan"];
- if ($a != $fa)
- {
- $d = abs(($a - $fa) * 210000);
- }
- else if ($b != $fb)
- {
- $d = abs(($b - $fb) * 1000);
- }
- else if ($c != $fc)
- {
- $d = 1000 + abs(($c - $fc) * 1000);
- }
- if($a < 1 | $a > $a2 | $b<1 | $b > $b2 | $c < 0 | $c > $c2)
- {
- $d = -1;
- }
- $e = round($h2need * $d / 35000 * (($p / 10) + 1) * (($p / 10) + 1)) + 1;
- $s = round(35000 / $p * sqrt($d * 50000 / $speed));
- // $s is time ind secounds
- // $e is h2 needed...
- // $d is distance in Mm (Mega meters) ($d000 km)
- $ret['h2need'] = $e;
- $ret['time'] = $s;
- $ret['dist'] = $d;
- return $ret;
- }
Auf 100 % stimmen die zeiten so gut wie überein
Gruss
Dragon