From aeda3df39efdddb2e3f4428881ab0bdd4a7966b6 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sun, 9 Nov 2014 18:41:57 +0100 Subject: [PATCH] Quest: * moved reputation requirement to conditions Misc: * removed temp-hack from ShowOnMap.js * fixed some formating in global.js * allow display of extra html in all generic templates --- includes/utilities.php | 21 +++++++++ localization/lang.class.php | 19 ++------ pages/quest.php | 58 +++++++++++++++-------- static/js/ShowOnMap.js | 15 ------ static/js/global.js | 59 ++++++++++++------------ template/bricks/footer.tpl.php | 2 +- template/pages/list-page-generic.tpl.php | 7 +-- template/pages/quest.tpl.php | 17 ------- template/pages/text-page-generic.tpl.php | 7 ++- 9 files changed, 103 insertions(+), 102 deletions(-) diff --git a/includes/utilities.php b/includes/utilities.php index 354b9ba0..1671bc75 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -702,6 +702,7 @@ class Util // creates an announcement; use if minor issues arise public static function addNote($uGroupMask, $str) { + // todo (med): log all those errors to DB self::$notes[] = [$uGroupMask, $str]; } @@ -893,6 +894,26 @@ class Util return 3; } + public static function getReputationLevelForPoints($pts) + { + if ($pts >= 41999) + return REP_EXALTED; + else if ($pts >= 20999) + return REP_REVERED; + else if ($pts >= 8999) + return REP_HONORED; + else if ($pts >= 2999) + return REP_FRIENDLY; + else if ($pts >= 0) + return REP_NEUTRAL; + else if ($pts >= -3000) + return REP_UNFRIENDLY; + else if ($pts >= -6000) + return REP_HOSTILE; + else + return REP_HATED; + } + // pageText for Books (Item or GO) and questText public static function parseHtmlText($text) { diff --git a/localization/lang.class.php b/localization/lang.class.php index 8184cae0..366ce0bd 100644 --- a/localization/lang.class.php +++ b/localization/lang.class.php @@ -121,22 +121,9 @@ class Lang public static function getReputationLevelForPoints($pts) { - if ($pts >= 41999) - return self::$game['rep'][REP_EXALTED]; - else if ($pts >= 20999) - return self::$game['rep'][REP_REVERED]; - else if ($pts >= 8999) - return self::$game['rep'][REP_HONORED]; - else if ($pts >= 2999) - return self::$game['rep'][REP_FRIENDLY]; - else if ($pts >= 0) - return self::$game['rep'][REP_NEUTRAL]; - else if ($pts >= -3000) - return self::$game['rep'][REP_UNFRIENDLY]; - else if ($pts >= -6000) - return self::$game['rep'][REP_HOSTILE]; - else - return self::$game['rep'][REP_HATED]; + $_ = Util::getReputationLevelForPoints($pts); + + return self::$game['rep'][$_]; } public static function getRequiredItems($class, $mask, $short = true) diff --git a/pages/quest.php b/pages/quest.php index 11b4b26e..bfb56e42 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -297,7 +297,7 @@ class QuestPage extends GenericPage $this->series[] = [$chain, null]; - // todo (low): sensibly merge te following lists into 'series' + // todo (low): sensibly merge the following lists into 'series' $listGen = function($cnd) { $chain = []; @@ -522,10 +522,11 @@ class QuestPage extends GenericPage // $startend + reqNpcOrGo[1-4] - $this->map = array( - 'data' => ['zone' => $this->typeId], + $this->map = null; + // array( + // 'data' => ['zone' => $this->typeId], // 'som' => json_encode($som, JSON_NUMERIC_CHECK) - ); + // ); /****************/ /* Main Content */ @@ -550,18 +551,6 @@ class QuestPage extends GenericPage if ($maTab) $this->lvTabs[] = $maTab; - if ($_ = $this->subject->getField('reqMinRepFaction')) - { - $val = $this->subject->getField('reqMinRepValue'); - $this->reqMinRep = sprintf(Lang::$quest['reqRepWith'], $_, FactionList::getName($_), Lang::$quest['reqRepMin'], sprintf(Util::$dfnString, $val.' '.Lang::$achievement['points'], Lang::getReputationLevelForPoints($val))); - } - - if ($_ = $this->subject->getField('reqMaxRepFaction')) - { - $val = $this->subject->getField('reqMaxRepValue'); - $this->reqMaxRep = sprintf(Lang::$quest['reqRepWith'], $_, FactionList::getName($_), Lang::$quest['reqRepMax'], sprintf(Util::$dfnString, $val.' '.Lang::$achievement['points'], Lang::getReputationLevelForPoints($val))); - } - // todo (low): create pendant from player_factionchange_quests /**************/ @@ -599,12 +588,41 @@ class QuestPage extends GenericPage } // tab: conditions - $sc = Util::getServerConditions([CND_SRC_QUEST_ACCEPT, CND_SRC_QUEST_SHOW_MARK], null, $this->typeId); - if (!empty($sc[0])) + $cnd = []; + if ($_ = $this->subject->getField('reqMinRepFaction')) + { + $cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [CND_REPUTATION_RANK, $_, 1 << Util::getReputationLevelForPoints($this->subject->getField('reqMinRepValue'))]; + $this->extendGlobalIds(TYPE_FACTION, $_); + } + + if ($_ = $this->subject->getField('reqMaxRepFaction')) + { + $cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0][] = [-CND_REPUTATION_RANK, $_, 1 << Util::getReputationLevelForPoints($this->subject->getField('reqMaxRepValue'))]; + $this->extendGlobalIds(TYPE_FACTION, $_); + } + + $_ = Util::getServerConditions([CND_SRC_QUEST_ACCEPT, CND_SRC_QUEST_SHOW_MARK], null, $this->typeId); + if (!empty($_[0])) + { + // awkward merger + if (isset($_[0][CND_SRC_QUEST_ACCEPT][$this->typeId][0])) + { + if (isset($cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0])) + $cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0] = array_merge($cnd[CND_SRC_QUEST_ACCEPT][$this->typeId][0], $_[0][CND_SRC_QUEST_ACCEPT][$this->typeId][0]); + else + $cnd[CND_SRC_QUEST_ACCEPT] = $_[0][CND_SRC_QUEST_ACCEPT]; + } + + if (isset($_[0][CND_SRC_QUEST_SHOW_MARK])) + $cnd[CND_SRC_QUEST_SHOW_MARK] = $_[0][CND_SRC_QUEST_SHOW_MARK]; + + $this->extendGlobalData($_[1]); + } + + if ($cnd) { - $this->extendGlobalData($sc[1]); $tab = ""; diff --git a/static/js/ShowOnMap.js b/static/js/ShowOnMap.js index 56cdc0c3..e9d500f0 100644 --- a/static/js/ShowOnMap.js +++ b/static/js/ShowOnMap.js @@ -787,18 +787,3 @@ ShowOnMap.buildTooltip = function(list, dailyOnly) { return ret; }; - - -// // !sarjuuk: tempfix! -Markup._fixUrl = function(url) { - if(!url) { - return ''; - } - - // Make local URLs absolute - var firstChar = url.charAt(0); - if(firstChar == '/' || firstChar == '?') - url = '?' + url.replace(/^[\/\?]+/, ''); - - return url; -} diff --git a/static/js/global.js b/static/js/global.js index 66fc9712..2cdd3449 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -90,7 +90,7 @@ function Ajax(url, opt) { $WH.cO(this, opt); this.method = this.method || (this.params && 'POST') || 'GET'; - _.open(this.method, url, this.async == null ? true: this.async); + _.open(this.method, url, this.async == null ? true : this.async); _.onreadystatechange = Ajax.onReadyStateChange.bind(this); if (this.method.toUpperCase() == 'POST') { @@ -1364,7 +1364,7 @@ function g_createAchievementBar(points, outOf, overall, bonus) { } var opt = { - text: points + (bonus > 0 ? '(+' + bonus + ')': '') + (outOf > 0 ? ' / ' + outOf: ''), + text: points + (bonus > 0 ? '(+' + bonus + ')' : '') + (outOf > 0 ? ' / ' + outOf : ''), color: (overall ? 'rep7' : 'ach' + (outOf > 0 ? 0 : 1)), width: (outOf > 0 ? parseInt(points / outOf * 100) : 100) }; @@ -2368,7 +2368,7 @@ var ScreenshotViewer = new function() { computeDimensions(0); - var url = (screenshot.url ? screenshot.url: g_staticUrl + '/uploads/screenshots/' + (resized ? 'resized/': 'normal/') + screenshot.id + '.jpg'); + var url = (screenshot.url ? screenshot.url : g_staticUrl + '/uploads/screenshots/' + (resized ? 'resized/': 'normal/') + screenshot.id + '.jpg'); var html = ' 0 && rowNo > 0 ? Math.floor(rowNo / rpp) * rpp: 0); + return (rpp > 0 && rowNo > 0 ? Math.floor(rowNo / rpp) * rpp : 0); }, resetRowVisibility: function() { @@ -6957,15 +6957,15 @@ Listview.headerFilter = function(col, res) { Listview.headerOver = function(a, col, e) { var buffer = ''; - buffer += '' + (col.tooltip ? col.tooltip: col.name) + ''; + buffer += '' + (col.tooltip ? col.tooltip : col.name) + ''; if (col.__filter) { - buffer += '
' + $WH.sprintf((col.__filter.invert ? LANG.tooltip_colfilter2: LANG.tooltip_colfilter1), col.__filter.text); + buffer += '
' + $WH.sprintf((col.__filter.invert ? LANG.tooltip_colfilter2 : LANG.tooltip_colfilter1), col.__filter.text); } buffer += '
' + LANG.tooltip_lvheader1 + ''; if (this.filtrable && (col.filtrable == null || col.filtrable)) { - buffer += '
' + ($WH.Browser.opera ? LANG.tooltip_lvheader3: LANG.tooltip_lvheader2) + ''; + buffer += '
' + ($WH.Browser.opera ? LANG.tooltip_lvheader3 : LANG.tooltip_lvheader2) + ''; } $WH.Tooltip.show(a, buffer, 0, 0, 'q'); @@ -9842,10 +9842,10 @@ Listview.templates = { value: 'level', type: 'range', getMinValue: function(item) { - return item.minlevel ? item.minlevel: item.level; + return item.minlevel ? item.minlevel : item.level; }, getMaxValue: function(item) { - return item.maxlevel ? item.maxlevel: item.level; + return item.maxlevel ? item.maxlevel : item.level; }, compute: function(item, td) { if (item.minlevel && item.maxlevel) { @@ -10100,8 +10100,8 @@ Listview.templates = { } var - na = (a.sourcemore && a.source.length == 1 ? a.sourcemore[0].n: null), - nb = (b.sourcemore && b.source.length == 1 ? b.sourcemore[0].n: null); + na = (a.sourcemore && a.source.length == 1 ? a.sourcemore[0].n : null), + nb = (b.sourcemore && b.source.length == 1 ? b.sourcemore[0].n : null); return $WH.strcmp(na, nb); } @@ -10398,8 +10398,8 @@ Listview.templates = { Listview.funcBox.createCenteredIcons(itemSet.pieces, td); }, sortFunc: function(a, b) { - var lena = (a.pieces != null ? a.pieces.length: 0); - var lenb = (b.pieces != null ? b.pieces.length: 0); + var lena = (a.pieces != null ? a.pieces.length : 0); + var lenb = (b.pieces != null ? b.pieces.length : 0); return $WH.strcmp(lena, lenb); } }, @@ -11577,7 +11577,7 @@ Listview.templates = { hidden: true, compute: function(spell, td) { var text = ''; - var schools = spell.schools ? spell.schools: spell.school; + var schools = spell.schools ? spell.schools : spell.school; for (var i = 0; i < 32; ++i) { if (!(schools & (1 << i))) { @@ -11693,7 +11693,7 @@ Listview.templates = { width: '9%', hidden: true, getValue: function(spell) { - return (spell.reagents ? spell.reagents.length: 0); + return (spell.reagents ? spell.reagents.length : 0); }, compute: function(spell, td) { var hasIcons = (spell.reagents != null); @@ -11718,8 +11718,8 @@ Listview.templates = { } }, sortFunc: function(a, b) { - var lena = (a.reagents != null ? a.reagents.length: 0); - var lenb = (b.reagents != null ? b.reagents.length: 0); + var lena = (a.reagents != null ? a.reagents.length : 0); + var lenb = (b.reagents != null ? b.reagents.length : 0); if (lena > 0 && lena == lenb) { return $WH.strcmp(a.reagents.toString(), b.reagents.toString()); } @@ -11901,7 +11901,7 @@ Listview.templates = { var skill = [a.learnedat, b.learnedat]; for (var s = 0; s < 2; ++s) { - var sp = (s == 0 ? a: b); + var sp = (s == 0 ? a : b); if (skill[s] == 9999 && sp.colors != null) { var i = 0; while (sp.colors[i] == 0 && i < sp.colors.length) { @@ -13500,7 +13500,7 @@ Listview.templates = { ], getItemLink: function(comment) { - return '?' + g_types[comment.type] + '=' + comment.typeId + (comment.id != null ? '#comments:id=' + comment.id: '') + return '?' + g_types[comment.type] + '=' + comment.typeId + (comment.id != null ? '#comments:id=' + comment.id : '') } }, @@ -16583,12 +16583,12 @@ function MessageBox(parent, text) { box.addClass("message-box"); box.html('

' + text + '

(Click on this box to close it)

'); - setTimeout(function() { // sarjuuk - custom: popups that never vanish are just insane + setTimeout(function() { // sarjuuk - custom: popups that never vanish are just insane box.fadeOut(); }, 5000); box.click(function (e) { - e.stopPropagation(); // sarjuuk - custom: without this, the comment-header would also register the click + $WH.sp(e); // sarjuuk - custom: without this, the comment-header would also register the click $(this).fadeOut(); }); @@ -17050,7 +17050,7 @@ var RedButton = { }, setFunc: function(button, func) { - button.onclick = (func ? func: null); + button.onclick = (func ? func : null); } }; @@ -17315,7 +17315,7 @@ var LiveSearch = new function() { colorDiv(bakDiv); } else { - var div = dir ? lastDiv.nextSibling: lastDiv.previousSibling; + var div = dir ? lastDiv.nextSibling : lastDiv.previousSibling; if (div) { if (div.nodeName == "STRONG") { div = container.lastChild; @@ -20047,6 +20047,7 @@ var ConditionList = new function() { var sName = srcGrp[1]; if ($WH.in_array([18, 21, 23], g) != -1) sName = g_npcs[srcGrp[1]]['name_' + Locale.getName()]; + buff += '[tab name="' + g_condition_types[g][0] + ' (' + sName + ')"]'; } else diff --git a/template/bricks/footer.tpl.php b/template/bricks/footer.tpl.php index 842a8161..6f765633 100644 --- a/template/bricks/footer.tpl.php +++ b/template/bricks/footer.tpl.php @@ -23,7 +23,7 @@ endif; ?> - +