add progress, XPs, rank and Character groups to Character page
This commit is contained in:
parent
79eabe1768
commit
eb2e701a5e
5 changed files with 94 additions and 16 deletions
|
|
@ -44,7 +44,7 @@
|
|||
public function getQuestsForCharactergroupsgroup($groupsgroupId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT id, questgroups_id, title, url '.
|
||||
'SELECT id, questgroups_id, title, url, xps '.
|
||||
'FROM charactergroupsquests '.
|
||||
'WHERE charactergroupsgroup_id = ?',
|
||||
'i',
|
||||
|
|
|
|||
|
|
@ -180,6 +180,30 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate only XPs for a Character achieved through Quests.
|
||||
*
|
||||
* @param int $characterId ID of Character
|
||||
* @return int Quest-XPs for Character
|
||||
*/
|
||||
public function getQuestXPsOfCharacter($characterId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT quest_xps '.
|
||||
'FROM v_charactersxps '.
|
||||
'WHERE character_id = ?',
|
||||
'i',
|
||||
$characterId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0]['quest_xps'];
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the XP-level of a Character.
|
||||
*
|
||||
|
|
@ -204,6 +228,32 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the rank of a XP-value of a Character.
|
||||
*
|
||||
* @param int $seminaryId ID of Seminary
|
||||
* @param int $xps XP-value to get rank for
|
||||
* @return int Rank of XP-value
|
||||
*/
|
||||
public function getXPRank($seminaryId, $xps)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT count(v_characters.id) AS c '.
|
||||
'FROM charactertypes '.
|
||||
'INNER JOIN v_characters ON v_characters.charactertype_id = charactertypes.id '.
|
||||
'WHERE seminary_id = ? AND v_characters.xps > ?',
|
||||
'id',
|
||||
$seminaryId, $xps
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0]['c'] + 1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@
|
|||
*/
|
||||
class SeminariesModel extends \hhu\z\Model
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('questgroupshierarchy', 'questgroups');
|
||||
|
||||
|
||||
|
||||
|
|
@ -100,6 +106,32 @@
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Calculate sum of XPs for a Seminary.
|
||||
*
|
||||
* @param int $seminaryId ID of Seminary
|
||||
* @return int Total sum of XPs
|
||||
*/
|
||||
public function getTotalXPs($seminaryId)
|
||||
{
|
||||
$xps = 0;
|
||||
|
||||
// Questgroups
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminaryId);
|
||||
foreach($questgroupshierarchy as &$hierarchy)
|
||||
{
|
||||
// Get Questgroups
|
||||
$questgroups = $this->Questgroups->getQuestgroupsForHierarchy($hierarchy['id']);
|
||||
foreach($questgroups as &$questgroup) {
|
||||
$xps += $this->Questgroups->getAchievableXPsForQuestgroup($questgroup['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $xps;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new seminary.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue