Example #1
0
 /**
  * @param array $data
  *
  * @return Name
  */
 public static function factory(array $data)
 {
     $name = new self();
     $name->setName($data['name']);
     $name->setGender($data['gender']);
     if (isset($data['probability'])) {
         $name->setProbability(floatval($data['probability']));
     }
     if (isset($data['count'])) {
         $name->setCount($data['count']);
     }
     if (isset($data['country_id'])) {
         $name->setCountry($data['country_id']);
     }
     if (isset($data['language_id'])) {
         $name->setLanguage($data['language_id']);
     }
     return $name;
 }
Example #2
0
 public static function getPokemon($where = null, $order = null, $limit = null)
 {
     if (!is_null($where)) {
         $where = ' WHERE ' . $where;
     }
     if (!is_null($order)) {
         $order = ' ORDER BY ' . $order;
     }
     if (!is_null($limit)) {
         $limit = ' LIMIT ' . $limit;
     }
     $getPokemon = TPP::db()->query("SELECT\r\n\t\t\tp.`id`, p.`pokemon`, p.`name`, p.`level`, p.`nickname`, p.`gender`, p.`hold_item`, p.`status`, p.`box_id`, p.`poke_ball`, p.`comment`,\r\n\t\t\tGROUP_CONCAT(DISTINCT m.`name` SEPARATOR ',') as `moves`,\r\n\t\t\ts.`status` as `status_name`\r\n\t\t\tFROM `pokemon` p\r\n\t\t\tLEFT JOIN `move` m\r\n\t\t\tON m.`pokemon` = p.`id`\r\n\t\t\tJOIN `status` s\r\n\t\t\tON s.`id` = p.`status`\r\n\t\t\t" . $where . " GROUP BY p.`id`" . $order . $limit) or die(TPP::db()->error);
     while ($pok = $getPokemon->fetch_assoc()) {
         $newPokemon = new self();
         $newPokemon->setAttributes(array('id' => $pok['id'], 'name' => $newPokemon->setName($pok['name'], $pok['pokemon']), 'pokemon' => $newPokemon->setPokemon($pok['pokemon']), 'level' => $newPokemon->setLevel($pok['level']), 'nickname' => $newPokemon->setNickname($pok['nickname']), 'poke_ball' => $newPokemon->setPokeBall($pok['poke_ball']), 'gender' => $newPokemon->setGender($pok['gender']), 'hold_item' => $newPokemon->setHoldItem($pok['hold_item']), 'status' => $pok['status_name'], 'comment' => FuncHelp::getDateTime($pok['comment']), 'moves' => $newPokemon->setMoves($pok['moves'])));
         $newPokemon->setAttributes($newPokemon->getFields());
         $return[] = $newPokemon;
     }
     return $return;
 }
Example #3
0
 public static function queryPokemon($where = null, $order = null, $limit = null)
 {
     if (!is_null($where)) {
         $where = ' WHERE ' . $where;
     }
     if (!is_null($order)) {
         $order = ' ORDER BY ' . $order;
     }
     if (!is_null($limit)) {
         $limit = ' LIMIT ' . $limit;
     }
     $getPokemon = TPP::db()->query("SELECT\n\t\t\tp.`id`, p.`pokemon`, p.`name`, p.`level`, p.`nickname`, p.`gender`, p.`hold_item`, p.`status`, p.`box_id`, p.`poke_ball`, p.`comment`,\n\t\t\tGROUP_CONCAT(DISTINCT m.`name` SEPARATOR ',') AS `moves`,\n\t\t\ts.`status` AS `status_name`\n\t\t\tFROM `pokemon` p\n\t\t\tLEFT JOIN `move` m\n\t\t\tON m.`pokemon` = p.`id`\n\t\t\tJOIN `status` s\n\t\t\tON s.`id` = p.`status`\n\t\t\t" . $where . " GROUP BY p.`id`" . $order . $limit);
     $return = [];
     while ($pok = $getPokemon->fetch()) {
         $newPokemon = new self();
         $newPokemon->setAttributes(['id' => $pok['id'], 'name' => $newPokemon->setName($pok['name'], $pok['pokemon']), 'pokemon' => $newPokemon->setPokemon($pok['pokemon']), 'level' => $newPokemon->setLevel($pok['level']), 'nickname' => $newPokemon->setNickname($pok['nickname']), 'poke_ball' => $newPokemon->setPokeBall($pok['poke_ball']), 'gender' => $newPokemon->setGender($pok['gender']), 'hold_item' => $newPokemon->setHoldItem($pok['hold_item']), 'box' => (int) $pok['box_id'], 'status' => $pok['status_name'], 'comment' => Helper::getDateTime($pok['comment']), 'moves' => $newPokemon->setMoves($pok['moves'])]);
         $return[$newPokemon->id] = $newPokemon;
     }
     $return = self::getFieldsAll($return);
     return $return;
 }
Example #4
0
 /**
  * Creates a character with attributes
  *
  * @param $name string Name of the character
  * @param $level integer Level of the character
  * @param $class string Class of the character
  * @param $race string Race of the character
  * @param $gender string Gender of the character
  * @return Charac The newly created instance of Charac
  */
 public static function withAttributes($name, $level, $class, $race, $gender)
 {
     $instance = new self();
     $instance->setName($name);
     $instance->setLevel($level);
     $instance->setClass($class);
     $instance->setRace($race);
     $instance->setGender($gender);
     return $instance;
 }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['skin' => null, 'hair' => null, 'shirt' => null, 'pants' => null, 'hat' => null, 'shoes' => null, 'gender' => null, 'eyes' => null, 'backpack' => null], $values);
     $message->setSkin($values['skin']);
     $message->setHair($values['hair']);
     $message->setShirt($values['shirt']);
     $message->setPants($values['pants']);
     $message->setHat($values['hat']);
     $message->setShoes($values['shoes']);
     $message->setGender($values['gender']);
     $message->setEyes($values['eyes']);
     $message->setBackpack($values['backpack']);
     return $message;
 }
Example #6
0
 /**
  * @param Profile $profile
  * @return Avatar
  */
 public static function generateRandom(Profile $profile)
 {
     $avatar = new self($profile);
     $avatar->setSkin(mt_rand(0, 3));
     $avatar->setHair(mt_rand(0, 5));
     $avatar->setShirt(mt_rand(0, 3));
     $avatar->setPants(mt_rand(0, 2));
     $avatar->setHat(mt_rand(0, 4));
     $avatar->setShoes(mt_rand(0, 6));
     $avatar->setGender(mt_rand(0, 1));
     $avatar->setEyes(mt_rand(0, 4));
     $avatar->setBackpack(mt_rand(0, 5));
     return $avatar;
 }
Example #7
0
 public static function createStudentFromId($id)
 {
     $student = new self();
     $query = "SELECT * FROM TUSERS U JOIN TSTUDENTS S ON U.`User ID` = S.`User ID` WHERE U.`User ID` = {$id}";
     $user = db_select($query);
     $student->setUserId($id);
     $student->setFirstName($user[0]['First Name']);
     $student->setSurname($user[0]['Surname']);
     $student->setPrefferedName($user[0]['Preferred Name']);
     $student->setStudentId($user[0]['Student ID']);
     $student->setEmail($user[0]['Email']);
     $student->setRole($user[0]['Role']);
     $student->setGender($user[0]['Gender']);
     $student->setDateOfBirth($user[0]['DOB']);
     $student->setValidation($user[0]['Validation']);
     return $student;
 }