Exemple #1
0
function echo_buildinglist()
{
    /*
      Se imprime una lista de naves y defensa en contruccion
    */
    global $lang, $user, $planetrow, $pricelist;
    //Array del b_hangar_id
    $b_hangar_id = explode(';', $planetrow['b_hangar_id']);
    $a = $b = $c = "";
    foreach ($b_hangar_id as $n => $array) {
        if ($array != '') {
            $array = explode(',', $array);
            //calculamos el tiempo
            $time = get_building_time($user, $planetrow, $array[0]);
            $totaltime += $time * $array[1];
            $c .= "{$time},";
            $b .= "'{$lang['tech'][$array[0]]}',";
            $a .= "{$array[1]},";
        }
    }
    $parse = $lang;
    $parse['a'] = $a;
    $parse['b'] = $b;
    $parse['c'] = $c;
    $parse['b_hangar_id_plus'] = $planetrow['b_hangar'];
    $parse['pretty_time_b_hangar'] = pretty_time($totaltime - $planetrow['b_hangar']);
    // //$planetrow['last_update']
    $text .= parsetemplate(gettemplate('buildings_script'), $parse);
    return $text;
}
Exemple #2
0
function echo_buildinglist()
{
    global $userrow, $planetrow, $pricelist;
    echo "<br>Producción actual: <div id=bx class=z></div>";
    //Array del b_hangar_id
    $b_hangar_id = explode(';', $planetrow['b_hangar_id']);
    $a = $b = $c = "";
    foreach ($b_hangar_id as $n => $array) {
        if ($array != '') {
            $array = explode(',', $array);
            //calculamos el tiempo
            $time = get_building_time($userrow, $planetrow, $array[0]);
            $totaltime += $time * $array[1];
            $c .= "{$time},";
            $b .= "'{$pricelist[$array[0]][name]}',";
            $a .= "{$array[1]},";
        }
    }
    echo "\r\n<script  type=\"text/javascript\">\r\n  v = new Date();\r\n  p = 0;\r\n  g = {$planetrow[b_hangar]};\r\n  s = 0;\r\n  hs = 0;\r\n  of = 1;\r\n  c = new Array({$c}'');\r\n  b = new Array({$b}'');\r\n  a = new Array({$a}'');\r\n  aa = 'Completado';\r\n";
    echo <<<HTML
  function t() {
    if (hs == 0) {
      xd();
      hs = 1;
    }
    n = new Date();
    s = c[p]-g-Math.round((n.getTime()-v.getTime())/1000.);
    s = Math.round(s);
    m = 0;
    h = 0;
    if (s < 0) {
      a[p]--;
      xd();
      if (a[p] <= 0) {
        p++;
        xd();
      }
      g = 0;
      v = new Date();
      s=0;
    }
    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;
    }
    if (p > b.length - 2) {
      document.getElementById("bx").innerHTML=aa ;
    } else {
      document.getElementById("bx").innerHTML=b[p]+" "+h+":"+m+":"+s;
    }
    window.setTimeout("t();", 200);
  }
  
  
  
  function xd() {
    while (document.Atr.auftr.length > 0) {
      document.Atr.auftr.options[document.Atr.auftr.length-1] = null;
    }
    if (p > b.length - 2) {
      document.Atr.auftr.options[document.Atr.auftr.length] = new Option(aa);
    }
    for (iv = p; iv <= b.length - 2; iv++) {
      if (a[iv] < 2) {
        ae=" ";
      }else{
        ae=" ";
      }
      if (iv == p) {
        act = " (En funcionamiento)";
      }else{
        act = "";
      }
      document.Atr.auftr.options[document.Atr.auftr.length] = new Option(a[iv]+ae+" \\""+b[iv]+"\\""+act, iv + of);
    }
  }
  
  window.onload = t;
  </script>
  <br>
  <form name="Atr" method="get" action="buildings">
  <input type="hidden" name="mode" value="fleet">
  <table width="530">
   <tr>
      <td class="c" >Trabajos por hacer</td>
  
   </tr>
   <tr>
    <th ><select name="auftr" size="10"></select></th>
     </tr>
   <tr>
    <td class="c" ></td>
   </tr>
  </table>
  </form>
  Tiempo total restante: 
HTML;
    echo pretty_time($totaltime - $planetrow['b_hangar']) . "<br></center>";
}
Exemple #3
0
 			  Mina de Cristal: 48*1,6^(nivel-1) Metal y 24*1,6^(nivel-1) Cristal
 			  Sintetizador de Deuterio: 225*1,5^(nivel-1) Metal y 75*1,5^(Nivel-1) Cristal
 			  Planta energía Solar: 75*1,5^(nivel-1) Metal y 30*1,5^(Nivel-1) cristal
 			  Planta Fusion: 900*1,8^(nivel-1) Metal y 360*1,8^(Nivel-1) cristal y 180*1,8^(Nivel-1) Deuterio
 			  tecnología Gravitón: *3 por Nivel.
   Todas las demás investigaciones y edificios *2^Nivel 
 */
 $is_buyeable = echo_price($userrow, $planetrow, $i);
 /*
   Calculo del tiempo de produccion
   [(Cris+Met)/2500]*[1/(Nivel f.robots+1)]* 0,5^NivelFabrica Nanos. 
 */
 //$time = ((($cost_crystal )+($cost_metal)) / 2500) * (1 / ($planetrow[$resource['14']] + 1)) * pow(0.5,$planetrow[$resource['15']]);
 //metodo temporal para mostrar el formato tiempo...
 //$time = ($time *60*60);
 $time = get_building_time($userrow, $planetrow, $i);
 echo_building_time($time);
 echo "<td class=k>";
 if (!$building) {
     if ($userrow["b_tech_planet"] != 0 && $i == 31) {
         //en caso de que sea el laboratorio y se este investigando algo.
         echo "<font color=#FF0000>Investigando</font>";
         //Muestra la opcion a elegir para construir o ampliar un edificio
     } elseif ($planetrow[$resource[$i]] == 0 && $planetrow["field_current"] < $planetrow["field_max"] && $is_buyeable) {
         echo "<a href=\"?bau={$i}\"><font color=#00FF00>Construir</font></a>";
     } elseif ($planetrow["field_current"] < $planetrow["field_max"] && $is_buyeable) {
         $nplus = $planetrow[$resource[$i]] + 1;
         echo "<a href=\"?bau={$i}\"><font color=#00FF00>Ampliar<br> al nivel {$nplus}</font></a>";
     } elseif ($planetrow["field_current"] < $planetrow["field_max"] && !$is_buyeable) {
         if ($planetrow[$resource[$i]] == 0) {
             echo "<font color=#FF0000>Construir</font>";
Exemple #4
0
function calculate_resources_planet(&$planet)
{
    global $resource, $game_config;
    /*
      calculate_resources_planet calcula y suma los recursos de un planeta dependiendo del ultimo acceso
      al planeta.
      El row de la base de datos last_update indica el tiempo inicial desde que se ejecuto el
      ultimo acceso al calculo de recursos.
      Cualquier usuario puede actualizar los recursos de otro planeta.
      Eso hace que se actualize sin la necesidad de que el due� ingrese a su cuenta.
    */
    //Entonces calculamos el tiempo de inactividad desde la ultima actualizacion del planeta.
    $left_time = time() - $planet['last_update'];
    $planet['last_update'] = time();
    //($left_time + $planet['last_update']);//$total_time va a ser el nuevo last_update
    //if($planet['energy_max']>=0){
    /*
      y ahora se agregan los recursos.
      Consideramos que dependiendo de la energia disponible. el modificador correspondiente a la produccion de energia
      //produccion total
    */
    if ($planet['energy_max'] == 0) {
        //en caso de que la energia maxima sea nula y la energia maxima sea mayor a cero.
        $planet['metal_perhour'] = 0;
        $planet['crystal_perhour'] = $game_config['crystal_basic_income'];
        $planet['deuterium_perhour'] = $game_config['deuterium_basic_income'];
        $production_level = 100;
    } elseif ($planet["energy_max"] >= $planet["energy_used"]) {
        //caso normal
        $production_level = 100;
    } else {
        //En caso de que la energya libre sea mayor que la maxima
        $production_level = floor($planet['energy_max'] / $planet['energy_used'] * 100);
    }
    //una pequeña comprobacion
    if ($production_level > 100) {
        $production_level = 100;
    }
    if ($production_level < 0) {
        $production_level = 0;
    }
    //
    //Se suman los recursos
    //
    //Sumamos el metal disponigle
    if ($planet['metal'] < $planet['metal_max'] + $planet['metal_max'] * 0.1) {
        $planet['metal'] += $left_time * ($planet['metal_perhour'] / 3600) * $game_config['resource_multiplier'] * (0.01 * $production_level);
        $planet['metal'] += $left_time * ($game_config['metal_basic_income'] * $game_config['resource_multiplier'] / 3600);
    }
    //Sumamos el crystal
    if ($planet['crystal'] < $planet['crystal_max'] + $planet['crystal_max'] * 0.1) {
        $planet['crystal'] += $left_time * ($planet['crystal_perhour'] / 3600) * $game_config['resource_multiplier'] * (0.01 * $production_level);
        $planet['crystal'] += $left_time * ($game_config['crystal_basic_income'] * $game_config['resource_multiplier'] / 3600);
    }
    //sumamos el deuterio disponible
    if ($planet['deuterium'] < $planet['deuterium_max'] + $planet['deuterium_max'] * 0.1) {
        $planet['deuterium'] += $left_time * ($planet['deuterium_perhour'] / 3600) * $game_config['resource_multiplier'] * (0.01 * $production_level);
        $planet['deuterium'] += $left_time * ($game_config['deuterium_basic_income'] * $game_config['resource_multiplier'] / 3600);
    }
    /*
      Tambien se debe actualizar el tema del hangar...
    */
    if ($planet['b_hangar_id'] != '') {
        $planet['b_hangar'] += $left_time;
        $b_hangar_id = explode(';', $planet['b_hangar_id']);
        foreach ($b_hangar_id as $n => $array) {
            if ($array != '') {
                $array = explode(',', $array);
                $buildArray[$n] = array($array[0], $array[1], get_building_time('', $planet, $array[0]));
            }
        }
        $planet['b_hangar_id'] = '';
        /*
          fixed. el loop revisaba todas las arrays. Pero las que tenian
          menor presio, se quitaban, sin importar el orden.
        */
        $endtaillist = false;
        foreach ($buildArray as $a => $b) {
            while ($planet['b_hangar'] >= $b[2] && !$endtaillist) {
                if ($b[1] > 0) {
                    $planet['b_hangar'] -= $b[2];
                    $summon[$b[0]]++;
                    $planet[$resource[$b[0]]]++;
                    $b[1]--;
                } else {
                    $endtaillist = true;
                    //Fix, no se respetaba la lista...
                    break;
                    //Fix, cuando queda tiempo de sobra. se creaba loop
                }
            }
            if ($b[1] != 0) {
                $planet['b_hangar_id'] .= "{$b[0]},{$b[1]};";
            }
        }
    } else {
        $planet['b_hangar'] = 0;
    }
    //despues se actualiza el $planet y se actualiza la base de datos con
    //el nuevo last_update
    $query = "UPDATE {{table}} SET\n\tmetal='{$planet['metal']}',\n\tcrystal='{$planet['crystal']}',\n\tdeuterium='{$planet['deuterium']}',\n\tlast_update='{$planet['last_update']}',\n\tb_hangar_id='{$planet['b_hangar_id']}',";
    //Para hacer las consultas, mas precisas
    if (isset($summon)) {
        foreach ($summon as $a => $b) {
            $query .= "{$resource[$a]}='{$planet[$resource[$a]]}', ";
        }
    }
    $query .= "b_hangar='{$planet['b_hangar']}' WHERE id={$planet['id']}";
    doquery($query, 'planets');
    touchPlanet($planet);
    //para las flotas
}
Exemple #5
0
function calculate_resources_planet(&$planet)
{
    global $resource;
    /*
      calculate_resources_planet calcula y suma los recursos de un planeta dependiendo del ultimo acceso
      al planeta.
      El row de la base de datos last_update indica el tiempo inicial desde que se ejecuto el
      ultimo acceso al calculo de recursos.
      Cualquier usuario puede actualizar los recursos de otro planeta.
      Eso hace que se actualize sin la necesidad de que el dueño ingrese a su cuenta.
    */
    //Entonces calculamos el tiempo de inactividad desde la ultima actualizacion del planeta.
    $left_time = time() - $planet['last_update'];
    $total_time = $left_time + $planet['last_update'];
    //$total_time va a ser el nuevo last_update
    if ($planet['energy_free'] >= 0) {
        //y ahora se agregan los recursos.
        if ($planet['metal'] < $planet['metal_max'] + $planet['metal_max'] * 0.25) {
            $planet['metal'] = $planet['metal'] + $left_time * ($planet['metal_perhour'] / 60);
        }
        if ($planet['crystal'] < $planet['crystal_max'] + $planet['crystal_max'] * 0.25) {
            $planet['crystal'] = $planet['crystal'] + $left_time * ($planet['crystal_perhour'] / 60);
        }
        if ($planet['deuterium'] < $planet['deuterium_max'] + $planet['deuterium_max'] * 0.25) {
            $planet['deuterium'] = $planet['deuterium'] + $left_time * ($planet['deuterium_perhour'] / 60);
        }
    }
    /*
      Tambien se debe actualizar el tema del hangar...
    */
    if ($planet['b_hangar_id'] != '') {
        $planet['b_hangar'] += $left_time;
        $b_hangar_id = explode(';', $planet['b_hangar_id']);
        foreach ($b_hangar_id as $n => $array) {
            if ($array != '') {
                $array = explode(',', $array);
                $buildArray[$n] = array($array[0], $array[1], get_building_time('', $planet, $array[0]));
            }
        }
        $planet['b_hangar_id'] = '';
        foreach ($buildArray as $a => $b) {
            while ($planet['b_hangar'] >= $b[2]) {
                if ($b[1] > 0) {
                    $planet['b_hangar'] -= $b[2];
                    $summon[$b[0]]++;
                    $planet[$resource[$b[0]]]++;
                    $b[1]--;
                } else {
                    break;
                }
                //Fix, cuando queda tiempo de sobra. se creaba loop
            }
            if ($b[1] != 0) {
                $planet['b_hangar_id'] .= "{$b[0]},{$b[1]};";
            }
        }
    } else {
        $planet['b_hangar'] = 0;
    }
    //despues se actualiza el $planet y se actualiza la base de datos con el nuevo last_update
    $query = "UPDATE {{table}} SET\r\n  metal='{$planet['metal']}',\r\n  crystal='{$planet['crystal']}',\r\n  deuterium='{$planet['deuterium']}',\r\n  last_update={$total_time},\r\n  b_hangar_id='{$planet['b_hangar_id']}',";
    //Para hacer las consultas, mas precisas
    if (isset($summon)) {
        foreach ($summon as $a => $b) {
            $query .= "{$resource[$a]}='{$planet[$resource[$a]]}', ";
        }
    }
    $query .= "b_hangar='{$planet['b_hangar']}' WHERE id={$planet['id']}";
    doquery($query, 'planets');
}