implement Questtexts and Sidequests
This commit is contained in:
parent
108ca65470
commit
46364ac6f2
10 changed files with 355 additions and 15 deletions
|
|
@ -76,8 +76,14 @@
|
|||
|
||||
// Get Quests
|
||||
$quests = null;
|
||||
if(count($childQuestgroupshierarchy) == 0) {
|
||||
if(count($childQuestgroupshierarchy) == 0)
|
||||
{
|
||||
$quests = $this->Quests->getQuestsForQuestgroup($questgroup['id']);
|
||||
|
||||
// Attach sidequests
|
||||
foreach($quests as &$quest) {
|
||||
$quest['sidequests'] = $this->Quests->getSidequestsForQuest($quest['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -51,9 +51,11 @@
|
|||
* Show a quest and its task.
|
||||
*
|
||||
* @throws IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $questgroupUrl URL-Title of a Questgroup
|
||||
* @param string $questUrl URL-Title of a Quest
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $questgroupUrl URL-Title of a Questgroup
|
||||
* @param string $questUrl URL-Title of a Quest
|
||||
* @param string $questtexttypeUrl URL-Title of a Questtexttype
|
||||
* @param int $questtextPos Position of Questtext
|
||||
*/
|
||||
public function quest($seminaryUrl, $questgroupUrl, $questUrl, $questtexttypeUrl=null, $questtextPos=1)
|
||||
{
|
||||
|
|
@ -73,10 +75,16 @@
|
|||
if(is_null($questtexttypeUrl)) {
|
||||
$questtexttypeUrl = 'Prolog';
|
||||
}
|
||||
if(in_array($questtexttypeUrl, $questtexttypes))
|
||||
$questtextCount = $this->Questtexts->getQuesttextsCountForQuest($quest['id'], $questtexttypeUrl);
|
||||
if($questtextCount > 0)
|
||||
{
|
||||
$questtextPos = max(intval($questtextPos), 1);
|
||||
$questtext = $this->Questtexts->getQuesttextByUrl($quest['id'], $questtexttypeUrl, $questtextPos);
|
||||
if(in_array($questtexttypeUrl, $questtexttypes))
|
||||
{
|
||||
$questtextPos = max(intval($questtextPos), 1);
|
||||
$questtext = $this->Questtexts->getQuesttextByUrl($quest['id'], $questtexttypeUrl, $questtextPos);
|
||||
$questtext['count'] = $questtextCount;
|
||||
$questtext['sidequests'] = $this->Quests->getSidequestsForQuesttext($questtext['id']);
|
||||
}
|
||||
}
|
||||
|
||||
// Show task only for Prologes
|
||||
|
|
@ -94,6 +102,71 @@
|
|||
$this->set('showtask', $showTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action: sidequest.
|
||||
*
|
||||
* Show a sidequest and its task.
|
||||
*
|
||||
* @throws IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $questgroupUrl URL-Title of a Questgroup
|
||||
* @param string $questUrl URL-Title of a Quest
|
||||
* @param string $sidequestUrl URL-Title of a Sidequest
|
||||
* @param string $questtexttypeUrl URL-Title of a Questtexttype
|
||||
* @param int $questtextPos Position of Questtext
|
||||
*/
|
||||
public function sidequest($seminaryUrl, $questgroupUrl, $questUrl, $sidequestUrl, $sidequesttexttypeUrl=null, $sidequesttextPos=1)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroup
|
||||
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
||||
|
||||
// Get Quest
|
||||
$quest = $this->Quests->getQuestByUrl($seminary['id'], $questgroup['id'], $questUrl);
|
||||
|
||||
// Get Sidequest
|
||||
$sidequest = $this->Quests->getSidequestByUrl($seminary['id'], $questgroup['id'], $quest['id'], $sidequestUrl);
|
||||
|
||||
// Get Questtext
|
||||
$questtext = $this->Questtexts->getQuesttextForSidequest($sidequest['id']);
|
||||
|
||||
// Get Sidequesttext
|
||||
$sidequesttext = null;
|
||||
$questtexttypes = $this->Questtexts->getQuesttexttypes();
|
||||
$questtexttypes = array_map(function($t) { return $t['url']; }, $questtexttypes);
|
||||
if(is_null($sidequesttexttypeUrl)) {
|
||||
$sidequesttexttypeUrl = 'Prolog';
|
||||
}
|
||||
$sidequesttextCount = $this->Questtexts->getQuesttextsCountForSidequest($sidequest['id'], $sidequesttexttypeUrl);
|
||||
if($sidequesttextCount > 0)
|
||||
{
|
||||
if(in_array($sidequesttexttypeUrl, $questtexttypes))
|
||||
{
|
||||
$sidequesttextPos = max(intval($sidequesttextPos), 1);
|
||||
$sidequesttext = $this->Questtexts->getSidequesttextByUrl($sidequest['id'], $sidequesttexttypeUrl, $sidequesttextPos);
|
||||
$sidequesttext['count'] = $sidequesttextCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Show task only for Prologes
|
||||
$showTask = false;
|
||||
if($sidequesttext['type'] == 'Prolog') {
|
||||
$showTask = true;
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('questgroup', $questgroup);
|
||||
$this->set('sidequesttext', $sidequesttext);
|
||||
$this->set('quest', $quest);
|
||||
$this->set('questtext', $questtext);
|
||||
$this->set('sidequest', $sidequest);
|
||||
$this->set('showtask', $showTask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue