|
|
@@ -25,145 +25,111 @@ require_once(PATH::ENTITY . "Rune_Set.php");
|
|
|
*
|
|
|
* @category Entity
|
|
|
* @todo Consider artifact drops.
|
|
|
- * @todo Currently not working, fix.
|
|
|
*/
|
|
|
class Run extends Entity{
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @var int Owner's player identifier.
|
|
|
*/
|
|
|
- public $player;
|
|
|
-
|
|
|
+ private $player;
|
|
|
+
|
|
|
/**
|
|
|
* @var int Run identifier.
|
|
|
*/
|
|
|
- public $id;
|
|
|
-
|
|
|
+ private $id;
|
|
|
+
|
|
|
/**
|
|
|
- * @var DateTime Run start datestamp.
|
|
|
+ * @var DateTime Run start times.
|
|
|
*/
|
|
|
- public $dtime;
|
|
|
-
|
|
|
+ private $start_time;
|
|
|
+
|
|
|
/**
|
|
|
* @var Area Area.
|
|
|
*/
|
|
|
- public $area;
|
|
|
-
|
|
|
+ private $area;
|
|
|
+
|
|
|
/**
|
|
|
* @var int Stage.
|
|
|
*/
|
|
|
- public $stage;
|
|
|
-
|
|
|
+ private $stage;
|
|
|
+
|
|
|
/**
|
|
|
* @var int Difficulty (only scenario and dimension hole)
|
|
|
*/
|
|
|
- public $difficulty;
|
|
|
-
|
|
|
+ private $difficulty;
|
|
|
+
|
|
|
/**
|
|
|
- * @var bool Win or lost run.
|
|
|
+ * @var bool Won or lost run.
|
|
|
*/
|
|
|
- public $win;
|
|
|
-
|
|
|
+ private $win;
|
|
|
+
|
|
|
/**
|
|
|
* @var int Clear time, milliseconds.
|
|
|
*/
|
|
|
- public $time;
|
|
|
-
|
|
|
- /**
|
|
|
- * @var int Reward mana.
|
|
|
- */
|
|
|
- public $mana = 0;
|
|
|
-
|
|
|
- /**
|
|
|
- * @var int Reward energy.
|
|
|
- */
|
|
|
- public $energy = 0;
|
|
|
-
|
|
|
- /**
|
|
|
- * @var int Reward crystal.
|
|
|
- */
|
|
|
- public $crystal = 0;
|
|
|
-
|
|
|
- /**
|
|
|
- * @var int Reward Honor Points (Arena).
|
|
|
- */
|
|
|
- public $honor_points = 0;
|
|
|
-
|
|
|
- /**
|
|
|
- * @var int Reward Guild Points.
|
|
|
- */
|
|
|
- public $guild_points = 0;
|
|
|
-
|
|
|
+ private $time;
|
|
|
+
|
|
|
/**
|
|
|
* @var bool Indicates if a frind/mentor helped.
|
|
|
*/
|
|
|
- public $helper;
|
|
|
-
|
|
|
+ private $helper;
|
|
|
+
|
|
|
/**
|
|
|
* @var int Score in battles that are rated (WB, rift dungeons...).
|
|
|
*/
|
|
|
- public $score;
|
|
|
-
|
|
|
+ private $score;
|
|
|
+
|
|
|
/**
|
|
|
* @var String Rank in battles that are rated (WB, rift dungeons...).
|
|
|
*/
|
|
|
- public $rank;
|
|
|
-
|
|
|
+ private $rank;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var bool Internal flag to check if the run parti has been loaded.
|
|
|
+ */
|
|
|
+ private $flag_party = false;
|
|
|
+
|
|
|
/**
|
|
|
* @var Unit[]|Monster[] Units or monsters used.
|
|
|
* If the unit is still owned, it will be a instance of Unit.
|
|
|
* If not, it will be a instance of monster.
|
|
|
*/
|
|
|
- public $party = [];
|
|
|
-
|
|
|
+ private $party = [];
|
|
|
+
|
|
|
/**
|
|
|
* @var int ID of the leader unit or monster.
|
|
|
*/
|
|
|
- public $leader;
|
|
|
-
|
|
|
+ private $leader;
|
|
|
+
|
|
|
/**
|
|
|
* @var int[] List of IDs of the frontline units or monsters.
|
|
|
*/
|
|
|
- public $frontline = [];
|
|
|
-
|
|
|
- /**
|
|
|
- * @var Item[] Dropped items.
|
|
|
- */
|
|
|
- public $item = [];
|
|
|
-
|
|
|
- /**
|
|
|
- * @var Monster[] Units dropped.
|
|
|
- */
|
|
|
- public $monster = [];
|
|
|
-
|
|
|
- /**
|
|
|
- * @var int Monster[] Units whose secret dungeons were found on the run.
|
|
|
- */
|
|
|
- public $sd = [];
|
|
|
-
|
|
|
- /**
|
|
|
- * @var mixed[] List of dropped summon pieces.
|
|
|
- *
|
|
|
- * Formated as:
|
|
|
- * [@{see Monster}, amount]
|
|
|
- */
|
|
|
- public $unit_piece = [];
|
|
|
-
|
|
|
- /**
|
|
|
- * @var int Number of shapeshifting stones dropped;
|
|
|
- */
|
|
|
- public $shapeshifting = 0;
|
|
|
-
|
|
|
+ private $frontline = [];
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * @var Rune[] List of Runes dropped.
|
|
|
+ * @var bool Internal flag to check if run rewards have been loaded.
|
|
|
*/
|
|
|
- public $rune = [];
|
|
|
-
|
|
|
+ private $flag_reward = false;
|
|
|
+
|
|
|
/**
|
|
|
- * @var Enchantment[] List of Enchantments dropped.
|
|
|
+ * @var array List of run rewards.
|
|
|
*/
|
|
|
- public $enchantment = [];
|
|
|
-
|
|
|
+ private $reward = [
|
|
|
+ "mana" => 0,
|
|
|
+ "energy" => 0,
|
|
|
+ "crystal" => 0,
|
|
|
+ "honor_points" => 0,
|
|
|
+ "guild_points" => 0,
|
|
|
+ "item" => [],
|
|
|
+ "monster" => null,
|
|
|
+ "sd" => null,
|
|
|
+ "monster_piece" => [],
|
|
|
+ "shapeshifting" => 0,
|
|
|
+ "rune" => [],
|
|
|
+ "enchantment" => [],
|
|
|
+ "artifact" => []
|
|
|
+ ];
|
|
|
+
|
|
|
/**
|
|
|
* Constructor.
|
|
|
*
|
|
|
@@ -173,7 +139,7 @@ class Run extends Entity{
|
|
|
* @param int $id Run identifier.
|
|
|
*/
|
|
|
public function __construct($id){
|
|
|
-
|
|
|
+
|
|
|
$statement = get_context()->get_db()->prepare("
|
|
|
SELECT
|
|
|
id,
|
|
|
@@ -201,327 +167,355 @@ class Run extends Entity{
|
|
|
if ($r){
|
|
|
$this->id = $r["id"];
|
|
|
$this->player = $r["player"];
|
|
|
- $this->dtime = $r["dtime"];
|
|
|
+ $this->start_time = new Datetime();
|
|
|
+ $this->start_time->setTimestamp($r["dtime"]);
|
|
|
$this->area = new Area($r["area"], $r["area_type"]);
|
|
|
$this->stage = $r["stage"];
|
|
|
$this->difficulty = $r["difficulty"];
|
|
|
- $this->win = $r["win"];
|
|
|
+ $this->win = filter_var($r["win"], FILTER_VALIDATE_BOOLEAN);
|
|
|
$this->time = $r["time"];
|
|
|
- $this->mana = $r["mana"];
|
|
|
- $this->energy = $r["energy"];
|
|
|
- $this->crystal = $r["crystal"];
|
|
|
- $this->honor_points = $r["honor_points"];
|
|
|
- $this->guild_points = $r["guild_points"];
|
|
|
- $this->helper = $r["helper"];
|
|
|
+ $this->reward["mana"] = $r["mana"];
|
|
|
+ $this->reward["energy"] = $r["energy"];
|
|
|
+ $this->reward["crystal"] = $r["crystal"];
|
|
|
+ $this->reward["honor_points"] = $r["honor_points"];
|
|
|
+ $this->reward["guild_points"] = $r["guild_points"];
|
|
|
+ $this->helper = filter_var($r["helper"], FILTER_VALIDATE_BOOLEAN);
|
|
|
$this->score = $r["score"];
|
|
|
$this->rank = $r["rank"];
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- SELECT
|
|
|
- unit,
|
|
|
- monster,
|
|
|
- (SELECT count(id) FROM unit WHERE unit.id = run_party.unit) AS owned,
|
|
|
- leader,
|
|
|
- front
|
|
|
- FROM run_party
|
|
|
- WHERE run = :run
|
|
|
- ORDER BY
|
|
|
- front DESC,
|
|
|
- leader DESC;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
- if ($r["owned"] > 0){
|
|
|
- array_push($this->party, new Unit($r["unit"], false));
|
|
|
- }
|
|
|
- else{
|
|
|
- array_push($this->party, new Monster($r["monster"], false));
|
|
|
- }
|
|
|
- if ($r["leader"] == 1){
|
|
|
- $this->leader = $r["unit"];
|
|
|
- }
|
|
|
- if ($r["front"] == 1){
|
|
|
- array_push($this->frontline, $r["unit"]);
|
|
|
- }
|
|
|
- }
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- SELECT
|
|
|
- item,
|
|
|
- amount
|
|
|
- FROM run_drop_item
|
|
|
- WHERE run = :run;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
- $i = new Item($r["item"]);
|
|
|
- $i->amount = $r["amount"];
|
|
|
- array_push($this->item, $i);
|
|
|
- }
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- SELECT monster
|
|
|
- FROM run_drop_monster
|
|
|
- WHERE run = :run;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
- array_push($this->monster, new Monster($r["monster"]));
|
|
|
- }
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- SELECT monster
|
|
|
- FROM run_drop_sd
|
|
|
- WHERE run = :run;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
- array_push($this->sd, new Monster($r["monster"]));
|
|
|
- }
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- SELECT
|
|
|
- monster,
|
|
|
- amount
|
|
|
- FROM run_drop_monster_pieces
|
|
|
- WHERE run = :run;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
- $i = [
|
|
|
- "monster" => new Monster($r["monster"]),
|
|
|
- "amount" => $r["amount"]
|
|
|
- ];
|
|
|
- array_push($this->unit_piece, $i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function load_party(){
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT
|
|
|
+ unit,
|
|
|
+ monster,
|
|
|
+ (SELECT count(id) FROM unit WHERE unit.id = run_party.unit) AS owned,
|
|
|
+ leader,
|
|
|
+ front
|
|
|
+ FROM run_party
|
|
|
+ WHERE run = :run
|
|
|
+ ORDER BY
|
|
|
+ front DESC,
|
|
|
+ leader DESC;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ if ($r["owned"] > 0){
|
|
|
+ array_push($this->party, new Unit($r["unit"], false));
|
|
|
}
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- SELECT amount
|
|
|
- FROM run_drop_shapeshifting
|
|
|
- WHERE run = :run;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- $r = $q->fetchArray(SQLITE3_ASSOC);
|
|
|
- if ($r){
|
|
|
- $this->shapeshifting = $r["amount"];
|
|
|
+ else{
|
|
|
+ array_push($this->party, new Monster($r["monster"], false));
|
|
|
}
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- 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 = :run;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
- $rune = new Rune($r["id"]);
|
|
|
- if (!isset($rune->id)){
|
|
|
- $rune->id = $r["id"];
|
|
|
- $rune->level = 0;
|
|
|
- $rune->assigned_to = null;
|
|
|
- $rune->type = new Rune_Set($r["type"]);
|
|
|
- $rune->slot = $r["slot"];
|
|
|
- $rune->stars = $r["stars"];
|
|
|
- $rune->ancient = $r["ancient"];
|
|
|
- $rune->quality = $r["quality"];
|
|
|
- $rune->original_quality = $r["quality"];
|
|
|
- $rune->quality_name = $this->get_rune_quality_name($r["quality"]);
|
|
|
- $rune->original_quality_name = $this->get_rune_quality_name($r["quality"]);
|
|
|
- $rune->value = $r["value"];
|
|
|
- $rune->value = 0;
|
|
|
- $rune->efficiency = $r["efficiency"];
|
|
|
- // TODO: Calculate?
|
|
|
- $rune->max_efficiency = $r["efficiency"];
|
|
|
- $rune->main_stat = new Rune_Stat(null, null);
|
|
|
- $rune->main_stat->slot = RUNE_STAT_SLOT_ID::MAIN;
|
|
|
- $rune->main_stat->stat = $r["main_stat"];
|
|
|
- $rune->main_stat->stat_name = $this->get_stat_name($r["main_stat"]);
|
|
|
- $rune->main_stat->value = $r["main_stat_value"];
|
|
|
- if ($r["innate_stat"] != null){
|
|
|
- $rune->innate_stat = new Rune_Stat(null, null);
|
|
|
- $rune->innate_stat->slot = RUNE_STAT_SLOT_ID::INNATE;
|
|
|
- $rune->innate_stat->stat = $r["innate_stat"];
|
|
|
- $rune->innate_stat->stat_name = $this->get_stat_name($r["innate_stat"]);
|
|
|
- $rune->innate_stat->value = $r["innate_stat_value"];
|
|
|
- }
|
|
|
- if ($r["substat_1"] != null){
|
|
|
- $substat = new Rune_Stat(null, null);
|
|
|
- $substat->slot = RUNE_STAT_SLOT_ID::SUBSTAT_1;
|
|
|
- $substat->stat = $r["substat_1"];
|
|
|
- $substat->stat_name = $this->get_stat_name($r["substat_1"]);
|
|
|
- $substat->value = $r["substat_1_value"];
|
|
|
- array_push($rune->substats, $substat);
|
|
|
- }
|
|
|
- if ($r["substat_2"] != null){
|
|
|
- $substat = new Rune_Stat(null, null);
|
|
|
- $substat->slot = RUNE_STAT_SLOT_ID::SUBSTAT_2;
|
|
|
- $substat->stat = $r["substat_2"];
|
|
|
- $substat->stat_name = $this->get_stat_name($r["substat_2"]);
|
|
|
- $substat->value = $r["substat_2_value"];
|
|
|
- array_push($rune->substats, $substat);
|
|
|
- }
|
|
|
- if ($r["substat_3"] != null){
|
|
|
- $substat = new Rune_Stat(null, null);
|
|
|
- $substat->slot = RUNE_STAT_SLOT_ID::SUBSTAT_3;
|
|
|
- $substat->stat = $r["substat_3"];
|
|
|
- $substat->stat_name = $this->get_stat_name($r["substat_3"]);
|
|
|
- $substat->value = $r["substat_3_value"];
|
|
|
- array_push($rune->substats, $substat);
|
|
|
- }
|
|
|
- if ($r["substat_4"] != null){
|
|
|
- $substat = new Rune_Stat(null, null);
|
|
|
- $substat->slot = RUNE_STAT_SLOT_ID::SUBSTAT_4;
|
|
|
- $substat->stat = $r["substat_4"];
|
|
|
- $substat->stat_name = $this->get_stat_name($r["substat_4"]);
|
|
|
- $substat->value = $r["substat_4_value"];
|
|
|
- array_push($rune->substats, $substat);
|
|
|
- }
|
|
|
- }
|
|
|
- array_push($this->rune, $rune);
|
|
|
+ if ($r["leader"] == 1){
|
|
|
+ $this->leader = $r["unit"];
|
|
|
}
|
|
|
- $statement = get_context()->get_db()->prepare("
|
|
|
- SELECT
|
|
|
- run_drop_enchantment.id AS id,
|
|
|
- type,
|
|
|
- run_drop_enchantment.quality AS quality,
|
|
|
- rune,
|
|
|
- run_drop_enchantment.stat AS stat,
|
|
|
- value,
|
|
|
- enchantment_type.inmemorial AS inmemorial,
|
|
|
- enchantment_type.ancient AS ancient,
|
|
|
- enchantment_range.min AS min,
|
|
|
- enchantment_range.max AS max
|
|
|
- FROM
|
|
|
- run_drop_enchantment,
|
|
|
- enchantment_type,
|
|
|
- enchantment_range
|
|
|
- WHERE
|
|
|
- run = :run AND
|
|
|
- run_drop_enchantment.type = enchantment_type.id AND
|
|
|
- enchantment_type.gem = enchantment_range.gem AND
|
|
|
- enchantment_type.gem = enchantment_range.gem AND
|
|
|
- enchantment_type.ancient = enchantment_range.ancient AND
|
|
|
- run_drop_enchantment.quality = enchantment_range.quality AND
|
|
|
- run_drop_enchantment.stat = enchantment_range.stat;
|
|
|
- ");
|
|
|
- $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
- $q = $statement->execute();
|
|
|
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
- $enchantment = new Enchantment($r["id"]);
|
|
|
- if (!isset($enchantment->id)){
|
|
|
- $enchantment->id = $r["id"];
|
|
|
- if ($r["type"] == ENCHANTMENT_TYPE_ID::ENCHANT_GEM || $r["type"] == ENCHANTMENT_TYPE_ID::INMEMORIAL_GEM){
|
|
|
- $enchantment->gem = 1;
|
|
|
- }
|
|
|
- else{
|
|
|
- $enchantment->gem = 0;
|
|
|
- }
|
|
|
- $enchantment->quality = $r["quality"];
|
|
|
- $enchantment->value = 0;
|
|
|
- $enchantment->stat = $r["stat"];
|
|
|
- $enchantment->ancient = $r["ancient"];
|
|
|
- $enchantment->inmemorial = $r["inmemorial"];
|
|
|
- $enchantment->rune = new Rune_Set($r["rune"]);
|
|
|
- $enchantment->min = $r["min"];
|
|
|
- $enchantment->max = $r["max"];
|
|
|
- $enchantment->value = $r["value"];
|
|
|
- $enchantment->amount = 0;
|
|
|
- $enchantment->refresh_names();
|
|
|
- }
|
|
|
- else{
|
|
|
- $enchantment->amount = 0;
|
|
|
- }
|
|
|
- array_push($this->enchantment, $enchantment);
|
|
|
+ if ($r["front"] == 1){
|
|
|
+ array_push($this->frontline, $r["unit"]);
|
|
|
}
|
|
|
}
|
|
|
+ $this->flag_party = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function load_reward(){
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT
|
|
|
+ item,
|
|
|
+ amount
|
|
|
+ FROM run_drop_item
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ $item = [
|
|
|
+ "inventory" => new Inventory($r["item"]),
|
|
|
+ "amount" => $r["amount"]
|
|
|
+ ];
|
|
|
+ array_push($this->reward["item"], $item);
|
|
|
+ }
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT unit AS monster
|
|
|
+ FROM run_drop_unit
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ $this->reward["monster"] = new Monster($r["monster"]);
|
|
|
+ }
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT unit AS monster
|
|
|
+ FROM run_drop_sd
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ $this->reward["sd"] = new Monster($r["monster"]);
|
|
|
+ }
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT
|
|
|
+ unit AS monster,
|
|
|
+ amount
|
|
|
+ FROM run_drop_unit_pieces
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ $i = [
|
|
|
+ "monster" => new Monster($r["monster"]),
|
|
|
+ "amount" => $r["amount"]
|
|
|
+ ];
|
|
|
+ array_push($this->reward["monster_piece"], $i);
|
|
|
+ }
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT amount
|
|
|
+ FROM run_drop_shapeshifting
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ $r = $q->fetchArray(SQLITE3_ASSOC);
|
|
|
+ if ($r){
|
|
|
+ $this->reward["shapeshifting"] = $r["amount"];
|
|
|
+ }
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT id
|
|
|
+ FROM run_drop_rune
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ $rune = new Rune($r["id"]);
|
|
|
+ array_push($this->reward["rune"], $rune);
|
|
|
+ }
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT id
|
|
|
+ FROM run_drop_artifact
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ $artifact = new Artifact($r["id"]);
|
|
|
+ array_push($this->reward["artifact"], $artifact);
|
|
|
+ }
|
|
|
+ $statement = get_context()->get_db()->prepare("
|
|
|
+ SELECT id
|
|
|
+ FROM run_drop_enchantment
|
|
|
+ WHERE run = :run;
|
|
|
+ ");
|
|
|
+ $statement->bindValue(':run', $this->id, SQLITE3_TEXT);
|
|
|
+ $q = $statement->execute();
|
|
|
+ while ($r = $q->fetchArray(SQLITE3_ASSOC)){
|
|
|
+ $enchantment = new Enchantment($r["id"]);
|
|
|
+ array_push($this->reward[enchantment], $enchantment);
|
|
|
+ }
|
|
|
+ $this->flag_reward = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the player identifier.
|
|
|
+ *
|
|
|
+ * @return int Player ID.
|
|
|
+ */
|
|
|
+ public function get_player(){
|
|
|
+ return $this->player;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the run identifier.
|
|
|
+ *
|
|
|
+ * @return int Run ID.
|
|
|
+ */
|
|
|
+ public function get_id(){
|
|
|
+ return $this->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets the time of the run start.
|
|
|
+ *
|
|
|
+ * If $format is supplied, a string in the desired format will be returned. If not, the raw
|
|
|
+ * DateTime object will e returned.
|
|
|
+ *
|
|
|
+ * @param string $format A date format (optional).
|
|
|
+ * @return DateTime | string The raw date, or a formatted version.
|
|
|
+ */
|
|
|
+ public function get_start_time($format = null){
|
|
|
+ if (null == $format){
|
|
|
+ return $this->start_time;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return $this->start_time->format($format);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the area of the run.
|
|
|
+ *
|
|
|
+ * @return Area Run area.
|
|
|
+ */
|
|
|
+ public function get_area(){
|
|
|
+ return $this->area;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the stage of the run, if any.
|
|
|
+ *
|
|
|
+ * @return int Stage number, null if none.
|
|
|
+ */
|
|
|
+ public function get_stage(){
|
|
|
+ return $this->stage;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the difficulty of the run, if any.
|
|
|
+ *
|
|
|
+ * @see DIFFICULTY_ID
|
|
|
+ * @return int Difficulty ID, null if none.
|
|
|
+ */
|
|
|
+ public function get_difficulty(){
|
|
|
+ return $this->difficulty;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks if the run was won.
|
|
|
+ *
|
|
|
+ * @return bool True if voctory, false otherwise.
|
|
|
+ */
|
|
|
+ public function is_win(){
|
|
|
+ return $this->win;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the duration of the run in millisecondes.
|
|
|
+ *
|
|
|
+ * @return int Run time.
|
|
|
+ */
|
|
|
+ public function get_time(){
|
|
|
+ return $this->time;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Check if a frind or mentor representative's help was used.
|
|
|
+ *
|
|
|
+ * @return bool True if helper included, false otherwise.
|
|
|
+ */
|
|
|
+ public function had_help(){
|
|
|
+ return $this->helper;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the score of the run.
|
|
|
+ *
|
|
|
+ * @return int Run score. Null if it's not a score based run.
|
|
|
+ */
|
|
|
+ public function get_score(){
|
|
|
+ return $this->score;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Gets a quality name frm the mappings.
|
|
|
+ * Retrieves the rank reached on the run.
|
|
|
*
|
|
|
- * @param int $quality Quality id.
|
|
|
- * @return string Quality name (Uppercase)
|
|
|
- */
|
|
|
- private function get_rune_quality_name($quality){
|
|
|
- switch ($quality){
|
|
|
- case QUALITY_ID::NORMAL:
|
|
|
- return "NORMAL";
|
|
|
- case QUALITY_ID::MAGIC:
|
|
|
- return "MAGIC";
|
|
|
- case QUALITY_ID::RARE:
|
|
|
- return "RARE";
|
|
|
- case QUALITY_ID::HERO:
|
|
|
- return "HERO";
|
|
|
- case QUALITY_ID::LEGEND:
|
|
|
- return "LEGEND";
|
|
|
- default:
|
|
|
- return "";
|
|
|
+ * @return string Rank, in human readable form. Null if not a rank based run.
|
|
|
+ */
|
|
|
+ public function get_rank(){
|
|
|
+ return $this->rank;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the party used in the run. If one of the units is not still owned, it will get
|
|
|
+ * the base monster instead.
|
|
|
+ *
|
|
|
+ * @return (Unit|Monster)[] Party units or monsters.
|
|
|
+ */
|
|
|
+ public function get_party(){
|
|
|
+ if (! $this->flag_party){
|
|
|
+ $this->load_party();
|
|
|
}
|
|
|
+ return $this->party;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Gets a stat name from the mappings.
|
|
|
+ * Retrieves the party leader identifier. If the leader unit is not still owned, it will get
|
|
|
+ * the base monster identifierinstead.
|
|
|
*
|
|
|
- * @param int $stat Stat id.
|
|
|
- * @return string Stat name (Uppercase)
|
|
|
- */
|
|
|
- private function get_stat_name($stat){
|
|
|
- switch ($stat){
|
|
|
- case RUNE_STAT_ID::HP:
|
|
|
- return "HP";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::HP_P:
|
|
|
- return "HP%";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::ATK:
|
|
|
- return "ATK";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::ATK_P:
|
|
|
- return "ATK%";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::DEF:
|
|
|
- return "DEF";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::DEF_P:
|
|
|
- return "DEF%";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::SPD:
|
|
|
- return "SPD";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::CRR:
|
|
|
- return "CRR";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::CRD:
|
|
|
- return "CRD";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::RES:
|
|
|
- return "RES";
|
|
|
- break;
|
|
|
- case RUNE_STAT_ID::ACC:
|
|
|
- return "ACC";
|
|
|
- break;
|
|
|
- default:
|
|
|
- return "";
|
|
|
+ * @return int Leader unit or monster ID.
|
|
|
+ */
|
|
|
+ public function get_leader(){
|
|
|
+ if (! $this->flag_party){
|
|
|
+ $this->load_party();
|
|
|
}
|
|
|
+ return $this->leader;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Retrieves the identifiers of the party members in the frontline. If one of the units is not
|
|
|
+ * still owned, it will get the base monster instead.
|
|
|
+ *
|
|
|
+ * @return int Unit or Monster identifiers.
|
|
|
+ */
|
|
|
+ public function get_frontline(){
|
|
|
+ if (! $this->flag_party){
|
|
|
+ $this->load_party();
|
|
|
+ }
|
|
|
+ return $this->frontline;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Retrieves the list of rewards from the run reward.
|
|
|
+ *
|
|
|
+ * Here is an example (note that, in most cases, only a few items will be populated for a run):
|
|
|
+ * <code>
|
|
|
+ * [
|
|
|
+ * "mana" => 2365, // Dropped mana, 0 if none
|
|
|
+ * "energy" => 1, // Dropped energy, 0 if none.
|
|
|
+ * "crystal" => 0, // Dropped crystals, 0 if none.
|
|
|
+ * "honor_points" => 3, // Dropped honor points, 0 if none.
|
|
|
+ * "guild_points" => 8, // Dropped guild points, 0 if none.
|
|
|
+ * "item" => [ // Items dropped, empty if none.
|
|
|
+ * [ // One item.
|
|
|
+ * "inventory" => (Inventory), // Inventory ID.
|
|
|
+ * "amount => 4 // Dropped quantity.
|
|
|
+ * ],
|
|
|
+ * [ // One item.
|
|
|
+ * "inventory" => (Inventory), // Inventory ID.
|
|
|
+ * "amount => 3 // Dropped quantity.
|
|
|
+ * ],
|
|
|
+ * ],
|
|
|
+ * "monster" => (Monster), // Dropped monster instance, null if none.
|
|
|
+ * "sd" => (Monster), // Opened Secret Dungeon monster instance, null if none.
|
|
|
+ * "monster_piece" => [ // Dropped monster pieces.
|
|
|
+ * "monster" => (Monster), // Monster entity
|
|
|
+ * "amount" => 4 // Quantity
|
|
|
+ * ],
|
|
|
+ * "shapeshifting" => 0, // Dropped transmogification stones, 0 if none.
|
|
|
+ * "rune" => [ // Dropped runes, empty if none.
|
|
|
+ * (Rune), // Rune instance.
|
|
|
+ * (Rune), // Rune instance.
|
|
|
+ * (Rune) // Rune instance.
|
|
|
+ * ],
|
|
|
+ * "enchantment" => [ // Dropped enchantments, empty if none.
|
|
|
+ * (Enchantment), // Enchantment instance.
|
|
|
+ * (Enchantment) // Enchantment instance.
|
|
|
+ * ],
|
|
|
+ * "artifact" => [ // Dropped artifacts, empty if none.
|
|
|
+ * (Artifact), // Enchantment instance.
|
|
|
+ * (Artifact), // Artifact instance.
|
|
|
+ * ]
|
|
|
+ * </code>
|
|
|
+ *
|
|
|
+ * @return mixed[]
|
|
|
+ */
|
|
|
+ public function get_rewards(){
|
|
|
+ if (! $this->flag_reward){
|
|
|
+ $this->load_reward();
|
|
|
+ }
|
|
|
+ return $this->reward;
|
|
|
+ }
|
|
|
+
|
|
|
}
|