PageRenderTime 23ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/eve/apiCorpClasses.php

http://ooe.googlecode.com/
PHP | 213 lines | 182 code | 31 blank | 0 comment | 26 complexity | 99e33a102bd8aa5169c0613689d38170 MD5 | raw file
  1. <?php
  2. class eveCorporationMember {
  3. var $characterID = 0;
  4. var $name = '';
  5. var $startDateTime = 0;
  6. var $baseID = 0;
  7. var $title = '';
  8. var $logonDateTime = 0;
  9. var $logoffDateTime = 0;
  10. var $locationID = 0;
  11. var $shipTypeID = 0;
  12. var $roles = 0;
  13. var $grantableRoles = 0;
  14. var $locationName = '';
  15. var $roleList = array();
  16. var $base = null;
  17. var $location = null;
  18. var $ship = null;
  19. var $db;
  20. function eveCorporationMember($acc, $corp, $db, $member) {
  21. $this->db = $db;
  22. $this->characterID = (int)$member['characterID'];
  23. $this->name = (string)$member['name'];
  24. $this->startDateTime = strtotime((string)$member['startDateTime']) + $acc->timeOffset;
  25. $this->baseID = (int)$member['baseID'];
  26. $this->title = (string)$member['title'];
  27. $this->logonDateTime = strtotime((string)$member['logonDateTime']) + $acc->timeOffset;
  28. $this->logoffDateTime = strtotime((string)$member['logoffDateTime']) + $acc->timeOffset;
  29. $this->locationID = (int)$member['locationID'];
  30. $this->shipTypeID = (int)$member['shipTypeID'];
  31. $this->roles = (int)$member['roles'];
  32. $this->grantableRoles = (int)$member['grantableRoles'];
  33. $this->setRoles($db);
  34. }
  35. function setRoles() {
  36. $corpRoles = $this->db->corpRoleList();
  37. for ($i = 0; $i < count($corpRoles); $i++) {
  38. if ($this->roles & (int)$corpRoles[$i]['rolebit']) {
  39. $this->roleList[$corpRoles[$i]['rolename']] = $corpRoles[$i];
  40. }
  41. }
  42. }
  43. function hasRole($roleName) {
  44. return isset($this->roleList[$roleName]);
  45. }
  46. function loadDetail() {
  47. if ($this->baseID > 0)
  48. $this->base = $this->db->eveStation($this->baseID);
  49. if ($this->locationID > 0) {
  50. $this->location = $this->db->eveStation($this->locationID);
  51. $this->locationName = $this->location->stationname;
  52. if ($this->location->stationid == 0) {
  53. $this->location = $this->db->eveSolarSystem($this->locationID);
  54. $this->locationName = $this->location->solarsystemname;
  55. }
  56. }
  57. if ($this->shipTypeID > 0)
  58. $this->ship = $this->db->eveItem($this->shipTypeID);
  59. }
  60. }
  61. class eveStarbase {
  62. var $itemID = 0;
  63. var $typeID = 0;
  64. var $locationID = 0;
  65. var $moonID = 0;
  66. var $state = 0;
  67. var $stateTimestamp = 0;
  68. var $onlineTimestamp = 0;
  69. var $generalSettings = array(
  70. 'usageFlags' => 0,
  71. 'deployFlags' => 0,
  72. 'allowCorporationMembers' => 0,
  73. 'allowAllianceMembers' => 0,
  74. 'claimSovereignty' => 0,
  75. );
  76. var $combatSettings = array(
  77. 'onStandingDrop' => array('enabled' => 0, 'standing' => 0),
  78. 'onStatusDrop' => array('enabled' => 0, 'standing' => 0),
  79. 'onAggression' => 0,
  80. 'onCorporationWar' => 0,
  81. );
  82. var $fuelRequired = array();
  83. var $fuel = array();
  84. var $solarSystem = null;
  85. var $moon = null;
  86. var $tower = null;
  87. var $remainingTime = 0;
  88. function eveStarbase($acc, $db, $starbase, $corp, $loadDetail = false) {
  89. $this->itemID = (int)$starbase['itemID'];
  90. $this->typeID = (int)$starbase['typeID'];
  91. $this->locationID = (int)$starbase['locationID'];
  92. $this->moonID = (int)$starbase['moonID'];
  93. $this->state = (int)$starbase['state'];
  94. $this->stateTimestamp = strtotime((string)$starbase['stateTimestamp']) + $acc->timeOffset;
  95. $this->onlineTimestamp = strtotime((string)$starbase['onlineTimestamp']) + $acc->timeOffset;
  96. $this->solarSystem = $db->eveSolarSystem($this->locationID);
  97. $this->moon = $db->eveCelestial($this->moonID);
  98. $this->tower = $db->eveItem($this->typeID);
  99. if ($loadDetail) {
  100. $this->loadDetail($db, $corp);
  101. }
  102. }
  103. function loadFuelRequired($db) {
  104. $tmpFuel = $db->eveFuelRequirements($this->typeID);
  105. for ($i = 0; $i < count($tmpFuel); $i++) {
  106. if (((int)$tmpFuel[$i]['factionid'] == 0)
  107. || (((int)$tmpFuel[$i]['factionid'] > 0) && ((int)$tmpFuel[$i]['factionid'] == (int)$this->solarSystem->factionid))) {
  108. $this->fuelRequired[] = $tmpFuel[$i];
  109. }
  110. $this->setupFuel($this->fuelRequired[count($this->fuelRequired)-1]['resource']->typeid, 0);
  111. }
  112. }
  113. function loadDetail($db, $corp) {
  114. $this->loadFuelRequired($db);
  115. $starbaseData = new apiRequest('corp/StarbaseDetail.xml.aspx', array($corp->account->userId,
  116. $corp->account->apiKey,
  117. $corp->character->characterID),
  118. array('version' => 2, 'itemID' => $this->itemID));
  119. if ($starbaseData->data) {
  120. if (!$starbaseData->data->error) {
  121. $this->state = (int)$starbaseData->data->result->state;
  122. $this->stateTimestamp = strtotime((string)$starbaseData->data->result->stateTimestamp) + $acc->timeOffset;
  123. $this->onlineTimestamp = strtotime((string)$starbaseData->data->result->onlineTimestamp) + $acc->timeOffset;
  124. $this->generalSettings['usageFlags'] = (int)$starbaseData->data->result->generalSettings->usageFlags;
  125. $this->generalSettings['deployFlags'] = (int)$starbaseData->data->result->generalSettings->deployFlags;
  126. $this->generalSettings['allowCorporationMembers'] = (int)$starbaseData->data->result->generalSettings->allowCorporationMembers;
  127. $this->generalSettings['allowAllianceMembers'] = (int)$starbaseData->data->result->generalSettings->allowAllianceMembers;
  128. $this->generalSettings['claimSovereignty'] = (int)$starbaseData->data->result->generalSettings->claimSovereignty;
  129. $this->combatSettings['onStandingDrop']['enabled'] = (int)$starbaseData->data->result->combatSettings->onStandingDrop['enabled'];
  130. $this->combatSettings['onStandingDrop']['standing'] = (float)$starbaseData->data->result->combatSettings->onStandingDrop['standing'];
  131. $this->combatSettings['onStatusDrop']['enabled'] = (int)$starbaseData->data->result->combatSettings->onStatusDrop['enabled'];
  132. $this->combatSettings['onStatusDrop']['standing'] = (float)$starbaseData->data->result->combatSettings->onStatusDrop['standing'];
  133. $this->combatSettings['onAggression'] = (int)$starbaseData->data->result->combatSettings->onAggression['enabled'];
  134. $this->combatSettings['onCorporationWar'] = (int)$starbaseData->data->result->combatSettings->onCorporationWar['enabled'];
  135. foreach ($starbaseData->data->result->rowset as $rowset) {
  136. if ($rowset['name'] == 'fuel') {
  137. foreach ($rowset->row as $fuel) {
  138. $this->setupFuel((int)$fuel['typeID'], (int)$fuel['quantity']);
  139. }
  140. }
  141. }
  142. } else {
  143. apiError($starbaseData->data->error);
  144. }
  145. }
  146. if (in_array($this->state, array(3)))
  147. $this->remainingTime = ($this->stateTimestamp-$acc->timeOffset) - $GLOBALS['eveTime'];
  148. else if (in_array($this->state, array(2, 4)))
  149. $this->remainingTime = ($this->onlineTimestamp-$acc->timeOffset) - $GLOBALS['eveTime'];
  150. }
  151. function setupFuel($fuelTypeID, $currentQty) {
  152. for ($i = 0; $i < count($this->fuelRequired); $i++) {
  153. if ($this->fuelRequired[$i]['resource']->typeid == $fuelTypeID) {
  154. $this->fuelRequired[$i]['current'] = array(
  155. 'quantity' => $currentQty,
  156. 'value' => 0,
  157. 'volume' => $currentQty * $this->fuelRequired[$i]['resource']->volume,
  158. 'remaining' => ($currentQty / $this->fuelRequired[$i]['quantity']) * 60 * 60,
  159. );
  160. $this->fuelRequired[$i]['7days'] = array(
  161. 'quantity' => $this->fuelRequired[$i]['quantity'] * (24*7),
  162. 'value' => 0,
  163. 'volume' => $this->fuelRequired[$i]['quantity'] * (24*7) * $this->fuelRequired[$i]['resource']->volume,
  164. );
  165. $this->fuelRequired[$i]['30days'] = array(
  166. 'quantity' => $this->fuelRequired[$i]['quantity'] * (24*30),
  167. 'value' => 0,
  168. 'volume' => $this->fuelRequired[$i]['quantity'] * (24*30) * $this->fuelRequired[$i]['resource']->volume,
  169. );
  170. }
  171. }
  172. }
  173. function setupFuelPricing($regionID = 0) {
  174. for ($i = 0; $i < count($this->fuelRequired); $i++) {
  175. $this->fuelRequired[$i]['resource']->getPricing($regionID);
  176. $this->fuelRequired[$i]['current']['value'] = $this->fuelRequired[$i]['current']['quantity'] * $this->fuelRequired[$i]['resource']->pricing->avgSell;
  177. $this->fuelRequired[$i]['7days']['value'] = $this->fuelRequired[$i]['7days']['quantity'] * $this->fuelRequired[$i]['resource']->pricing->avgSell;
  178. $this->fuelRequired[$i]['30days']['value'] = $this->fuelRequired[$i]['30days']['quantity'] * $this->fuelRequired[$i]['resource']->pricing->avgSell;
  179. }
  180. }
  181. }
  182. ?>