AutoJoust

Joust Tab

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/399266/787096/AutoJoust.js

  1. /**************************** Joust Tab ****************************************/
  2. // @tabversion 20190705
  3.  
  4. Tabs.Joust = {
  5. tabOrder: 2120,
  6. tabLabel : 'Joust',
  7. tabColor : 'brown',
  8. ValidJoust: false,
  9. isBusy: false,
  10. myDiv : null,
  11. timer : null,
  12. NumJousts : 0,
  13. NumWins : 0,
  14. Options: {
  15. JoustRunning: false,
  16. JoustDelay: 7,
  17. },
  18.  
  19. init : function (div){
  20. var t = Tabs.Joust;
  21. t.myDiv = div;
  22. if (!Options.JoustOptions) {
  23. Options.JoustOptions = t.Options;
  24. }
  25. else {
  26. for (var y in t.Options) {
  27. if (!Options.JoustOptions.hasOwnProperty(y)) {
  28. Options.JoustOptions[y] = t.Options[y];
  29. }
  30. }
  31. }
  32. t.CheckEvent(t.show);
  33. },
  34. CheckEvent : function (notify) {
  35. var t = Tabs.Joust;
  36. t.ValidJoust = uW.cm.JoustingModel.getTimeLeft() > 0;
  37. t.ValidJoust = true;
  38. var elem = ById("bttcJoust");
  39. if (t.ValidJoust) {
  40. elem.setAttribute("style","color:#f00");
  41. }
  42. if (Options.JoustOptions.JoustRunning) {
  43. t.start();
  44. }
  45. if (notify) { notify(); }
  46. },
  47. eventDoJoust: function () {
  48. var t = Tabs.Joust;
  49. if (!t.isBusy) return;
  50.  
  51. var div = $("pbjoust_info");
  52.  
  53. // get opponents
  54. var params = uW.Object.clone(uW.g_ajaxparams);
  55. params.ctrl = 'jousting\\JoustingController';
  56. params.action = 'opponents';
  57. new MyAjaxRequest(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{
  58. method:"post",
  59. parameters:params,
  60. onSuccess:function(rslt) {
  61. if (rslt.ok){
  62. for (var o=0;o<rslt.opponents.length;o++) {
  63. setTimeout(t.eventDoFight,(o*1000*Math.ceil(Options.JoustOptions.JoustDelay,1000)),rslt.opponents[o].id, rslt.opponents[o].serverid);
  64. }
  65. var DelayAdjustment = Math.floor(Math.random() * 4);
  66. setTimeout(t.nextfight, 1000*Math.ceil(((Options.JoustOptions.JoustDelay*3)+DelayAdjustment),3));
  67. }
  68. else {
  69. div.innerHTML = '<span style="color:#800;">'+tx('Server Error')+' '+rslt.msg+'</span><br>'+div.innerHTML;
  70. ById('pbJoustCancel').firstChild.innerHTML = uW.g_js_strings.commonstr.close;
  71. t.isBusy = false;
  72. }
  73. },
  74. onFailure: function () {
  75. div.innerHTML = '<span style="color:#800;">'+tx('Server Error')+'!</span><br>'+div.innerHTML;
  76. ById('pbJoustCancel').firstChild.innerHTML = uW.g_js_strings.commonstr.close;
  77. t.isBusy = false;
  78. },
  79. },true);
  80. },
  81. eventDoFight : function (opponent,opponentServerId) {
  82. var t = Tabs.Joust;
  83. if (!t.isBusy) return;
  84.  
  85. var div = $("pbjoust_info");
  86. var params = uW.Object.clone(uW.g_ajaxparams);
  87.  
  88. params.ctrl = 'jousting\\JoustingController';
  89. params.action = 'fight';
  90. params.opponent = opponent;
  91. params.opponentServerId = opponentServerId;
  92. new MyAjaxRequest(uW.g_ajaxpath+"ajax/_dispatch53.php"+uW.g_ajaxsuffix,{
  93. method:"post",
  94. parameters:params,
  95. onSuccess:function(rslt2) {
  96. if (rslt2.ok){
  97. t.NumJousts++;
  98. reward = '';
  99. if (rslt2.reward) {
  100. uW.ksoItems[rslt2.reward.itemId].add(rslt2.reward.quantity);
  101. Seed.items["i"+rslt2.reward.itemId] = parseInt(Seed.items["i"+rslt2.reward.itemId])+rslt2.reward.quantity;
  102. reward = ' - '+tx('Awarded')+' '+rslt2.reward.quantity+' '+uW.itemlist['i'+rslt2.reward.itemId].name;
  103. }
  104. if (rslt2.report.s1.won) {
  105. t.NumWins++;
  106. div.innerHTML = '<span style="color:#080;">'+tx('Won against')+' '+rslt2.report.s0.nam+reward+'</span><br>'+div.innerHTML;
  107. }
  108. else {
  109. div.innerHTML = '<span style="color:#800;">'+tx('Lost against')+' '+rslt2.report.s0.nam+reward+'</span><br>'+div.innerHTML;
  110. }
  111. }
  112. else {
  113. div.innerHTML = '<span style="color:#800;">'+tx('Server Error')+' '+rslt2.msg+'</span><br>'+div.innerHTML;
  114. }
  115. ById('joustHeader').innerHTML = tx('Jousting Results')+'... ('+t.NumWins+'/'+t.NumJousts+')';
  116. },
  117. onFailure: function () {
  118. div.innerHTML = '<span style="color:#800;">'+tx('Server Error')+'!</span><br>'+div.innerHTML;
  119. ById('pbJoustCancel').firstChild.innerHTML = uW.g_js_strings.commonstr.close;
  120. t.isBusy = false;
  121. },
  122. },true);
  123. },
  124. show : function (){
  125. var t = Tabs.Joust;
  126. if (!t.isBusy) {
  127. var m = '<DIV class=divHeader align=center>JOUST</div>';
  128. m += '<div style="min-height:400px;">';
  129. if (t.ValidJoust) {
  130. m += '<br><DIV align=center>'+tx("Joust interval")+': <INPUT id=btjoustinterval type=text size=3 value=' + Options.JoustOptions.JoustDelay + ' /> '+tx("seconds");
  131. m += '</div>';
  132. m +='<br><br><center><input type=button value="'+uW.g_js_strings.modal_mmb.playnow+'" id=btJoustStart></center>';
  133. }
  134. else {
  135. m += '<br><div align=center>'+tx('No active event')+'</div>';
  136. }
  137. m += '</div>';
  138. m += '<div align=center><div style="position:absolute;bottom:0px;width:'+GlobalOptions.btWinSize.x+'px;"><br><hr>';
  139. m += '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">\
  140. <input type="hidden" name="cmd" value="_s-xclick">\
  141. <input type="hidden" name="hosted_button_id" value="8VEDPV3X9X82L">\
  142. <input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">\
  143. <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">\
  144. </form>';
  145. m += '<br>'+tx('This additional tab has been provided free of charge for the benefit of players. Please donate to help with future support and development of this and other features')+'.<br>'+tx('Thanks')+',&nbsp;Barbarossa.<br>&nbsp;</div></div>';
  146. t.myDiv.innerHTML = m;
  147. ResetFrameSize('btMain',100,GlobalOptions.btWinSize.x);
  148.  
  149. if (t.ValidJoust) {
  150. ById('btJoustStart').addEventListener('click', function(){t.start();} , false);
  151.  
  152. ChangeOption('JoustOptions','btjoustinterval', 'JoustDelay');
  153. }
  154. }
  155. else { // reset curtain position..
  156. t.setCurtain(true);
  157. }
  158. },
  159. setPopup: function (onoff) {
  160. var t = Tabs.Joust;
  161. if (onoff) {
  162. var div = document.createElement('div');
  163. div.id = 'ptJoustPop';
  164. div.style.backgroundColor = '#fff';
  165. div.style.zindex = mainPop.div.zIndex + 2;
  166. div.style.opacity = '1';
  167. div.style.border = '3px outset black';
  168. div.style.width = (GlobalOptions.btWinSize.x-200)+'px';
  169. div.style.height = '300px';
  170. div.style.display = 'block';
  171. div.style.position = 'absolute';
  172. div.style.top = '100px';
  173. div.style.left = '100px';
  174. t.myDiv.appendChild(div);
  175. return div;
  176. } else {
  177. t.myDiv.removeChild(ById('ptJoustPop'));
  178. }
  179. },
  180.  
  181. setCurtain: function (onoff) {
  182. var t = Tabs.Joust;
  183. if (onoff) {
  184. var off = getAbsoluteOffsets(t.myDiv);
  185. var curtain = ById('ptJoustCurtain');
  186. if (!curtain) {
  187. curtain = document.createElement('div');
  188. curtain.id = 'ptJoustCurtain';
  189. curtain.style.zindex = mainPop.div.zIndex + 1;
  190. curtain.style.backgroundColor = "#000000";
  191. curtain.style.opacity = '0.5';
  192. curtain.style.display = 'block';
  193. curtain.style.position = 'absolute';
  194. t.myDiv.appendChild(curtain);
  195. }
  196. curtain.style.width = (t.myDiv.clientWidth+4) + 'px';
  197. curtain.style.height = (t.myDiv.clientHeight+4) + 'px';
  198. curtain.style.top = off.top + 'px';
  199. curtain.style.left = off.left + 'px';
  200. } else {
  201. t.myDiv.removeChild(ById('ptJoustCurtain'));
  202. }
  203. },
  204.  
  205. e_Cancel: function () {
  206. var t = Tabs.Joust;
  207. if (t.isBusy) {
  208. t.isBusy = false;
  209. Options.JoustOptions.JoustRunning = false;
  210. var div = $("pbjoust_info");
  211. div.innerHTML += "<br><span>"+tx('Cancelled')+"!</span>";
  212. ById('pbJoustCancel').firstChild.innerHTML = uW.g_js_strings.commonstr.close;
  213. return;
  214. }
  215. t.setCurtain(false);
  216. t.setPopup(false);
  217. t.show();
  218. },
  219.  
  220. start : function (){
  221. var t = Tabs.Joust;
  222. t.isBusy = true;
  223. t.NumJousts = 0;
  224. t.NumWins = 0;
  225. Options.JoustOptions.JoustRunning = true;
  226. t.setCurtain(true);
  227. var popDiv = t.setPopup(true);
  228. popDiv.innerHTML = '<TABLE class=xtab width=100% height=100%><TR><TD align=center>\
  229. <DIV class=divHeader align=center id=joustHeader>'+tx('Jousting Results')+'...</div>\
  230. <DIV id=pbjoust_info style="padding:10px; height:225px; max-height:225px; overflow-y:auto"></div>\
  231. </td></tr><TR><TD align=center>' + strButton20(uW.g_js_strings.commonstr.cancel, 'id=pbJoustCancel') + '</td></tr></table>';
  232. ById('pbJoustCancel').addEventListener('click', t.e_Cancel, false);
  233.  
  234. t.nextfight();
  235. },
  236.  
  237. nextfight : function (){
  238. var t = Tabs.Joust;
  239. if(!t.isBusy)
  240. return;
  241. var div = $("pbjoust_info");
  242. t.eventDoJoust();
  243. },
  244. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址