evolve QuesttypeAgents with fixed Actions and Character submission handling
This commit is contained in:
parent
5461a4d937
commit
1c1d12a116
22 changed files with 724 additions and 140 deletions
|
|
@ -150,6 +150,35 @@
|
|||
return $data[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Character by its Id.
|
||||
*
|
||||
* @throws IdNotFoundException
|
||||
* @param string $characterId ID of the Character
|
||||
* @return array Character data
|
||||
*/
|
||||
public function getCharacterById($characterId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT characters.id, characters.created, characters.charactertype_id, characters.name, characters.url, characters.user_id, characters.xps, characters.xplevel, charactertypes.name AS charactertype_name, charactertypes.url AS charactertypes_url, media.url AS avatar_url, media.description AS avatar_description '.
|
||||
'FROM v_characters AS characters '.
|
||||
'LEFT JOIN charactertypes ON charactertypes.id = characters.charactertype_id '.
|
||||
'LEFT JOIN avatars ON avatars.id = characters.avatar_id '.
|
||||
'LEFT JOIN avatarpictures ON avatarpictures.media_id = avatars.avatarpicture_id '.
|
||||
'LEFT JOIN media ON media.id = avatarpictures.media_id '.
|
||||
'WHERE characters.id = ?',
|
||||
'i',
|
||||
$characterId
|
||||
);
|
||||
if(empty($data)) {
|
||||
throw new \nre\exceptions\IdNotFoundException($characterUrl);
|
||||
}
|
||||
|
||||
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -299,6 +299,46 @@
|
|||
return (!empty($count) && intval($count[0]['c']) > 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Characters that solved a Quest.
|
||||
*
|
||||
* @param int $questId ID of Quest to get Characters for
|
||||
* @return array Characters data
|
||||
*/
|
||||
public function getCharactersSolvedQuest($questId)
|
||||
{
|
||||
return $data = $this->db->query(
|
||||
'SELECT character_id, created, text '.
|
||||
'FROM questtypes_submit_characters '.
|
||||
'WHERE quest_id = ? AND EXISTS ('.
|
||||
'SELECT character_id FROM quests_characters WHERE quest_id = questtypes_submit_characters.quest_id AND status = 0'.
|
||||
')',
|
||||
'i',
|
||||
$questId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Characters that did not solved a Quest.
|
||||
*
|
||||
* @param int $questId ID of Quest to get Characters for
|
||||
* @return array Characters data
|
||||
*/
|
||||
public function getCharactersUnsolvedQuest($questId)
|
||||
{
|
||||
return $data = $this->db->query(
|
||||
'SELECT character_id, created, text '.
|
||||
'FROM questtypes_submit_characters '.
|
||||
'WHERE quest_id = ? AND NOT EXISTS ('.
|
||||
'SELECT character_id FROM quests_characters WHERE quest_id = questtypes_submit_characters.quest_id AND status = 0'.
|
||||
')',
|
||||
'i',
|
||||
$questId
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue