correcty check permissions for a Quest if one of the previous Quests has as following Quest the Quest itself (Issue #229)

This commit is contained in:
coderkun 2014-05-12 16:17:26 +02:00
commit ee6f25dbdb

View file

@ -165,12 +165,13 @@
{ {
// Previous Quests // Previous Quests
// One previous Quest has to be solved and no other // One previous Quest has to be solved and no other
// following Quests of ones has to be tried // following Quest of ones has to be tried
// except it is also an previous Quest of the current Quest
$solved = false; $solved = false;
$tried = false; $tried = false;
foreach($previousQuests as &$previousQuest) foreach($previousQuests as &$previousQuest)
{ {
// // Check previous Quest // Check previous Quest
if($this->Quests->hasCharacterSolvedQuest($previousQuest['id'], $character['id'])) if($this->Quests->hasCharacterSolvedQuest($previousQuest['id'], $character['id']))
{ {
$solved = true; $solved = true;
@ -181,11 +182,15 @@
{ {
// Check following Quest // Check following Quest
if($followingQuest['id'] != $quest['id'] && $this->Quests->hasCharacterTriedQuest($followingQuest['id'], $character['id'])) if($followingQuest['id'] != $quest['id'] && $this->Quests->hasCharacterTriedQuest($followingQuest['id'], $character['id']))
{
$followingFollowingQuests = $this->Quests->getNextQuests($followingQuest['id']);
if(!in_array($quest['id'], array_map(function($q) { return $q['id']; }, $followingFollowingQuests)))
{ {
$tried = true; $tried = true;
break; break;
} }
} }
}
break; break;
} }