Rune_Stat.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * Rune stat 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. * Rune_stat.
  15. *
  16. * Represents an object from the table 'rune'.
  17. *
  18. * @category Entity
  19. */
  20. class Rune_Stat extends Entity{
  21. /**
  22. * @var int Stat slot.
  23. *
  24. * @see RUNE_STAT_SLOT_ID
  25. */
  26. public $slot;
  27. /**
  28. * @var int Substat 1 of the rune.
  29. *
  30. * @see RUNE_STAT_ID
  31. */
  32. public $stat;
  33. /**
  34. * @var string Substat 1 name (uppercase).
  35. */
  36. public $stat_name = "";
  37. /**
  38. * @var int Substat 1 value of the rune.
  39. */
  40. public $value;
  41. /**
  42. * @var int Ammount gained by the substat 1 enchant.
  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. * rune, populating it and it's items.
  54. *
  55. * @param int $id Rune id.
  56. * @global resource Database connection.
  57. */
  58. public function __construct($rune, $slot){
  59. global $db;
  60. $statement = $db->prepare("
  61. SELECT
  62. slot,
  63. stat,
  64. value,
  65. enchant,
  66. grind
  67. FROM rune_stat
  68. WHERE
  69. rune = :rune AND
  70. slot = :slot;
  71. ");
  72. $statement->bindValue(':rune', $rune, SQLITE3_INTEGER);
  73. $statement->bindValue(':slot', $slot, SQLITE3_INTEGER);
  74. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  75. if ($r){
  76. $this->slot = $r["slot"];
  77. $this->stat = $r["stat"];
  78. $this->value = $r["value"];
  79. $this->enchant = $r["enchant"];
  80. $this->grind = $r["grind"];
  81. switch ($this->stat){
  82. case RUNE_STAT_ID::HP:
  83. $this->stat_name = "HP";
  84. break;
  85. case RUNE_STAT_ID::HP_P:
  86. $this->stat_name = "HP%";
  87. break;
  88. case RUNE_STAT_ID::ATK:
  89. $this->stat_name = "ATK";
  90. break;
  91. case RUNE_STAT_ID::ATK_P:
  92. $this->stat_name = "ATK%";
  93. break;
  94. case RUNE_STAT_ID::DEF:
  95. $this->stat_name = "DEF";
  96. break;
  97. case RUNE_STAT_ID::DEF_P:
  98. $this->stat_name = "DEF%";
  99. break;
  100. case RUNE_STAT_ID::SPD:
  101. $this->stat_name = "SPD";
  102. break;
  103. case RUNE_STAT_ID::CRR:
  104. $this->stat_name = "CRR";
  105. break;
  106. case RUNE_STAT_ID::CRD:
  107. $this->stat_name = "CRD";
  108. break;
  109. case RUNE_STAT_ID::RES:
  110. $this->stat_name = "RES";
  111. break;
  112. case RUNE_STAT_ID::ACC:
  113. $this->stat_name = "ACC";
  114. break;
  115. }
  116. }
  117. }
  118. }
  119. ?>