| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <?php
- require_once($path["entity"] . "Entity.php");
- require_once($path["entity"] . "Unit.php");
- require_once($path["entity"] . "K_Unit.php");
- require_once($path["entity"] . "Rune.php");
- require_once($path["entity"] . "Inventory.php");
- require_once($path["entity"] . "K_Area.php");
- require_once($path["entity"] . "K_Rune_Set.php");
- /**
- * A run.
- *
- * Represents an object from the table 'run'.
- */
- class Run extends Entity{
- /**
- * Player identifier.
- */
- public $uid;
- /**
- * Run identifier.
- */
- public $id;
- /**
- * Run start datestame.
- */
- public $dtime;
- /**
- * Area.
- */
- public $area;
- /**
- * Stage.
- */
- public $stage;
- /**
- * Difficulty (only scenario and dimension hole)
- */
- public $difficulty;
- /**
- * Win or lost run.
- */
- public $win;
- /**
- * Clear time.
- */
- public $time;
- /**
- * Reward mana.
- */
- public $mana;
- /**
- * Reward energy.
- */
- public $energy;
- /**
- * Reward crystal.
- */
- public $crystal;
- /**
- * Indicates if a frind/mentor helped.
- */
- public $helper;
- /**
- * Array of {@see Unit}s or {@see K_Unit}.
- * If the unit is still owned, it will be a instance of Unit.
- * If not, it will be a instance of K_Unit.
- */
- public $party = [];
- /**
- * List of {@see Inventory}, of dropped items.
- */
- public $item = [];
- /**
- * List of {@see K_Unit}s dropped.
- */
- public $unit = [];
- /**
- * List of {@see K_Unit}s whose secret dungeons were found on the run.
- */
- public $sd= [];
- /**
- * List of [{@see K_Unit}, quantity] of dropped summon pieces.
- */
- public $unit_piece = [];
- /**
- * Number of shapeshifting stones dropped;
- */
- public $shapeshifting = 0;
- /**
- * List of {@see Rune}s dropped.
- */
- public $rune= [];
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * run, populating it and it's items.
- *
- * @param SQLite3 $db Connection to the database.
- * @param int $id Run identifier.
- */
- public function __construct($db, $id){
- global $path;
- global $AREA_TYPE;
- global $SCENARIO;
- global $DUNGEON;
- global $RAID_RIFT_DUNGEON;
- global $ELEMENTAL_RIFT_DUNGEON;
- parent::__construct($db);
- $s = "
- SELECT
- id,
- uid,
- dtime,
- area,
- stage,
- difficulty,
- win,
- time,
- mana,
- energy,
- crystal,
- helper
- FROM run
- WHERE id = $id;
- ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $this->id = $r["id"];
- $this->uid = $r["uid"];
- $this->dtime = $r["dtime"];
- $type = 0;
- if (in_array($r["area"], $RAID_RIFT_DUNGEON) && $r["stage"] < 1){
- $type = $AREA_TYPE["RIFT_RAID_DUNGEON"];
- }
- elseif (in_array($r["area"], $SCENARIO)){
- $type = $AREA_TYPE["SCENARIO"];
- }
- elseif (in_array($r["area"], $ELEMENTAL_RIFT_DUNGEON) && $r["stage"] < 1){
- $type = $AREA_TYPE["ELEMENTAL_RIFT_DUNGEON"];
- }
- elseif (in_array($r["area"], $DUNGEON)){
- $type = $AREA_TYPE["CAIROS_DUNGEON"];
- }
- $this->area = new K_Area($this->db, $r["area"], $type);
- $this->stage = $r["stage"];
- $this->difficulty = $r["difficulty"];
- $this->win = $r["win"];
- $this->time = $r["time"];
- $this->mana = $r["mana"];
- $this->energy = $r["energy"];
- $this->crystal = $r["crystal"];
- $this->helper = $r["helper"];
- $s = "
- SELECT
- unit,
- k_unit,
- (SELECT count(id) FROM unit WHERE unit.unit = k_unit) AS owned
- FROM run_party
- WHERE run = $id;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- if ($r["owned"] > 0){
- array_push($this->party, new Unit($this->db, $r["unit"], false));
- }
- else{
- array_push($this->party, new K_Unit($this->db, $r["k_unit"], false));
- }
- }
- $s = "
- SELECT
- item,
- quantity
- FROM run_drop_item
- WHERE run = $this->id;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- $i = new K_Inventory($this->db, $r["item"]);
- $i->amount = $r["quantity"];
- array_push($this->item, $i);
- }
- $s = "
- SELECT unit
- FROM run_drop_unit
- WHERE run = $this->id;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->unit, new K_Unit($this->db, $r["unit"]));
- }
- $s = "
- SELECT unit
- FROM run_drop_sd
- WHERE run = $this->id;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->sd, new K_Unit($this->db, $r["unit"]));
- }
- $s = "
- SELECT
- unit,
- quantity
- FROM run_drop_unit_pieces
- WHERE run = $this->id;
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- $i = [
- "unit" => new K_Unit($this->db, $r["unit"]),
- "quantity" => $r["quantity"]
- ];
- array_push($this->unit_piece, $i);
- }
- $s = "
- SELECT quantity
- FROM run_drop_shapeshifting
- WHERE run = $this->id;
- ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->shapeshifting = $r["quantity"];
- }
- $s = "
- SELECT
- id,
- type,
- slot,
- stars,
- ancient,
- quality,
- value,
- efficiency,
- main_stat,
- main_stat_value,
- innate_stat,
- innate_stat_value,
- substat_1,
- substat_1_value,
- substat_2,
- substat_2_value,
- substat_3,
- substat_3_value,
- substat_4,
- substat_4_value
- FROM run_drop_rune
- WHERE run = $this->id;
- ";
- if ($this->id == 9){
- error_log("DEBUG RUNE: " . $s);
- }
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- $rune = new Rune($this->db, $r["id"]);
- //if ($this->id == 9){
- error_log("DEBUG RUNE ID: " . $rune->id);
- //}
- if (!isset($rune->id)){
- if ($this->id == 9){
- error_log("DEBUG RUNE: NEW");
- }
- $rune->id = $r["id"];
- $rune->assigned_to = null;
- $rune->type = new K_Rune_Set($this->db, $r["type"]);
- $rune->slot = $r["slot"];
- $rune->stars = $r["stars"];
- $rune->ancient = $r["ancient"];
- $rune->quality = $r["quality"];
- $rune->original_quality = $r["quality"];
- $rune->value = $r["value"];
- $rune->value = 0;
- $rune->efficiency = $r["efficiency"];
- // TODO: Calculate?
- $rune->max_efficiency = $r["efficiency"];
- $rune->main_stat = $r["main_stat"];
- $rune->main_stat_value = $r["main_stat_value"];
- $rune->innate_stat = $r["innate_stat"];
- $rune->innate_stat_value = $r["innate_stat_value"];
- $rune->substat_1 = $r["substat_1"];
- $rune->substat_1_value = $r["substat_1_value"];
- $rune->substat_1_enchant = 0;
- $rune->substat_1_grind = 0;
- $rune->substat_2 = $r["substat_2"];
- $rune->substat_2_value = $r["substat_2_value"];
- $rune->substat_2_enchant = 0;
- $rune->substat_2_grind = 0;
- $rune->substat_3 = $r["substat_3"];
- $rune->substat_3_value = $r["substat_3_value"];
- $rune->substat_3_enchant = 0;
- $rune->substat_3_grind = 0;
- $rune->substat_4 = $r["substat_4"];
- $rune->substat_4_value = $r["substat_4_value"];
- $rune->substat_4_enchant = 0;
- $rune->substat_4_grind = 0;
- $rune->refresh_names();
- }
- array_push($this->rune, $rune);
- }
- }
- }
- ?>
|