correctly set Achievements count (Issue #286)

This commit is contained in:
coderkun 2014-05-15 21:30:43 +02:00
commit 67af12a3cf
3 changed files with 41 additions and 7 deletions

View file

@ -156,9 +156,11 @@
/**
* Get all not yet achieved Achievements for a Character.
*
* @param int $seminaryId ID of Seminary
* @param int $characterId ID of Character
* @return array Achievements data
* @param int $seminaryId ID of Seminary
* @param int $characterId ID of Character
* @param boolean $includeOnlyOnce Include Achievements that can only be achieved by one Character
* @param boolean $alsoWithDeadline Include milestone Achievements
* @return array Achievements data
*/
public function getUnachhievedAchievementsForCharacter($seminaryId, $characterId, $includeOnlyOnce=false, $alsoWithDeadline=true)
{
@ -183,6 +185,34 @@
}
/**
* Get the amount of Achievement for a Seminary.
*
* @param int $seminaryId ID of Seminary
* @param boolean $includeOnlyOnce Include Achievements that can only be achieved by one Character
* @param boolean $alsoWithDeadline Include milestone Achievements
* @return int Count of Achievements
*/
public function getAchievementsCountForSeminary($seminaryId, $includeOnlyOnce=false, $alsoWithDeadline=true)
{
$data = $this->db->query(
'SELECT count(id) AS c '.
'FROM achievements '.
'WHERE seminary_id = ? AND only_once <= ?'.
(!$alsoWithDeadline ? ' AND achievements.deadline IS NULL ' : null),
'ii',
$seminaryId,
$includeOnlyOnce
);
if(!empty($data)) {
return $data[0]['c'];
}
return 0;
}
/**
* Get the rank for the number of achieved Achievements.
*