| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- /**
- * Team entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "K_Area.php");
- require_once(PATH::ENTITY . "Unit.php");
- /**
- * A Team.
- *
- * Represents an object from the table 'unit'.
- *
- * @category Entity
- */
- class Team extends Entity{
- /**
- * @var int Owner identifier.
- */
- public $uid;
- /**
- * @var int Team identifier.
- */
- public $id;
- /**
- * @var string Team name.
- */
- public $name;
- /**
- * @var string Team description.
- */
- public $description;
- /**
- * @var \Unit[] Units in the team.
- */
- public $unit = [];
- /**
- * @var Area Area the team is designed for.
- */
- public $area;
- /**
- * @var int Stage the team is designed for. It can be null.
- */
- public $stage;
- /**
- * @var int difficulty the team is designed for. It can be null.
- *
- * @see DIFFICULTY
- */
- public $difficulty;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * monster, populating it and it's items.
- *
- * @param resource $db Connection to the database.
- * @param int $id Monster identifier.
- * @param bool $complete If false, it won't load the units.
- */
- public function __construct($db, $id, $complete = true){
- parent::__construct($db);
- $s = "
- SELECT
- uid,
- id,
- name,
- description,
- area_type,
- area,
- stage,
- difficulty
- FROM team
- WHERE id = '$id';
- ";
- $q = $this->db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $this->uid = $r["uid"];
- $this->id = $r["id"];
- $this->name = HTML::e($r["name"]);
- $this->description = HTML::e($r["description"]);
- $this->area = new K_Area($this->db, $r["area"], $r["area_type"]);
- $this->stage = $r["stage"];
- if ($complete){
- $s = "
- SELECT unit
- FROM team_unit
- WHERE team = '$id';
- ";
- $q = $this->db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->unit, new Unit($this->db, $r["unit"], false));
- }
- }
- }
- }
- ?>
|