Artifact_Effect.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * Artifact effect entity file.
  4. *
  5. * Creates the entity and makes it available.
  6. *
  7. * @category Entity
  8. */
  9. /**
  10. * Require dependent entities if not present.
  11. */
  12. require_once(PATH::ENTITY . "Entity.php");
  13. /**
  14. * Artifact effect.
  15. *
  16. * Represents an object from the table 'artifact_effect'.
  17. *
  18. * @category Entity
  19. */
  20. class Artifact_Effect extends Entity{
  21. /**
  22. * @var int Effect slot.
  23. *
  24. * @see ARTIFACT_EFFECT_SLOT_ID
  25. */
  26. public $slot;
  27. /**
  28. * @var int Effect identifier.
  29. *
  30. * @see ARTIFACT_EFFECT_ID
  31. */
  32. public $effect;
  33. /**
  34. * @var string Effect name (uppercase).
  35. */
  36. public $name = "";
  37. /**
  38. * @var int Effect value.
  39. */
  40. public $value;
  41. /**
  42. * @var int Ammount gained by effect grindstone.
  43. */
  44. public $grind;
  45. /**
  46. * @var int Indicates if a gem has been used.
  47. */
  48. public $enchant;
  49. /**
  50. * Constructor.
  51. *
  52. * Searches the database and retrieves the information about the
  53. * artifact effect, populating it and it's items.
  54. *
  55. * @param int $artifact Artifact id.
  56. * @param int $slot Artifact slot id.
  57. * @global resource Database connection.
  58. */
  59. public function __construct($artifact, $slot){
  60. global $db;
  61. $statement = $db->prepare("
  62. SELECT
  63. slot,
  64. effect,
  65. value,
  66. enchant,
  67. grind
  68. FROM artifact_effect
  69. WHERE
  70. artifact = :artifact AND
  71. slot = :slot;
  72. ");
  73. $statement->bindValue(':artifact', $artifact, SQLITE3_TEXT);
  74. $statement->bindValue(':slot', $slot, SQLITE3_TEXT);
  75. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  76. if ($r){
  77. $this->effect = $r["effect"];
  78. $this->value = $r["value"];
  79. $this->enchant = $r["enchant"];
  80. $this->grind = $r["grind"];
  81. $statement = $db->prepare("
  82. SELECT name
  83. FROM k_artifact_effect
  84. WHERE id = :id;
  85. ");
  86. $statement->bindValue(':id', $this->effect, SQLITE3_TEXT);
  87. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  88. if ($r){
  89. $this->name = str_replace("{}", $this->value, $r["name"]);
  90. }
  91. }
  92. }
  93. }
  94. ?>