function login() { $this->intentos = 0; do { $this->reqLogin(); if ($this->error && $this->intentos > 0) { $tiempo_espera = $this->tiempoEspera($this->intentos); report('err', "ERROR. Login fallido. Intentando volver a loguear en " . segundosCadenaTiempo($tiempo_espera) . "..."); sleep($tiempo_espera); } } while ($this->error); report('act', "Login satisfactorio."); }
public function inicializar() { //Escaneo de actividad e inicialización $colas = $this->coordinator->escanearColas(); if ($colas["construcción"] > 0) { $this->builder->finCola = time() + $colas["construcción"]; report('wait', 'Ya hay algo construyéndose hasta dentro de ' . segundosCadenaTiempo($colas["construcción"]) . "."); } if ($colas["investigación"] > 0) { $this->researcher->finCola = time() + $colas["investigación"]; report('wait', 'Ya hay algo investigándose hasta dentro de ' . segundosCadenaTiempo($colas["investigación"]) . "."); } $this->commander->inicializar($this->coordenadas); }
function mandarFlota($flota, $destino, $mision) { $this->navesSalientes = $flota->naves; if (!isset($mision["velocidad"])) { $mision["velocidad"] = 10; } $pagina2 = $this->elegirNaves(); if (!$this->pasoFlotaFallido($pagina2)) { $pagina3 = $this->elegirDestino($destino, $mision["velocidad"]); if (!$this->pasoFlotaFallido($pagina3)) { $duracion = $this->calculoDuracion($pagina3); //TODO: Calcular tiempos de llegada y vuelta $token = $this->leerToken($pagina3); $campos = $this->elegirMision($destino, $mision, $token); $paginaF = $this->despegue($campos); if (!$this->pasoFlotaFallido($paginaF)) { $datosMision = array("salida" => time(), "llegada" => time() + $duracion, "vuelta" => time() + 2 * $duracion); $stringCoords = $destino[0] . ":" . $destino[1] . ":" . $destino[2]; report('act', "Mandando flota a [" . $stringCoords . "] que llegará a su destino en " . segundosCadenaTiempo($duracion) . " y volverá aquí en " . segundosCadenaTiempo(2 * $duracion) . "."); return $datosMision; } else { report('err', "No pudo completarse el envío de flota"); die; } } else { report('err', "Hubo un problema eligiendo destino"); die; } } else { report('err', "Hubo un problema eligiendo naves"); die; } }