php strategy game engine Wiki
Status: Abandoned
Brought to you by:
raffa505
You can use PhpSge as Framework, the code is self documented with PhpDoc and an IDE like PhpStorm is recomended.
All Framework files are inside the include folder, and each .php file represents a class.
Each class is usually also a table on the database, all fileds are public.
You can rewrite or extend the PhpSge Framework.
The better way to extend or edit (for example the battle system) is to create a new class and extend the right class!
Why this? Because if you edit the code it is more difficult for you to update your PhpSge.
In this short example I'll show you how to write a new custom battle system withoud editing the original code!
class MyCity extends City {
public static function LoadCity( $_id ){
global $DB;
$query= $DB->query("select * from ".TB_PREFIX."city where id = ".(int)$_id);
if( $query->num_rows == 0 ) throw new Exception("Invalid City id $_id");
$fetch = $query->fetch_array();
return new MyCity( $fetch, new User( $fetch["owner"] ) );
}
public function MyCity( Array $_row, User $_user ){
$this->user = $_user;
$this->id = $_row["id"];
$this->name = $_row["name"];
$this->lastUpdate = $_row["last_update"];
switch( MAP_SYS ){
case 1:
$this->mapPosition= new MapCoordinates( $_row["x"], $_row["y"], $_row["z"] );
break;
case 2:
$this->mapPosition= new MapCoordinates( $_row["x"], $_row["y"] );
break;
}
$this->resources= array();
$this->DoResourceProduction();
}
public function SufferAttacks(){
//your implementation
}
}
coming soon!