Reference

Reference Tab

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/399274/787111/Reference.js

  1. /***Reference Tab***/
  2. Tabs.Reference = {
  3. tabOrder: 1120,
  4. tabLabel: 'Reference',
  5. unitsaccuracy: [],
  6. z: null,
  7. keyz: null,
  8. myDiv: null,
  9. UniqueTRItems : null,
  10. UniqueCHItems : null,
  11. MultiFaction : [30230,30231,30240,30241,30250,30251,30261,30262,30263,30264,30265,30266],
  12. TechBoosts : {1:0.1,2:0.1,3:0.1,4:0.1,5:0.1,6:0,8:0.05,9:0.05,10:0.1,11:0.1,12:0.05,13:0.05,14:0.1,15:0.05,16:0.1,17:0.01},
  13. BritonTechBoosts : {1:0.05,2:0.01,3:0.05,4:0.05,5:0.02,6:0.02},
  14. JewelQuality: [],
  15. chSorted : false,
  16. chSortArray : [],
  17. trSorted : false,
  18. trSortArray : [],
  19. GloryResetTime : 0,
  20.  
  21. init: function (div) {
  22. var t = Tabs.Reference;
  23.  
  24. uWExportFunction('btShowAccuracyPop',Tabs.Reference.AccuracyPop);
  25.  
  26. t.z = CM.WorldSettings.getSettingAsObject("UNIT_ACCURACY_MODIFIER");
  27. t.keyz = uW.Object.keys(uWCloneInto(t.z));
  28.  
  29. // accuracy matrix only has certain troops and defences
  30.  
  31. t.unitsaccuracy = [];
  32. for (var ui=0;ui<t.keyz.length;ui++) {
  33. if (t.keyz[ui]) {
  34. var i = CM.UNIT_TYPES[t.keyz[ui]];
  35. if (i==null) {
  36. if (t.keyz[ui]=="FORTIFICATION_TYPE_ARCHERTOWER") { i = 53; }
  37. else if (t.keyz[ui]=="FORTIFICATION_TYPE_GREEK_FIRE") { i = 63; }
  38. else if (t.keyz[ui]=="VIRTUAL_UNIT_TYPE_DEFENSIVE_TOWER") { i = 100; }
  39. else if (t.keyz[ui]=="VIRTUAL_UNIT_TYPE_DEFENSIVE_TOWER_REDOUBT") { i = 99; }
  40. else { i = 0; } // no idea what this is, but we need it in the array
  41. }
  42. t.unitsaccuracy.push(i);
  43. }
  44. }
  45.  
  46. for (var J=0;J<=4;J++) {
  47. t.JewelQuality.push(uW.g_js_strings.jewel["quality_"+J]);
  48. }
  49.  
  50. var UniqueItems = {};
  51. eval(GM_getResourceText("champion_uniques"));
  52. t.UniqueCHItems = JSON.parse(JSON.stringify(UniqueItems));
  53.  
  54. for (var i=28001;i<29000;i++) {
  55. if (!uW.itemlist['i'+i]) continue;
  56. if (!t.UniqueCHItems[i]) {
  57. t.UniqueCHItems[i] = {Id:i,Name:uW.itemlist['i'+i].name, Effects:[],Faction:0,Type:0};
  58. }
  59. var CHCard = t.BuildChampCard(i,0);
  60. uW.ksoItems[i].description = t.DisplayCHCard(CHCard,false);
  61. }
  62.  
  63. UniqueItems = {};
  64. UniqueItems = CM.WorldSettings.getSettingAsObject("TR_UNIQUE_ITEMS");
  65. for (var k in UniqueItems) {
  66. var throne_item = UniqueItems[k];
  67. if (parseInt(throne_item.Id) < 29000) delete UniqueItems[k];
  68. throne_item.Name = uW.itemlist["i"+throne_item.Id].name;
  69. if (t.MultiFaction.indexOf(parseInt(throne_item.Id))!=-1) {
  70. throne_item.Name = throne_item.Name + ' ('+uW.g_js_strings.commonstr[cardFaction[throne_item.Faction-1]]+')';
  71. }
  72. }
  73. t.UniqueTRItems = JSON.parse(JSON.stringify(UniqueItems));
  74. for (var i in t.UniqueTRItems) {
  75. if (!uW.itemlist['i'+i]) continue;
  76. var TRCard = t.BuildThroneCard(i,1);
  77. uW.ksoItems[i].description = t.DisplayTRCard(TRCard,false);
  78. }
  79.  
  80. t.myDiv = div;
  81.  
  82. var ag = ByCl('avatarGlory')[0];
  83. if (ag) {
  84. ag.addEventListener('mouseover',t.checkGloryReset,false);
  85. t.checkGloryReset();
  86. }
  87. },
  88.  
  89. checkGloryReset : function () {
  90. var t = Tabs.Reference;
  91. var now = unixTime();
  92. var ag = ByCl('avatarGlory')[0];
  93. if (ag) {
  94. if (t.GloryResetTime < now) {
  95. var params = uW.Object.clone(uW.g_ajaxparams);
  96. params.perPage = 10;
  97. params.type = "glory";
  98. params.page = 'X';
  99. new MyAjaxRequest(uW.g_ajaxpath + "ajax/getUserLeaderboard.php" + uW.g_ajaxsuffix, {
  100. method: "post",
  101. parameters: params,
  102. onSuccess: function (rslt) {
  103. if (rslt.gloryResetTime) {
  104. t.GloryResetTime = rslt.gloryResetTime;
  105. ag.title = tx('Glory resets in '+timestr(t.GloryResetTime-now));
  106. }
  107. },
  108. });
  109. }
  110. else {
  111. ag.title = tx('Glory resets in '+timestr(t.GloryResetTime-now));
  112. }
  113. }
  114. },
  115.  
  116. show: function () {
  117. var t = Tabs.Reference;
  118. var troopa, troopb;
  119.  
  120. dt = new Date();
  121. dt.setTime(Seed.player.datejoinUnixTime * 1000);
  122.  
  123. m = '<div>';
  124. m += '<div class="divHeader" align="center">'+tx('REFERENCE SECTION')+'</div>';
  125. m += '<div align="center">';
  126. m += '<table align=center>';
  127. m += '<TR><TD class=xtab>&nbsp;</td><td align=right class=xtab>'+uW.g_js_strings.commonstr.nametx+':</td><td class=xtab><b>'+Seed.player.name+'</b></td><td class=xtab align=right>'+uW.g_js_strings.commonstr.alliance+':</td><td class=xtab><b>'+getMyAlliance()[1]+'</b></td></tr>';
  128. m += '<TR><TD class=xtab>&nbsp;</td><td align=right class=xtab>'+tx("UID")+':</td><td class=xtab><b>'+uW.tvuid+'</b></td><td align=right class=xtab>'+tx('FBUID')+':</td><td class=xtab><b>'+uW.user_id+'</b></td></tr>';
  129. m += '<TR><TD class=xtab>&nbsp;</td><td align=right class=xtab>'+uW.g_js_strings.commonstr.domain+':</td><td class=xtab><b>'+uW.domainName+'</b></td><td class=xtab align=right>'+tx('Playing Since')+':</td><td class=xtab><b>'+dt.toLocaleDateString()+'</b></td></tr>';
  130. m += '<TR><TD class=xtab>&nbsp;</td><td align=right class=xtab>'+tx('Camelot Version')+':</td><td class=xtab><b>'+anticd.getKOCversion()+'</b></td><td class=xtab align=right>'+tx('PowerBot+ Version')+':</td><td class=xtab><b>'+Version+'</b></td></tr>';
  131. m += '<TR><TD class=xtab>&nbsp;</td><td align=right class=xtab>'+tx('Browser')+':</td><td class=xtab><b>'+FFVersion.Browser+' '+FFVersion.Version+'</b></td><td class=xtab align=right>'+GMVersion.Handler+':</td><td class=xtab><b>'+GMVersion.Version+'</b></td></tr>';
  132. m += '</table><br></div>';
  133.  
  134. // links
  135.  
  136. m += '<a id=btLinkLink class=divLink ><div class="divHeader" align="left"><img id=btLinkArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('USEFUL LINKS')+'</div></a>';
  137. m += '<div id=btLink class=divHide>';
  138.  
  139. m += '<TABLE align=center cellpadding=1 cellspacing=0>';
  140. m += '<TR><TD class=xtabHD width="300px">'+tx('Scripts')+'</td><TD class=xtabHD width="300px">'+tx('Information sites')+'</td></tr>';
  141. m += '<TR><TD class=xtab><a class=xlink href="https://www.facebook.com/PowerBotPlus" target="_blank">'+tx('Power Bot Plus (Facebook Page)')+'</a></td>';
  142. m += '<TD class=xtab><a class=xlink href="http://www.slideshare.net/Aderik/documents" target="_blank">'+tx('Aderik\'s Tutorials')+'</a></td></tr>';
  143. m += '<TR><TD class=xtab><a class=xlink href="https://greatest.deepsurf.us/en/scripts/889-koc-additional-throne-monitor" target="_blank">'+tx('Additional Throne Monitor (Greasyfork)')+'</a></td>';
  144. m += '<TD class=xtab><a class=xlink href="https://www.facebook.com/groups/SolarsKOCinfoPage/" target="_blank">'+tx('KOC Information (Facebook Group)')+'</a></td></tr>';
  145. m += '<TR><TD class=xtab><a class=xlink href="https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/?page=1#version-1.15.1-signed" target="_blank">'+tx('Greasemonkey (Version 1.15)')+'</a></td>';
  146. m += '<TD class=xtab><a class=xlink href="https://www.facebook.com/groups/1467954843521680/" target="_blank">'+tx('Elements of KOC (Facebook Group)')+'</a></td></tr>';
  147. m += '<TR><TD class=xtab><a class=xlink href="http://tampermonkey.net/" target="_blank">Tampermonkey (Chrome, Opera, Safari etc)</a></td>';
  148. m += '<TD class=xtab><a class=xlink href="http://basickoc.weebly.com/" target="_blank">'+tx('KOC Basics')+'</a></td></tr>';
  149. m += '<TR><TD class=xtab><a class=xlink href="https://addons.mozilla.org/en-US/firefox/addon/violentmonkey/" target="_blank">ViolentMonkey (Firefox)</a></td>';
  150. m += '<TD class=xtab><a class=xlink href="http://koc.wikia.com/wiki/" target="_blank">'+tx('KofC Wiki')+'</a></td></tr>';
  151. m += '<TR><TD class=xtab><a class=xlink href="https://addons.mozilla.org/en/firefox/addon/scriptish/versions/" target="_blank">Scriptish</a></td>';
  152. m += '<TD class=xtab><a class=xlink href="http://f89kocguide.weebly.com/" target="_blank">'+tx('F89 Unofficial KOC Guide')+'</a></td></tr>';
  153. m += '<TR><TD class=xtab><a class=xlink href="https://chrome.google.com/webstore/detail/clean-on-refresh/moogoheinbbibflghkinbcmgkncleoid" target="_blank">'+tx('Clean on Refresh (Chrome)')+'</a></td>';
  154. m += '<TD class=xtab><a class=xlink href="http://koc.weezeewig.com/index.sjs?f=ListServers" target="_blank">'+tx('KofC Mapper')+'</a></td></tr>';
  155. m += '</table><BR></div>';
  156.  
  157. // map
  158.  
  159. m += '<a id=btMapLink class=divLink ><div class="divHeader" align="left"><img id=btMapArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('MAP')+'</div></a>';
  160. m += '<div id=btMap class=divHide>';
  161.  
  162. m += '<BR><TABLE align=center cellpadding=1 cellspacing=0>';
  163. m += '<TR><TD colspan=2 class=xtab align=left><DIV id=ptProvMap style="height:' + provMapCoords.imgHeight + 'px; width:' + provMapCoords.imgWidth + 'px; background-repeat:no-repeat; background-image:url(\'' + URL_PROVINCE_MAP + '\')"></div></td></tr>';
  164. m += '<TR><TD colspan=2 class=xtab align=center><DIV style="color:#000;font-size:14px; border: 1px solid; background-color:white; margin:20px 3px 3px 0px; padding:4px" id=ptdistout>&nbsp;</div></td></tr>';
  165. m += '<TR><TD class=xtab align=left><B>'+tx('First Location')+': </b></td><TD class=xtab>&nbsp;X:&nbsp;<INPUT id=calcX type=text\>&nbsp;Y:&nbsp;<INPUT id=calcY type=text\> '+tx('Or, choose city')+': <SPAN id=ptloc1></span></td></tr>';
  166. m += '<TR><TD class=xtab align=left><B>'+tx('Second Location')+': </b></td><TD class=xtab>&nbsp;X:&nbsp;<INPUT id=calcX2 type=text\>&nbsp;Y:&nbsp;<INPUT id=calcY2 type=text\> '+tx('Or, choose city')+': <SPAN id=ptloc2></span></td></tr></table>';
  167. m += '<br></div>';
  168.  
  169. // unit information
  170.  
  171. var rownum = 1;
  172.  
  173. m += '<a id=btUnitInfoLink class=divLink ><div class="divHeader" align="left"><img id=btUnitInfoArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('UNIT INFORMATION')+'</div></a>';
  174. m += '<div id=btUnitInfo class=divHide>';
  175.  
  176. var u = '<TABLE align=center cellpadding=1 cellspacing=0>';
  177. var ch = '<TR align=center><TD class=xtab></td><TD class=xtab></td><TD class=xtabHL colspan=8><B>'+tx('Base Stats')+'</b></td><TD class=xtabHL colspan=5><B>'+tx('Cost to Build')+'</b></td><TD class=xtabHL><B>'+tx('Upkeep')+'</b></td></tr>\
  178. <TR valign=bottom align=right><TD class=xtab></td><TD class=xtab></td><TD class=xtabHL>'+uW.g_js_strings.commonstr.might+'</td><TD class=xtabH>'+uW.g_js_strings.commonstr.life+'</td><TD class=xtabH>'+uW.g_js_strings.commonstr.atk+'</td><TD class=xtabH>'+tx('Def')+'</td><TD class=xtabH>'+uW.g_js_strings.commonstr.speed+'</td><TD class=xtabH>'+uW.g_js_strings.commonstr.range+'</td><TD class=xtabH>'+uW.g_js_strings.modal_barracks_train.load+'</td><TD class=xtabH>'+tx('Spell')+'</td>\
  179. <TD class=xtabHL>'+uW.g_js_strings.commonstr.food+'</td><TD class=xtabH>'+uW.g_js_strings.commonstr.wood+'</td><TD class=xtabH>'+uW.g_js_strings.commonstr.stone+'</td><TD class=xtabH>'+uW.g_js_strings.commonstr.ore+'</td><TD class=xtabH>'+tx('Pop')+'</td><TD class=xtabHL>'+uW.g_js_strings.commonstr.food+'</td></tr>\
  180. <TR style="height:1px;"><TD style="padding:0px; spacing:0px; height:1px; border-color:black; border-width: 1px; border-style: none none solid none" colspan=16></td></tr>';
  181. u += ch;
  182. for (var ui in CM.UNIT_TYPES) {
  183. i = CM.UNIT_TYPES[ui];
  184. if (++rownum % 2) { rsty = 'evenRow'; }
  185. else { rsty = 'oddRow'; }
  186. cost = uW.unitcost['unt' + i]; // NAME, Food, Wood, Stone, Ore, ?, IdlePop, Time
  187. stats = uW.unitstats['unt' + i]; // Life, Attack, Defense, Speed, Range, Load, Might, SpellPower
  188. food = uW.unitupkeeps[i];
  189. might = uW.unitmight['unt' + i];
  190. u += '<TR class="'+rsty+'" align=right><TD class=xtab align=left><B>'+TroopImage(i,"vertical-align:middle;")+cost[0].substr(0,20)+'</b></td><TD class=xtab align=right>'+capitalize(CM.unitFrontendType[i])+'</td>';
  191. u += '<TD class=xtabL>'+might+'</td><TD class=xtab>'+stats[0]+'</td><TD class=xtab>'+stats[1]+'</td><TD class=xtab>'+stats[2]+'</td><TD class=xtab>'+stats[3]+'</td><TD class=xtab>'+stats[4]+'</td><TD class=xtab>'+stats[5]+'</td><TD class=xtab>'+(stats[7]?stats[7]:"")+'</td>';
  192. if (!CM.BarracksUnitsTypeMap.isUnitType(i, "rare")) {
  193. u+= '<TD class=xtabL>'+cost[1]+'</td><TD class=xtab>'+cost[2]+'</td><TD class=xtab>'+cost[3]+'</td><TD class=xtab>'+cost[4]+'</td><TD class=xtab>'+cost[6]+'</td>';
  194. }
  195. else {
  196. u+= '<TD colspan=5 class=xtabL align=center><span style="opacity:0.6;"><i>'+uW.g_js_strings.modal_openBarracks.rarettl+'</i></span></td>';
  197. }
  198. u += '<TD class=xtabL>'+food+'</td></tr>';
  199. }
  200. u += '<TR class=xtabLine><TD colspan=16 class=xtabLine></td></tr>';
  201. u += ch;
  202. for (var k in uW.fortcost) {
  203. if (++rownum % 2) { rsty = 'evenRow'; }
  204. else { rsty = 'oddRow'; }
  205. cost = uW.fortcost[k]; // NAME, Food, Wood, Stone, Ore, ?, IdlePop, Time
  206. fi = k.substring(3);
  207. stats = uW.fortstats['unt' + fi]; // Life, Attack, Defense, Speed, Range, Space
  208. food = 0;
  209. might = fortmight['f' + fi];
  210. var name = cost[0].replace(tx('Defensive'), '');
  211. name = name.replace(tx('Wall-Mounted'), '');
  212. var dtype = tx('Field');
  213. if (fi < 60 || fi==63) { dtype = tx('Wall'); }
  214. u += '<TR class="'+rsty+'" align=right><TD align=left class=xtab><B>'+TroopImage(fi,"vertical-align:middle;")+name+'</b></td><TD class=xtab>'+dtype+'</td><TD class=xtabL>'+might+'</td>\
  215. <TD class=xtab>'+stats[0]+'</td><TD class=xtab>'+stats[1]+'</td><TD class=xtab>'+stats[2]+'</td><TD class=xtab>'+stats[3]+'</td>\
  216. <TD class=xtab>'+stats[4]+'</td><TD class=xtab>'+stats[5]+'</td><TD class=xtab>'+(stats[7]?stats[7]:"")+'</td><TD class=xtabL>'+cost[1]+'</td><TD class=xtab>'+cost[2]+'</td>\
  217. <TD class=xtab>'+cost[3]+'</td><TD class=xtab>'+cost[4]+'</td><TD class=xtab>'+(cost[6]||'')+'</td><TD class=xtabL>&nbsp;</td></tr>';
  218. }
  219. u += '<TR class=xtabLine><TD colspan=16 class=xtabLine></td></tr>';
  220.  
  221. m += u + '</table><BR></div>';
  222.  
  223. // research
  224.  
  225. var rownum = 1;
  226.  
  227. m += '<a id=btResearchInfoLink class=divLink ><div class="divHeader" align="left"><img id=btResearchInfoArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('RESEARCH LEVELS')+'</div></a>';
  228. m += '<div id=btResearchInfo class=divHide>';
  229.  
  230. m += '<TABLE width=95% align=center class=xtab><TR valign=top align=center><td><table class=xtab border=1px cellpadding=2 cellspacing=0><TR valign=top align=left><td><b>'+uW.g_js_strings.commonstr.research+'</b></td><td align=center><b>'+uW.g_js_strings.commonstr.level+'</b></td><td align=right><b>'+tx('Bonus')+'</b></td></tr>';
  231. for (var i in uW.techcost) {
  232. if (++rownum % 2) { rsty = 'evenRow'; }
  233. else { rsty = 'oddRow'; }
  234. var csty = '<span>';
  235. var ui = i.split("tch")[1];
  236. if (Seed.tech[i] == uW.Research.Methods.maxLevel(ui, 1)) csty = '<span style="color:#080">';
  237. if (Seed.tech[i] == 0) csty = '<span style="color:#800">';
  238. m += '<tr class="'+rsty+'"><TD style="width:150px;" title="'+uW.techcost[i][10]+'">' + uW.techcost[i][0] + '</td><TD align=center style="width:50px; max-width:150px;">'+csty+Seed.tech[i]+'</span></td><TD align=right style="width:50px; max-width:150px;">'+csty+(t.TechBoosts[ui]!=0?parseInt(parseIntNan(Seed.tech[i])*t.TechBoosts[ui]*100)+'%':'')+'</span></td></tr>';
  239. }
  240. m += '</table></td>';
  241. m += '<td><table class=xtab border=1px cellpadding=2 cellspacing=0><TR valign=top align=left><td><b>'+tx('Briton Research')+'</b></td><td align=center><b>'+uW.g_js_strings.commonstr.level+'</b></td><td align=right><b>'+tx('Bonus')+'</b></td></tr>';
  242. rownum = 1;
  243. for (var i in uW.techcost2) {
  244. if (++rownum % 2) { rsty = 'evenRow'; }
  245. else { rsty = 'oddRow'; }
  246. var csty = '<span>';
  247. var ui = i.split("tch")[1];
  248. if (Seed.tech2[i] == uW.Research.Methods.maxLevel(ui, 2)) csty = '<span style="color:#080">';
  249. if (Seed.tech2[i] == 0) csty = '<span style="color:#800">';
  250. m += '<tr class="'+rsty+'"><TD style="width:150px;" title="'+uW.techcost2[i][10]+'">' + uW.techcost2[i][0] + '</td><TD align=center style="width:50px; max-width:150px;">'+csty+Seed.tech2[i]+'</span></td><TD align=right style="width:50px; max-width:150px;">'+csty+(t.BritonTechBoosts[ui]!=0?parseInt(parseIntNan(Seed.tech2[i])*t.BritonTechBoosts[ui]*100)+'%':'')+'</span></td></tr>';
  251. m += '</td></tr>';
  252. }
  253. m += '</table></td></tr></table></div>';
  254.  
  255. // tr Caps
  256.  
  257. m += '<a id=btRefCapsLink class=divLink ><div class="divHeader" align="left"><img id=btRefCapsArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('THRONE ROOM CAPS')+'</div></a>';
  258. m += '<div id=btRefCaps class=divHide>';
  259.  
  260. var caps = '<br><TABLE class=xtab align=center border=1px cellspacing=0 cellpadding=2>';
  261. caps += '<TR><TD width="200px"><B>'+tx('Effect Name')+'</b></td><TD width="50px"><B>'+uW.g_js_strings.commonstr.max+'</b></td><TD width="50px"><B>'+tx('Min')+'</b></td><TD style="border:0;width:10px">&nbsp;</td><TD width="200px"><B>'+tx('Effect Name')+'</b></td><TD width="50px"><B>'+uW.g_js_strings.commonstr.max+'</b></td><TD width="50px"><B>'+tx('Min')+'</b></td></tr>';
  262.  
  263. var boosts = [];
  264. for (var k in uW.cm.thronestats.boosts) {
  265. if (uW.cm.thronestats.boosts[k].BoostName) {
  266. boosts.push(uW.cm.thronestats.boosts[k]);
  267. }
  268. }
  269. boosts.sort(function(a, b){ return a.BoostName > b.BoostName});
  270.  
  271. var counter = 0;
  272. var rownum = 0;
  273. caps += '<TR class=oddRow>';
  274. for (var k in boosts) {
  275. counter++
  276. var boost = boosts[k]
  277. if (boost.BoostName) {
  278. caps += '<TD>'+boost.BoostName+'</td><TD>'+boost.Max+'<SPAN id=capmaxPerc_'+k+'></span></div></td><TD>'+boost.Min+'<SPAN id=capminPerc_'+k+'></span></div>';
  279. if (counter % 2 == 0) {
  280. if (++rownum % 2) { rsty = 'evenRow'; }
  281. else { rsty = 'oddRow'; }
  282. caps += '<TR class="'+rsty+'">';
  283. }
  284. else { caps += '</td><TD style="border:0">'; }
  285. }
  286. }
  287. m += caps + '</table><br></div>';
  288.  
  289. // ch Caps
  290.  
  291. m += '<a id=btRefChCapsLink class=divLink ><div class="divHeader" align="left"><img id=btRefChCapsArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('CHAMPION HALL CAPS')+'</div></a>';
  292. m += '<div id=btRefChCaps class=divHide>';
  293.  
  294. var caps = '<br><TABLE class=xtab align=center border=1px cellspacing=0 cellpadding=2>';
  295. caps += '<TR><TD width="200px"><B>'+tx('Effect Name')+'</b></td><TD width="50px"><B>'+uW.g_js_strings.commonstr.max+'</b></td><TD width="50px"><B>'+tx('Min')+'</b></td><TD style="border:0;width:10px">&nbsp;</td><TD width="200px"><B>'+tx('Effect Name')+'</b></td><TD width="50px"><B>'+uW.g_js_strings.commonstr.max+'</b></td><TD width="50px"><B>'+tx('Min')+'</b></td></tr>';
  296.  
  297. var boosts = [];
  298. for (var k in CE_EFFECT_TIERS) {
  299. if (CE_EFFECT_TIERS[k].Id_Tier && (CE_EFFECT_TIERS[k].Max != 0 || CE_EFFECT_TIERS[k].Min !=0)) {
  300. effsplit=CE_EFFECT_TIERS[k]["Id_Tier"].split(",");
  301. if (effsplit[1]==1) { // caps are at tier 1 (?)
  302. var boost = {};
  303. boost.BoostName = CM.ChampionManager.getEffectName(effsplit[0]);
  304. boost.Effect = effsplit[0];
  305. boost.Max = CE_EFFECT_TIERS[k].Max;
  306. boost.Min = CE_EFFECT_TIERS[k].Min;
  307. boosts.push(boost);
  308. }
  309. }
  310. }
  311. boosts.sort(function(a, b){ return a.BoostName > b.BoostName});
  312.  
  313. var counter = 0;
  314. var rownum = 0;
  315. caps += '<TR class=oddRow>';
  316. for (var k in boosts) {
  317. counter++
  318. var boost = boosts[k]
  319. if (boost.BoostName) {
  320. caps += '<TD>'+boost.BoostName+'</td><TD>'+boost.Max+'<SPAN id=chcapmaxPerc_'+k+'></span></div></td><TD>'+boost.Min+'<SPAN id=chcapminPerc_'+k+'></span></div>';
  321. if (counter % 2 == 0) {
  322. if (++rownum % 2) { rsty = 'evenRow'; }
  323. else { rsty = 'oddRow'; }
  324. caps += '<TR class="'+rsty+'">';
  325. }
  326. else { caps += '</td><TD style="border:0">'; }
  327. }
  328. }
  329. m += caps + '</table><br></div>';
  330.  
  331. // glory icons
  332.  
  333. m += '<a id=btRefIconsLink class=divLink ><div class="divHeader" align="left"><img id=btRefIconsArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('GLORY ICONS')+'</div></a>';
  334. m += '<div id=btRefIcons class=divHide>';
  335.  
  336. var icons = '<br><TABLE class=xtab align=center style="background:'+Options.Colors.Panel+';border:2px;">';
  337. icons += '<TR><TD width="50px" align=right><B>'+tx('Icon')+'</b></td><TD width="200px"><B>'+uW.g_js_strings.commonstr.glory+'</b></td><TD style="border:0;width:10px">&nbsp;</td><TD width="50px" align=right><B>'+tx('Icon')+'</b></td><TD width="200px"><B>'+uW.g_js_strings.commonstr.glory+'</b></td></tr><TR>';
  338. var iconarray = [];
  339. for (var k in Seed.gloryChatMapping) {
  340. iconarray.push(k);
  341. }
  342. var counter = 0;
  343. for (var k=0;k<iconarray.length;k++) {
  344. counter++
  345. var start = addCommas(iconarray[k]);
  346. if (k<iconarray.length-1) { var end = ' - '+addCommas(iconarray[k+1]-1); }
  347. else { var end = ' +'; }
  348. icons += '<TD align=right><img src="'+IMGURL+'chat_'+Seed.gloryChatMapping[iconarray[k]]+'.png"></td><TD>'+start+end+'</td>';
  349. if (counter % 2 == 0) { icons += '</tr><TR>'; }
  350. else { icons += '<TD style="border:0">&nbsp;</td>'; }
  351. }
  352. m += icons + '</tr></table><br></div>';
  353.  
  354. // throne uniques
  355.  
  356. m += '<a id=btRefTRUniqueLink class=divLink ><div class="divHeader" align="left"><img id=btRefTRUniqueArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('UNIQUE THRONE ROOM CARDS')+'</div></a>';
  357. m += '<div id=btRefTRUnique class=divHide></div>';
  358.  
  359. // champ uniques
  360.  
  361. m += '<a id=btRefCHUniqueLink class=divLink ><div class="divHeader" align="left"><img id=btRefCHUniqueArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('UNIQUE CHAMPION CARDS')+'</div></a>';
  362. m += '<div id=btRefCHUnique class=divHide></div>';
  363.  
  364. // accuracy
  365.  
  366. m += '<a id=btRefAccuracyLink class=divLink ><div class="divHeader" align="left"><img id=btRefAccuracyArrow height="10" src="'+RightArrow+'">&nbsp;'+tx('ACCURACY MATRIX')+'</div></a>';
  367. m += '<div id=btRefAccuracy class=divHide>';
  368. m += '<DIV style="padding-top:4px;max-height:750px;overflow-y:scroll;width:'+GlobalOptions.btWinSize.x+'px";overflow-x:scroll;">'+strButton8(tx('Show Full Table'), 'onclick="btShowAccuracyPop();"');
  369. m += t.BuildAccuracyTable()+'</div><br></div></br>';
  370.  
  371. t.myDiv.innerHTML = m;
  372.  
  373. t.PaintTRUniques(ById('btRefTRUnique'));
  374. t.PaintCHUniques(ById('btRefCHUnique'));
  375.  
  376. if (!OpenDiv["Reference"]) { OpenDiv["Reference"] = ""; }
  377. if (OpenDiv["Reference"] != "") {
  378. var LastOpenDiv = OpenDiv["Reference"];
  379. OpenDiv["Reference"] = "";
  380. ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,LastOpenDiv,true);
  381. }
  382.  
  383.  
  384. ById('btRefCapsLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btRefCaps",true)}, false);
  385. ById('btRefChCapsLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btRefChCaps",true)}, false);
  386. ById('btRefTRUniqueLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btRefTRUnique",true)}, false);
  387. ById('btRefCHUniqueLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btRefCHUnique",true)}, false);
  388. ById('btRefAccuracyLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btRefAccuracy",true)}, false);
  389. ById('btRefIconsLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btRefIcons",true)}, false);
  390. ById('btUnitInfoLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btUnitInfo",true)}, false);
  391. ById('btResearchInfoLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btResearchInfo",true)}, false);
  392. ById('btLinkLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btLink",true)}, false);
  393. ById('btMapLink').addEventListener ('click', function () {ToggleMainDivDisplay("Reference",100,GlobalOptions.btWinSize.x,"btMap",true)}, false);
  394.  
  395. for (var k in boosts) {
  396. var boost = boosts[k]
  397. if (boost.CapType == "percent") {
  398. if (boost.Max != "none") { ById('capmaxPerc_' + k).innerHTML = '%'; }
  399. if (boost.Min != "none") { ById('capminPerc_' + k).innerHTML = '%'; }
  400. }
  401. }
  402.  
  403. for (var c = 0; c < Cities.numCities; c++)
  404. PlotCityImage(c, ById('ptProvMap'));
  405. if (Seed.allianceHQ) {
  406. PlotAllianceHQ(ById('ptProvMap'),[]);
  407. }
  408. new CdispCityPicker('ptloc1', ById('ptloc1'), true, t.eventLocChanged).bindToXYboxes(ById('calcX'), ById('calcY'));
  409. new CdispCityPicker('ptloc2', ById('ptloc2'), true, t.eventLocChanged).bindToXYboxes(ById('calcX2'), ById('calcY2'));
  410. t.eventLocChanged(Cities.cities[0], Cities.cities[0].x, Cities.cities[0].y);
  411. },
  412.  
  413. AccuracyPop: function () {
  414. var t = Tabs.Reference;
  415. var helpText = '<div>'+t.BuildAccuracyTable()+'<br>&nbsp;</div>';
  416.  
  417. var pop = new CPopup ('BotAccuracy', 0, 0, 800, 800, true);
  418. pop.centerMe (mainPop.getMainDiv());
  419. pop.getMainDiv().innerHTML = helpText;
  420. pop.getTopDiv().innerHTML = '<CENTER><B>'+tx("Accuracy Matrix")+'</b></center>';
  421. pop.show (true);
  422. ResetFrameSize('BotAccuracy',800,800);
  423. },
  424.  
  425. BuildAccuracyTable: function () {
  426. var t = Tabs.Reference;
  427.  
  428. var main = '<TABLE cellpadding=0 cellspacing=0 align=left><TR>';
  429. main += '<TD class=xtab></td><TD align=center colspan='+ (t.unitsaccuracy.length+1) +' class=xtab><b>'+uW.g_js_strings.commonstr.target+'</b></td></tr>';
  430. main += '<TR><TD class=xtabHD>&nbsp;</td>';
  431.  
  432. for (var iu=0;iu<t.unitsaccuracy.length;iu++) {
  433. var u = t.unitsaccuracy[iu];
  434. if (u!=0) {
  435. if (u==99) main += '<TD width=30 class=xtabHD align=center><img style="vertical-align:middle;" src="'+IMGURL+'units/redoubt_30.jpg" title="'+uW.buildingcost.bdg31[0]+'" width=30></td>';
  436. else if (u==100) main += '<TD width=30 class=xtabHD align=center><img style="vertical-align:middle;" src="'+IMGURL+'units/tower_30.jpg" title="'+uW.buildingcost.bdg30[0]+'" width=30></td>';
  437. else {
  438. main += '<TD width=30 class=xtabHD align=center>' + TroopImageBig(u) + '</td>';
  439. }
  440. }
  441. }
  442. main += '</tr>';
  443.  
  444. var r = 0;
  445. for (var ui=0;ui<t.unitsaccuracy.length;ui++) {
  446. var u = t.unitsaccuracy[ui];
  447. if (u != 0) {
  448. if (++r % 2) { rowClass = 'evenRow'; }
  449. else { rowClass = 'oddRow'; }
  450. main += '<TR class="'+rowClass+'">';
  451. if (u<51) {
  452. main += '<TD class=xtab align=right><b>' + uW.unitcost['unt'+u][0] + '</b></td>';
  453. }
  454. else {
  455. if (u==99) rowtext = uW.g_js_strings.redoubt.redoubt
  456. else if (u==100) rowtext = uW.g_js_strings.tower.towerName
  457. else {
  458. var rowtext = uW.fortcost['frt'+u][0];
  459. if (u==53) { rowtext = tx('Crossbows'); } // "Wall Mounted Crossbows" is pointlessly long!
  460. }
  461. main += '<TD class=xtab align=right><b>' + rowtext + '</b></td>';
  462. }
  463. troopa = t.keyz[ui];
  464. for (var uj=0;uj<t.unitsaccuracy.length;uj++) {
  465. var cellstyle = '';
  466. if (ui==uj) { cellstyle = 'style="background: rgba(0,0,0,0.10);"'; }
  467. troopb = t.keyz[uj];
  468. if (!t.z[troopa] || !t.z[troopa][troopb])
  469. main += '<TD class=xtab align=center '+cellstyle+'>??</td>';
  470. else
  471. main += '<TD class=xtab align=center '+cellstyle+'>' + t.z[troopa][troopb] + '</td>';
  472. }
  473. main += '</tr>';
  474. }
  475. }
  476. main += '</table>';
  477. return main;
  478. },
  479.  
  480. plotMapImg: function (markNum, eMap, x, y) {
  481. var t = Tabs.Reference;
  482. var xplot = parseInt((provMapCoords.mapWidth * x) / 750);
  483. var yplot = parseInt((provMapCoords.mapHeight * y) / 750);
  484. if (ById('plotmap_' + markNum) == null) {
  485. var ce = document.createElement('div');
  486. ce.style.background = 'black';
  487. ce.id = 'plotmap_' + markNum;
  488. ce.style.opacity = '1.0';
  489. ce.style.position = 'relative';
  490. ce.style.display = 'block';
  491. ce.style.width = '16px';
  492. ce.style.height = '16px';
  493. ce.style.border = '1px solid #fff';
  494. ce.style.color = 'white';
  495. ce.style.textAlign = 'center';
  496. } else {
  497. ce = ById('plotmap_' + markNum);
  498. }
  499. ce.style.top = (yplot + provMapCoords.topMargin - ((Cities.numCities + markNum) * 16) - 8) + 'px';
  500. ce.style.left = (xplot + provMapCoords.leftMargin - 8) + 'px';
  501. ce.title = "("+x+','+y+')';
  502. eMap.appendChild(ce);
  503. ce.innerHTML = (markNum + 1) + '';
  504. },
  505. eventLocChanged: function (city, x, y) {
  506. var t = Tabs.Reference;
  507. var x1 = parseInt(ById('calcX').value);
  508. var y1 = parseInt(ById('calcY').value);
  509. if (!isNaN(x1) && !isNaN(y1)) {
  510. t.plotMapImg(0, ById('ptProvMap'), x1, y1);
  511. }
  512. var x2 = parseInt(ById('calcX2').value);
  513. var y2 = parseInt(ById('calcY2').value);
  514. if (!isNaN(x2) && !isNaN(y2)) {
  515. t.plotMapImg(1, ById('ptProvMap'), x2, y2);
  516. }
  517. if (!isNaN(x1) && !isNaN(y1) && !isNaN(x2) && !isNaN(y2)) {
  518. var m = tx('The distance from')+' ' + x1 + ',' + y1 + ' '+tx('to')+' ' + x2 + ',' + y2 + ' '+tx('is')+': &nbsp;<B>' + distance(x1, y1, x2, y2).toFixed(2) + '</b>';
  519. ById('ptdistout').innerHTML = m;
  520. }
  521. },
  522.  
  523. PaintTRUniques: function (div) {
  524. var t = Tabs.Reference;
  525. var maxlevel = CM.MAX_MASTERS_TOKEN_LEVEL;
  526. var selectedCard1 = 0;
  527. var selectedCard2 = 0;
  528. var selectedType1 = 0;
  529. var selectedType2 = 0;
  530. uWExportFunction('pbrefreshuniques', Tabs.Reference.GetInventory);
  531.  
  532. t.trSortArray = [];
  533. for (var k in t.UniqueTRItems) {
  534. t.trSortArray.push(t.UniqueTRItems[k]);
  535. }
  536. if (t.trSorted) {
  537. t.trSortArray.sort(function(a, b){ if (a.Name<b.Name) return -1; if (a.Name>b.Name) return 1; return 0; });
  538. }
  539.  
  540. var m = '<div align=center style="height:480px;overflow-y:auto;">';
  541. m += '<TABLE width=90% class=xtabBR>';
  542. m += '<tr align=center><td width=50%/></td><td width=50%/><div align=right><INPUT id=bttrUniqueSort type=checkbox '+(t.trSorted?"CHECKED" : "")+'/>&nbsp;'+tx("Sort Alphabetically")+'</div></td></tr>';
  543.  
  544. m += '<tr><td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.type+':&nbsp;</b><select id="bttrUniqueType1">';
  545. m += '<option value="0">-- '+tx('ALL')+' --</option>';
  546. for (var type_index = 0; type_index < trTypes.length; ++type_index) {
  547. m += '<option value="' + trTypes[type_index] + '">' + uW.g_js_strings.throneRoom[trTypes[type_index]] + '</option>';
  548. }
  549. m += '</select></div></td>';
  550.  
  551. m += '<td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.type+':&nbsp;</b><select id="bttrUniqueType2">';
  552. m += '<option value="0">-- '+tx('ALL')+' --</option>';
  553. for (var type_index = 0; type_index < trTypes.length; ++type_index) {
  554. m += '<option value="' + trTypes[type_index] + '">' + uW.g_js_strings.throneRoom[trTypes[type_index]] + '</option>';
  555. }
  556. m += '</select></div></td>';
  557.  
  558. m += '<tr><td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.item+':&nbsp;</b><select id="bttrUnique1">';
  559. m += '<option value="0">-- '+uW.g_js_strings.commonstr.items+' --</option>';
  560. for (var k=0;k<t.trSortArray.length;k++) {
  561. var throne_item = t.trSortArray[k];
  562. if (throne_item == null || !throne_item) continue;
  563. var style = '';
  564. if (throne_item.Faction == 0) style = 'style="color:#aaa;"';
  565. m += '<option '+style+' value="' + throne_item.Id + '">' + throne_item.Name + ' </option>';
  566. }
  567. m += '</select></div></td>';
  568.  
  569. m += '<td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.item+':&nbsp;</b><select id="bttrUnique2">';
  570. m += '<option value="0">-- '+uW.g_js_strings.commonstr.items+' --</option>';
  571. for (var k=0;k<t.trSortArray.length;k++) {
  572. var throne_item = t.trSortArray[k];
  573. if (throne_item == null || !throne_item) continue;
  574. var style = '';
  575. if (throne_item.Faction == 0) style = 'style="color:#aaa;"';
  576. m += '<option '+style+' value="' + throne_item.Id + '">' + throne_item.Name + ' </option>';
  577. }
  578. m += '</select></div></td>';
  579.  
  580. m += '<tr><td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.level+':&nbsp;</b><select id="bttrUniqueLevel1">';
  581. m += '<option value="1" selected>1</option>';
  582. for (var type_index = 2; type_index < maxlevel + 1; ++type_index) {
  583. m += '<option value="' + type_index + '">' + type_index + '</option>';
  584. }
  585. m += '</select></div></td>';
  586. m += '<td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.level+':&nbsp;</b><select id="bttrUniqueLevel2">';
  587. m += '<option value="1" selected>1</option>';
  588. for (var type_index = 2; type_index < maxlevel + 1; ++type_index) {
  589. m += '<option value="' + type_index + '">' + type_index + '</option>';
  590. }
  591. m += '</select></div></td></tr>';
  592.  
  593. m += '<tr>';
  594. m += '<td id="bttrUniqueItem1" style="overflow: visible; width: auto; height: auto;"/>';
  595. m += '<td id="bttrUniqueItem2" style="overflow: visible; width: auto; height: auto;"/>';
  596. m += '</tr>';
  597. m += '<tr>';
  598. m += '<td id="bttrUniqueInv1" style="overflow: visible; width: auto; height: auto;"/>';
  599. m += '<td id="bttrUniqueInv2" style="overflow: visible; width: auto; height: auto;"/>';
  600. m += '</tr>';
  601.  
  602. m += '</TABLE>';
  603. m += '</div>';
  604.  
  605. div.innerHTML = m;
  606.  
  607. ById('bttrUniqueSort').addEventListener('click', function (e) {
  608. t.trSorted = e.target.checked;
  609. t.PaintTRUniques(div);
  610. },false)
  611.  
  612. jQuery("#bttrUniqueType1").change(function () {
  613. var trType = ById('bttrUniqueType1').value;
  614. var trList = ById('bttrUnique1');
  615. if (selectedType1 != trType && trType != 0) {
  616. selectedCard1 = 0;
  617. }
  618. jQuery("#bttrUnique1").empty();
  619. var trOption = document.createElement('option');
  620. trOption.text = '-- '+uW.g_js_strings.commonstr.items+' --';
  621. trOption.value = 0;
  622. trList.add(trOption);
  623. for (var k=0;k<t.trSortArray.length;k++) {
  624. var throne_item = t.trSortArray[k];
  625. if (throne_item == null || !throne_item) continue;
  626. if (trTypes[parseInt(throne_item.Type)-1] == trType || trType == 0) {
  627. var trOption = document.createElement('option');
  628. trOption.text = throne_item.Name;
  629. trOption.value = throne_item.Id;
  630. trList.add(trOption);
  631. }
  632. }
  633.  
  634. if (selectedCard1 != 0) {
  635. jQuery("#bttrUnique1").val(selectedCard1);
  636. }
  637.  
  638. });
  639.  
  640. jQuery("#bttrUniqueType2").change(function () {
  641. var trType = ById('bttrUniqueType2').value;
  642. var trList = ById('bttrUnique2');
  643. if (selectedType2 != trType && trType != 0) {
  644. selectedCard2 = 0;
  645. }
  646. jQuery("#bttrUnique2").empty();
  647. var trOption = document.createElement('option');
  648. trOption.text = '-- '+uW.g_js_strings.commonstr.items+' --';
  649. trOption.value = 0;
  650. trList.add(trOption);
  651. for (var k=0;k<t.trSortArray.length;k++) {
  652. var throne_item = t.trSortArray[k];
  653. if (throne_item == null || !throne_item) continue;
  654. if (trTypes[parseInt(throne_item.Type)-1] == trType || trType == 0) {
  655. var trOption = document.createElement('option');
  656. trOption.text = throne_item.Name;
  657. trOption.value = throne_item.Id;
  658. trList.add(trOption);
  659. }
  660. }
  661.  
  662. if (selectedCard2 != 0) {
  663. jQuery("#bttrUnique2").val(selectedCard2);
  664. }
  665. });
  666.  
  667. jQuery("#bttrUnique1").change(function () { changeUnique1(this); });
  668.  
  669. jQuery("#bttrUnique1").keyup(function (event) { changeUnique1(this); });
  670.  
  671. function changeUnique1(thisObj) {
  672. var trID = jQuery(thisObj).val();
  673. var trDisplay = ById('bttrUniqueItem1');
  674. var trLevel = ById('bttrUniqueLevel1');
  675. selectedCard1 = 0;
  676. ConvertToCard(trID,trDisplay,trLevel);
  677. t.GetInventory(trID,'bttrUniqueInv1');
  678. selectedCard1 = trID;
  679. selectedType1 = trTypes[parseInt(t.UniqueTRItems[trID].Type)-1];
  680. }
  681.  
  682. jQuery("#bttrUnique2").change(function () { changeUnique2(this); });
  683.  
  684. jQuery("#bttrUnique2").keyup(function (event) { changeUnique2(this); });
  685.  
  686. function changeUnique2(thisObj) {
  687. var trID = jQuery(thisObj).val();
  688. var trDisplay = ById('bttrUniqueItem2');
  689. var trLevel = ById('bttrUniqueLevel2');
  690. selectedCard2 = 0;
  691. ConvertToCard(trID,trDisplay,trLevel);
  692. t.GetInventory(trID,'bttrUniqueInv2');
  693. selectedCard2 = trID;
  694. selectedType2 = trTypes[parseInt(t.UniqueTRItems[trID].Type)-1];
  695. }
  696.  
  697. jQuery("#bttrUniqueLevel1").keyup(function (event) { changeLevel1(); });
  698.  
  699. jQuery("#bttrUniqueLevel1").change(function () { changeLevel1(); });
  700.  
  701. function changeLevel1() {
  702. if (selectedCard1 != 0) {
  703. var trID = selectedCard1;
  704. var trDisplay = ById('bttrUniqueItem1');
  705. var trLevel = ById('bttrUniqueLevel1');
  706. trDisplay.innerHTML = '';
  707. ConvertToCard(trID,trDisplay,trLevel);
  708. }
  709. }
  710.  
  711. jQuery("#bttrUniqueLevel2").keyup(function (event) { changeLevel2(); });
  712.  
  713. jQuery("#bttrUniqueLevel2").change(function () { changeLevel2(); });
  714.  
  715. function changeLevel2() {
  716. if (selectedCard2 != 0) {
  717. var trID = selectedCard2;
  718. var trDisplay = ById('bttrUniqueItem2');
  719. var trLevel = ById('bttrUniqueLevel2');
  720. trDisplay.innerHTML = '';
  721. ConvertToCard(trID,trDisplay,trLevel);
  722. }
  723. }
  724.  
  725. function ConvertToCard (trID,div,lvl) {
  726. div.innerHTML = '';
  727. var TRCard = t.BuildThroneCard(trID,parseIntNan(lvl.value));
  728. div.innerHTML = t.DisplayTRCard(TRCard,true);
  729. };
  730.  
  731. },
  732.  
  733. BuildThroneCard : function (trID,lvl) {
  734. var t = Tabs.Reference;
  735. var TRCard = {};
  736. TRCard = t.UniqueTRItems[trID];
  737. TRCard.id = TRCard.Id;
  738. TRCard.name = uW.itemlist["i"+trID].name;
  739. if (TRCard.Faction != 0) {
  740. TRCard.faction = cardFaction[TRCard.Faction-1];
  741. TRCard.type = trTypes[parseInt(TRCard.Type)-1].toLowerCase();
  742. }
  743. else {
  744. TRCard.faction = 'unknown';
  745. TRCard.type = 'unknown';
  746. TRCard.unknown = true;
  747. }
  748. TRCard.unique = TRCard.id;
  749. TRCard.level = lvl;
  750. TRCard.quality = 6;
  751. TRCard.createPrefix = function () { return ""; };
  752. TRCard.createSuffix = function () { return ""; };
  753. TRCard.effects = {};
  754. var effects = eval(TRCard.Effects);
  755. var slot = 0;
  756.  
  757. for (var k in effects) {
  758. slot++
  759. TRCard.effects["slot"+slot] = {};
  760. TRCard.effects["slot"+slot].id = effects[k].type;
  761. TRCard.effects["slot"+slot].tier = effects[k].tier;
  762.  
  763. if (slot==6) {
  764. var qual = 5; // assume bright jewel
  765. if (UniqueJewels && UniqueJewels.hasOwnProperty(TRCard.id)) { // some uniques don't have bright jewels...
  766. qual = UniqueJewels[TRCard.id];
  767. }
  768. TRCard.effects["slot"+slot].quality = qual;
  769. TRCard.effects["slot"+slot].fromJewel = true;
  770.  
  771. TRCard.jewel = {};
  772. TRCard.jewel.valid = true;
  773. TRCard.jewel.id = TRCard.effects["slot"+slot].id;
  774. TRCard.jewel.quality = qual;
  775. TRCard.jewel.tier = TRCard.effects["slot"+slot].tier;
  776. TRCard.jewel.fromJewel = true;
  777. TRCard.jewel.gift = false;
  778. TRCard.jewel.quantity = 1;
  779. }
  780. }
  781. return TRCard;
  782. },
  783.  
  784. GetInventory : function (trID,div) {
  785. var t = Tabs.Reference;
  786. div.innerHTML = '';
  787. var m = '<br><b>'+uW.g_js_strings.commonstr.throneroom+'</b><br>';
  788. var tritem = {};
  789. for (var k in uW.kocThroneItems) {
  790. var throne_item = uW.kocThroneItems[k];
  791. if (throne_item.unique == trID) {
  792. if (tritem[throne_item.level]) {tritem[throne_item.level]++} else {tritem[throne_item.level] = 1;}
  793. }
  794. }
  795. var gotitem = false;
  796. for (var l in tritem) {
  797. gotitem = true;
  798. m += tx('You have')+' '+tritem[l]+' '+tx('at level')+' '+l+'<br>';
  799. }
  800. if (!gotitem) m += tx('You have none in your throne room')+'.<br>';
  801. else {
  802. //if (t.UniqueTRItems[trID].Faction == 0) {
  803. m += '<a class=xlink id=pbgenstats'+trID+'>Generate Stats</a><br>';
  804. //}
  805. }
  806.  
  807. m += '<br><b>'+uW.g_js_strings.commonstr.inventory+'</b><br>';
  808. var inv = uW.seed.items['i'+trID];
  809. m += tx('You have')+' '+(inv?inv:uW.g_js_strings.commonstr.none)+' '+tx('in your inventory')+'.';
  810. if ((inv?inv:0) != 0 && !gotitem) {
  811. m += '<br><a class=xlink onClick="cm.ItemController.use(\''+trID+'\');setTimeout(function(){pbrefreshuniques('+trID+',\''+div+'\')},2000);">'+tx('Add to Throne Room')+'</a>';
  812. }
  813. ById(div).innerHTML = m;
  814. if (ById('pbgenstats'+trID)) {
  815. ById('pbgenstats'+trID).addEventListener('click',function () { window.prompt(tx("Copy to clipboard: Ctrl+C"), GenerateStats(trID)); } , false);
  816. }
  817.  
  818. function GenerateStats(trID) {
  819. for (var k in uW.kocThroneItems) {
  820. var throne_item = uW.kocThroneItems[k];
  821. if (throne_item.unique == trID) {
  822. var Results = 'UniqueItems["'+trID+'"] = {Id:'+trID+',Name:"'+throne_item.name+'", Effects:[';
  823. var firsteffect = true;
  824. for (var e in throne_item.effects) {
  825. if (!firsteffect) Results += ',';
  826. Results += '{type:'+throne_item.effects[e].id+',tier:'+throne_item.effects[e].tier+'}';
  827. firsteffect = false;
  828. }
  829. Results += '],Faction:'+(cardFaction.indexOf(throne_item.faction)+1)+',Type:'+(trTypes.indexOf(throne_item.type)+1)+'};';
  830. break;
  831. }
  832. }
  833. return Results;
  834. }
  835. },
  836.  
  837. DisplayTRCard : function (throne_item,Links,ScaleFactor) {
  838. var t = Tabs.Reference;
  839. var D = [];
  840. if (throne_item == null) {
  841. D.push("<div>");
  842. D.push("</div>");
  843. return D.join("");
  844. }
  845.  
  846. if (!ScaleFactor) { ScaleFactor = 1; }
  847. var CardWidth = Math.floor(200*ScaleFactor);
  848. var BigFont = Math.floor(14*ScaleFactor);
  849. var ImageSize = Math.floor(70*ScaleFactor);
  850. var SmallFont = Math.floor(11*ScaleFactor);
  851.  
  852. var E = []; // copy to clip/post to chat array
  853.  
  854. D.push("<div style='overflow: hidden; position: relative; left: 0px; top: 0px;'>");
  855. D.push(" <div id='throneInventoryItemTooltip'>");
  856. D.push("<div class='section' style='overflow:visible;width:"+CardWidth+"px;' id='idsection'>");
  857. D.push(" <div class='title " + throne_item.createPrefix().toLowerCase() + "' style='color:#3F2300;text-transform:capitalize;font-size:"+BigFont+"px;'> ");
  858. D.push(throne_item.name + (throne_item.unique ? " +" + throne_item.level : ""));
  859. D.push(" </div> ");
  860. D.push(" <div class='description'> ");
  861. var uniquestyle = "";
  862. if (throne_item.isBroken) {
  863. uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+BrokenIcon+'); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;';
  864. }
  865. else {
  866. if (throne_item.unique > 29000) {
  867. uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'throne/icons/70/'+throne_item.faction+'_'+throne_item.type+'_unique_'+throne_item.unique + '.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;';
  868. if (throne_item.unique == 30262 || throne_item.unique == 30264 || throne_item.unique == 30266) { uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'throne/icons/70/christmas_advisor_normal_1.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;'; }
  869. if (throne_item.unique == 30261 || throne_item.unique == 30263 || throne_item.unique == 30265) { uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'throne/icons/70/christmas_candelabrum_normal_1.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;'; }
  870. if (throne_item.unique == 30230 || throne_item.unique == 30240 || throne_item.unique == 30250) { uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'throne/icons/70/halloween_table_normal_1.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;'; }
  871. if (throne_item.unique == 30231 || throne_item.unique == 30241 || throne_item.unique == 30251) { uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'throne/icons/70/halloween_chair_normal_1.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;'; }
  872. }
  873. else {
  874. uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'throne/icons/70/'+throne_item.faction+'_'+throne_item.type+'_normal_1_'+throne_item.quality+'.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;';
  875. }
  876. }
  877.  
  878. D.push("<div class='portrait " + throne_item.faction + " " + throne_item.type + "' style='"+uniquestyle+"'> </div> ");
  879. D.push("<ul style='margin-top:0px;'>");
  880. D.push("<li style='float:none;margin:0px;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.faction + ": " + uW.g_js_strings.commonstr[throne_item.faction] + "</li>");
  881. D.push("<li style='float:none;margin:0px;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.quality + ": " + CardQuality(throne_item.quality,throne_item.unique) + "</li>");
  882. D.push("<li style='float:none;margin:0px;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.type + ": " + uW.g_js_strings.throneRoom[throne_item.type] + "</li>");
  883. D.push("<li style='float:none;margin:0px;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.level + ": " + throne_item.level + "</li>");
  884. D.push("<li style='float:none;margin:0px;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.might + ": " + CardMight(throne_item) + "</li>");
  885.  
  886. if (throne_item.jewel && throne_item.jewel.valid) { D.push("<li style='float:none;margin:0px;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.jewel + ": " + t.JewelQuality[throne_item.jewel.quality-1] + "</li>"); }
  887.  
  888. D.push("</ul>");
  889. D.push(" </div> ");
  890. D.push(" <ul> ");
  891.  
  892. E.push(throne_item.name.replace(/\'/g, "") + (throne_item.unique ? " +" + throne_item.level : ""));
  893. E.push(uW.g_js_strings.commonstr.faction + ": " + uW.g_js_strings.commonstr[throne_item.faction]);
  894. E.push(uW.g_js_strings.commonstr.quality + ": " + CardQuality(throne_item.quality,throne_item.unique));
  895. E.push(uW.g_js_strings.commonstr.type + ": " + uW.g_js_strings.throneRoom[throne_item.type]);
  896. // E.push(uW.g_js_strings.commonstr.level + ": " + throne_item.level);
  897. E.push(uW.g_js_strings.commonstr.might + ": " + CardMight(throne_item));
  898. if (throne_item.jewel && throne_item.jewel.valid) { E.push(uW.g_js_strings.commonstr.jewel + ": " + t.JewelQuality[throne_item.jewel.quality-1]); }
  899.  
  900. if (throne_item.unknown) {
  901. if (Links) {
  902. D.push(" <li style='font-size:"+BigFont+"px;' class='effect'><center>"+tx("Unknown")+"</center></li> ");
  903. D.push(" <li style='font-size:"+BigFont+"px;' class='effect'><div style='font-size:"+SmallFont+"px;'><center>"+tx("If you have one in your Throne Room please click the 'Generate Stats' link below and send the results to the script developer")+".</center></div></li>");
  904. }
  905. }
  906. else {
  907. for (var slot in throne_item.effects) {
  908. try {
  909. var N = throne_item.effects[slot];
  910. tier = parseInt(N.tier);
  911. effect = getThroneEffectName(N.id,tier);
  912. p = uW.cm.thronestats.tiers[N.id][tier];
  913. while (!p && (tier > 0)) { tier--; p = uW.cm.thronestats.tiers[N.id][tier]; }
  914. if (!p) continue; // can't find stats for tier
  915.  
  916. var base = +p.base || 0;
  917. var level = +throne_item.level || 0;
  918. var growth = +p.growth || 0;
  919. if (slot == 'slot6') { //if it has a slot 6, it automatically has a jewel
  920. JewelQuality = throne_item["effects"]['slot6'].quality;
  921. GrowthLimit = uW.cm.thronestats.jewelGrowthLimit[JewelQuality];
  922. if (GrowthLimit <= level) level = GrowthLimit
  923. }
  924. percent = Number(base + ((level * level + level) * growth * 0.5));
  925. var wholeNumber = false;
  926. if (Math.round(parseFloat(percent)) == parseFloat(percent)) wholeNumber = true;
  927. percent = (percent > 0) ? "+" + percent : +percent;
  928. if (wholeNumber)
  929. percent = parseFloat(percent).toFixed(0);
  930. else
  931. percent = parseFloat(percent).toFixed(2);
  932. css = (slot % 2 === 0) ? "even" : "odd";
  933. B = +(slot.split("slot")[1]);
  934. percent = (percent > 0) ? "+" + percent : percent;
  935. if (B <= throne_item.quality) {
  936. D.push(" <li class='effect " + css + "' style='float:none;margin:0px;font-size:"+BigFont+"px;'> " + percent + "% " + effect + " </li> ");
  937. } else {
  938. D.push(" <li class='effect disabled " + css + "' style='float:none;margin:0px;font-size:"+BigFont+"px;'> " + percent + "% " + effect + " </li> ");
  939. }
  940. E.push("Row " + B + ": " + percent + "% " + effect);
  941. }
  942. catch (e) { }
  943. }
  944. }
  945. D.push(" </ul> ");
  946. D.push(" </div> ");
  947. D.push(" </ul> ");
  948. D.push(" </div> ");
  949. D.push(" </div> ");
  950.  
  951. var cText = ":::. |" + E.join('||');
  952. var clipText = E.join(' ');
  953.  
  954. if (Links) {
  955. D.push('<table width="210" class=xtab><tr><td><a class=xlink onClick="window.prompt(\''+tx("Copy to clipboard: Ctrl+C")+'\', \''+clipText+'\');">'+tx("Copy to Clipboard")+'</a></td><td align=right><a class=xlink onClick="Chat.sendChat(\''+cText+'\')">'+tx("Post to Chat")+'</a></td></tr></table>');
  956. }
  957. return D.join("");
  958. },
  959.  
  960. PaintCHUniques: function (div) {
  961. var t = Tabs.Reference;
  962. var maxlevel = CM.CHAMPION.MAX_LEVELS;
  963. var itemTypes = { weapon: 0, chest: 1, helm: 2, boots: 3, shield: 4, ring: 5, pendant: 7, cloak: 8 };
  964. var selectedCard1 = 0;
  965. var selectedCard2 = 0;
  966. var selectedType1 = 0;
  967. var selectedType2 = 0;
  968. uWExportFunction('pbrefreshchuniques', Tabs.Reference.GetCHInventory);
  969.  
  970. t.chSortArray = [];
  971. for (var k in t.UniqueCHItems) {
  972. t.chSortArray.push(t.UniqueCHItems[k]);
  973. }
  974. if (t.chSorted) {
  975. t.chSortArray.sort(function(a, b){ var x=a.Set-b.Set; var y=0; if (a.name<b.name) y=-1; if (a.name>b.name) y=1; return (x==0)?y:x; });
  976. }
  977.  
  978. var m = '<div align=center style="height:480px;overflow-y:auto;">';
  979. m += '<TABLE width=90% class=xtabBR>';
  980. m += '<tr align=center><td width=50%/></td><td width=50%/><div align=right><INPUT id=btchUniqueSort type=checkbox '+(t.chSorted?"CHECKED" : "")+'/>&nbsp;'+tx("Sort by Champion Set")+'</div></td></tr>';
  981.  
  982. m += '<tr><td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.type+':&nbsp;</b><select id="btchUniqueType1">';
  983. m += '<option value="0">-- '+tx('ALL')+' --</option>';
  984. for (var type in itemTypes) {
  985. m += '<option value="' + type + '">' + uW.g_js_strings.champ[type] + '</option>';
  986. }
  987. m += '</select></div></td>';
  988.  
  989. m += '<td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.type+':&nbsp;</b><select id="btchUniqueType2">';
  990. m += '<option value="0">-- '+tx('ALL')+' --</option>';
  991. for (var type in itemTypes) {
  992. m += '<option value="' + type + '">' + uW.g_js_strings.champ[type] + '</option>';
  993. }
  994. m += '</select></div></td>';
  995.  
  996. m += '<tr><td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.item+':&nbsp;</b><select id="btchUnique1">';
  997. m += '<option value="0">-- '+uW.g_js_strings.commonstr.items+' --</option>';
  998. for (var k=0;k<t.chSortArray.length;k++) {
  999. var champ_item = t.chSortArray[k];
  1000. if (champ_item == null || !champ_item) continue;
  1001. var style = '';
  1002. if (champ_item.Faction == 0) style = 'style="color:#aaa;"';
  1003. m += '<option '+style+' value="' + champ_item.Id + '">' + uW.itemlist["i"+champ_item.Id].name + ' </option>';
  1004. }
  1005. m += '</select></div></td>';
  1006.  
  1007. m += '<td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.item+':&nbsp;</b><select id="btchUnique2">';
  1008. m += '<option value="0">-- '+uW.g_js_strings.commonstr.items+' --</option>';
  1009. for (var k=0;k<t.chSortArray.length;k++) {
  1010. var champ_item = t.chSortArray[k];
  1011. if (champ_item == null || !champ_item) continue;
  1012. var style = '';
  1013. if (champ_item.Faction == 0) style = 'style="color:#aaa;"';
  1014. m += '<option '+style+' value="' + champ_item.Id + '">' + uW.itemlist["i"+champ_item.Id].name + ' </option>';
  1015. }
  1016. m += '</select></div></td>';
  1017.  
  1018. m += '<tr><td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.level+':&nbsp;</b><select id="btchUniqueLevel1">';
  1019. m += '<option value="0" selected>0</option>';
  1020. for (var type_index = 1; type_index < maxlevel + 1; ++type_index) {
  1021. m += '<option value="' + type_index + '">' + type_index + '</option>';
  1022. }
  1023. m += '</select></div></td>';
  1024. m += '<td><div style="max-width:100%;"><b>'+uW.g_js_strings.commonstr.level+':&nbsp;</b><select id="btchUniqueLevel2">';
  1025. m += '<option value="0" selected>0</option>';
  1026. for (var type_index = 1; type_index < maxlevel + 1; ++type_index) {
  1027. m += '<option value="' + type_index + '">' + type_index + '</option>';
  1028. }
  1029. m += '</select></div></td></tr>';
  1030.  
  1031. m += '<tr>';
  1032. m += '<td id="btchUniqueItem1" style="overflow: visible; width: auto; height: auto;"/>';
  1033. m += '<td id="btchUniqueItem2" style="overflow: visible; width: auto; height: auto;"/>';
  1034. m += '</tr>';
  1035. m += '<tr>';
  1036. m += '<td id="btchUniqueInv1" style="overflow: visible; width: auto; height: auto;"/>';
  1037. m += '<td id="btchUniqueInv2" style="overflow: visible; width: auto; height: auto;"/>';
  1038. m += '</tr>';
  1039.  
  1040. m += '</TABLE>';
  1041. m += '</div>';
  1042.  
  1043. div.innerHTML = m;
  1044.  
  1045. ById('btchUniqueSort').addEventListener('click', function (e) {
  1046. t.chSorted = e.target.checked;
  1047. t.PaintCHUniques(div);
  1048. },false)
  1049.  
  1050. jQuery("#btchUniqueType1").change(function () {
  1051. var chType = ById('btchUniqueType1').value;
  1052. var chList = ById('btchUnique1');
  1053. if (selectedType1 != chType && chType != 0) {
  1054. selectedCard1 = 0;
  1055. }
  1056. jQuery("#btchUnique1").empty();
  1057. var chOption = document.createElement('option');
  1058. chOption.text = '-- '+uW.g_js_strings.commonstr.items+' --';
  1059. chOption.value = 0;
  1060. chList.add(chOption);
  1061. for (var k=0;k<t.chSortArray.length;k++) {
  1062. var champ_item = t.chSortArray[k];
  1063. if (champ_item == null || !champ_item) continue;
  1064. if (chTypeStrings[parseInt(champ_item.Type)-1] == chType || chType == 0) {
  1065. var chOption = document.createElement('option');
  1066. chOption.text = uW.itemlist["i"+champ_item.Id].name;
  1067. chOption.value = champ_item.Id;
  1068. if (champ_item.Faction == 0) chOption.style = 'color:#aaa;';
  1069. chList.add(chOption);
  1070. }
  1071. }
  1072.  
  1073. if (selectedCard1 != 0) {
  1074. jQuery("#btchUnique1").val(selectedCard1);
  1075. }
  1076.  
  1077. });
  1078.  
  1079. jQuery("#btchUniqueType2").change(function () {
  1080. var chType = ById('btchUniqueType2').value;
  1081. var chList = ById('btchUnique2');
  1082. if (selectedType2 != chType && chType != 0) {
  1083. selectedCard2 = 0;
  1084. }
  1085. jQuery("#btchUnique2").empty();
  1086. var chOption = document.createElement('option');
  1087. chOption.text = '-- '+uW.g_js_strings.commonstr.items+' --';
  1088. chOption.value = 0;
  1089. chList.add(chOption);
  1090. for (var k=0;k<t.chSortArray.length;k++) {
  1091. var champ_item = t.chSortArray[k];
  1092. if (champ_item == null || !champ_item) continue;
  1093. if (chTypeStrings[parseInt(champ_item.Type)-1] == chType || chType == 0) {
  1094. var chOption = document.createElement('option');
  1095. chOption.text = uW.itemlist["i"+champ_item.Id].name;
  1096. chOption.value = champ_item.Id;
  1097. if (champ_item.Faction == 0) chOption.style = 'color:#aaa;';
  1098. chList.add(chOption);
  1099. }
  1100. }
  1101.  
  1102. if (selectedCard2 != 0) {
  1103. jQuery("#btchUnique2").val(selectedCard2);
  1104. }
  1105.  
  1106. });
  1107.  
  1108. jQuery("#btchUnique1").change(function () { changeUnique1(this); });
  1109.  
  1110. jQuery("#btchUnique1").keyup(function (event) { changeUnique1(this); });
  1111.  
  1112. function changeUnique1(thisObj) {
  1113. var chID = jQuery(thisObj).val();
  1114. var chDisplay = ById('btchUniqueItem1');
  1115. var chLevel = ById('btchUniqueLevel1');
  1116. selectedCard1 = 0;
  1117. ConvertToCard(chID,chDisplay,chLevel);
  1118. t.GetCHInventory(chID,'btchUniqueInv1');
  1119. selectedCard1 = chID;
  1120. selectedType1 = chTypeStrings[parseInt(t.UniqueCHItems[chID].Type)-1];
  1121.  
  1122. }
  1123.  
  1124. jQuery("#btchUnique2").change(function () { changeUnique2(this); });
  1125.  
  1126. jQuery("#btchUnique2").keyup(function (event) { changeUnique2(this); });
  1127.  
  1128. function changeUnique2(thisObj) {
  1129. var chID = jQuery(thisObj).val();
  1130. var chDisplay = ById('btchUniqueItem2');
  1131. var chLevel = ById('btchUniqueLevel2');
  1132. selectedCard2 = 0;
  1133. ConvertToCard(chID,chDisplay,chLevel);
  1134. t.GetCHInventory(chID,'btchUniqueInv2');
  1135. selectedCard2 = chID;
  1136. selectedType2 = chTypeStrings[parseInt(t.UniqueCHItems[chID].Type)-1];
  1137. }
  1138.  
  1139. jQuery("#btchUniqueLevel1").keyup(function (event) { changeLevel1(); });
  1140.  
  1141. jQuery("#btchUniqueLevel1").change(function () { changeLevel1(); });
  1142.  
  1143. function changeLevel1() {
  1144. if (selectedCard1 != 0) {
  1145. var chID = selectedCard1;
  1146. var chDisplay = ById('btchUniqueItem1');
  1147. var chLevel = ById('btchUniqueLevel1');
  1148. chDisplay.innerHTML = '';
  1149. ConvertToCard(chID,chDisplay,chLevel);
  1150. }
  1151. }
  1152.  
  1153. jQuery("#btchUniqueLevel2").keyup(function (event) { changeLevel2(); });
  1154.  
  1155. jQuery("#btchUniqueLevel2").change(function () { changeLevel2(); });
  1156.  
  1157. function changeLevel2() {
  1158. if (selectedCard2 != 0) {
  1159. var chID = selectedCard2;
  1160. var chDisplay = ById('btchUniqueItem2');
  1161. var chLevel = ById('btchUniqueLevel2');
  1162. chDisplay.innerHTML = '';
  1163. ConvertToCard(chID,chDisplay,chLevel);
  1164. }
  1165. }
  1166.  
  1167. function ConvertToCard (chID,div,lvl) {
  1168. div.innerHTML = '';
  1169. var CHCard = t.BuildChampCard(chID,parseIntNan(lvl.value));
  1170. div.innerHTML = t.DisplayCHCard(CHCard,true);
  1171. };
  1172. },
  1173.  
  1174. BuildChampCard : function (chID,lvl) {
  1175. var t = Tabs.Reference;
  1176. var CHCard = {};
  1177. CHCard = t.UniqueCHItems[chID];
  1178. CHCard.uniqueCompare = true;
  1179. CHCard.id = CHCard.Id;
  1180. CHCard.name = uW.itemlist["i"+chID].name;
  1181. if (CHCard.Faction != 0) {
  1182. CHCard.faction = CHCard.Faction;
  1183. CHCard.type = CHCard.Type;
  1184. }
  1185. else {
  1186. CHCard.unknown = true;
  1187. }
  1188. CHCard.unique = CHCard.id;
  1189. CHCard.level = lvl;
  1190. CHCard.rarity = 5;
  1191. CHCard.createPrefix = function () { return ""; };
  1192. CHCard.createSuffix = function () { return ""; };
  1193. CHCard.effects = {};
  1194. var effects = eval(CHCard.Effects);
  1195. var slot = 0;
  1196. for (var k in effects) {
  1197. slot++
  1198. CHCard.effects["slot"+slot] = {};
  1199. CHCard.effects["slot"+slot].id = effects[k].type;
  1200. CHCard.effects["slot"+slot].tier = effects[k].tier;
  1201. }
  1202. return CHCard;
  1203. },
  1204.  
  1205. isBroken : function(champ_item) {
  1206. if (champ_item.status) {
  1207. return (champ_item.status < 0 || champ_item.status == 2 || champ_item.status == 3);
  1208. }
  1209. },
  1210.  
  1211. GetCHInventory : function (chID,div) {
  1212. var t = Tabs.Reference;
  1213. div.innerHTML = '';
  1214. var m = '<br><b>'+uW.g_js_strings.champ.title+'</b><br>';
  1215. var chitem = {};
  1216. for (var k in uW.kocChampionItems) {
  1217. var champ_item = uW.kocChampionItems[k];
  1218. if (champ_item.unique == chID) {
  1219. if (chitem[champ_item.level]) {chitem[champ_item.level]++} else {chitem[champ_item.level] = 1;}
  1220. }
  1221. }
  1222. var gotitem = false;
  1223. for (var l in chitem) {
  1224. gotitem = true;
  1225. m += tx('You have')+' '+chitem[l]+' '+tx('at level')+' '+l+'<br>';
  1226. }
  1227. if (!gotitem) m += tx('You have none in your champion hall')+'.<br>';
  1228. else {
  1229. if (t.UniqueCHItems[chID].Faction == 0) {
  1230. m += '<a class=xlink id=pbgenchstats'+chID+'>Generate Stats</a><br>';
  1231. }
  1232. }
  1233.  
  1234. m += '<br><b>'+uW.g_js_strings.commonstr.inventory+'</b><br>';
  1235. var inv = uW.seed.items['i'+chID];
  1236. m += tx('You have')+' '+(inv?inv:uW.g_js_strings.commonstr.none)+' '+tx('in your inventory')+'.';
  1237. if ((inv?inv:0) != 0) {
  1238. m += '<br><a class=xlink onClick="cm.ItemController.use(\''+chID+'\');setTimeout(function(){pbrefreshchuniques('+chID+',\''+div+'\')},2000);">'+tx('Add to Champion Hall')+'</a>';
  1239. }
  1240. ById(div).innerHTML = m;
  1241. if (ById('pbgenchstats'+chID)) {
  1242. ById('pbgenchstats'+chID).addEventListener('click',function () { window.prompt(tx("Copy to clipboard: Ctrl+C"), GenerateStats(chID)); } , false);
  1243. }
  1244.  
  1245. function GenerateStats(chID) {
  1246. for (var k in uW.kocChampionItems) {
  1247. var champ_item = uW.kocChampionItems[k];
  1248. if (champ_item.unique == chID) {
  1249. var Results = 'UniqueItems["'+chID+'"] = {Id:'+chID+',Name:"'+champ_item.subtype+'", Effects:[';
  1250. var firsteffect = true;
  1251. for (var e in champ_item.effects) {
  1252. if (!firsteffect) Results += ',';
  1253. Results += '{type:'+champ_item.effects[e].id+',tier:'+champ_item.effects[e].tier+'}';
  1254. firsteffect = false;
  1255. }
  1256. Results += '],Faction:'+champ_item.faction+',Type:'+champ_item.type+',Set:'+champ_item.set+'};';
  1257. break;
  1258. }
  1259. }
  1260. return Results;
  1261. }
  1262. },
  1263.  
  1264. DisplayCHCard : function (champ_item,Links,ScaleFactor,showChamp) {
  1265. var t = Tabs.Reference;
  1266. var D = [];
  1267. if (champ_item == null) {
  1268. D.push("<div>");
  1269. D.push("</div>");
  1270. return D.join("");
  1271. }
  1272.  
  1273. if (!ScaleFactor) { ScaleFactor = 1; }
  1274. var CardWidth = Math.floor(220*ScaleFactor);
  1275. var BigFont = Math.floor(14*ScaleFactor);
  1276. var ImageSize = Math.floor(70*ScaleFactor);
  1277. var SmallFont = Math.floor(12*ScaleFactor);
  1278.  
  1279. if (champ_item.rarity) champ_item.quality = parseIntNan(champ_item.rarity);
  1280. if (!champ_item.Type) champ_item.Type = parseIntNan(champ_item.type);
  1281.  
  1282. var E = []; // copy to clip/post to chat array
  1283.  
  1284. D.push("<div style='overflow: hidden; position: relative; left: 0px; top: 0px;'>");
  1285. D.push("<div id='throneInventoryItemTooltip'>");
  1286. D.push("<div class='section' style='overflow:visible;background:#E7E3D6;width:"+CardWidth+"px;color:#3f2300;' id='idsection'>");
  1287. D.push("<div class='title " + champ_item.createPrefix().toLowerCase() + "' style='text-transform:capitalize;background:#E7E3D6;border-bottom:2px solid #A4753A;font-size:"+BigFont+"px;'> ");
  1288. D.push(champ_item.name + (champ_item.uniqueCompare ? " +" + champ_item.level : ""));
  1289. D.push("</div>");
  1290. D.push("<div class='description' style='border-bottom:2px solid #A4753A;'>");
  1291. var uniquestyle = "";
  1292. if (t.isBroken(champ_item)) {
  1293. uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+BrokenIcon+'); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;';
  1294. }
  1295. else {
  1296. if (champ_item.unique != 0) { uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'champion_hall/unique_'+champUniqueImageTypes[champ_item.Type-1]+'_'+cardFaction[champ_item.faction-1]+'_70x70_'+champ_item.unique + '.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;'; }
  1297. else { uniquestyle = 'width:'+ImageSize+'px;height:'+ImageSize+'px;background:transparent url('+IMGURL+'champion_hall/'+cardQuality[champ_item.rarity].toLowerCase()+'_'+champImageTypes[champ_item.Type-1]+'_'+cardFaction[champ_item.faction-1]+'_70x70.png); top left no-repeat; background-size:'+ImageSize+'px '+ImageSize+'px;'; }
  1298. }
  1299. D.push("<div class='portrait " + champ_item.faction + " " + champ_item.type + "' style='border:none;margin-left:3px;margin-top:8px;"+uniquestyle+"'> </div> ");
  1300. D.push("<ul>");
  1301. D.push("<li style='float:none;margin:0px;color:#A4753A;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.faction + ": " + (champ_item.unknown?"Unknown":uW.g_js_strings.commonstr[cardFaction[champ_item.faction-1]]) + "</li>");
  1302. D.push("<li style='float:none;margin:0px;color:#A4753A;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.quality + ": " + CardQuality(champ_item.rarity,champ_item.unique) + "</li>");
  1303. D.push("<li style='float:none;margin:0px;color:#A4753A;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.type + ": " + (champ_item.unknown?"Unknown":uW.g_js_strings.champ[chTypeStrings[champ_item.type-1]]) + "</li>");
  1304. D.push("<li style='float:none;margin:0px;color:#A4753A;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.level + ": " + champ_item.level + "</li>");
  1305. D.push("<li style='float:none;margin:0px;color:#A4753A;font-size:"+SmallFont+"px;'> " + uW.g_js_strings.commonstr.might + ": " + CardMight(champ_item,true) + "</li>");
  1306. if (showChamp && champ_item.equippedTo) {
  1307. for (var y in Seed.champion.champions) {
  1308. var chkchamp = Seed.champion.champions[y];
  1309. if (chkchamp.championId && chkchamp.championId==champ_item.equippedTo) {
  1310. D.push("<li style='float:none;margin:0px;color:#A4753A;font-size:"+SmallFont+"px;'> " + tx('Equipped') + ": " + chkchamp.name + "</li>");
  1311. break;
  1312. }
  1313. }
  1314. }
  1315. D.push("</ul>");
  1316. D.push("</div>");
  1317. D.push("<ul>");
  1318.  
  1319. E.push(champ_item.name.replace(/\'/g, "") + (champ_item.uniqueCompare ? " +" + champ_item.level : ""));
  1320. E.push(uW.g_js_strings.commonstr.faction + ": " + (champ_item.unknown?"Unknown":uW.g_js_strings.commonstr[cardFaction[champ_item.faction-1]]));
  1321. E.push(uW.g_js_strings.commonstr.quality + ": " + CardQuality(champ_item.rarity,champ_item.unique));
  1322. E.push(uW.g_js_strings.commonstr.type + ": " + (champ_item.unknown?"Unknown":uW.g_js_strings.commonstr[cardFaction[champ_item.faction-1]]));
  1323. // E.push(uW.g_js_strings.commonstr.level + ": " + champ_item.level);
  1324. E.push(uW.g_js_strings.commonstr.might + ": " + CardMight(champ_item,true));
  1325.  
  1326. if (champ_item.unknown) {
  1327. if (Links) {
  1328. D.push(" <li style='font-size:"+BigFont+"px;' class='effect'><center>"+tx("Unknown")+"</center></li> ");
  1329. D.push(" <li style='font-size:"+BigFont+"px;' class='effect'><div style='font-size:"+SmallFont+"px;'><center>"+tx("If you have one in your Champions Hall please click the 'Generate Stats' link below and send the results to the script developer")+".</center></div></li>");
  1330. }
  1331. }
  1332. else {
  1333. for (var slot in champ_item.effects) {
  1334. try {
  1335. var N = champ_item.effects[slot];
  1336. effect = uW.g_js_strings.effects["name_"+N.id];
  1337.  
  1338. tier = parseInt(N.tier);
  1339. p = ChampionStatTiers[N.id][tier];
  1340. while (!p && (tier > 0)) { tier--; p = ChampionStatTiers[N.id][tier]; }
  1341. if (!p) continue; // can't find stats for tier
  1342.  
  1343. var base = +p.base || 0;
  1344. var level = +champ_item.level || 0;
  1345. var growth = +p.growth || 0;
  1346. percent = Number(base + ((level * level + level) * growth * 0.5));
  1347. if (N.id>=300) {
  1348. percent = Number(base + (level * growth));
  1349. if (N.id<400) percent = percent*100;
  1350. }
  1351. var wholeNumber = false;
  1352. if (Math.round(parseFloat(percent)) == parseFloat(percent)) wholeNumber = true;
  1353. percent = (percent > 0) ? percent : +percent;
  1354. if (wholeNumber)
  1355. percent = parseFloat(percent).toFixed(0);
  1356. else
  1357. percent = parseFloat(percent).toFixed(2);
  1358. css = (slot % 2 === 0) ? "even" : "odd";
  1359. B = +(slot.split("slot")[1]);
  1360. if (!B) B = slot;
  1361. percent = (N.id>=300)?percent+'%':percent;
  1362. if (B <= champ_item.rarity) {
  1363. if (N.id < 200) {
  1364. D.push(" <li title='tier "+tier+"' class='effect " + css + "' style='float:none;margin:0px;color: #1751A5;font-size:"+BigFont+"px;'> " + percent + " " + effect + " </li> ");
  1365. }
  1366. else {
  1367. if (N.id >= 400) {
  1368. D.push(" <li title='tier "+tier+"' class='effect " + css + "' style='float:none;margin:0px;color: #f80;font-size:"+BigFont+"px;'> " + percent + " " + effect + " </li> ");
  1369. }
  1370. else {
  1371. if (N.id >= 300) {
  1372. D.push(" <li title='tier "+tier+"' class='effect " + css + "' style='float:none;margin:0px;color: #808;font-size:"+BigFont+"px;'> " + percent + " " + effect + " </li> ");
  1373. }
  1374. else {
  1375. D.push(" <li title='tier "+tier+"' class='effect " + css + "' style='float:none;margin:0px;font-size:"+BigFont+"px;'> " + percent + " " + effect + " </li> ");
  1376. }
  1377. }
  1378. }
  1379. } else {
  1380. D.push(" <li title='tier "+tier+"' class='effect disabled " + css + "' style='float:none;margin:0px;font-size:"+BigFont+"px;'> " + percent + " " + effect + " </li> ");
  1381. }
  1382. E.push("Row " + B + ": " + percent + " " + effect);
  1383. }
  1384. catch (e) { }
  1385. }
  1386. }
  1387. D.push(" </ul> ");
  1388. D.push(" </div> ");
  1389. D.push(" </ul> ");
  1390. D.push(" </div> ");
  1391. D.push(" </div> ");
  1392.  
  1393. var cText = ":::. |" + E.join('||');
  1394. var clipText = E.join(' ');
  1395. if (Links) {
  1396. D.push('<table width="210" class=xtab><tr><td><a class=xlink onClick="window.prompt(\''+tx("Copy to clipboard: Ctrl+C")+'\', \''+clipText+'\');">'+tx("Copy to Clipboard")+'</a></td><td align=right><a class=xlink onClick="Chat.sendChat(\''+cText+'\')">'+tx("Post to Chat")+'</a></td></tr></table>');
  1397. }
  1398. return D.join("");
  1399. },
  1400. }