/solar27/include/game/classes/research.php
PHP | 98 lines | 59 code | 23 blank | 16 comment | 8 complexity | dd526f609d510e50008ea04271355771 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0, BSD-3-Clause, LGPL-2.0, MIT, GPL-2.0
- <?php
- // Solar Imperium is licensed under GPL2, Check LICENSE.TXT for mode details //
- class Research
- {
- var $DB;
- var $TEMPLATE;
- var $tech_data;
- var $tech_done;
- var $game_id;
- ///////////////////////////////////////////////////////////////////////
- //
- ///////////////////////////////////////////////////////////////////////
- function Research($DB,$TEMPLATE)
- {
- $this->DB = $DB;
- $this->game_id = round($_SESSION["game"]);
- $this->TEMPLATE = $TEMPLATE;
- $this->tech_data = array();
- $this->tech_done = array();
- }
- ///////////////////////////////////////////////////////////////////////
- //
- ///////////////////////////////////////////////////////////////////////
- function load($empire_id)
- {
- $rs = $this->DB->Execute("SELECT * FROM game".$this->game_id."_tb_research_tech");
- if (!$rs) trigger_error($this->DB->ErrorMsg());
- while(!$rs->EOF)
- {
- $this->tech_data[] = $rs->fields;
- $rs->MoveNext();
- }
- $rs = $this->DB->Execute("SELECT * FROM game".$this->game_id."_tb_research_done WHERE empire_id='".intval($empire_id)."'");
- if (!$rs) trigger_error($this->DB->ErrorMsg());
- while(!$rs->EOF)
- {
- $this->tech_done[] = $rs->fields["tech_id"];
- $rs->MoveNext();
- }
- return true;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- ///////////////////////////////////////////////////////////////////////
- function getLevel($level)
- {
- $techs = array();
- for ($i=0;$i<count($this->tech_data);$i++)
- {
- if ($this->tech_data[$i]["level"] == $level) $techs[] = $this->tech_data[$i];
- }
-
- return $techs;
-
- }
- ///////////////////////////////////////////////////////////////////////
- //
- ///////////////////////////////////////////////////////////////////////
- function getTechFromId($tech_id)
- {
- for ($i=0;$i<count($this->tech_data);$i++)
- {
- if ($this->tech_data[$i]["id"] == $tech_id) return $this->tech_data[$i];
- }
-
- return null;
- }
- ///////////////////////////////////////////////////////////////////////
- //
- ///////////////////////////////////////////////////////////////////////
- function getGrowthPoints($planets,$production)
- {
- $points = floor(($planets/100) * $production);
- $points *= CONF_RESEARCH_POINTS_PER_PLANET;
- return $points;
- }
- }
- ?>