add progress, XPs, rank and Character groups to Character page
This commit is contained in:
parent
79eabe1768
commit
eb2e701a5e
5 changed files with 94 additions and 16 deletions
|
|
@ -81,12 +81,13 @@
|
|||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
$seminary['achievable_xps'] = $this->Seminaries->getTotalXPs($seminary['id']);
|
||||
|
||||
// Get Character
|
||||
$character = $this->Characters->getCharacterByUrl($seminary['id'], $characterUrl);
|
||||
|
||||
// Character Level
|
||||
$character['quest_xps'] = $this->Characters->getQuestXPsOfCharacter($character['id']);
|
||||
$character['xplevel'] = $this->Characters->getXPLevelOfCharacters($character['id']);
|
||||
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
|
||||
|
||||
// Get Seminarycharacterfields
|
||||
$characterfields = $this->Seminarycharacterfields->getFieldsForCharacter($character['id']);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
public function getQuestsForCharactergroupsgroup($groupsgroupId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT id, questgroups_id, title, url '.
|
||||
'SELECT id, questgroups_id, title, url, xps '.
|
||||
'FROM charactergroupsquests '.
|
||||
'WHERE charactergroupsgroup_id = ?',
|
||||
'i',
|
||||
|
|
|
|||
|
|
@ -180,6 +180,30 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate only XPs for a Character achieved through Quests.
|
||||
*
|
||||
* @param int $characterId ID of Character
|
||||
* @return int Quest-XPs for Character
|
||||
*/
|
||||
public function getQuestXPsOfCharacter($characterId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT quest_xps '.
|
||||
'FROM v_charactersxps '.
|
||||
'WHERE character_id = ?',
|
||||
'i',
|
||||
$characterId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0]['quest_xps'];
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the XP-level of a Character.
|
||||
*
|
||||
|
|
@ -204,6 +228,32 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the rank of a XP-value of a Character.
|
||||
*
|
||||
* @param int $seminaryId ID of Seminary
|
||||
* @param int $xps XP-value to get rank for
|
||||
* @return int Rank of XP-value
|
||||
*/
|
||||
public function getXPRank($seminaryId, $xps)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT count(v_characters.id) AS c '.
|
||||
'FROM charactertypes '.
|
||||
'INNER JOIN v_characters ON v_characters.charactertype_id = charactertypes.id '.
|
||||
'WHERE seminary_id = ? AND v_characters.xps > ?',
|
||||
'id',
|
||||
$seminaryId, $xps
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0]['c'] + 1;
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@
|
|||
*/
|
||||
class SeminariesModel extends \hhu\z\Model
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('questgroupshierarchy', 'questgroups');
|
||||
|
||||
|
||||
|
||||
|
|
@ -100,6 +106,32 @@
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Calculate sum of XPs for a Seminary.
|
||||
*
|
||||
* @param int $seminaryId ID of Seminary
|
||||
* @return int Total sum of XPs
|
||||
*/
|
||||
public function getTotalXPs($seminaryId)
|
||||
{
|
||||
$xps = 0;
|
||||
|
||||
// Questgroups
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminaryId);
|
||||
foreach($questgroupshierarchy as &$hierarchy)
|
||||
{
|
||||
// Get Questgroups
|
||||
$questgroups = $this->Questgroups->getQuestgroupsForHierarchy($hierarchy['id']);
|
||||
foreach($questgroups as &$questgroup) {
|
||||
$xps += $this->Questgroups->getAchievableXPsForQuestgroup($questgroup['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $xps;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new seminary.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,24 +6,24 @@
|
|||
<div class="cinfo">
|
||||
<div class="cdata">
|
||||
<div class="xpbar">
|
||||
<span style="width:85%"></span>
|
||||
<span style="width:<?=round($character['quest_xps']*100/$seminary['achievable_xps'])?>%"></span>
|
||||
</div>
|
||||
<p><small>Gesamtfortschritt: 85%</small></p>
|
||||
<p><small><?=_('Total progress')?>: <?=round($character['quest_xps']*100/$seminary['achievable_xps'])?> %</small></p>
|
||||
</div>
|
||||
<div class="cdata square">
|
||||
<p class="value"><?=$character['xplevel']['level']?></p>
|
||||
<p><small><?=_('Level')?></small></p>
|
||||
</div>
|
||||
<div class="cdata square">
|
||||
<p class="value">500</p>
|
||||
<p class="value"><?=$character['xps']?></p>
|
||||
<p><small>XP</small></p>
|
||||
</div>
|
||||
<div class="cdata square blue">
|
||||
<p class="value">7.</p>
|
||||
<p><small>Platz</small></p>
|
||||
<p class="value"><?=$character['rank']?>.</p>
|
||||
<p><small><?=_('Rank')?></small></p>
|
||||
</div>
|
||||
|
||||
<h1><i class="fa fa-certificate fa-fw"></i>Belohnungen</h1>
|
||||
<h1><i class="fa fa-certificate fa-fw"></i><?=_('Achievements')?></h1>
|
||||
<ul class="crewards">
|
||||
<li>
|
||||
<p class="unlocked"><i class="fa fa-check-circle fa-fw"></i>Aktive Beteiligung</p>
|
||||
|
|
@ -50,16 +50,11 @@
|
|||
<section>
|
||||
<h1><i class="fa fa-users fa-fw"></i><?=_('Character Groups')?></h1>
|
||||
<ul class="cgroups cf">
|
||||
<li class="cf">
|
||||
<img src="http://s1.directupload.net/images/140325/3eqybn4i.png">
|
||||
<a href="#">Super wilde Arbeits Gruppe [SWAG]</a><p><span>500 XP</span></p>
|
||||
</li>
|
||||
<li class="cf">
|
||||
<img src="http://s1.directupload.net/images/140325/3eqybn4i.png">
|
||||
<a href="#">Mit Herz und Seele</a><p><span>500 XP</span></p>
|
||||
</li>
|
||||
<?php foreach($groups as &$group) : ?>
|
||||
<li><a href="<?=$linker->link(array('charactergroups','group',$seminary['url'],$group['charactergroupsgroup_url'],$group['url']))?>"><?=$group['name']?></a> (<?=$group['xps']?> XPs)</li>
|
||||
<li class="cf">
|
||||
<img src="http://s1.directupload.net/images/140325/3eqybn4i.png">
|
||||
<a href="<?=$linker->link(array('charactergroups','group',$seminary['url'],$group['charactergroupsgroup_url'],$group['url']))?>"><?=$group['name']?></a><p><span><?=$group['xps']?> XPs</span></p>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue