get_db()->prepare(" SELECT player, id, name, description, area_type, area, stage, difficulty, score FROM team WHERE id = :id; "); $statement->bindValue(':id', $id, SQLITE3_TEXT); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r){ $this->player = $r["player"]; $this->id = $r["id"]; $this->name = HTML::e($r["name"]); $this->description = HTML::e($r["description"]); $this->area = new Area($r["area"], $r["area_type"]); $this->stage = $r["stage"]; $this->score = $r["score"]; } } private function load_units(){ $statement = get_context()->get_db()->prepare(" SELECT unit, leader, front FROM team_unit WHERE team = :team ORDER BY front DESC, leader DESC; "); $statement->bindValue(':team', $this->id, SQLITE3_TEXT); $q = $statement->execute(); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ array_push($this->unit, new Unit($r["unit"], false)); if ($r["leader"] == 1){ $this->leader = $r["unit"]; } if ($r["front"] == 1){ array_push($this->frontline, $r["unit"]); } } $this->flag_units = true; } /** * Retrieves the account's player identifier. * * @return number Player ID. */ public function get_player(){ return $this->player; } /** * Retrieves the team identifier. * * @return number Team ID. */ public function get_id(){ return $this->id; } /** * Retrieves the team name. * * @return string Team name. */ public function get_name(){ return $this->name; } /** * Retrieves the team description. * * @return string Team description (can be an empty string). */ public function get_description(){ return $this->description; } /** * Retrieves the units in the team. * * @return Unit[] Units in the team. */ public function get_units(){ if (! $this->flag_units){ $this->load_units(); } return $this->unit; } /** * Retrieves the leader unit's identifier. * * @return number Leader unit ID. */ public function get_leader(){ return $this->leader; } /** * Retrieves the identifiers of the units in the frontline. * * @return number[] ID of units in the frontline. */ public function get_frontline(){ return $this->frontline; } /** * Retrieves the area the team is set for. * * @return Area Team area. */ public function get_area(){ return $this->area; } /** * Retrieves the stage the team is intended to. * * @return number Team stage, can be null. */ public function get_stage(){ return $this->stage; } /** * Retrieves the difficulty of the area the team is intended for. * * @see DIFFICULTY_ID * * @return number Difficulty ID, can be null. */ public function get_difficulty(){ return $this->difficulty; } /** * Retrieves the score of the team for the optimizer. * * @return number Team score. */ public function get_score(){ return $this->score; } } ?>