| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- require_once($path["entity"] . "Entity.php");
- require_once($path["entity"] . "K_Monster.php");
- /**
- * Fusion.
- *
- * Represents an object from the table 'fusion'.
- */
- class Fusion extends Entity{
- /**
- * Fusion identifier.
- */
- public $id;
- /**
- * {@see K_Monster} to fuse.
- */
- public $product;
- /**
- * {@see K_Monster} to fuse (awakened).
- */
- public $product_awaken;
- /**
- * {@see K_Monster} to fuse (awakened).
- */
- public $product_unawaken;
- /**
- * Fusions required to create ingredients.
- */
- public $fusion = [];
- /**
- * List of unfuseable {@see K_Monster} material.
- */
- public $ingredient = [];
- /**
- * List of unfuseable {@see K_Monster} material (awakened).
- */
- public $ingredient_unawaken = [];
- /**
- * Stars of the monster to fuse.
- */
- public $stars;
- /**
- * Fusion cost.
- */
- public $cost;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * fusion, populating it and it's items.
- *
- * @param SQLite3 $db Connection to the database.
- * @param int $id Product monster id.
- */
- public function __construct($db, $id){
- global $path;
- parent::__construct($db);
- $s =
- "SELECT DISTINCT " .
- " id, " .
- " product, " .
- " stars, " .
- " cost " .
- "FROM k_fusion " .
- "WHERE " .
- " product = $id OR " .
- " product = (SELECT awakens_to FROM k_monster WHERE id = $id) OR " .
- " product = (SELECT awakens_from FROM k_monster WHERE id = $id); ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $this->id = $r["id"];
- $this->product = new K_Monster($this->db, $r["product"]);
- $this->product_awaken = new K_Monster($this->db, $this->product->awakens_to);
- $this->stars = $r["stars"];
- $this->cost = $r["cost"];
- $s_f =
- "SELECT DISTINCT " .
- " ingredient " .
- "FROM k_fusion " .
- "WHERE " .
- " product = " . $this->product->id . " AND " .
- " ingredient IN ( " .
- " SELECT DISTINCT k_monster.id " .
- " FROM " .
- " k_fusion, " .
- " k_monster " .
- " WHERE " .
- " k_fusion.product = k_monster.awakens_from OR " .
- " k_fusion.product = k_monster.awakens_to OR " .
- " k_fusion.product = k_monster.id " .
- " ); ";
- $q_f = $this->db->query($s_f);
- while ($r_f = $q_f->fetchArray(SQLITE3_ASSOC)){
- array_push($this->fusion, new Fusion($this->db, $r_f["ingredient"]));
- }
- $s_m =
- "SELECT " .
- " id, " .
- " awakens_from " .
- "FROM k_monster " .
- "WHERE id IN ( " .
- " SELECT DISTINCT " .
- " ingredient " .
- " FROM k_fusion " .
- " WHERE " .
- " product = " . $this->product->id . " AND " .
- " ingredient NOT IN ( " .
- " SELECT DISTINCT k_monster.id " .
- " FROM " .
- " k_fusion, " .
- " k_monster " .
- " WHERE " .
- " k_fusion.product = k_monster.awakens_from OR " .
- " k_fusion.product = k_monster.awakens_to OR " .
- " k_fusion.product = k_monster.id " .
- " ) " .
- " ); ";
- error_log("ING: " . $s_m);
- $q_m = $this->db->query($s_m);
- while ($r_m = $q_m->fetchArray(SQLITE3_ASSOC)){
- array_push($this->ingredient, new K_Monster($this->db, $r_m["id"]));
- error_log("NEW awakens_from: " . $r_m["awakens_from"]);
- array_push($this->ingredient_unawaken, new K_Monster($this->db, $r_m["awakens_from"]));
- }
- }
- }
- ?>
|