Skip to content

Instantly share code, notes, and snippets.

@pedrofaria
Created September 8, 2010 21:02
Show Gist options
  • Save pedrofaria/570827 to your computer and use it in GitHub Desktop.
Save pedrofaria/570827 to your computer and use it in GitHub Desktop.
<?php
class Awproxy_Map {
public static function load() {
$proxy = Awproxy::instance();
$data = $proxy->get('/0/Map/Coordinates.php');
$proxy->check_session($data);
$map = new StdClass;
$xmap = $data->body->table[1]->tr->td->table;
// Range
$n_col = $xmap->tr[0]->count();
$n_row = $xmap->tr->count();
$map->range = array(
'min_x' => (string) $xmap->tr[0]->td[0],
'max_x' => (string) $xmap->tr[0]->td[$n_col-2],
'min_y' => (string) $xmap->tr[1]->td[$n_col-1],
'max_y' => (string) $xmap->tr[$n_row-1]->td[$n_col-1],
);
// Systems
$systems = $xmap->xpath("//img[@src!='blank.gif']");
$map->sys = array();
foreach ($systems as $sys) {
$title = (string) $sys['title'];
preg_match('/^(.*?) \((-?\d+)\/(-?\d+)\)\r?\nID:(\d+)\r?\nLevel: (\d+)/s', $title, $rs);
$map->sys[$rs[4]] = array(
'name' => $rs[1],
'x' => $rs[2],
'y' => $rs[3],
'id' => $rs[4],
'level' => $rs[5],
);
}
return $map;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment