Rune.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "K_Rune_Set.php");
  4. /**
  5. * Owned rune.
  6. *
  7. * Represents an object from the table 'rune'.
  8. */
  9. class Rune extends Entity{
  10. /**
  11. * Owner identifier.
  12. */
  13. public $uid;
  14. /**
  15. * Rune identifier.
  16. */
  17. public $id;
  18. /**
  19. * ID of the monster the rune is assigned to.
  20. */
  21. public $assigned_to;
  22. /**
  23. * {@see K_Rune_Set}.
  24. */
  25. public $type;
  26. /**
  27. * Position of the rune type (1-6).
  28. */
  29. public $slot;
  30. /**
  31. * Rune stars.
  32. */
  33. public $stars;
  34. /**
  35. * Indicates if the rune is ancient.
  36. */
  37. public $ancient;
  38. /**
  39. * Level of the rune.
  40. */
  41. public $level;
  42. /**
  43. * Rune quality.
  44. */
  45. public $quality;
  46. /**
  47. * Rune original quality.
  48. */
  49. public $original_quality;
  50. /**
  51. * Rune quality name (uppercase).
  52. */
  53. public $quality_name;
  54. /**
  55. * Rune original quality name (uppercase).
  56. */
  57. public $original_quality_name;
  58. /**
  59. * Price of the rune.
  60. */
  61. public $value;
  62. /**
  63. * Current efficiency of the rune.
  64. */
  65. public $efficiency;
  66. /**
  67. * Maximum potential efficiency of the rune.
  68. */
  69. public $max_efficiency;
  70. /**
  71. * Main stat of the rune.
  72. */
  73. public $main_stat;
  74. /**
  75. * Main stat name (uppercase).
  76. */
  77. public $main_stat_name;
  78. /**
  79. * Main stat value of the rune.
  80. */
  81. public $main_stat_value;
  82. /**
  83. * Extra stat of the rune.
  84. */
  85. public $innate_stat;
  86. /**
  87. * Extra stat name (uppercase).
  88. */
  89. public $innate_stat_name;
  90. /**
  91. * Extra stat value of the rune.
  92. */
  93. public $innate_stat_value;
  94. /**
  95. * Number of substats.
  96. */
  97. public $substats;
  98. /**
  99. * Substat 1 of the rune.
  100. */
  101. public $substat_1;
  102. /**
  103. * Substat 1 name (uppercase).
  104. */
  105. public $substat_1_name;
  106. /**
  107. * Substat 1 value of the rune.
  108. */
  109. public $substat_1_value;
  110. /**
  111. * Ammount gained by the substat 1 enchant.
  112. */
  113. public $substat_1_craft;
  114. /**
  115. * Substat 2 of the rune.
  116. */
  117. public $substat_2;
  118. /**
  119. * Substat 2 name (uppercase).
  120. */
  121. public $substat_2_name;
  122. /**
  123. * Substat 2 value of the rune.
  124. */
  125. public $substat_2_value;
  126. /**
  127. * Ammount gained by the substat 2 enchant.
  128. */
  129. public $substat_2_craft;
  130. /**
  131. * Substat 3 of the rune.
  132. */
  133. public $substat_3;
  134. /**
  135. * Substat 3 name (uppercase).
  136. */
  137. public $substat_3_name;
  138. /**
  139. * Substat 3 value of the rune.
  140. */
  141. public $substat_3_value;
  142. /**
  143. * Ammount gained by the substat 3 enchant.
  144. */
  145. public $substat_3_craft;
  146. /**
  147. * Substat 4 of the rune.
  148. */
  149. public $substat_4;
  150. /**
  151. * Substat 4 name (uppercase).
  152. */
  153. public $substat_4_name;
  154. /**
  155. * Substat 4 value of the rune.
  156. */
  157. public $substat_4_value;
  158. /**
  159. * Ammount gained by the substat 4 enchant.
  160. */
  161. public $substat_4_craft;
  162. /**
  163. * Constructor.
  164. *
  165. * Searches the database and retrieves the information about the
  166. * rune, populating it and it's items.
  167. *
  168. * @param SQLite3 $db Connection to the database.
  169. * @param int $id Rune id.
  170. */
  171. public function __construct($db, $id){
  172. global $path;
  173. parent::__construct($db);
  174. $s =
  175. "SELECT " .
  176. " id, " .
  177. " assigned_to, " .
  178. " type, " .
  179. " slot, " .
  180. " stars, " .
  181. " level, " .
  182. " ancient, " .
  183. " quality, " .
  184. " original_quality, " .
  185. " value, " .
  186. " efficiency, " .
  187. " max_efficiency, " .
  188. " main_stat, " .
  189. " main_stat_value, " .
  190. " innate_stat, " .
  191. " innate_stat_value, " .
  192. " substat_1, " .
  193. " substat_1_value, " .
  194. " substat_1_enchant, " .
  195. " substat_1_grind, " .
  196. " substat_2, " .
  197. " substat_2_value, " .
  198. " substat_2_enchant, " .
  199. " substat_2_grind, " .
  200. " substat_3, " .
  201. " substat_3_value, " .
  202. " substat_3_enchant, " .
  203. " substat_3_grind, " .
  204. " substat_4, " .
  205. " substat_4_value, " .
  206. " substat_4_enchant, " .
  207. " substat_4_grind " .
  208. "FROM rune " .
  209. "WHERE id = '$id'; ";
  210. $q = $this->db->query($s);
  211. $r = $q->fetchArray(SQLITE3_ASSOC);
  212. if ($r){
  213. $this->id = $r["id"];
  214. $this->assigned_to = $r["assigned_to"];
  215. $this->type = new K_Rune_Set($this->db, $r["type"]);
  216. $this->slot = $r["slot"];
  217. $this->stars = $r["stars"];
  218. $this->level = $r["level"];
  219. $this->ancient = $r["ancient"];
  220. $this->quality = $r["quality"];
  221. $this->original_quality = $r["original_quality"];
  222. $this->value = $r["value"];
  223. $this->efficiency = $r["efficiency"];
  224. $this->max_efficiency = $r["max_efficiency"];
  225. $this->main_stat = $r["main_stat"];
  226. $this->main_stat_value = $r["main_stat_value"];
  227. $this->innate_stat = $r["innate_stat"];
  228. $this->innate_stat_value = $r["innate_stat_value"];
  229. $this->substat_1 = $r["substat_1"];
  230. $this->substat_1_value = $r["substat_1_value"];
  231. $this->substat_1_enchant = $r["substat_1_enchant"];
  232. $this->substat_1_grind = $r["substat_1_grind"];
  233. $this->substat_2 = $r["substat_2"];
  234. $this->substat_2_value = $r["substat_2_value"];
  235. $this->substat_2_enchant = $r["substat_2_enchant"];
  236. $this->substat_2_grind = $r["substat_2_grind"];
  237. $this->substat_3 = $r["substat_3"];
  238. $this->substat_3_value = $r["substat_3_value"];
  239. $this->substat_3_enchant = $r["substat_3_enchant"];
  240. $this->substat_3_grind = $r["substat_3_grind"];
  241. $this->substat_4 = $r["substat_4"];
  242. $this->substat_4_value = $r["substat_4_value"];
  243. $this->substat_4_enchant = $r["substat_4_enchant"];
  244. $this->substat_4_grind = $r["substat_4_grind"];
  245. $this->refresh_names();
  246. }
  247. }
  248. /**
  249. * Decodes some properties and assigns name variables.
  250. */
  251. public function refresh_names(){
  252. $this->main_stat_name = $this->stat_name($this->main_stat);
  253. $this->innate_stat_name = $this->stat_name($this->innate_stat);
  254. $this->substat_1_name = $this->stat_name($this->substat_1);
  255. $this->substat_2_name = $this->stat_name($this->substat_2);
  256. $this->substat_3_name = $this->stat_name($this->substat_3);
  257. $this->substat_4_name = $this->stat_name($this->substat_4);
  258. $this->quality_name = $this->quality_name($this->quality);
  259. $this->original_quality_name = $this->quality_name($this->original_quality);
  260. }
  261. /**
  262. * Gets a stat name frm the maps.
  263. *
  264. * @param int $stat Stat id.
  265. * @return string Stat name (Uppercase)
  266. */
  267. private function stat_name($stat){
  268. global $RUNE_STAT;
  269. switch ($stat){
  270. case $RUNE_STAT["HP"]:
  271. return "HP";
  272. case $RUNE_STAT["HP%"]:
  273. return "HP%";
  274. case $RUNE_STAT["ATK"]:
  275. return "ATK";
  276. case $RUNE_STAT["ATK%"]:
  277. return "ATK%";
  278. case $RUNE_STAT["DEF"]:
  279. return "DEF";
  280. case $RUNE_STAT["DEF%"]:
  281. return "DEF%";
  282. case $RUNE_STAT["SPD"]:
  283. return "SPD";
  284. case $RUNE_STAT["CRR"]:
  285. return "CRR";
  286. case $RUNE_STAT["CRD"]:
  287. return "CRD";
  288. case $RUNE_STAT["RES"]:
  289. return "RES";
  290. case $RUNE_STAT["ACC"]:
  291. return "ACC";
  292. default:
  293. return "";
  294. }
  295. }
  296. /**
  297. * Gets a stat name frm the maps.
  298. *
  299. * @param int $q Quality id.
  300. * @return string Quality (Uppercase)
  301. */
  302. private function quality_name($q){
  303. global $QUALITY;
  304. switch ($q){
  305. case $QUALITY["NORMAL"]:
  306. return "NORMAL";
  307. case $QUALITY["MAGIC"]:
  308. return "MAGIC";
  309. case $QUALITY["RARE"]:
  310. return "RARE";
  311. case $QUALITY["HERO"]:
  312. return "HERO";
  313. case $QUALITY["LEGEND"]:
  314. return "LEGEND";
  315. default:
  316. return "";
  317. }
  318. }
  319. }
  320. ?>