Example #1
0
 /**
  * Load ships and return_tick information from the db.
  *  
  * @return unknown_type
  */
 public function load_fleet()
 {
     // load all ships from the db if not done
     if (!isset($this->ships)) {
         // 1 - get all ship names
         $ships = $this->ship2column($this->fleet_id);
         // prepare ships array (in case captain moron didn't paste anything yet and the fleet
         // query will be returned empty)
         $this->ships = array();
         // 2 - construct sql
         $sql = " SELECT";
         foreach ($ships as $i => $ship) {
             if ($i == count($ships) - 1) {
                 $sql = $sql . " mf." . $ship;
             } else {
                 $sql = $sql . " mf." . $ship . ", ";
             }
         }
         $sql = $sql . " FROM " . EVO_PREFIX . "_member_fleets mf";
         $sql = $sql . " WHERE mf.user_id = " . (int) $this->db->real_escape_string($this->user_id) . ";";
         // 3 - get amount of these ships from db and set in object
         // 4 - append each ship object to the $this->ships array
         if ($result = $this->db->query($sql)) {
             // do we actually retrieve a row?
             if ($result->num_rows != 0) {
                 // fetch an associative array instead of an object because we can index the array by
                 // constructing the keyname from the list of ship types
                 $row = $result->fetch_assoc();
                 foreach ($row as $i => $amount) {
                     $ship_name = substr(ucwords($i), 0, count($i) - 3);
                     // e.g., "demeter_0" becomes "Demeter"
                     $ship = new ship($ship_name);
                     // create new ship object
                     $ship->set_amount($amount);
                     // set amount of this ship
                     $this->ships[] = $ship;
                     // append to array of ships
                 }
             }
         } else {
             echo $this->db->error;
             exit;
         }
     }
     // get return tick from the db if not set
     if (!isset($this->return_tick)) {
         // if we are in the base fleet; return 0
         if ($this->fleet_id == 0) {
             $this->return_tick = 0;
         } else {
             $sql = "SELECT mf.return_tick_" . $this->fleet_id . " as return_tick";
             $sql = $sql . " FROM " . EVO_PREFIX . "_member_fleets mf";
             $sql = $sql . " WHERE mf.user_id = " . (int) $this->db->real_escape_string($this->user_id) . ";";
             if ($result = $this->db->query($sql)) {
                 // if no row exists, set return tick to 0
                 if ($result->num_rows == 0) {
                     $this->return_tick = 0;
                 } else {
                     $row = $result->fetch_object();
                     $this->return_tick = $row->return_tick;
                 }
             } else {
                 echo $this->db->error;
                 exit;
             }
         }
     }
 }
Example #2
0
		<title>Dat board</title>
		<link rel="stylesheet" type="text/css" href="board.css">
	</head>
<body>

<h1>TyE boafdgkjrde.</h1>

	<table>

	<script type="text/javascript">

		document.write("<p>plop</p>");

		<?php 
include_once "Ship.class.php";
$ship = new ship(array('posX' => 34, 'posY' => '20', 'sprite' => "../cruseship.jpg"));
?>

		var X = <?php 
$ship->getPosX;
?>
;
		var Y = <?php 
$ship->getPosY;
?>
;

		for (var j=0; j<100; j++) {
			document.write("<tr>");
			for (var i=0; i<150; i++) {
				if ( X == i &&  Y == j)
Example #3
0
 /**
  * Process a missions page parse.
  * 
  * @return (nothing)
  */
 private function process_missions()
 {
     // 0 - regular expressions
     // a - ships
     $re_ships = "/(.*)";
     $re_ships = $re_ships . "\\s+(Fighter|Corvette|Frigate|Destroyer|Cruiser|Battleship)";
     // class
     $re_ships = $re_ships . "\\s+(Fighter|Corvette|Frigate|Destroyer|Cruiser|Battleship|Asteroids|Structures|-)";
     // t1
     $re_ships = $re_ships . "\\s+(Fighter|Corvette|Frigate|Destroyer|Cruiser|Battleship|-)";
     // t2
     $re_ships = $re_ships . "\\s+(Fighter|Corvette|Frigate|Destroyer|Cruiser|Battleship|-)";
     // t3
     $re_ships = $re_ships . "\\s+(Normal|Emp|Cloak|Steal|Pod|Structure Killer)";
     // type
     $re_ships = $re_ships . "\\s+(\\d+)/";
     // b - various tt regex's that can be applied
     $re_1 = "/Galaxy\\s+ETA:\\s+(\\d+)\\s+ticks,\\s+Cluster\\s+Defence\\s+ETA:\\s+(\\d+)\\s+ticks,\\s+Universe\\s+ETA:\\s+(\\d+)\\s+ticks,\\s+Alliance\\s+ETA:\\s+(\\d+)\\s+ticks/";
     $re_2 = "/Launching\\s+in\\s+tick\\s+(\\d+),\\s+arrival\\s+in\\s+tick\\s+(\\d+)/";
     $re_3 = "/Return\\s+ETA:\\s+(\\d+)/";
     $re_4 = "/ETA:\\s+(\\d+),\\s+Return\\s+ETA:\\s+(\\d+)/";
     // 1 - explode string into an array
     $lines = explode("\r\n", $this->text);
     // 2 - check each array element for "Fleet	Location	Target (eta)	Mission"
     // 		if this matches, remember array element where the match occured (throw into $blocks_begin array)
     $limits = array();
     foreach ($lines as $i => $line) {
         $a = preg_match('/Fleet\\s+Location\\s+Target\\s+\\(eta\\)\\s+Mission/', $line);
         if ($a) {
             $limits[] = $i;
         }
     }
     // do all the following for every fleet block we find
     for ($j = 0; $j < 4; $j++) {
         // 3 - cut array apart
         if ($j == 3) {
             $fleet_array = array_slice($lines, $limits[$j]);
         } else {
             $fleet_array = array_slice($lines, $limits[$j], $limits[$j + 1] - $limits[$j]);
         }
         // 4 - implode the blocks
         $fleet_string = implode("\r\n", $fleet_array);
         // 5 - apply regular expressions for ships
         preg_match_all($re_ships, $fleet_string, $matches);
         // 6 - process ships
         $ships_name = $matches[1];
         $ships_amount = $matches[7];
         // build an array of ( ['shipname'] => $number_of_ships )
         $ships = array();
         foreach ($ships_name as $k => $ship_name) {
             $ship = new ship(trim($ship_name));
             // new ship
             $ship->set_amount($ships_amount[$k]);
             // set amount of ships
             $ships[] = $ship;
             // append to array
         }
         $mf = new member_fleet($j, $this->user_id);
         $mf->set_ships_in_fleet($ships);
         // 7 - apply regular expressions to determine return tick;
         // 		default value is the current_tick
         $return_tick = $this->tick;
         if (preg_match($re_4, $fleet_string, $match)) {
             $eta = $match[1];
             $return_eta = $match[2];
             $return_tick = $eta + $return_eta + $eta + $this->tick;
             $eta_bonus = $this->compute_eta_bonus($ships, $eta + $return_eta);
         } elseif (preg_match($re_3, $fleet_string, $match)) {
             $return_eta = $match[1];
             $return_tick = $return_eta + $this->tick;
         } elseif (preg_match($re_2, $fleet_string, $match)) {
             $launch = $match[1];
             $arrival = $match[2];
             $return_tick = $arrival + ($arrival - $launch);
             $eta_bonus = $this->compute_eta_bonus($ships, $arrival - $launch);
         } elseif (preg_match($re_1, $fleet_string, $match)) {
             $return_tick = $this->tick;
             $eta_bonus = $this->compute_eta_bonus($ships, $match[3]);
         }
         // 8 - save return tick and fleets
         $mf->set_return_tick($return_tick);
         $mf->save_fleet();
         // 9 - save eta bonus
         if (isset($eta_bonus)) {
             $member = new member($this->user_id);
             $member->set_eta_bonus($eta_bonus);
         }
         unset($ships);
         unset($mf);
     }
     if (isset($eta_bonus)) {
         $this->feedback = "Parsed Missions for " . $this->coords . " at Tick " . $this->tick . ".<br /><br />";
         $this->feedback = $this->feedback . "Detected ETA Bonus: " . $eta_bonus . ".";
     } else {
         $this->feedback = "Parsed Missions for " . $this->coords . " at Tick " . $this->tick . ".";
     }
 }
Example #4
0
	<head>
		<title>Dat board</title>
		<link rel="stylesheet" type="text/css" href="board.css">
	</head>
<body>

<h1>TyE boafdgkjrde.</h1>

	<table>

	<script type="text/javascript">


		<?php 
include_once "Ship.class.php";
$ship = new ship(array('name' => "\"Destructor\"", 'posX' => 54, 'posY' => 10, 'sprite' => "\"../cruseship.jpg\"", 'hull' => 10, 'power' => 5, 'speed' => 15, 'flex' => 3, 'shield' => '100'));
?>

		var nlt = "&#013;";
		var nlh = "<br>";
		var X = <?php 
print $ship->getPosX();
?>
 ;
		var Y = <?php 
print $ship->getPosY();
?>
 ;
		var URL = <?php 
echo $ship->getSprite();
?>