get_db()->prepare(" SELECT player, area_type, area, stage, time, score, rank FROM record WHERE player = :player AND area_type = :area_type AND area = :area; "); $statement->bindValue(':player', $player_id, SQLITE3_TEXT); $statement->bindValue(':area_type', $area_type, SQLITE3_TEXT); $statement->bindValue(':area', $area, SQLITE3_TEXT); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r){ $this->player = $r["player"]; $this->area = new Area($r["area"], $r["area_type"]); $this->stage = $r["stage"]; $this->time = $r["time"]; if (intval($r["score"]) > 0){ $this->score = $r["score"]; } if (strlen($r["rank"]) > 0){ $this->rank = $r["rank"]; } } } private function load_party(){ $statement = get_context()->get_db()->prepare(" SELECT unit, monster, (SELECT count(id) FROM unit WHERE unit.id = record_party.unit) AS owned, leader, front FROM record_party WHERE player = :player AND area_type = :area_type AND area = :area ORDER BY front DESC, leader DESC; "); $statement->bindValue(':player', $$this->player, SQLITE3_TEXT); $statement->bindValue(':area_type', $this->area->get_type(), SQLITE3_TEXT); $statement->bindValue(':area', $this->get_area()->get_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)); if ($r["leader"] == 1){ $this->leader = $r["unit"]; } if ($r["front"] == 1){ array_push($this->frontline, $r["unit"]); } } else{ array_push($this->party, new Monster($r["monster"], false)); if ($r["leader"] == 1){ $this->leader = $r["monster"]; } if ($r["front"] == 1){ array_push($this->frontline, $r["monster"]); } } } } /** * Retrieves the record holder's player identifier. * * @return number Player ID. */ public function get_player(){ return $this->player; } /** * Retrieves the area of the record * * @return Area Record area. */ public function get_area(){ return $this->area; } /** * Retrieves the stage of the record. * * @return number Record stage. */ public function get_stage(){ return $this->stage; } /** * Retrieves the time of the record. * * @return number record time, in milliseconds. */ public function get_time(){ return $this->time; } /** * Retrieves the score of the record. * * @return number Record score. Null if it's not a score based record. */ public function get_score(){ return $this->score; } /** * Retrieves the rank reached on the record. * * @return string Rank, in human readable form. Null if not a rank based record. */ public function get_rank(){ return $this->rank; } /** * Retrieves the party used in the record. 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; } /** * Retrieves the party leader identifier. If the leader unit is not still owned, it will get * the base monster identifierinstead. * * @return number 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 number Unit or Monster identifiers. */ public function get_frontline(){ if (! $this->flag_party){ $this->load_party(); } return $this->frontline; } } ?>