only check last Quest(s) of a Questgroup for determining if Character has solved this Questgroup
This commit is contained in:
parent
e4a030ce1f
commit
eea8797bb1
2 changed files with 35 additions and 31 deletions
|
|
@ -318,8 +318,7 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the given Character has solved the Quests form
|
* Determine if the given Character has solved a Questgroup.
|
||||||
* this Questgroup.
|
|
||||||
*
|
*
|
||||||
* @param int $questgroupId ID of Questgroup to check
|
* @param int $questgroupId ID of Questgroup to check
|
||||||
* @param int $characterId ID of Character to check
|
* @param int $characterId ID of Character to check
|
||||||
|
|
@ -330,39 +329,20 @@
|
||||||
// Get data of Questgroup
|
// Get data of Questgroup
|
||||||
$questgroup = $this->getQuestgroupById($questgroupId);
|
$questgroup = $this->getQuestgroupById($questgroupId);
|
||||||
|
|
||||||
// Chack all Quests
|
// Check last Quest(s)
|
||||||
$currentQuest = $this->Quests->getFirstQuestOfQuestgroup($questgroup['id']);
|
$solvedLastQuest = false;
|
||||||
if(!is_null($currentQuest))
|
$lastQuests = $this->Quests->getLastQuestsOfQuestgroup($questgroup['id']);
|
||||||
|
foreach($lastQuests as &$lastQuest)
|
||||||
{
|
{
|
||||||
if(!$this->Quests->hasCharacterSolvedQuest($currentQuest['id'], $characterId)) {
|
if($this->Quests->hasCharacterSolvedQuest($lastQuest['id'], $characterId))
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get next Quests
|
|
||||||
$nextQuests = !is_null($currentQuest) ? $this->Quests->getNextQuests($currentQuest['id']) : null;
|
|
||||||
while(!is_null($currentQuest) && !empty($nextQuests))
|
|
||||||
{
|
{
|
||||||
// Get choosed Quest
|
$solvedLastQuest = true;
|
||||||
$currentQuest = null;
|
break;
|
||||||
foreach($nextQuests as &$nextQuest) {
|
|
||||||
if($this->Quests->hasCharacterEnteredQuest($nextQuest['id'], $characterId)) {
|
|
||||||
$currentQuest = $nextQuest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check Quest
|
|
||||||
if(is_null($currentQuest)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check status
|
|
||||||
if(!$this->Quests->hasCharacterSolvedQuest($currentQuest['id'], $characterId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$nextQuests = !is_null($currentQuest) ? $this->Quests->getNextQuests($currentQuest['id']) : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!$solvedLastQuest) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check all child Questgroups
|
// Check all child Questgroups
|
||||||
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all Quests a Qusetgroup that do not have a following
|
||||||
|
* Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Questgroup
|
||||||
|
* @return array List of last Quests
|
||||||
|
*/
|
||||||
|
public function getLastQuestsOfQuestgroup($questgroupId)
|
||||||
|
{
|
||||||
|
return $this->db->query(
|
||||||
|
'SELECT id, questtype_id, title, url, xps, task '.
|
||||||
|
'FROM quests '.
|
||||||
|
'WHERE questgroup_id = ? AND NOT EXISTS ('.
|
||||||
|
'SELECT quest_id '.
|
||||||
|
'FROM quests_previousquests '.
|
||||||
|
'WHERE quests_previousquests.previous_quest_id = quests.id'.
|
||||||
|
')',
|
||||||
|
'i',
|
||||||
|
$questgroupId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Quests that follow-up a Quest.
|
* Get Quests that follow-up a Quest.
|
||||||
*
|
*
|
||||||
|
|
@ -243,6 +266,7 @@
|
||||||
$characterId,
|
$characterId,
|
||||||
self::QUEST_STATUS_ENTERED, self::QUEST_STATUS_SOLVED, self::QUEST_STATUS_UNSOLVED
|
self::QUEST_STATUS_ENTERED, self::QUEST_STATUS_SOLVED, self::QUEST_STATUS_UNSOLVED
|
||||||
);
|
);
|
||||||
|
//debug_print_backtrace();
|
||||||
|
|
||||||
|
|
||||||
return (!empty($count) && intval($count[0]['c']) > 0);
|
return (!empty($count) && intval($count[0]['c']) > 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue