Player.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. <?php
  2. /**
  3. * Player entity file.
  4. *
  5. * Creates the entity and makes it available.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::ENTITY . "Entity.php");
  12. require_once(PATH::ENTITY . "Unit.php");
  13. require_once(PATH::ENTITY . "Building.php");
  14. require_once(PATH::ENTITY . "Decoration.php");
  15. require_once(PATH::ENTITY . "Item.php");
  16. require_once(PATH::ENTITY . "Record.php");
  17. require_once(PATH::ENTITY . "Server.php");
  18. /**
  19. * A Player.
  20. *
  21. * Represents a game account.
  22. *
  23. * @category Entity
  24. */
  25. class Player extends Entity{
  26. /**
  27. * @var int User ID.
  28. */
  29. private $user;
  30. /**
  31. * @var int In-game player ID.
  32. */
  33. private $id;
  34. /**
  35. * @var int Account server ID.
  36. */
  37. private $server;
  38. /**
  39. * @var string Account country code.
  40. */
  41. private $country;
  42. /**
  43. * @var string Account language code.
  44. */
  45. private $language;
  46. /**
  47. * @var int Player level.
  48. */
  49. private $level;
  50. /**
  51. * @var string Player name.
  52. */
  53. private $name;
  54. /**
  55. * @var int Total experience.
  56. */
  57. private $experience;
  58. /**
  59. * @var Unit Player's representative unit.
  60. */
  61. private $rep;
  62. /**
  63. * @var int Player's representative unit ID.
  64. */
  65. private $rep_id;
  66. /**
  67. * @var DateTime Time the player joined the game.
  68. */
  69. private $joined = 0;
  70. /**
  71. * @var int Player's top rank in the Arena.
  72. * @see ARENA_RANK_ID
  73. */
  74. private $top_rank_arena = 0;
  75. /**
  76. * @var int Player's top rank in the World Arena.
  77. * @see ARENA_RANK_ID
  78. */
  79. private $top_rank_world_arena = 0;
  80. /**
  81. * @var int Player's top rank in the Special League.
  82. * @see ARENA_RANK_ID
  83. */
  84. private $top_rank_special_league = 0;
  85. /**
  86. * @var int Player's top rank in Guild War.
  87. * @see ARENA_RANK_ID
  88. */
  89. private $top_rank_gw = 0;
  90. /**
  91. * @var int Player's top rank in the Siege Battle.
  92. * @see ARENA_RANK_ID
  93. */
  94. private $top_rank_siege = 0;
  95. /**
  96. * @var int Player's top rank in World Boss
  97. * @see WORLD_BOSS_RANK_ID
  98. */
  99. private $top_rank_wboss = 0;
  100. /**
  101. * @var int Top floor reached in the Trial of Ascension Normal.
  102. */
  103. private $top_rank_toan = 0;
  104. /**
  105. * @var int Top floor reached in the Trial of Ascension Hard.
  106. */
  107. private $top_rank_toah = 0;
  108. /**
  109. * @var int Maximum stars achieved in the Trial of Ascension Hell.
  110. */
  111. private $top_rank_toal = 0;
  112. /**
  113. * @var bool Internal flag to chek if Arena, GW and Siege defenses have been read.
  114. */
  115. private $flag_defense = false;
  116. /**
  117. * @var Unit[] Arena defense.
  118. */
  119. private $arena_defense = [];
  120. /**
  121. * @var Unit[][] Guild War defenses.
  122. */
  123. private $gw_defense = [[], []];
  124. /**
  125. * @var Unit[] Siege defenses.
  126. */
  127. private $siege_defense = [];
  128. /**
  129. * @var int[] Various currencies.
  130. */
  131. private $currency = [
  132. "mana" => 0,
  133. "crystal" => 0,
  134. "energy" => 0,
  135. "energy_max" => 0,
  136. "arena_energy" => 0,
  137. "darkportal_energy" => 0,
  138. "dimension_energy" => 0,
  139. "honor_point" => 0,
  140. "guild_point" => 0,
  141. "honor_medal" => 0,
  142. "honor_mark" => 0,
  143. "event_coin" => 0,
  144. "social_point" => 0,
  145. "ancient_stone" => 0,
  146. "costume_point" => 0,
  147. ];
  148. /**
  149. * @var bool Internal flag to check if the buildings and decorations have been loaded into the
  150. * entity.
  151. */
  152. private $flag_building = false;
  153. /**
  154. * @var Building[] Player's buildings.
  155. */
  156. private $building = [];
  157. /**
  158. * @var Decoration[] Player's decorations.
  159. */
  160. private $decoration = [];
  161. /**
  162. * @var bool Internal flags to check if various types of inventory items have been loaded into
  163. * the entity;
  164. */
  165. private $flag_item = false;
  166. /**
  167. * @var Item[] Player's scrolls.
  168. */
  169. private $item_scroll = [];
  170. /**
  171. * @var Item[] Player's rune craft materials..
  172. */
  173. private $item_craft_rune = [];
  174. /**
  175. * @var Item[] Player's craft materials.
  176. */
  177. private $item_craft = [];
  178. /**
  179. * @var Item[] Player's essences.
  180. */
  181. private $item_essence = [];
  182. /**
  183. * @var bool Internal flag to check if the player records have been loaded into the entity.
  184. */
  185. private $flag_record = false;
  186. /**
  187. * @var Record[] Player records.
  188. */
  189. private $record = [];
  190. /**
  191. * @var bool Indicates the profile visibility.
  192. */
  193. private $public = false;
  194. /**
  195. * Constructor.
  196. *
  197. * Searches the database and retrieves the information about the
  198. * player, populating it and it's items.
  199. *
  200. * @param int $id Player identifier.
  201. */
  202. public function __construct($id){
  203. $statement = get_context()->get_db()->prepare("
  204. SELECT
  205. user,
  206. id,
  207. server,
  208. country,
  209. lang,
  210. name,
  211. level,
  212. experience,
  213. rep,
  214. mana,
  215. crystal,
  216. energy,
  217. energy_max,
  218. arena_energy,
  219. darkportal_energy,
  220. dimension_energy,
  221. honor_point,
  222. guild_point,
  223. honor_medal,
  224. honor_mark,
  225. event_coin,
  226. social_point,
  227. costume_point,
  228. joined,
  229. top_rank_arena,
  230. top_rank_world_arena,
  231. top_rank_special_league,
  232. top_rank_gw,
  233. top_rank_siege,
  234. top_rank_wboss,
  235. top_rank_toan,
  236. top_rank_toah,
  237. top_rank_toal,
  238. public
  239. FROM player
  240. WHERE id = :id;
  241. ");
  242. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  243. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  244. if ($r){
  245. $this->user = $r["user"];
  246. $this->id = $r["id"];
  247. $this->server = new Server($r["server"]);
  248. $this->country = $r["country"];
  249. $this->lang = $r["lang"];
  250. $this->name = $r["name"];
  251. $this->level = $r["level"];
  252. $this->experience = $r["experience"];
  253. if (strlen($r["rep"]) > 0){
  254. $this->rep_id = $r["rep"];
  255. }
  256. $this->currency["mana"] = $r["mana"];
  257. $this->currency["crystal"] = $r["crystal"];
  258. $this->currency["energy"] = $r["energy"];
  259. $this->currency["energy_max"] = $r["energy_max"];
  260. $this->currency["arena_energy"] = $r["arena_energy"];
  261. $this->currency["darkportal_energy"] = $r["darkportal_energy"];
  262. $this->currency["dimension_energy"] = $r["dimension_energy"];
  263. $this->currency["honor_point"] = $r["honor_point"];
  264. $this->currency["guild_point"] = $r["guild_point"];
  265. $this->currency["honor_medal"] = $r["honor_medal"];
  266. $this->currency["honor_mark"] = $r["honor_mark"];
  267. $this->currency["event_coin"] = $r["event_coin"];
  268. $this->currency["social_point"] = $r["social_point"];
  269. $this->currency["costume_point"] = $r["costume_point"];
  270. $this->joined = new Datetime();
  271. $this->joined->setTimestamp($r["joined"]);
  272. $this->top_rank_arena = $r["top_rank_arena"];
  273. $this->top_rank_world_arena = $r["top_rank_world_arena"];
  274. $this->top_rank_special_league = $r["top_rank_special_league"];
  275. $this->top_rank_gw = $r["top_rank_gw"];
  276. $this->top_rank_siege = $r["top_rank_siege"];
  277. $this->top_rank_wboss = $r["top_rank_wboss"];
  278. $this->top_rank_toan = $r["top_rank_toan"];
  279. $this->top_rank_toah = $r["top_rank_toah"];
  280. $this->top_rank_toal = $r["top_rank_toal"];
  281. if (strlen($r["public"]) == 1){
  282. $this->public = true;
  283. }
  284. }
  285. }
  286. /**
  287. * Loads the defenses into the entity.
  288. *
  289. * Must be called only once before trying to get the units in Arena, Guild War or Siege
  290. * defenses. Sets the flag {@link Player:$flag_defenses} to true.
  291. */
  292. private function load_defenses(){
  293. $statement = get_context()->get_db()->prepare("
  294. SELECT unit
  295. FROM defense
  296. WHERE
  297. player = :player AND
  298. area_type = :area_type
  299. ORDER BY position;
  300. ");
  301. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  302. $statement->bindValue(':area_type', AREA_TYPE_ID::ARENA, SQLITE3_INTEGER);
  303. $q = $statement->execute();
  304. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  305. array_push($this->arena_defense, new Unit($r["unit"], false));
  306. }
  307. $statement = get_context()->get_db()->prepare("
  308. SELECT
  309. unit,
  310. slot
  311. FROM defense
  312. WHERE
  313. player = :player AND
  314. area_type = :area_type
  315. ORDER BY
  316. slot,
  317. position;
  318. ");
  319. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  320. $statement->bindValue(':area_type', AREA_TYPE_ID::GUILD_WAR, SQLITE3_INTEGER);
  321. $q = $statement->execute();
  322. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  323. array_push($this->gw_defense[$r["slot"]], new Unit($r["unit"], false));
  324. }
  325. // TODO: Siege defenses
  326. $statement = get_context()->get_db()->prepare("
  327. SELECT
  328. unit,
  329. position
  330. FROM defense
  331. WHERE
  332. player = :player AND
  333. area_type = :area_type
  334. ORDER BY
  335. slot,
  336. position;
  337. ");
  338. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  339. $statement->bindValue(':area_type', AREA_TYPE_ID::GUILD_SIEGE, SQLITE3_INTEGER);
  340. $q = $statement->execute();
  341. $i = 0;
  342. $siege = [null, null, null];
  343. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  344. $siege[$i] = new Unit($r["unit"]);
  345. $i ++;
  346. if ($i == 3){
  347. array_push($this->siege_defense, $siege);
  348. $i = 0;
  349. $siege = [null, null, null];
  350. }
  351. }
  352. $this->flag_defense = true;
  353. }
  354. /**
  355. * Loads buildings and decorations into the entity.
  356. *
  357. * Must be called only once before trying to get the buildings or decorations. Sets the flag
  358. * {@link Player:$flag_defenses} to true.
  359. */
  360. private function load_buildings(){
  361. $statement = get_context()->get_db()->prepare("
  362. SELECT
  363. building.id AS id,
  364. min(building.buildable) AS min
  365. FROM
  366. building,
  367. buildable
  368. WHERE
  369. player = :player AND
  370. building.buildable = buildable.id
  371. GROUP BY building.buildable;
  372. ");
  373. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  374. $q = $statement->execute();
  375. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  376. array_push($this->building, new Building($r["id"]));
  377. }
  378. $statement = get_context()->get_db()->prepare("
  379. SELECT id
  380. FROM decoration
  381. WHERE player = :player;
  382. ");
  383. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  384. $q = $statement->execute();
  385. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  386. array_push($this->decoration, new Decoration($r["id"]));
  387. }
  388. $this->flag_building = true;
  389. }
  390. /**
  391. * Loads items into the entity.
  392. *
  393. * Must be called only once before trying to get any of the items in the inventory. Sets the
  394. * flag {@link Player:$flag_defenses} to true.
  395. */
  396. private function load_items(){
  397. $statement = get_context()->get_db()->prepare("
  398. SELECT
  399. id,
  400. type
  401. FROM item
  402. WHERE
  403. player = :player AND
  404. type = :type AND
  405. amount > 0
  406. ORDER BY item.type;
  407. ");
  408. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  409. $statement->bindValue(':type', INVENTORY_TYPE_ID::SCROLL, SQLITE3_TEXT);
  410. $q = $statement->execute();
  411. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  412. array_push($this->item_scroll, new Item($this->id, $r["id"], $r["type"]));
  413. }
  414. // Rune crafting items are marked as generic crafting.
  415. $statement = get_context()->get_db()->prepare("
  416. SELECT
  417. id,
  418. type
  419. FROM item
  420. WHERE
  421. player = :player AND
  422. type = :type AND
  423. amount > 0
  424. ORDER BY id;
  425. ");
  426. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  427. $statement->bindValue(':type', INVENTORY_TYPE_ID::ENCHANTMENT, SQLITE3_TEXT);
  428. $q = $statement->execute();
  429. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  430. array_push($this->item_craft_rune, new Item($this->id, $r["id"], $r["type"]));
  431. }
  432. $statement = get_context()->get_db()->prepare("
  433. SELECT
  434. id,
  435. type
  436. FROM item
  437. WHERE
  438. player = :player AND
  439. type = :type AND
  440. amount > 0
  441. ORDER BY id;
  442. ");
  443. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  444. $statement->bindValue(':type', INVENTORY_TYPE_ID::CRAFT_STUFF, SQLITE3_TEXT);
  445. $q = $statement->execute();
  446. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  447. array_push($this->item_craft, new Item($this->id, $r["id"], $r["type"]));
  448. }
  449. $statement = get_context()->get_db()->prepare("
  450. SELECT
  451. item.id AS id,
  452. item.type AS type
  453. FROM
  454. item,
  455. inventory
  456. WHERE
  457. item.id = inventory.id AND
  458. item.type = inventory.type AND
  459. item.player = :player AND
  460. item.type = :type AND
  461. amount > 0
  462. ORDER BY
  463. upper(inventory.name) NOT LIKE '%MAGIC%',
  464. upper(inventory.name) NOT LIKE '%FIRE%',
  465. upper(inventory.name) NOT LIKE '%WATER%',
  466. upper(inventory.name) NOT LIKE '%WIND%',
  467. upper(inventory.name) NOT LIKE '%LIGHT%',
  468. upper(inventory.name) NOT LIKE '%DARK%',
  469. upper(inventory.name) NOT LIKE '%LOW%',
  470. upper(inventory.name) NOT LIKE '%MID%',
  471. upper(inventory.name) NOT LIKE '%HIGH%'
  472. ;
  473. ");
  474. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  475. $statement->bindValue(':type', INVENTORY_TYPE_ID::ESSENCES, SQLITE3_TEXT);
  476. $q = $statement->execute();
  477. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  478. array_push($this->item_essence, new Item($this->id, $r["id"], $r["type"]));
  479. }
  480. $this->flag_item = true;
  481. }
  482. /**
  483. * Loads the records into the entity.
  484. *
  485. * Must be called only once before trying to get records. Sets the flag
  486. * {@link Player:$flag_defenses} to true.
  487. */
  488. private function load_records(){
  489. $statement = get_context()->get_db()->prepare("
  490. SELECT
  491. player,
  492. area_type,
  493. area
  494. FROM record
  495. WHERE player = :player
  496. ORDER BY
  497. CASE
  498. WHEN (area_type = 2 AND area = 8001) THEN 1 -- Giant's Keep
  499. WHEN (area_type = 2 AND area = 9001) THEN 2 -- Dragon's Lair
  500. WHEN (area_type = 2 AND area = 6001) THEN 3 -- Necropolis
  501. WHEN (area_type = 2 AND area = 9501) THEN 4 -- Steel Fortress
  502. WHEN (area_type = 2 AND area = 9502) THEN 5 -- Punisher's Crypt
  503. WHEN (area_type = 4) THEN 6 -- Rift of Worlds
  504. WHEN (area_type = 3 AND area = 1001) THEN 7 -- Rift Dungeon - Ice Beast
  505. WHEN (area_type = 3 AND area = 2001) THEN 8 -- Rift Dungeon - Fire Beast
  506. WHEN (area_type = 3 AND area = 3001) THEN 9 -- Rift Dungeon - Wind Beast
  507. WHEN (area_type = 3 AND area = 4001) THEN 10 -- Rift Dungeon - Light Beast
  508. WHEN (area_type = 3 AND area = 5001) THEN 11 -- Rift Dungeon - Dark Beast
  509. WHEN (area_type = 2 AND area = 5001) THEN 12 -- Hall of Magic
  510. WHEN (area_type = 2 AND area = 3001) THEN 13 -- Hall of Water
  511. WHEN (area_type = 2 AND area = 2001) THEN 14 -- Hall of Fire
  512. WHEN (area_type = 2 AND area = 4001) THEN 15 -- Hall of Wind
  513. WHEN (area_type = 2 AND area = 7001) THEN 16 -- Hall of Light
  514. WHEN (area_type = 2 AND area = 1001) THEN 17 -- Hall of Dark
  515. ELSE area
  516. END ASC
  517. ");
  518. $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
  519. $q = $statement->execute();
  520. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  521. array_push($this->record, new Record($r["player"], $r["area_type"], $r["area"]));
  522. }
  523. $this->flag_record = true;
  524. }
  525. /**
  526. * Retrieves the user identifier
  527. *
  528. * @return int User ID.
  529. */
  530. public function get_user(){
  531. return $this->user;
  532. }
  533. /**
  534. * Retrieves the player identifier
  535. *
  536. * @return int Player ID.
  537. */
  538. public function get_id(){
  539. return $this->id;
  540. }
  541. /**
  542. * Retrieves the player server.
  543. *
  544. * @return Server The player's account server.
  545. */
  546. public function get_server(){
  547. return $this->server;
  548. }
  549. /**
  550. * Retrieves the player's country.
  551. *
  552. * @return string Two digit country code.
  553. */
  554. public function get_country(){
  555. return $this->country;
  556. }
  557. /**
  558. * Retrieves the player's language.
  559. *
  560. * @return string Two digit language code.
  561. */
  562. public function get_language(){
  563. return $this->language;
  564. }
  565. /**
  566. * Retrieves the player's level,
  567. *
  568. * @return int Player's level
  569. */
  570. public function get_level(){
  571. return $this->level;
  572. }
  573. /**
  574. * Retrieves the player's name
  575. *
  576. * @return string The playe's name.
  577. */
  578. public function get_name(){
  579. return $this->name;
  580. }
  581. /**
  582. * Retrieves the total experience earned by the user.
  583. *
  584. * @return int Total experience.
  585. */
  586. public function get_experience(){
  587. return $this->experience;
  588. }
  589. /**
  590. * Retrieves the player's representative unit.
  591. *
  592. * @return Unit Player's representative
  593. */
  594. public function get_rep(){
  595. if ($this->rep_id != null && $this->rep == null){
  596. $this->rep = new Unit($this->rep_id);
  597. }
  598. return $this->rep;
  599. }
  600. /**
  601. * Gets the date the user joined the game.
  602. *
  603. * If $format is supplied, a string in the desired format will be returned. If not, the raw
  604. * DateTime object will e returned.
  605. *
  606. * @param string $format A date format (optional).
  607. * @return DateTime | string The raw date, or a formatted version.
  608. */
  609. public function get_joined($format = null){
  610. if (null == $format){
  611. return $this->joined;
  612. }
  613. else{
  614. return $this->joined->format($format);
  615. }
  616. }
  617. /**
  618. * Retrieves the user's top rank in the Arena.
  619. *
  620. * @return int Top rank.
  621. */
  622. public function get_top_rank_arena(){
  623. return $this->top_rank_arena;
  624. }
  625. /**
  626. * Retrieves the user's top rank in the WorldArena.
  627. *
  628. * @return int Top rank.
  629. */
  630. public function get_top_rank_world_arena(){
  631. return $this->top_rank_world_arena;
  632. }
  633. /**
  634. * Retrieves the user's top rank in the Arena.
  635. *
  636. * @return int Top rank.
  637. */
  638. public function get_top_rank_special_league(){
  639. return $this->top_rank_special_league;
  640. }
  641. /**
  642. * Retrieves the user's top rank in Guild War.
  643. *
  644. * @return int Top rank.
  645. */
  646. public function get_top_rank_gw(){
  647. return $this->top_rank_gw;
  648. }
  649. /**
  650. * Retrieves the user's top rank in Siege battle.
  651. *
  652. * @return int Top rank.
  653. */
  654. public function get_top_rank_siege(){
  655. return $this->top_rank_siege;
  656. }
  657. /**
  658. * Retrieves the user's top rank in the World Boss.
  659. *
  660. * @return int Top rank.
  661. */
  662. public function get_top_rank_wboss(){
  663. return $this->top_rank_wboss;
  664. }
  665. /**
  666. * Retrieves the user's top rank in the Trial of Ascension (normal difficulty).
  667. *
  668. * @return int Top rank.
  669. */
  670. public function get_top_rank_toan(){
  671. return $this->top_rank_toan;
  672. }
  673. /**
  674. * Retrieves the user's top rank in the Trial of Ascension (hard difficulty).
  675. *
  676. * @return int Top rank.
  677. */
  678. public function get_top_rank_toah(){
  679. return $this->top_rank_toah;
  680. }
  681. /**
  682. * Retrieves the user's top rank in the Trial of Ascension (hell difficulty).
  683. *
  684. * @return int Top rank.
  685. */
  686. public function get_top_rank_toal(){
  687. return $this->top_rank_toal;
  688. }
  689. /**
  690. * Retrieves the Arena defense units.
  691. *
  692. * @return \Unit[] Units in the arena defense.
  693. */
  694. public function get_arena_defense(){
  695. if (!$this->flag_defense){
  696. $this->load_defenses();
  697. }
  698. return $this->arena_defense;
  699. }
  700. /**
  701. * Retrieves the Guild War defenses.
  702. *
  703. * @return Unit[][]: Units in Guild War defense, grouped by team.
  704. */
  705. public function get_gw_defense(){
  706. if (!$this->flag_defense){
  707. $this->load_defenses();
  708. }
  709. return $this->gw_defense;
  710. }
  711. /**
  712. * Retrieves the Guild War defenses.
  713. *
  714. * @return Unit[][]: Units in Siege Battle defense, grouped by team.
  715. */
  716. public function get_siege_defense(){
  717. if (!$this->flag_defense){
  718. $this->load_defenses();
  719. }
  720. return $this->siege_defense;
  721. }
  722. /**
  723. * Retrieves various currencies.
  724. *
  725. * @return int[] Array with the keys: mana, crystal, energy, energy_max, arena_energy,
  726. * darkportal_energy, dimension_energy, honor_point, guild_point, honor_medal, honor_mark,
  727. * event_coin, social_point, ancient_stone, costume_point,
  728. */
  729. public function get_currencies(){
  730. return $this->currency;
  731. }
  732. /**
  733. * Retrieves the list of buildings owned by the user.
  734. *
  735. * @return \Building[] Buildings owned.
  736. */
  737. public function get_buildings(){
  738. if (!$this->flag_building){
  739. $this->load_buildings();
  740. }
  741. return $this->building;
  742. }
  743. /**
  744. * Retrieves the list of decorations owned by the user.
  745. *
  746. * @return \Decoration[] Owned decorations.
  747. */
  748. public function get_decorations(){
  749. if (!$this->flag_building){
  750. $this->load_buildings();
  751. }
  752. return $this->decoration;
  753. }
  754. /**
  755. * Retrieves the list of owned scrolls.
  756. *
  757. * @return \Item[] Scrolls.
  758. */
  759. public function get_scrolls(){
  760. if (!$this->flag_item){
  761. $this->load_items();
  762. }
  763. return $this->item_scroll;
  764. }
  765. /**
  766. * Retrieves the list of rune crafting mateials.
  767. *
  768. * @return \Item[] Rune craft materials.
  769. */
  770. public function get_rune_craft_materials(){
  771. if (!$this->flag_item){
  772. $this->load_items();
  773. }
  774. return $this->item_craft_rune;
  775. }
  776. /**
  777. * Retrieves the list of crafting materials.
  778. *
  779. * @return \Item[] Crafting materials
  780. */
  781. public function get_craft_materials(){
  782. if (!$this->flag_item){
  783. $this->load_items();
  784. }
  785. return $this->item_craft;
  786. }
  787. /**
  788. * Retrieves the list of essences owned by the player.
  789. *
  790. * @return \Item[] Essences.
  791. */
  792. public function get_essences(){
  793. if (!$this->flag_item){
  794. $this->load_items();
  795. }
  796. return $this->item_essence;
  797. }
  798. /**
  799. * Retrieves the list of the player's records in the logbook.
  800. *
  801. * @return \Record[] List of records.
  802. */
  803. public function get_records(){
  804. if (!$this->flag_record){
  805. $this->load_records();
  806. }
  807. return $this->record;
  808. }
  809. /**
  810. * Checks if the player profile is public.
  811. *
  812. * @return bool True for public profile, false otherwise.
  813. */
  814. public function is_public(){
  815. return $this->public;
  816. }
  817. }