K_Fusion.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. //require_once($path["entity"] . "Monster.php");
  4. /**
  5. * Monster.
  6. *
  7. * Represents an object from the table 'monster'.
  8. */
  9. class Fusion extends Entity{
  10. /**
  11. * {@see Monster} to fuse.
  12. */
  13. public $target;
  14. /**
  15. * {@see Monster} material.
  16. */
  17. public $source = [];
  18. /**
  19. * Stars of the monster to fuse.
  20. */
  21. public $target_stars;
  22. /**
  23. * Stars of the source monsters.
  24. */
  25. public $source_stars;
  26. /**
  27. * Monster materials level.
  28. */
  29. public $source_level;
  30. /**
  31. * Constructor.
  32. *
  33. * Searches the database and retrieves the information about the
  34. * project, populating it and it's items.
  35. *
  36. * @param SQLite3 $db Connection to the database.
  37. * @param int $id Target monster id.
  38. */
  39. public function __construct($db, $id){
  40. global $path;
  41. parent::__construct($db);
  42. $s =
  43. "SELECT " .
  44. " target, " .
  45. " target_stars, " .
  46. " source, " .
  47. " source_stars, " .
  48. " source_level " .
  49. "FROM fusion " .
  50. "WHERE target = $id; ";
  51. $q = $this->db->query($s);
  52. $set = false;
  53. while ($r = $q->fetchArray(SQLITE3_ASSOC)){
  54. if ($set == false){
  55. $this->target_stars = $r["target_stars"];
  56. $this->source_stars = $r["source_stars"];
  57. $this->source_level = $r["source_level"];
  58. $this->target = new Monster($this->db, $r["target"]);
  59. $set = true;
  60. }
  61. array_push($this->source, new Monster($this->db, $r["source"]));
  62. }
  63. }
  64. }
  65. ?>