add some checks to not throw IdNotFound exception for empty Quests (fixes #9)
This commit is contained in:
parent
8b01676622
commit
dec602da34
7 changed files with 68 additions and 52 deletions
|
|
@ -99,7 +99,7 @@
|
|||
{
|
||||
// Get Boss-Fight
|
||||
$fight = $this->Bossfight->getBossFight($quest['id']);
|
||||
if(!is_null($fight['boss_seminarymedia_id'])) {
|
||||
if(!is_null($fight) && !is_null($fight['boss_seminarymedia_id'])) {
|
||||
$fight['bossmedia'] = $this->Media->getSeminaryMediaById($fight['boss_seminarymedia_id']);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@
|
|||
/**
|
||||
* Get a Boss-Fight.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param int $questId ID of Quest
|
||||
* @return array Boss-Fight data
|
||||
*/
|
||||
|
|
@ -84,12 +83,11 @@
|
|||
'i',
|
||||
$questId
|
||||
);
|
||||
if(empty($data)) {
|
||||
throw new \nre\exceptions\IdNotFoundException($questId);
|
||||
if(!empty($data)) {
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
|
||||
return $data[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,34 +1,36 @@
|
|||
<?php if(!is_null($fight)) : ?>
|
||||
<div class="cf">
|
||||
<section class="opponent">
|
||||
<p class="fwb"><?=$character['name']?></p>
|
||||
<p class="portrait"><img src="<?=$linker->link(array('media','avatar',$seminary['url'],$character['charactertype_url'],$character['xplevel']))?>" class="hero" /></p>
|
||||
<p>
|
||||
<?php if($lives['character'] > 0) : ?>
|
||||
<?php foreach(range(1,$lives['character']) as $i) : ?>
|
||||
<i class="fa fa-heart fa-fw"></i>
|
||||
<?php endforeach ?>
|
||||
<?php else : ?>
|
||||
<?=_('lost')?>
|
||||
<?php endif ?>
|
||||
</p>
|
||||
</section>
|
||||
<section class="opponent">
|
||||
<p class="fwb"><?=$fight['bossname']?></p>
|
||||
<p class="portrait"><img src="<?=$linker->link(array('media','seminary',$seminary['url'],$fight['bossmedia']['url']))?>" class="boss" /></p>
|
||||
<p>
|
||||
<?php if($lives['boss'] > 0) : ?>
|
||||
<?php foreach(range(1,$lives['boss']) as $i) : ?>
|
||||
<i class="fa fa-heart fa-fw"></i>
|
||||
<?php endforeach ?>
|
||||
<?php else : ?>
|
||||
<b><?=_('lost')?></b>
|
||||
<?php endif ?>
|
||||
</p>
|
||||
</section>
|
||||
<section class="opponent">
|
||||
<p class="fwb"><?=$character['name']?></p>
|
||||
<p class="portrait"><img src="<?=$linker->link(array('media','avatar',$seminary['url'],$character['charactertype_url'],$character['xplevel']))?>" class="hero" /></p>
|
||||
<p>
|
||||
<?php if($lives['character'] > 0) : ?>
|
||||
<?php foreach(range(1,$lives['character']) as $i) : ?>
|
||||
<i class="fa fa-heart fa-fw"></i>
|
||||
<?php endforeach ?>
|
||||
<?php else : ?>
|
||||
<?=_('lost')?>
|
||||
<?php endif ?>
|
||||
</p>
|
||||
</section>
|
||||
<section class="opponent">
|
||||
<p class="fwb"><?=$fight['bossname']?></p>
|
||||
<p class="portrait"><img src="<?=$linker->link(array('media','seminary',$seminary['url'],$fight['bossmedia']['url']))?>" class="boss" /></p>
|
||||
<p>
|
||||
<?php if($lives['boss'] > 0) : ?>
|
||||
<?php foreach(range(1,$lives['boss']) as $i) : ?>
|
||||
<i class="fa fa-heart fa-fw"></i>
|
||||
<?php endforeach ?>
|
||||
<?php else : ?>
|
||||
<b><?=_('lost')?></b>
|
||||
<?php endif ?>
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if(!is_null($stage)) : ?>
|
||||
<p><?=\hhu\z\Utils::t($stage['text'])?></p>
|
||||
|
||||
<form method="post" action="<?=$linker->link(null,0,false,null,true,'task')?>">
|
||||
<input type="hidden" name="stage" value="<?=$stage['id']?>" />
|
||||
<ul class="bossfight cf">
|
||||
|
|
@ -49,3 +51,4 @@
|
|||
<?php endif ?>
|
||||
</ul>
|
||||
</form>
|
||||
<?php endif ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue