implement copying of Stations for Seminary copy feature
This commit is contained in:
commit
40a233fa7d
4342 changed files with 1215466 additions and 0 deletions
24
questtypes/bossfight/BossfightQuesttypeAgent.inc
Normal file
24
questtypes/bossfight/BossfightQuesttypeAgent.inc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The Legend of Z
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||
* @license http://www.gnu.org/licenses/gpl.html
|
||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||
*/
|
||||
|
||||
namespace hhu\z\questtypes;
|
||||
|
||||
|
||||
/**
|
||||
* QuesttypeAgent for a boss-fight.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class BossfightQuesttypeAgent extends \hhu\z\agents\QuesttypeAgent
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
||||
292
questtypes/bossfight/BossfightQuesttypeController.inc
Normal file
292
questtypes/bossfight/BossfightQuesttypeController.inc
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The Legend of Z
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||
* @license http://www.gnu.org/licenses/gpl.html
|
||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||
*/
|
||||
|
||||
namespace hhu\z\questtypes;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the BossfightQuesttypeAgent for a boss-fight.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class BossfightQuesttypeController extends \hhu\z\controllers\QuesttypeController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('media');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save the answers of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $answers Character answers for the Quest
|
||||
*/
|
||||
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||
{
|
||||
// Prepare session
|
||||
$this->prepareSession($quest['id']);
|
||||
|
||||
// Remove previous answers
|
||||
$this->Bossfight->clearCharacterSubmissions($quest['id'], $character['id']);
|
||||
|
||||
// Save answers
|
||||
foreach($_SESSION['quests'][$quest['id']]['stages'] as &$stage) {
|
||||
$this->Bossfight->setCharacterSubmission($stage['id'], $character['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save additional data for the answers of a Character for a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $data Additional (POST-) data
|
||||
*/
|
||||
public function saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $data)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if answers of a Character for a Quest match the correct ones.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param array $answers Character answers for the Quest
|
||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||
*/
|
||||
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: quest.
|
||||
*
|
||||
* Display a stage with a text and the answers for the following
|
||||
* stages.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
* @param \Exception $exception Character submission exception
|
||||
*/
|
||||
public function quest($seminary, $questgroup, $quest, $character, $exception)
|
||||
{
|
||||
// Get Boss-Fight
|
||||
$fight = $this->Bossfight->getBossFight($quest['id']);
|
||||
if(!is_null($fight) && !is_null($fight['boss_seminarymedia_id'])) {
|
||||
$fight['bossmedia'] = $this->Media->getSeminaryMediaById($fight['boss_seminarymedia_id']);
|
||||
}
|
||||
|
||||
// Prepare session
|
||||
$this->prepareSession($quest['id']);
|
||||
|
||||
// Get Stage
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('submit_stages')))
|
||||
{
|
||||
$stages = $this->request->getPostParam('submit_stages');
|
||||
$stageId = array_keys($stages)[0];
|
||||
$stage = $this->Bossfight->getStageById($stageId);
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['quests'][$quest['id']]['stages'] = array();
|
||||
$stage = $this->Bossfight->getFirstStage($quest['id']);
|
||||
}
|
||||
|
||||
// Store Stage in session
|
||||
if(count($_SESSION['quests'][$quest['id']]['stages']) == 0 || $_SESSION['quests'][$quest['id']]['stages'][count($_SESSION['quests'][$quest['id']]['stages'])-1]['id'] != $stage['id']) {
|
||||
$_SESSION['quests'][$quest['id']]['stages'][] = $stage;
|
||||
}
|
||||
|
||||
// Calculate lives
|
||||
$lives = array(
|
||||
'character' => $fight['lives_character'],
|
||||
'boss' => $fight['lives_boss']
|
||||
);
|
||||
foreach($_SESSION['quests'][$quest['id']]['stages'] as &$stage)
|
||||
{
|
||||
$lives['character'] += $stage['livedrain_character'];
|
||||
$lives['boss'] += $stage['livedrain_boss'];
|
||||
}
|
||||
|
||||
// Get Child-Stages
|
||||
$childStages = $this->Bossfight->getChildStages($stage['id']);
|
||||
|
||||
// Get answer of Character
|
||||
if($this->request->getGetParam('show-answer') == 'true') {
|
||||
foreach($childStages as &$childStage) {
|
||||
$childStage['answer'] = $this->Bossfight->getCharacterSubmission($childStage['id'], $character['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('character', $character);
|
||||
$this->set('fight', $fight);
|
||||
$this->set('stage', $stage);
|
||||
$this->set('lives', $lives);
|
||||
$this->set('childStages', $childStages);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: submission.
|
||||
*
|
||||
* Display all stages with the answers the character has
|
||||
* choosen.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
* @param array $character Current Character data
|
||||
*/
|
||||
public function submission($seminary, $questgroup, $quest, $character)
|
||||
{
|
||||
// Get Boss-Fight
|
||||
$fight = $this->Bossfight->getBossFight($quest['id']);
|
||||
if(!is_null($fight['boss_seminarymedia_id'])) {
|
||||
$fight['bossmedia'] = $this->Media->getSeminaryMediaById($fight['boss_seminarymedia_id']);
|
||||
}
|
||||
|
||||
// Get stages
|
||||
$stages = array();
|
||||
$stage = $this->Bossfight->getFirstStage($quest['id']);
|
||||
while(!is_null($stage))
|
||||
{
|
||||
$stages[] = $stage;
|
||||
|
||||
$childStages = $this->Bossfight->getChildStages($stage['id']);
|
||||
$stage = null;
|
||||
foreach($childStages as &$childStage)
|
||||
{
|
||||
if($this->Bossfight->getCharacterSubmission($childStage['id'], $character['id']))
|
||||
{
|
||||
$stage = $childStage;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate lives
|
||||
$stages[0]['lives'] = array(
|
||||
'character' => $fight['lives_character'],
|
||||
'boss' => $fight['lives_boss']
|
||||
);
|
||||
for($i=1; $i<count($stages); $i++)
|
||||
{
|
||||
$stages[$i]['lives'] = array(
|
||||
'character' => $stages[$i-1]['lives']['character'] + $stages[$i]['livedrain_character'],
|
||||
'boss' => $stages[$i-1]['lives']['boss'] + $stages[$i]['livedrain_boss'],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('character', $character);
|
||||
$this->set('fight', $fight);
|
||||
$this->set('stages', $stages);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO Action: edittask.
|
||||
*
|
||||
* Edit the task of a Quest.
|
||||
*
|
||||
* @param array $seminary Current Seminary data
|
||||
* @param array $questgroup Current Questgroup data
|
||||
* @param array $quest Current Quest data
|
||||
*/
|
||||
public function edittask($seminary, $questgroup, $quest)
|
||||
{
|
||||
$fight = $this->Bossfight->getBossFight($quest['id']);
|
||||
/*
|
||||
if(!is_null($fight['boss_seminarymedia_id'])) {
|
||||
$fight['bossmedia'] = $this->Media->getSeminaryMediaById($fight['boss_seminarymedia_id']);
|
||||
}
|
||||
*/
|
||||
|
||||
// Get stages
|
||||
$stage = $this->Bossfight->getFirstStage($quest['id']);
|
||||
$stage['childs'] = $this->getChildStages($stage['id']);
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('fight', $fight);
|
||||
$this->set('stages', $stage);
|
||||
//print_r($stage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prepare the session to store stage information in
|
||||
*
|
||||
* @param int $questId ID of Quest
|
||||
*/
|
||||
private function prepareSession($questId)
|
||||
{
|
||||
if(!array_key_exists('quests', $_SESSION)) {
|
||||
$_SESSION['quests'] = array();
|
||||
}
|
||||
if(!array_key_exists($questId, $_SESSION['quests'])) {
|
||||
$_SESSION['quests'][$questId] = array();
|
||||
}
|
||||
if(!array_key_exists('stages', $_SESSION['quests'][$questId])) {
|
||||
$_SESSION['quests'][$questId]['stages'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all child-stages of a parent-stage.
|
||||
*
|
||||
* @param int $stageId ID of parent-stage
|
||||
* @return array List of child-stages
|
||||
*/
|
||||
private function getChildStages($stageId)
|
||||
{
|
||||
$childStages = $this->Bossfight->getChildStages($stageId);
|
||||
if(!empty($childStages)) {
|
||||
foreach($childStages as &$stage) {
|
||||
$stage['childs'] = $this->getChildStages($stage['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $childStages;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
286
questtypes/bossfight/BossfightQuesttypeModel.inc
Normal file
286
questtypes/bossfight/BossfightQuesttypeModel.inc
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The Legend of Z
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||
* @license http://www.gnu.org/licenses/gpl.html
|
||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||
*/
|
||||
|
||||
namespace hhu\z\questtypes;
|
||||
|
||||
|
||||
/**
|
||||
* Model of the BossfightQuesttypeAgent for a boss-fight.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class BossfightQuesttypeModel extends \hhu\z\models\QuesttypeModel
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('media');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copy a Quest
|
||||
*
|
||||
* @param int $userId ID of creating user
|
||||
* @param int $sourceQuestId ID of Quest to copy from
|
||||
* @param int $targetQuestId ID of Quest to copy to
|
||||
* @param int $seminaryMediaIds Mapping of SeminaryMedia-IDs from source Seminary to targetSeminary
|
||||
*/
|
||||
public function copyQuest($userId, $sourceQuestId, $targetQuestId, $seminaryMediaIds)
|
||||
{
|
||||
// Check Seminary media
|
||||
if(is_null($seminaryMediaIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get boss fight
|
||||
$bossfight = $this->getBossFight($sourceQuestId);
|
||||
|
||||
// Copy media
|
||||
$this->Media->copyQuestsmedia($userId, $seminaryMediaIds[$bossfight['boss_seminarymedia_id']]);
|
||||
|
||||
// Copy boss fight
|
||||
$this->db->query(
|
||||
'INSERT INTO questtypes_bossfight '.
|
||||
'(quest_id, created_user_id, bossname, boss_seminarymedia_id, lives_character, lives_boss) '.
|
||||
'SELECT ?, ?, bossname, ?, lives_character, lives_boss '.
|
||||
'FROM questtypes_bossfight '.
|
||||
'WHERE quest_id = ?',
|
||||
'iiii',
|
||||
$targetQuestId, $userId, $seminaryMediaIds[$bossfight['boss_seminarymedia_id']],
|
||||
$sourceQuestId
|
||||
);
|
||||
|
||||
// Copy stages
|
||||
$stage = $this->getFirstStage($sourceQuestId);
|
||||
$this->copyStage($userId, $targetQuestId, $stage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a Quest.
|
||||
*
|
||||
* @param int $questId ID of Quest to delete
|
||||
*/
|
||||
public function deleteQuest($questId)
|
||||
{
|
||||
$this->db->query('DELETE FROM questtypes_bossfight WHERE quest_id = ?', 'i', $questId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Boss-Fight.
|
||||
*
|
||||
* @param int $questId ID of Quest
|
||||
* @return array Boss-Fight data
|
||||
*/
|
||||
public function getBossFight($questId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT bossname, boss_seminarymedia_id, lives_character, lives_boss '.
|
||||
'FROM questtypes_bossfight '.
|
||||
'WHERE quest_id = ?',
|
||||
'i',
|
||||
$questId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the first Stage to begin the Boss-Fight with.
|
||||
*
|
||||
* @param int $questId ID of Quest
|
||||
* @return array Data of first Stage
|
||||
*/
|
||||
public function getFirstStage($questId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT id, parent_stage_id, text, question, livedrain_character, livedrain_boss '.
|
||||
'FROM questtypes_bossfight_stages '.
|
||||
'WHERE questtypes_bossfight_quest_id = ? AND parent_stage_id IS NULL',
|
||||
'i',
|
||||
$questId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a Stage by its ID.
|
||||
*
|
||||
* @param int $stageId ID of Stage
|
||||
* @return array Stage data or null
|
||||
*/
|
||||
public function getStageById($stageId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT id, text, question, livedrain_character, livedrain_boss '.
|
||||
'FROM questtypes_bossfight_stages '.
|
||||
'WHERE id = ?',
|
||||
'i',
|
||||
$stageId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the follow-up Stages for a Stage.
|
||||
*
|
||||
* @param int $parentStageId ID of Stage to get follow-up Stages for
|
||||
* @return array List of follow-up Stages
|
||||
*/
|
||||
public function getChildStages($parentStageId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT id, parent_stage_id, text, question, livedrain_character, livedrain_boss '.
|
||||
'FROM questtypes_bossfight_stages '.
|
||||
'WHERE parent_stage_id = ?',
|
||||
'i',
|
||||
$parentStageId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset all Character submissions of a Boss-Fight.
|
||||
*
|
||||
* @param int $questId ID of Quest
|
||||
* @param int $characterId ID of Character
|
||||
*/
|
||||
public function clearCharacterSubmissions($questId, $characterId)
|
||||
{
|
||||
$this->db->query(
|
||||
'DELETE FROM questtypes_bossfight_stages_characters '.
|
||||
'WHERE questtypes_bossfight_stage_id IN ('.
|
||||
'SELECT id '.
|
||||
'FROM questtypes_bossfight_stages '.
|
||||
'WHERE questtypes_bossfight_quest_id = ?'.
|
||||
') AND character_id = ?',
|
||||
'ii',
|
||||
$questId,
|
||||
$characterId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save Character’s submitted answer for one Boss-Fight-Stage.
|
||||
*
|
||||
* @param int $regexId ID of list
|
||||
* @param int $characterId ID of Character
|
||||
*/
|
||||
public function setCharacterSubmission($stageId, $characterId)
|
||||
{
|
||||
$this->db->query(
|
||||
'INSERT INTO questtypes_bossfight_stages_characters '.
|
||||
'(questtypes_bossfight_stage_id, character_id) '.
|
||||
'VALUES '.
|
||||
'(?, ?) '.
|
||||
'ON DUPLICATE KEY UPDATE '.
|
||||
'questtypes_bossfight_stage_id = ?',
|
||||
'iii',
|
||||
$stageId, $characterId, $stageId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get answer of one Boss-Fight-Stage submitted by Character.
|
||||
*
|
||||
* @param int $regexId ID of list
|
||||
* @param int $characterId ID of Character
|
||||
* @return boolean Stage taken
|
||||
*/
|
||||
public function getCharacterSubmission($stageId, $characterId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT questtypes_bossfight_stage_id '.
|
||||
'FROM questtypes_bossfight_stages_characters '.
|
||||
'WHERE questtypes_bossfight_stage_id = ? AND character_id = ? ',
|
||||
'ii',
|
||||
$stageId, $characterId
|
||||
);
|
||||
|
||||
|
||||
return (!empty($data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copy a Bossfight stage and its child-stages.
|
||||
*
|
||||
* @param int $userId ID of copying user
|
||||
* @param int $targetQuestId ID of Quest to copy to
|
||||
* @param array $stage Data of stage to copy
|
||||
* @param array $stageIds Mapping of Stage-IDs from source Seminary to target Seminary
|
||||
*/
|
||||
private function copyStage($userId, $targetQuestId, $stage, $stageIds=array())
|
||||
{
|
||||
// Copy stage
|
||||
if(is_null($stage['parent_stage_id']))
|
||||
{
|
||||
$this->db->query(
|
||||
'INSERT INTO questtypes_bossfight_stages '.
|
||||
'(questtypes_bossfight_quest_id, text, question, livedrain_character, livedrain_boss) '.
|
||||
'SELECT ?, text, question, livedrain_character, livedrain_boss '.
|
||||
'FROM questtypes_bossfight_stages '.
|
||||
'WHERE id = ?',
|
||||
'ii',
|
||||
$targetQuestId,
|
||||
$stage['id']
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->query(
|
||||
'INSERT INTO questtypes_bossfight_stages '.
|
||||
'(questtypes_bossfight_quest_id, parent_stage_id, text, question, livedrain_character, livedrain_boss) '.
|
||||
'SELECT ?, ?, text, question, livedrain_character, livedrain_boss '.
|
||||
'FROM questtypes_bossfight_stages '.
|
||||
'WHERE id = ?',
|
||||
'iii',
|
||||
$targetQuestId, $stageIds[$stage['parent_stage_id']],
|
||||
$stage['id']
|
||||
);
|
||||
}
|
||||
$stageIds[$stage['id']] = $this->db->getInsertId();
|
||||
|
||||
// Copy child stages
|
||||
$childStages = $this->getChildStages($stage['id']);
|
||||
foreach($childStages as $childStage) {
|
||||
$this->copyStage($userId, $targetQuestId, $childStage, $stageIds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
41
questtypes/bossfight/html/edittask.tpl
Normal file
41
questtypes/bossfight/html/edittask.tpl
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<form method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<legend><?=_('Boss-Fight')?></legend>
|
||||
<label><?=_('Boss name')?></label>
|
||||
<input type="text" name="bossname" value="<?=$fight['bossname']?>" /><br />
|
||||
<label><?=_('Boss image')?></label>
|
||||
<input type="file" name="bossimage" /><br />
|
||||
<label><?=_('Boss lives')?></label>
|
||||
<input type="number" name="lives_boss" value="<?=$fight['lives_boss']?>" /><br />
|
||||
<label><?=_('Character lives')?></label>
|
||||
<input type="number" name="lives_character" value="<?=$fight['lives_character']?>" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?=_('Stages')?></legend>
|
||||
<?php renderStage($stages, $fight['lives_boss'], $fight['lives_character']); ?>
|
||||
</fieldset>
|
||||
<input type="submit" name="save" value="<?=_('save')?>" />
|
||||
</form>
|
||||
|
||||
<?php function renderStage($stage, $livesBoss, $livesCharacter, $level=0, $indices=array()) { ?>
|
||||
<div style="margin-left:<?=$level?>em">
|
||||
<h2><?=implode('.', $indices)?></h2>
|
||||
<?php if(!empty($stage['question'])) : ?>
|
||||
<p><?=$stage['question']?></p>
|
||||
<?php endif ?>
|
||||
<p><?=_('Character')?> <?=$livesCharacter?> vs. <?=$livesBoss?> <?=_('Boss')?></p>
|
||||
<p><?=$stage['text']?></p>
|
||||
<?php foreach($stage['childs'] as $index => &$childStage) : ?>
|
||||
<?php $childIndices = $indices; ?>
|
||||
<?php $childIndices[] = $index+1; ?>
|
||||
<?php renderStage($childStage, $livesBoss+$childStage['livedrain_boss'], $livesCharacter+$childStage['livedrain_character'], $level+1, $childIndices); ?>
|
||||
<?php endforeach ?>
|
||||
<?php if($livesBoss == 0 && $livesCharacter == 0) : ?>
|
||||
Bedie verloren
|
||||
<?php elseif($livesBoss == 0) : ?>
|
||||
Boss verloren, Character gewonnen
|
||||
<?php elseif($livesCharacter == 0) : ?>
|
||||
Boss gewonnen, Character verloren
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
54
questtypes/bossfight/html/quest.tpl
Normal file
54
questtypes/bossfight/html/quest.tpl
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?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>
|
||||
</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">
|
||||
<?php foreach($childStages as &$childStage) : ?>
|
||||
<li class="option">
|
||||
<p><i>
|
||||
<?php if(array_key_exists('answer', $childStage) && $childStage['answer']) : ?>→<?php endif ?>
|
||||
<?=\hhu\z\Utils::t($childStage['question'])?>
|
||||
</i></p>
|
||||
<p><input type="submit" name="submit_stages[<?=$childStage['id']?>]" value="<?=_('Choose')?>" /></p>
|
||||
</li>
|
||||
<?php endforeach?>
|
||||
<?php if($lives['character'] == 0 || $lives['boss'] == 0) : ?>
|
||||
<li>
|
||||
<input type="hidden" name="answers" value="" />
|
||||
<input type="submit" name="submit" value="<?=_('solve')?>" />
|
||||
</li>
|
||||
<?php endif ?>
|
||||
</ul>
|
||||
</form>
|
||||
<?php endif ?>
|
||||
38
questtypes/bossfight/html/submission.tpl
Normal file
38
questtypes/bossfight/html/submission.tpl
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<div class="cf">
|
||||
<section class="opponent">
|
||||
<p class="portrait"><img src="<?=$linker->link(array('media','avatar',$seminary['url'],$character['charactertype_url'],$character['xplevel']))?>" class="hero" /></p>
|
||||
</section>
|
||||
<section class="opponent">
|
||||
<p class="portrait"><img src="<?=$linker->link(array('media','seminary',$seminary['url'],$fight['bossmedia']['url']))?>" class="boss" /></p>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<?php foreach($stages as &$stage) : ?>
|
||||
<p><?=$stage['question']?></p>
|
||||
<div class="cf">
|
||||
<section class="opponent">
|
||||
<p class="fwb"><?=$character['name']?></p>
|
||||
<p>
|
||||
<?php if($stage['lives']['character'] > 0) : ?>
|
||||
<?php foreach(range(1,$stage['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>
|
||||
<?php if($stage['lives']['boss'] > 0) : ?>
|
||||
<?php foreach(range(1,$stage['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 endforeach ?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue