Reputation

* apply reputation_reward_rate to rewards on Quest Detail Page
 * apply reputation_reward_rate to NPC Detail Page
This commit is contained in:
Sarjuuk
2017-03-16 20:45:03 +01:00
parent a163279fab
commit 9fabd2c728
8 changed files with 72 additions and 30 deletions

View File

@@ -122,12 +122,18 @@ class QuestList extends BaseType
return $this->curTpl['flags'] & QUEST_FLAG_REPEATABLE || $this->curTpl['specialFlags'] & QUEST_FLAG_SPECIAL_REPEATABLE;
}
public function isDaily($strict = false)
public function isDaily()
{
if ($strict)
return $this->curTpl['flags'] & QUEST_FLAG_DAILY;
else
return $this->curTpl['flags'] & (QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY) || $this->curTpl['specialFlags'] & QUEST_FLAG_SPECIAL_MONTHLY;
if ($this->curTpl['flags'] & QUEST_FLAG_DAILY)
return 1;
if ($this->curTpl['flags'] & QUEST_FLAG_WEEKLY)
return 2;
if ($this->curTpl['specialFlags'] & QUEST_FLAG_SPECIAL_MONTHLY)
return 3;
return 0;
}
// using reqPlayerKills and rewardHonor as a crutch .. has TC this even implemented..?

View File

@@ -1464,12 +1464,12 @@ class Util
switch ($c['ConditionTypeOrReference'])
{
case CND_AURA: // 1
$c['ConditionValue2'] = NULL; // do not use his param
$c['ConditionValue2'] = null; // do not use his param
case CND_SPELL: // 25
$jsGlobals[TYPE_SPELL][] = $c['ConditionValue1'];
break;
case CND_ITEM: // 2
$c['ConditionValue3'] = NULL; // do not use his param
$c['ConditionValue3'] = null; // do not use his param
case CND_ITEM_EQUIPPED: // 3
$jsGlobals[TYPE_ITEM][] = $c['ConditionValue1'];
break;

View File

@@ -134,12 +134,15 @@ class FactionPage extends GenericPage
switch ($k)
{
case 'quest_rate': $buff .= '[tr][td]'.Lang::game('quests') .Lang::main('colon').'[/td]'; break;
case 'quest_daily_rate': $buff .= '[tr][td]'.Lang::game('quests').' ('.Lang::quest('daily').')' .Lang::main('colon').'[/td]'; break;
case 'quest_weekly_rate': $buff .= '[tr][td]'.Lang::game('quests').' ('.Lang::quest('weekly').')' .Lang::main('colon').'[/td]'; break;
case 'quest_monthly_rate': $buff .= '[tr][td]'.Lang::game('quests').' ('.Lang::quest('monthly').')'.Lang::main('colon').'[/td]'; break;
case 'creature_rate': $buff .= '[tr][td]'.Lang::game('npcs') .Lang::main('colon').'[/td]'; break;
case 'spell_rate': $buff .= '[tr][td]'.Lang::game('spells') .Lang::main('colon').'[/td]'; break;
case 'quest_rate': $buff .= '[tr][td]'.Lang::game('quests') .Lang::main('colon').'[/td]'; break;
case 'quest_daily_rate': $buff .= '[tr][td]'.Lang::game('quests').' ('.Lang::quest('daily').')' .Lang::main('colon').'[/td]'; break;
case 'quest_weekly_rate': $buff .= '[tr][td]'.Lang::game('quests').' ('.Lang::quest('weekly').')' .Lang::main('colon').'[/td]'; break;
case 'quest_monthly_rate': $buff .= '[tr][td]'.Lang::game('quests').' ('.Lang::quest('monthly').')' .Lang::main('colon').'[/td]'; break;
case 'quest_repeatable_rate': $buff .= '[tr][td]'.Lang::game('quests').' ('.Lang::quest('repeatable').')'.Lang::main('colon').'[/td]'; break;
case 'creature_rate': $buff .= '[tr][td]'.Lang::game('npcs') .Lang::main('colon').'[/td]'; break;
case 'spell_rate': $buff .= '[tr][td]'.Lang::game('spells') .Lang::main('colon').'[/td]'; break;
default:
continue;
}
$buff .= '[td width=35px align=right][span class=q'.($v < 1 ? '10]' : '2]+').intVal(($v - 1) * 100).'%[/span][/td][/tr]';

View File

@@ -869,15 +869,19 @@ class NpcPage extends GenericPage
$set = array(
'id' => $row['faction'],
'qty' => $row['qty'],
'qty' => [$row['qty'], 0],
'name' => $factions->getField('name', true),
'npc' => $row['npc'],
'cap' => $row['maxRank'] && $row['maxRank'] < REP_EXALTED ? Lang::game('rep', $row['maxRank']) : null
);
$cuRate = DB::World()->selectCell('SELECT creature_rate FROM reputation_reward_rate WHERE creature_rate <> 1 AND faction = ?d', $row['faction']);
if ($cuRate !== null)
$set['qty'][1] = $set['qty'][0] * ($cuRate - 1);
if ($row['spillover'])
{
$spillover[$factions->getField('cat')] = [intVal($row['qty'] / 2), $row['maxRank']];
$spillover[$factions->getField('cat')] = [intVal(array_sum($row['qty']) / 2), $row['maxRank']];
$set['spillover'] = $factions->getField('cat');
}

View File

@@ -170,7 +170,7 @@ class QuestPage extends GenericPage
$startEnd = DB::Aowow()->select('SELECT * FROM ?_quests_startend WHERE questId = ?d', $this->typeId);
// start
$start = '[icon name=quest_start'.($this->subject->isDaily() ? '_daily' : '').']'.Lang::event('start').Lang::main('colon').'[/icon]';
$start = '[icon name=quest_start'.($this->subject->isRepeatable() ? '_daily' : '').']'.Lang::event('start').Lang::main('colon').'[/icon]';
$s = [];
foreach ($startEnd as $se)
{
@@ -185,7 +185,7 @@ class QuestPage extends GenericPage
$infobox[] = implode('[br]', $s);
// end
$end = '[icon name=quest_end'.($this->subject->isDaily() ? '_daily' : '').']'.Lang::event('end').Lang::main('colon').'[/icon]';
$end = '[icon name=quest_end'.($this->subject->isRepeatable() ? '_daily' : '').']'.Lang::event('end').Lang::main('colon').'[/icon]';
$e = [];
foreach ($startEnd as $se)
{
@@ -200,7 +200,7 @@ class QuestPage extends GenericPage
$infobox[] = implode('[br]', $e);
// Repeatable
if ($_flags & QUEST_FLAG_REPEATABLE || $_specialFlags & QUEST_FLAG_SPECIAL_REPEATABLE)
if ($this->subject->isRepeatable())
$infobox[] = Lang::quest('repeatable');
// sharable | not sharable
@@ -1259,11 +1259,30 @@ class QuestPage extends GenericPage
if (!$fac || !$qty)
continue;
$gains['rep'][] = array(
'qty' => $qty,
$rep = array(
'qty' => [$qty, 0],
'id' => $fac,
'name' => FactionList::getName($fac)
);
if ($cuRates = DB::World()->selectRow('SELECT * FROM reputation_reward_rate WHERE faction = ?d', $fac))
{
if ($dailyType = $this->subject->isDaily())
{
if ($dailyType == 1 && $cuRates['quest_daily_rate'] != 1.0)
$rep['qty'][1] = $rep['qty'][0] * ($cuRates['quest_daily_rate'] - 1);
else if ($dailyType == 2 && $cuRates['quest_weekly_rate'] != 1.0)
$rep['qty'][1] = $rep['qty'][0] * ($cuRates['quest_weekly_rate'] - 1);
else if ($dailyType == 3 && $cuRates['quest_monthly_rate'] != 1.0)
$rep['qty'][1] = $rep['qty'][0] * ($cuRates['quest_monthly_rate'] - 1);
}
else if ($this->subject->isRepeatable() && $cuRates['quest_repeatable_rate'] != 1.0)
$rep['qty'][1] = $rep['qty'][0] * ($cuRates['quest_repeatable_rate'] - 1);
else if ($cuRates['quest_rate'] != 1.0)
$rep['qty'][1] = $rep['qty'][0] * ($cuRates['quest_rate'] - 1);
}
$gains['rep'][] = $rep;
}
// title

View File

@@ -985,7 +985,7 @@ class SpellPage extends GenericPage
if ($list)
{
$tbTrainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&']));
$tbTrainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', null, '!'], ['ct.npcflag', 0x10, '&']));
if (!$tbTrainer->error)
{
$this->extendGlobalData($tbTrainer->getJSGlobals());
@@ -1758,9 +1758,8 @@ class SpellPage extends GenericPage
$_ = ' (<a href="?faction='.$effMV.'">'.$n.'</a>)';
// apply custom reward rated
if ($cuRate = DB::World()->selectCell('SELECT spell_rate FROM reputation_reward_rate WHERE faction = ?d', $effMV))
if ($cuRate != 1.0)
$foo['value'] .= sprintf(Util::$dfnString, Lang::faction('customRewRate'), ' ('.(($cuRate < 1 ? '-' : '+').intVal(($cuRate - 1) * $foo['value'])).')');
if ($cuRate = DB::World()->selectCell('SELECT spell_rate FROM reputation_reward_rate WHERE spell_rate <> 1 && faction = ?d', $effMV))
$foo['value'] .= sprintf(Util::$dfnString, Lang::faction('customRewRate'), ' ('.(($cuRate < 1 ? '-' : '+').intVal(($cuRate - 1) * $foo['value'])).')');
$foo['name'] .= $_;
@@ -1940,8 +1939,8 @@ class SpellPage extends GenericPage
break;
case 30: // Mod Skill
case 98: // Mod Skill Value
if ($_ = SkillList::getName($effMV))
$bar = ' (<a href="?skill='.$effMV.'">'.SkillList::getName($effMV).'</a>)';
if ($n = SkillList::getName($effMV))
$bar = ' (<a href="?skill='.$effMV.'">'.$n.'</a>)';
else
$bar = Lang::main('colon').Util::ucFirst(Lang::game('skill')).' #'.$effMV;;
@@ -1998,7 +1997,8 @@ class SpellPage extends GenericPage
$foo['value'] = sprintf(Util::$dfnString, $foo['value'], Lang::game('rep', $foo['value']));
// DO NOT BREAK
case 190: // Mod Faction Reputation Gain
$bar = ' (<a href="?faction='.$effMV.'">'.FactionList::getName($effMV).'</a>)';
$n = FactionList::getName($effMV);
$bar = ' ('.($n ? '<a href="?faction='.$effMV.'">'.$n.'</a>' : Util::ucFirst(Lang::game('faction')).' #'.$effMV).')';
break; // also breaks for 139
}
$foo['name'] .= strstr($bar, 'href') || strstr($bar, '#') ? $bar : ($bar ? ' ('.$bar.')' : null);

View File

@@ -91,8 +91,13 @@ if ($this->reputation):
echo '<ul>';
foreach ($set[1] as $itr):
echo '<li><div'.($itr['qty'] < 0 ? ' class="reputation-negative-amount"' : null).'><span>'.$itr['qty'].'</span> '.Lang::npc('repWith') .
' <a href="?faction='.$itr['id'].'">'.$itr['name'].'</a>'.($itr['cap'] && $itr['qty'] > 0 ? '&nbsp;('.sprintf(Lang::npc('stopsAt'), $itr['cap']).')' : null).'</div></li>';
if ($itr['qty'][1] && User::isInGroup(U_GROUP_EMPLOYEE))
$qty = $itr['qty'][0] . sprintf(Util::$dfnString, Lang::faction('customRewRate'), ($itr['qty'][1] > 0 ? '+' : '').$itr['qty'][1]);
else
$qty = array_sum($itr['qty']);
echo '<li><div'.($itr['qty'][0] < 0 ? ' class="reputation-negative-amount"' : null).'><span>'.$qty.'</span> '.Lang::npc('repWith') .
' <a href="?faction='.$itr['id'].'">'.$itr['name'].'</a>'.($itr['cap'] && $itr['qty'][0] > 0 ? '&nbsp;('.sprintf(Lang::npc('stopsAt'), $itr['cap']).')' : null).'</div></li>';
endforeach;
echo '</ul>';

View File

@@ -179,7 +179,12 @@ if ($g = $this->gains):
if (!empty($g['rep'])):
foreach ($g['rep'] as $r):
echo ' <li><div>'.($r['qty'] < 0 ? '<b class="q10">'.$r['qty'].'</b>' : $r['qty']).' '.Lang::npc('repWith').' <a href="?faction='.$r['id'].'">'.$r['name']."</a></div></li>\n";
if ($r['qty'][1] && User::isInGroup(U_GROUP_EMPLOYEE))
$qty = $r['qty'][0] . sprintf(Util::$dfnString, Lang::faction('customRewRate'), ($r['qty'][1] > 0 ? '+' : '').$r['qty'][1]);
else
$qty = array_sum($r['qty']);
echo ' <li><div>'.($r['qty'][0] < 0 ? '<b class="q10">'.$qty.'</b>' : $qty).' '.Lang::npc('repWith').' <a href="?faction='.$r['id'].'">'.$r['name']."</a></div></li>\n";
endforeach;
endif;