Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 86.58 KB | None | 0 0
  1. // ==UserScript==
  2. // @name OGameRediseño Compactador Batallas
  3. // @namespace http://userscripts.org/users/143231
  4. // @description OGameRediseño Compactador Batallas
  5. // @version 1.4.14
  6. // @author HoChiChaos/trustux & Rudolph/Granja_VIP [trusreno]
  7. // @updateURL http://userscripts.org/scripts/source/75647.meta.js
  8. // @downloadURL https://userscripts.org/scripts/source/75647.user.js
  9. // @include http://*/game/index.php?*page=*
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_log
  12. // @grant unsafeWindow
  13. // ==/UserScript==
  14.  
  15.  
  16. (function ()
  17. {
  18.  
  19. var SCRIPT = {
  20. name: "Compactador automático de batallas trusreno"
  21. ,url: "http://userscripts.org/scripts/show/75647"
  22. ,version: "1.4"
  23. ,version_completa: "1.4.14"
  24. ,funciona_ok: "5.7.99.99"
  25. };
  26.  
  27.  
  28.  
  29. // ==============================================================================================
  30. // ==============================================================================================
  31. // ==============================================================================================
  32.  
  33. function gethttprequest(dirurl) {
  34. var respuesta;
  35. GM_xmlhttpRequest({
  36. method: "GET",
  37. url: dirurl,
  38. onload: function(response) {
  39. var resphttprequest = document.createElement('div');
  40. resphttprequest.id = "resphttprequest";
  41. resphttprequest.innerHTML = response.responseText;
  42. resphttprequest.style.display = "none";
  43. resphttprequest.tag = dirurl;
  44. document.body.appendChild(resphttprequest);
  45. }
  46. });
  47. }
  48.  
  49. var btndonate = '';
  50. btndonate += '<center><form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">';
  51. btndonate += '<input type="hidden" name="cmd" value="_s-xclick">';
  52. btndonate += '<input type="hidden" name="hosted_button_id" value="7CBAVV6WKZ526">'
  53. btndonate += '<input type="image" src="https://www.paypalobjects.com/es_ES/ES/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal. La forma rápida y segura de pagar en Internet.">';
  54. btndonate += '<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">';
  55. btndonate += '</form></center><br>';
  56.  
  57. function MenuLib() {
  58.  
  59. // crea un boton en el menu izquierdo dentro del juego
  60. this.menuButton_create = function() {
  61. var MenuTableTools = document.getElementById('menuTableTools');
  62. var Data = document.getElementById('trusrenocomp');
  63. if (! Data) {
  64. var ListElement = document.createElement('li');
  65. ListElement.innerHTML = '<div id="trusrenocomp" style="display: none;"></div>'
  66. + '<a id="btn_menu_trusrenocomp" href="javascript:void(0)" class="menubutton"><span class="textlabel"><p style="color:#F59754">Ganancias Batalla</p></span></a>';
  67. if (MenuTableTools.childNodes.length) {
  68. MenuTableTools.insertBefore( ListElement, MenuTableTools.childNodes[0]);
  69. }
  70. else {
  71. MenuTableTools.appendChild(ListElement);
  72. }
  73. Data = document.getElementById('trusrenocomp');
  74. Data.parentNode.addEventListener('click', this.menuButton_click, false);
  75. }
  76. };
  77.  
  78. // acciones a realizar al pulsar sobre el boton del menu
  79. this.menuButton_click = function() {
  80. var ContentWrapper = document.getElementById('contentWrapper');
  81. if (ContentWrapper) {
  82. var content = '',
  83. Inhalt = document.getElementById('inhalt'),
  84. Container = document.getElementById('trusrenocomp_div_container');
  85. if (Inhalt) { Inhalt.style.display = (Container) ? 'block' : 'none'; }
  86. }
  87. if (Container) {
  88. ContentWrapper.removeChild( Container );
  89. }
  90. else {
  91. Container = document.createElement('div');
  92. Container.id = 'trusrenocomp_div_container';
  93. if (ContentWrapper.childNodes.length) {
  94. ContentWrapper.insertBefore( Container, ContentWrapper.childNodes[0] );
  95. }
  96. else {
  97. ContentWrapper.appendChild( Container );
  98. }
  99. // seccion menu
  100. content += '<p align="center"><br><br><table class="" width="100%">';
  101. content += '<tr><td colspan="4" style="background-color:#0A122A">'
  102. content += '<br><center><b><a href="http://userscripts.org/scripts/show/75647" target="_blank">Compactador automático de batallas trusreno [' + SCRIPT.version_completa + ']</b><br>';
  103. content += '<br>HoChiChaos/trustux & Rudolph/Granja_VIP<br>[trusreno]</a></center><br>'
  104. content += btndonate;
  105. content += '</td></tr>';
  106. content += '<tr>';
  107. content += '<td width="25%" style="text-align:center;" bgcolor="#240B3B"><a style="color: #FFFFFF; font-size: 10pt" id="mostrar_sec1" href="javascript:void(0)">Diario</a></td>';
  108. content += '<td width="25%" style="text-align:center;" bgcolor="#240B3B"><a style="color: #FFFFFF; font-size: 10pt" id="mostrar_sec2" href="javascript:void(0)">Mensual</a></td>';
  109. content += '<td width="25%" style="text-align:center;" bgcolor="#240B3B"><a style="color: #FFFFFF; font-size: 10pt" id="mostrar_sec3" href="javascript:void(0)">Consideraciones</a></td>';
  110. content += '<td width="25%" style="text-align:center;" bgcolor="#240B3B"><a style="color: #FFFFFF; font-size: 10pt" id="mostrar_sec4" href="javascript:void(0)">-[ CERRAR ]-</a></td>';
  111. content += '</tr></table></p>';
  112.  
  113. // seccion diario
  114. content += '<div id="div_diario" style="background-color:#0A122A"><br>';
  115. content += '<table>';
  116. content += '<tr><td width="120" align="right"><b>DIA</b></td><td width="120" align="right"><b>BATALLAS</b></td><td width="120" align="right"><b>METAL</b></td><td width="120" align="right"><b>CRISTAL</b></td><td width="120" align="right"><b>DEUTERIO</b></td><td width="120" align="right"><b>TOTAL</b></td></tr>';
  117.  
  118. var diario_metal = new HashTable();
  119. diario_metal.parse(options.get("diario_metal"));
  120.  
  121. var diario_cristal = new HashTable();
  122. diario_cristal.parse(options.get("diario_cristal"));
  123.  
  124. var diario_deu = new HashTable();
  125. diario_deu.parse(options.get("diario_deu"));
  126.  
  127. var diario_batallas = new HashTable();
  128. diario_batallas.parse(options.get("diario_batallas"));
  129.  
  130. var keys = diario_metal.keys();
  131.  
  132. var b, m, c, d;
  133. var tb, tm, tc, td;
  134. var muestras = 0;
  135.  
  136. b = tb = m = tm = c = tc = d = td = 0;
  137.  
  138. var bbcodediario = "\n[size=14][u][b]Ganancias diarias en batallas de " + options.get("playername") + "[/b][/u] [/size]\n\n";
  139.  
  140. for(var i = keys.length-1; i >= 0; i--) {
  141. b = soloN(diario_batallas.getItem(keys[i]));
  142. m = soloN(diario_metal.getItem(keys[i]));
  143. c = soloN(diario_cristal.getItem(keys[i]));
  144. d = soloN(diario_deu.getItem(keys[i]));
  145. muestras ++;
  146. tb += b; tm += m; tc += c; td += d;
  147. content += '<tr>';
  148. content += '<td align="right"><b>' + keys[i] + '<b></td>';
  149. content += '<td align="right">' + N(b) + '</td>';
  150. content += '<td align="right"><p style="color:#9999ff;">' + N(m) + '</p></td>';
  151. content += '<td align="right"><p style="color:#00ff00;">' + N(c) + '</p></td>';
  152. content += '<td align="right"><p style="color:#ff00ff;">' + N(d) + '</p></td>';
  153. content += '<td align="right">' + N(parseInt(m)+parseInt(c)+parseInt(d)) + '</td>';
  154. content += '</tr>';
  155. bbcodediario += keys[i] + ' [' + N(b) + ' batallas] : [color=#9999ff]' + N(m) + '[/color] Metal, [color=#00ff00]' + N(c) + '[/color] Cristal, [color=#ff00ff]' + N(d) + '[/color] Deuterio\n'
  156. }
  157.  
  158.  
  159. content += '<tr><td colspan="6"><br></td></tr><tr><td colspan="6"><br></td></tr><tr><td colspan="6"></td></tr><tr><td colspan="6"></td></tr>';
  160. content += '<tr>';
  161. content += '<td align="right"><b>TOTAL</b></td>';
  162. content += '<td align="right">' + N(tb) + '</td>';
  163. content += '<td align="right"><p style="color:#9999ff;">' + N(tm) + '</p></td>';
  164. content += '<td align="right"><p style="color:#00ff00;">' + N(tc) + '</p></td>';
  165. content += '<td align="right"><p style="color:#ff00ff;">' + N(td) + '</p></td>';
  166. content += '<td align="right">' + N(parseInt(tm)+parseInt(tc)+parseInt(td)) + '</td>';
  167. bbcodediario += '\nTOTAL [' + N(tb) + ' batallas] : [color=#9999ff]' + N(tm) + '[/color] Metal, [color=#00ff00]' + N(tc) + '[/color] Cristal, [color=#ff00ff]' + N(td) + '[/color] Deuterio\n'
  168. content += '</tr><tr>';
  169. content += '<td align="right"><b>MEDIA-DIA</b></td>';
  170. content += '<td align="right">' + N(Math.floor(tb/muestras)) + '</td>';
  171. content += '<td align="right"><p style="color:#9999ff;">' + N(Math.floor(tm/muestras)) + '</p></td>';
  172. content += '<td align="right"><p style="color:#00ff00;">' + N(Math.floor(tc/muestras)) + '</p></td>';
  173. content += '<td align="right"><p style="color:#ff00ff;">' + N(Math.floor(td/muestras)) + '</p></td>';
  174. content += '<td align="right">' + N(Math.floor((parseInt(tm)+parseInt(tc)+parseInt(td))/muestras)) + '</td>';
  175. bbcodediario += '[size=9]MEDIA-DIA [' + N(Math.floor(tb/muestras)) + ' batallas] : [color=#9999ff]' + N(Math.floor(tm/muestras)) + '[/color] Metal, [color=#00ff00]' + N(Math.floor(tc/muestras)) + '[/color] Cristal, [color=#ff00ff]' + N(Math.floor(td/muestras)) + '[/color] Deuterio[/size]\n'
  176. content += '</tr><tr>';
  177. content += '<td align="right"><b>MEDIA-BATALLA</b></td>';
  178. content += '<td align="right">' + N(Math.floor(tb/tb)) + '</td>';
  179. content += '<td align="right"><p style="color:#9999ff;">' + N(Math.floor(tm/tb)) + '</p></td>';
  180. content += '<td align="right"><p style="color:#00ff00;">' + N(Math.floor(tc/tb)) + '</p></td>';
  181. content += '<td align="right"><p style="color:#ff00ff;">' + N(Math.floor(td/tb)) + '</p></td>';
  182. content += '<td align="right">' + N(Math.floor((parseInt(tm)+parseInt(tc)+parseInt(td))/tb)) + '</td>';
  183. bbcodediario += '[size=9]MEDIA-BATALLA : [color=#9999ff]' + N(Math.floor(tm/tb)) + '[/color] Metal, [color=#00ff00]' + N(Math.floor(tc/tb)) + '[/color] Cristal, [color=#ff00ff]' + N(Math.floor(td/tb)) + '[/color] Deuterio[/size]\n'
  184. content += '</tr>'
  185. content += '<tr><td colspan="6"><br></td></tr><tr><td colspan="6"><br></td></tr><tr><td colspan="6"></td></tr><tr><td colspan="6"></td></tr>';
  186. content += '<tr>';
  187. content += '<td align="right"><b>RATIO-DEUTERIO</b></td>';
  188. content += '<td align="right">Media</td>';
  189. content += '<td align="right"><p style="color:#9999ff;">' + redondeo((tm/tb)/(td/tb),2) + '</p></td>';
  190. content += '<td align="right"><p style="color:#00ff00;">' + redondeo((tc/tb)/(td/tb),2) + '</td>';
  191. content += '<td align="right"><p style="color:#ff00ff;">1.00</p></td>';
  192. content += '<td align="right">-</td>';
  193. content += '</tr>';
  194. content += '<tr>';
  195. content += '<td align="right"><b>PROPORCION</b></td>';
  196. content += '<td align="right">Media</td>';
  197. content += '<td align="right"><p style="color:#9999ff;">' + redondeo(tm/(tm + tc + td)*100.0,2) + ' %</p></td>';
  198. content += '<td align="right"><p style="color:#00ff00;">' + redondeo(tc/(tm + tc + td)*100.0,2) + ' %</p></td>';
  199. content += '<td align="right"><p style="color:#ff00ff;">' + redondeo(td/(tm + tc + td)*100.0,2) + ' %</p></td>';
  200. content += '<td align="right">100%</td>';
  201. bbcodediario += '[size=9]PROPORCION : [color=#9999ff]' + redondeo(tm/(tm + tc + td)*100.0,2) + '%[/color] Metal, [color=#00ff00]' + redondeo(tc/(tm + tc + td)*100.0,2) + '%[/color] Cristal, [color=#ff00ff]' + redondeo(td/(tm + tc + td)*100.0,2) + '%[/color] Deuterio[/size]\n'
  202. content += '</tr>';
  203. content += '</table><br><br>';
  204. bbcodediario += '\n[url=http://userscripts.org/scripts/show/75647]Compactador automático de batallas trusreno [1.4][/url]\n'
  205. content += '<center><textarea name="bbcodediario" cols="90" rows="10" onclick="this.focus();this.select()" readonly="readonly">' + bbcodediario + '</textarea></center><br><br>'
  206. content += '<br><center><a id="btn_limpiar1" href="javascript:void(0)">[reset datos]</a></center><br><br><br>';
  207. content += "</div>";
  208.  
  209. // seccion mensual
  210.  
  211.  
  212. content += '<div id="div_mensual" style="background-color:#0A122A"><br>';
  213. content += '<table>';
  214. content += '<tr><td width="120" align="right"><b>MES</b></td><td width="120" align="right"><b>BATALLAS</b></td><td width="120" align="right"><b>METAL</b></td><td width="120" align="right"><b>CRISTAL</b></td><td width="120" align="right"><b>DEUTERIO</b></td><td width="120" align="right"><b>TOTAL</b></td></tr>';
  215.  
  216. var mensual_metal = new HashTable();
  217. mensual_metal.parse(options.get("mensual_metal"));
  218.  
  219. var mensual_cristal = new HashTable();
  220. mensual_cristal.parse(options.get("mensual_cristal"));
  221.  
  222. var mensual_deu = new HashTable();
  223. mensual_deu.parse(options.get("mensual_deu"));
  224.  
  225. var mensual_batallas = new HashTable();
  226. mensual_batallas.parse(options.get("mensual_batallas"));
  227.  
  228. var keys = mensual_metal.keys();
  229.  
  230. var b, m, c, d;
  231. var tb, tm, tc, td;
  232. var muestras = 0;
  233.  
  234. b = tb = m = tm = c = tc = d = td = 0;
  235.  
  236. var bbcodemensual = "\n[size=14][u][b]Ganancias mensuales en batallas de " + options.get("playername") + "[/b][/u] [/size]\n\n";;
  237.  
  238. for(var i = keys.length-1; i >= 0; i--) {
  239. b = soloN(mensual_batallas.getItem(keys[i]));
  240. m = soloN(mensual_metal.getItem(keys[i]));
  241. c = soloN(mensual_cristal.getItem(keys[i]));
  242. d = soloN(mensual_deu.getItem(keys[i]));
  243. muestras ++;
  244. tb += b; tm += m; tc += c; td += d;
  245. content += '<tr>';
  246. content += '<td align="right"><b>' + keys[i] + '<b></td>';
  247. content += '<td align="right">' + N(b) + '</td>';
  248. content += '<td align="right"><p style="color:#9999ff;">' + N(m) + '</p></td>';
  249. content += '<td align="right"><p style="color:#00ff00;">' + N(c) + '</p></td>';
  250. content += '<td align="right"><p style="color:#ff00ff;">' + N(d) + '</p></td>';
  251. content += '<td align="right">' + N(parseInt(m)+parseInt(c)+parseInt(d)) + '</td>';
  252. content += '</tr>';
  253. bbcodemensual += keys[i] + ' [' + N(b) + ' batallas] : [color=#9999ff]' + N(m) + '[/color] Metal, [color=#00ff00]' + N(c) + '[/color] Cristal, [color=#ff00ff]' + N(d) + '[/color] Deuterio\n'
  254. }
  255.  
  256. content += '<tr><td colspan="6"><br></td></tr><tr><td colspan="6"><br></td></tr><tr><td colspan="6"></td></tr><tr><td colspan="6"></td></tr>';
  257. content += '<tr>';
  258. content += '<td align="right"><b>TOTAL</b></td>';
  259. content += '<td align="right">' + N(tb) + '</td>';
  260. content += '<td align="right"><p style="color:#9999ff;">' + N(tm) + '</p></td>';
  261. content += '<td align="right"><p style="color:#00ff00;">' + N(tc) + '</p></td>';
  262. content += '<td align="right"><p style="color:#ff00ff;">' + N(td) + '</p></td>';
  263. content += '<td align="right">' + N(parseInt(tm)+parseInt(tc)+parseInt(td)) + '</td>';
  264. bbcodemensual += '\nTOTAL [' + N(tb) + ' batallas] : [color=#9999ff]' + N(tm) + '[/color] Metal, [color=#00ff00]' + N(tc) + '[/color] Cristal, [color=#ff00ff]' + N(td) + '[/color] Deuterio\n'
  265. content += '</tr><tr>';
  266. content += '<td align="right"><b>MEDIA-MES</b></td>';
  267. content += '<td align="right">' + N(Math.floor(tb/muestras)) + '</td>';
  268. content += '<td align="right"><p style="color:#9999ff;">' + N(Math.floor(tm/muestras)) + '</p></td>';
  269. content += '<td align="right"><p style="color:#00ff00;">' + N(Math.floor(tc/muestras)) + '</p></td>';
  270. content += '<td align="right"><p style="color:#ff00ff;">' + N(Math.floor(td/muestras)) + '</p></td>';
  271. content += '<td align="right">' + N(Math.floor((parseInt(tm)+parseInt(tc)+parseInt(td))/muestras)) + '</td>';
  272. bbcodemensual += '[size=9]MEDIA-MES [' + N(Math.floor(tb/muestras)) + ' batallas] : [color=#9999ff]' + N(Math.floor(tm/muestras)) + '[/color] Metal, [color=#00ff00]' + N(Math.floor(tc/muestras)) + '[/color] Cristal, [color=#ff00ff]' + N(Math.floor(td/muestras)) + '[/color] Deuterio[/size]\n'
  273. content += '</tr><tr>';
  274. content += '<td align="right"></b>MEDIA-BATALLA</b></td>';
  275. content += '<td align="right">' + N(Math.floor(tb/tb)) + '</td>';
  276. content += '<td align="right"><p style="color:#9999ff;">' + N(Math.floor(tm/tb)) + '</p></td>';
  277. content += '<td align="right"><p style="color:#00ff00;">' + N(Math.floor(tc/tb)) + '</p></td>';
  278. content += '<td align="right"><p style="color:#ff00ff;">' + N(Math.floor(td/tb)) + '</p></td>';
  279. content += '<td align="right">' + N(Math.floor((parseInt(tm)+parseInt(tc)+parseInt(td))/tb)) + '</td>';
  280. bbcodemensual += '[size=9]MEDIA-BATALLA : [color=#9999ff]' + N(Math.floor(tm/tb)) + '[/color] Metal, [color=#00ff00]' + N(Math.floor(tc/tb)) + '[/color] Cristal, [color=#ff00ff]' + N(Math.floor(td/tb)) + '[/color] Deuterio[/size]\n'
  281. content += '</tr>';
  282. content += '<tr><td colspan="6"><br></td></tr><tr><td colspan="6"><br></td></tr><tr><td colspan="6"></td></tr><tr><td colspan="6"></td></tr>';
  283. content += '<tr>';
  284. content += '<td align="right"><b>RATIO-DEUTERIO</b></td>';
  285. content += '<td align="right">Media</td>';
  286. content += '<td align="right"><p style="color:#9999ff;">' + redondeo((tm/tb)/(td/tb),2) + '</p></td>';
  287. content += '<td align="right"><p style="color:#00ff00;">' + redondeo((tc/tb)/(td/tb),2) + '</td>';
  288. content += '<td align="right"><p style="color:#ff00ff;">1.00</p></td>';
  289. content += '<td align="right">-</td>';
  290. content += '</tr>';
  291. content += '<tr>';
  292. content += '<td align="right"><b>PROPORCION</b></td>';
  293. content += '<td align="right">Media</td>';
  294. content += '<td align="right"><p style="color:#9999ff;">' + redondeo(tm/(tm + tc + td)*100.0,2) + ' %</p></td>';
  295. content += '<td align="right"><p style="color:#00ff00;">' + redondeo(tc/(tm + tc + td)*100.0,2) + ' %</p></td>';
  296. content += '<td align="right"><p style="color:#ff00ff;">' + redondeo(td/(tm + tc + td)*100.0,2) + ' %</p></td>';
  297. content += '<td align="right">100%</td>';
  298. bbcodemensual += '[size=9]PROPORCION : [color=#9999ff]' + redondeo(tm/(tm + tc + td)*100.0,2) + '%[/color] Metal, [color=#00ff00]' + redondeo(tc/(tm + tc + td)*100.0,2) + '%[/color] Cristal, [color=#ff00ff]' + redondeo(td/(tm + tc + td)*100.0,2) + '%[/color] Deuterio[/size]\n'
  299. content += '</tr>';
  300. content += '</table><br><br><br>';
  301. bbcodemensual += '\n[url=http://userscripts.org/scripts/show/75647]Compactador automático de batallas trusreno [1.4][/url]\n'
  302. content += '<center><textarea name="bbcodediario" cols="90" rows="10" onclick="this.focus();this.select()" readonly="readonly">' + bbcodemensual + '</textarea></center><br><br>'
  303. content += '<br><center><a id="btn_limpiar2" href="javascript:void(0)">[reset datos]</a></center><br><br>'
  304. content += "</div>";
  305.  
  306.  
  307. // seccion consideraciones
  308.  
  309. content += '<div id="div_consideraciones" style="background-color:#0A122A"><br><br>';
  310.  
  311. content += ' * Para contabilizar la batalla hay que abrir el mensaje de batalla. (no es necesario abrir el reporte detallado)';
  312. content += '<br><br>';
  313. content += ' * Se suma la rentabilidad final, teniendo en cuenta perdidas, robo de recursos y recoleccion completa de escombros.';
  314. content += '<br><br>';
  315. content += ' * No se tiene en cuenta gastos de deuterio ni perdidas/robos de escombros.';
  316. content += '<br><br>';
  317. content += ' * En SAC se suma la rentabilidad total final, sin dividir entre numero miembros (sin reparto).';
  318. content += '<br><br><br>'
  319. content += '</div>';
  320.  
  321.  
  322.  
  323.  
  324. document.getElementById('trusrenocomp_div_container').innerHTML = content;
  325. addEvent(document.getElementById("btn_limpiar1"), "click", function(){limpiar_datos(1)});
  326. addEvent(document.getElementById("btn_limpiar2"), "click", function(){limpiar_datos(2)});
  327. addEvent(document.getElementById("mostrar_sec1").parentNode, "click", function(){mostrarSeccion(1)});
  328. addEvent(document.getElementById("mostrar_sec2").parentNode, "click", function(){mostrarSeccion(2)});
  329. addEvent(document.getElementById("mostrar_sec3").parentNode, "click", function(){mostrarSeccion(3)});
  330. addEvent(document.getElementById("mostrar_sec4").parentNode, "click", function(){mostrarSeccion(4)});
  331. mostrarSeccion(1);
  332.  
  333.  
  334. }
  335. }
  336.  
  337. }
  338.  
  339.  
  340.  
  341. // ==============================================================================================
  342.  
  343.  
  344. function limpiar_datos(tipo) {
  345.  
  346. if (confirm("¿Seguro que deseas borrar la informacion almacenada de las batallas?")) {
  347. switch(tipo) {
  348. case 1:
  349. options.set("diario_timestamp_dia", (new Date()).getTime());
  350. options.set("diario_metal", "");
  351. options.set("diario_cristal", "");
  352. options.set("diario_deu", "");
  353. options.set("diario_batallas", "");
  354. options.set("almacenado_dia", "");
  355. ogMenu.menuButton_click();
  356. ogMenu.menuButton_click();
  357. mostrarSeccion(1);
  358. break;
  359. case 2:
  360. options.set("mensual_timestamp_mes", (new Date()).getTime());
  361. options.set("mensual_metal", "");
  362. options.set("mensual_cristal", "");
  363. options.set("mensual_deu", "");
  364. options.set("mensual_batallas", "");
  365. options.set("almacenado_mes", "");
  366. ogMenu.menuButton_click();
  367. ogMenu.menuButton_click();
  368. mostrarSeccion(2);
  369. break;
  370. }
  371. }
  372. }
  373.  
  374.  
  375.  
  376. function addEvent (el, evt, fxn)
  377. {
  378. if (el.addEventListener)
  379. el.addEventListener (evt, fxn, false);
  380. else if (el.attachEvent)
  381. el.attachEvent ("on" + evt, fxn);
  382. else
  383. el ['on' + evt] = fxn;
  384. }
  385.  
  386.  
  387. function mostrarSeccion(seccion) {
  388. switch(seccion) {
  389. case 1:
  390. document.getElementById("div_diario").style.display = "";
  391. document.getElementById("div_mensual").style.display = "none";
  392. document.getElementById("div_consideraciones").style.display = "none";
  393. document.getElementById("mostrar_sec1").parentNode.style.backgroundColor = "#4C0B5F";
  394. document.getElementById("mostrar_sec2").parentNode.style.backgroundColor = "#240B3B";
  395. document.getElementById("mostrar_sec3").parentNode.style.backgroundColor = "#240B3B";
  396. break;
  397. case 2:
  398. document.getElementById("div_diario").style.display = "none";
  399. document.getElementById("div_mensual").style.display = "";
  400. document.getElementById("div_consideraciones").style.display = "none";
  401. document.getElementById("mostrar_sec1").parentNode.style.backgroundColor = "#240B3B";
  402. document.getElementById("mostrar_sec2").parentNode.style.backgroundColor = "#4C0B5F";
  403. document.getElementById("mostrar_sec3").parentNode.style.backgroundColor = "#240B3B";
  404. break;
  405. case 3:
  406. document.getElementById("div_diario").style.display = "none";
  407. document.getElementById("div_mensual").style.display = "none";
  408. document.getElementById("div_consideraciones").style.display = "";
  409. document.getElementById("mostrar_sec1").parentNode.style.backgroundColor = "#240B3B";
  410. document.getElementById("mostrar_sec2").parentNode.style.backgroundColor = "#240B3B";
  411. document.getElementById("mostrar_sec3").parentNode.style.backgroundColor = "#4C0B5F";
  412. break;
  413. case 4:
  414. ogMenu.menuButton_click();
  415. break;
  416. }
  417.  
  418. }
  419.  
  420.  
  421. // ==============================================================================================
  422. // ==============================================================================================
  423. // ==============================================================================================
  424.  
  425. // http://www.mojavelinux.com/articles/javascript_hashes.html
  426.  
  427. function HashTable(obj)
  428. {
  429. this.length = 0;
  430. this.items = {};
  431. for (var p in obj) {
  432. if (obj.hasOwnProperty(p)) {
  433. this.items[p] = obj[p];
  434. this.length++;
  435. }
  436. }
  437.  
  438. this.setItem = function(key, value)
  439. {
  440. if (this.hasItem(key)) {
  441. this.items[key] = parseInt(this.items[key]) + parseInt(value);
  442. }
  443. else {
  444. this.length++;
  445. this.items[key] = parseInt(value);
  446. }
  447. }
  448.  
  449. this.getItem = function(key) {
  450. return this.hasItem(key) ? this.items[key] : undefined;
  451. }
  452.  
  453. this.hasItem = function(key)
  454. {
  455. return this.items.hasOwnProperty(key);
  456. }
  457.  
  458. this.removeItem = function(key)
  459. {
  460. if (this.hasItem(key)) {
  461. previous = this.items[key];
  462. this.length--;
  463. delete this.items[key];
  464. return previous;
  465. }
  466. else {
  467. return undefined;
  468. }
  469. }
  470.  
  471. this.keys = function()
  472. {
  473. var keys = [];
  474. for (var k in this.items) {
  475. if (this.hasItem(k)) {
  476. keys.push(k);
  477. }
  478. }
  479. return keys;
  480. }
  481.  
  482. this.values = function()
  483. {
  484. var values = [];
  485. for (var k in this.items) {
  486. if (this.hasItem(k)) {
  487. values.push(this.items[k]);
  488. }
  489. }
  490. return values;
  491. }
  492.  
  493. this.each = function(fn) {
  494. for (var k in this.items) {
  495. if (this.hasItem(k)) {
  496. fn(k, this.items[k]);
  497. }
  498. }
  499. }
  500.  
  501. this.clear = function()
  502. {
  503. this.items = {}
  504. this.length = 0;
  505. }
  506.  
  507. this.getString = function()
  508. {
  509. var str = "";
  510. for (var k in this.items) {
  511. if (this.hasItem(k)) {
  512. str += k + "=" + this.items[k] + "#";
  513. }
  514. }
  515. return str;
  516. }
  517.  
  518. this.purgue = function()
  519. {
  520. var nlength = 0;
  521. var nitems = {};
  522. for (var k in this.items) {
  523. if (this.hasItem(k)) {
  524. if(parseInt((new Date()).getTime() - parseInt(this.items[k])) < 777600000) { // 9 dias
  525. nlength++;
  526. nitems[k] = parseInt(this.items[k]);
  527. }
  528. }
  529. }
  530. this.length = nlength;
  531. this.items = nitems;
  532. }
  533.  
  534. this.parse = function(str) {
  535. this.items = {};
  536. this.length = 0;
  537. var pairs = str.split("#");
  538. for (var i = 0, len = pairs.length, keyVal; i < len; ++i) {
  539. keyVal = pairs[i].split("=");
  540. if (keyVal[0]) {
  541. this.items[keyVal[0]] = keyVal[1];
  542. this.length++;
  543. }
  544. }
  545. }
  546. }
  547.  
  548. // ==============================================================================================
  549. // ==============================================================================================
  550. // ==============================================================================================
  551.  
  552.  
  553. function SAC() {
  554. var lstNombres = new Array();
  555. var lstFlotas = new Array();
  556.  
  557. this.length = function() {
  558. return lstNombres.length
  559. }
  560.  
  561. this.getNombre = function(n) {
  562. return lstNombres[n];
  563. }
  564.  
  565. this.getFlotas = function(n) {
  566. var ret = null;
  567. if(isNaN(parseInt(n))) {
  568. for(var i = 0; i < lstNombres.length; i++) {
  569. if(lstNombres[i] == n) ret = lstFlotas[i];
  570. }
  571. }
  572. else {
  573. ret = lstFlotas[n];
  574. }
  575. return ret;
  576. }
  577.  
  578. this.add = function (nombre, idFlota, unidades) {
  579. var insertado = false;
  580. for(var i = 0; i < lstNombres.length; i++) {
  581. if(lstNombres[i] == nombre) {
  582. insertado = true;
  583. if(arguments.length == 3) lstFlotas[i].add(idFlota, unidades);
  584. }
  585. }
  586. if(!insertado) {
  587. var pos = lstNombres.length;
  588. lstNombres[pos] = nombre;
  589. lstFlotas[pos] = new Flota();
  590. if(arguments.length == 3) lstFlotas[pos].add(idFlota, unidades);
  591. }
  592.  
  593. }
  594.  
  595. this.addSupervivientes = function(s) {
  596. for(var i = 0; i < s.length(); i++) {
  597. var nombre = s.getNombre(i);
  598. for(var j = 0; j < lstNombres.length; j++){
  599. if(lstNombres[j] == nombre)
  600. lstFlotas[j].addSupervivientes(s.getFlotas(i));
  601. }
  602.  
  603. }
  604. }
  605.  
  606. this.ordenar = function() {
  607. for(var i = 0; i < lstNombres.length; i++) {
  608. lstFlotas[i].ordenar();
  609. }
  610. }
  611.  
  612.  
  613. this.getCostePerdidas = function(id) {
  614. var ret = [0,0,0, 0]; // metal, cristal, deu, total
  615.  
  616. if(id == -1) {
  617. for(var i = 0; i < lstNombres.length; i++) {
  618. var coste = lstFlotas[i].getCostePerdidas();
  619. ret[0] += coste[0];
  620. ret[1] += coste[1];
  621. ret[2] += coste[2];
  622. ret[3] += coste[3];
  623. }
  624. }
  625. else {
  626. var coste = lstFlotas[id].getCostePerdidas();
  627. ret[0] += coste[0];
  628. ret[1] += coste[1];
  629. ret[2] += coste[2];
  630. ret[3] += coste[3];
  631. }
  632.  
  633.  
  634. return ret;
  635. }
  636.  
  637. }
  638.  
  639.  
  640. // ============================================================
  641. // ============================================================
  642.  
  643. function Flota() {
  644. var idNombre = new Array();
  645. var nombre = new Array();
  646. var unidades = new Array();
  647. var perdidas = new Array();
  648.  
  649. var datosFlota = [
  650. ['P.Carga','Nave pequeña de Carga', 2000,2000,0, 'P.Carga'],
  651. ['Gr.Carga','Nave grande de Carga', 6000,6000,0, 'Gr.Carga'],
  652. ['Cazador L.','Cazador ligero', 3000,1000,0, 'C.Ligero'],
  653. ['Cazador P.','Cazador pesado', 6000,4000,0, 'C.Pesado'],
  654. ['Crucero','Crucero', 20000,7000,2000, 'Crucero'],
  655. ['Nave de batalla','Nave de batalla', 45000,15000,0, 'NB'],
  656. ['Acoraz.','Acorazado', 30000,40000,15000, 'Acorazado'],
  657. ['Bombardero','Bombardero', 50000,25000,15000, 'Bomb.'],
  658. ['Destructor','Destructor', 60000,50000,15000, 'Desct.'],
  659. ['Est.Muerte','Estrella de la muerte', 5000000,4000000,1000000, 'EDLM'],
  660. ['Colonizador','Colonizador', 10000,20000,10000, 'Colono'],
  661. ['Reciclador.','Reciclador', 10000,6000,2000, 'Reci.'],
  662. ['Sonda','Sonda de espionaje', 0,1000,0, 'Sonda'],
  663. ['Satélite S.','Satélite Solar', 0,2000,500, 'Satelite'],
  664. ['Misil', 'Lanzamisiles', 2000,0,0, 'Lanzas'],
  665. ['Láser Peq.','Láser pequeño', 1500,500,0, 'L.Peq.'],
  666. ['Láser Gr.','Lase grande', 6000,2000,0, 'L.Grande'],
  667. ['C.Gauss','Cañón Gauss', 20000,15000,2000, 'Gauss'],
  668. ['C.Iónico','Cañón Iónico', 2000,6000,0, 'Ionico'],
  669. ['C.Plasma','Cañón de Plasma', 50000,50000,30000, 'Plasma'],
  670. ['Cúpula Peq.','Cúpula pequeña', 10000,10000,0, 'CupulaP'],
  671. ['Cúpula Gr.','Cúpula grande', 50000,50000,0, 'CupulaG']];
  672.  
  673.  
  674. this.length = function () {
  675. return idNombre.length;
  676. }
  677.  
  678. this.getId = function(n) {
  679. return idNombre[n];
  680. }
  681.  
  682. this.getNombre = function(n, reducido) {
  683. reducido = reducido || false;
  684. var id = idNombre[n]
  685. var ret = id;
  686. for(var i = 0; i < datosFlota.length; i++) {
  687. if(id == datosFlota[i][0]) {
  688. if(reducido) {
  689. ret = datosFlota[i][5];
  690. } else {
  691. ret = datosFlota[i][1];
  692. }
  693. }
  694. }
  695. return ret;
  696. }
  697.  
  698. this.getUnidades = function(n) {
  699. return unidades[n];
  700. }
  701.  
  702. this.getPerdidas = function(n) {
  703. return perdidas[n];
  704. }
  705.  
  706. this.add = function(id, u) {
  707. var insertado = false;
  708. for(var i = 0; i < idNombre.length; i++) {
  709. if(idNombre[i] == id) {
  710. insertado = true;
  711. unidades[i] += parseInt(u);
  712. perdidas[i] += parseInt(u);
  713. }
  714. }
  715. if(!insertado) {
  716. var pos = idNombre.length;
  717. idNombre[pos] = id;
  718. nombre[pos] = '';
  719. unidades[pos] = parseInt(u);
  720. perdidas[pos] = parseInt(u);
  721. }
  722. }
  723.  
  724. this.addSupervivientes = function(f) {
  725. for(var i = 0; i < f.length(); i++) {
  726. for(var j = 0; j < idNombre.length; j++) {
  727. if(idNombre[j] == f.getId(i)) {
  728. perdidas[j] -= parseInt(f.getUnidades(i));
  729. }
  730. }
  731. }
  732. }
  733.  
  734. this.ordenar = function() {
  735. var n_idNombre = new Array();
  736. var n_nombre = new Array();
  737. var n_unidades = new Array();
  738. var n_perdidas = new Array();
  739.  
  740. var contador = 0;
  741.  
  742. for(var i = 0; i < datosFlota.length; i++) {
  743. for(var j = 0; j<idNombre.length; j++) {
  744. if(idNombre[j] == datosFlota[i][0]) {
  745. n_idNombre[contador] = idNombre[j];
  746. n_nombre[contador] = datosFlota[i][1];
  747. n_unidades[contador] = unidades[j];
  748. n_perdidas[contador] = perdidas[j];
  749. contador++;
  750. }
  751. }
  752. }
  753. idNombre = n_idNombre;
  754. nombre = n_nombre;
  755. unidades = n_unidades;
  756. perdidas = n_perdidas;
  757. }
  758.  
  759.  
  760. this.getCostePerdidas = function() {
  761. var ret = [0,0,0, 0];
  762. for(var i = 0; i < idNombre.length; i++) {
  763. for(var j = 0; j < datosFlota.length; j++) {
  764. if(idNombre[i] == datosFlota[j][0]) {
  765. ret[0] += (perdidas[i] * datosFlota[j][2]);
  766. ret[1] += (perdidas[i] * datosFlota[j][3]);
  767. ret[2] += (perdidas[i] * datosFlota[j][4]);
  768. ret[3] += ((perdidas[i] * datosFlota[j][2]) + (perdidas[i] * datosFlota[j][3]) + (perdidas[i] * datosFlota[j][4]));
  769. }
  770. }
  771. }
  772. return ret;
  773. }
  774.  
  775.  
  776. }
  777.  
  778.  
  779. // ============================================================
  780. // ============================================================
  781.  
  782. var op = function () {
  783. this.set = function(key, value) {
  784. return localStorage.setItem ("trusreno_" + getServer() + "_" + key, value);
  785. }
  786.  
  787. this.get = function(key){
  788. var def = "";
  789. return localStorage.getItem ("trusreno_" + getServer() + "_" + key) || def;
  790. }
  791. }
  792. var options = new op();
  793.  
  794. function getServer() {
  795. var server = location.href;
  796. server = server.replace("http://", "").replace("www.", "");
  797. server = server.substring(0, server.indexOf("."));
  798. return server;
  799. }
  800.  
  801.  
  802. function getElementsByClass(cls) {
  803. var itemsfound = new Array;
  804. var elements = document.getElementsByTagName('*');
  805. for(var i=0;i<elements.length;i++){
  806. if(elements[i].className == cls){
  807. itemsfound.push(elements[i]);
  808. }
  809. }
  810. return itemsfound;
  811. }
  812.  
  813. function getElementsByClass(searchClass,node,tag) {
  814. var classElements = new Array();
  815. if (node == null)
  816. node = document;
  817. if (tag == null)
  818. tag = '*';
  819. var els = node.getElementsByTagName(tag);
  820. var elsLen = els.length;
  821.  
  822. for (var i = 0, j = 0; i < elsLen; i++) {
  823. var sep = els[i].className.split(" ");
  824. var content = false;
  825.  
  826. for(var k = 0; k < sep.length; k++){
  827. if(sep[k] == searchClass)
  828. content = true;
  829. }
  830.  
  831. if (els[i].className == searchClass || content) {
  832. classElements[j] = els[i];
  833. j++;
  834. }
  835. }
  836. return classElements;
  837. }
  838.  
  839. function redondeo(numero, decimales)
  840. {
  841. if(isNaN(numero)) numero = "0";
  842. var flotante = parseFloat(numero);
  843. var resultado = Math.round(flotante*Math.pow(10,decimales))/Math.pow(10,decimales);
  844. return resultado;
  845. }
  846.  
  847. function soloN(value) {
  848. value = Number(value);
  849. if (isNaN(value)) value = 0;
  850. return value;
  851. }
  852.  
  853. function numeroReducido(num) {
  854. num = num.toString();
  855. num = num.replace(/\./g,'')
  856. num = parseInt(num);
  857. var numrec;
  858.  
  859. var procesado = false;
  860.  
  861. numrec = num/1000000000.0;
  862. if(Math.abs(numrec) > 1) {
  863. procesado = true;
  864. if(Math.abs(numrec)>=10) {
  865. num = Math.floor(numrec) + "B";
  866. } else {
  867. num = redondeo(numrec, 2) + "B";
  868. }
  869. }
  870.  
  871. if(!procesado) {
  872. numrec = num/1000000.0;
  873. if(Math.abs(numrec) > 1) {
  874. procesado = true;
  875. if(Math.abs(numrec)>=10) {
  876. num = Math.floor(numrec) + "M";
  877. } else {
  878. num = redondeo(numrec, 2) + "M";
  879. }
  880. }
  881. }
  882.  
  883. if(!procesado) {
  884. numrec = num/1000.0;
  885. if(Math.abs(numrec) > 1) {
  886. procesado = true;
  887. if(Math.abs(numrec)>=10) {
  888. num = Math.floor(numrec) + "K";
  889. } else {
  890. num = redondeo(numrec, 2) + "K";
  891. }
  892. }
  893. }
  894.  
  895. return num;
  896. }
  897.  
  898. function mostrarNumero(num) {
  899. var negativo = false;
  900.  
  901. if(isNaN(num)) num = "0";
  902.  
  903. if(parseInt(num) < 0) {
  904. num = parseInt(num)*-1;
  905. negativo = true;
  906. }
  907.  
  908. var nNmb = String(parseInt(num));
  909. var sRes = "";
  910. for (var j = 0, i = nNmb.length - 1; i >= 0; i--, j++)
  911. sRes = nNmb.charAt(i) + ((j > 0) && (j % 3 == 0)? ".": "") + sRes;
  912.  
  913. if(negativo) sRes = '-' + sRes;
  914.  
  915. return sRes;
  916. }
  917.  
  918. function N(num) {
  919. var ret = new Array();
  920.  
  921. if(typeof num == 'object') {
  922. for(var i = 0; i < num.length; i++) {
  923. ret[i] = mostrarNumero(num[i]);
  924. }
  925. return ret;
  926. }
  927. else {
  928. return mostrarNumero(num);
  929. }
  930. }
  931.  
  932.  
  933. function codificar(patron, tipo, version, noCentrado) {
  934. noCentrado = noCentrado || false;
  935. var marcas = new Array();
  936. var url_script = SCRIPT.url;
  937. var txt_firma = SCRIPT.name + ' [' + SCRIPT.version + ']';
  938.  
  939. if(!noCentrado) {
  940. patron = '{CENTER}' + patron + '{/CENTER}';
  941. }
  942.  
  943.  
  944. var colores = [
  945. [/{COLOR_R1}/gi, '#FFCC66'],
  946. [/{COLOR_R2}/gi, '#9E7625'],
  947. [/{COLOR_R3}/gi, '#FF0000'], //escombros
  948. [/{COLOR_R4}/gi, '#F0EC64'], //rec.robo
  949. [/{COLOR_T1}/gi, '#6699FF'], // titulo 1 ("defensores", "atacantes", "perdidas", y "rentabilidad"
  950. [/{COLOR_A1}/gi, '#00FF40'],
  951. [/{COLOR_A2}/gi, '#00DDDD'],
  952. [/{COLOR_D1}/gi, '#ED7010'],
  953. [/{COLOR_RB}/gi, '#007F22'], // resultado batalla
  954. [/{COLOR_RECI}/gi, '#00CC00'], // atacante reciclando
  955. [/{COLOR_SINRECI}/gi, '#FFFF00'], // atacante sin reciclar
  956. [/{COLOR_RECIDEF}/gi, '#FF6600'], // reciclando defensor
  957. [/{COLOR_D2}/gi, '#00DDDD']];
  958.  
  959.  
  960. if(tipo == "HTML") {
  961.  
  962. marcas = [
  963. [/{B}/gi, '<b>'],
  964. [/{\/B}/gi, '</b>'],
  965. [/{I}/gi, '<i>'],
  966. [/{\/I}/gi, '</i>'],
  967. [/{NL}/gi, '<br>\n'],
  968. [/{CENTER}/gi, '<center>'],
  969. [/{\/CENTER}/gi, '</center>'],
  970. [/{SIZE_PEQ}/gi, '<font style="font-size:8pt;">'],
  971. [/{SIZE_MED}/gi, '<font style="font-size:14pt;">'],
  972. [/{SIZE_GRA}/gi, '<font style="font-size:18pt;">'],
  973. [/{\/SIZE}/gi, '</font>'],
  974. [/{\/COLOR}/gi, '</font>'] ];
  975.  
  976. patron = patron.replace(/{ENLACE_SCRIPT}/gi, '<a href="' + url_script + '">' + txt_firma + '</a>');
  977.  
  978. for(var i = 0; i < colores.length; i++)
  979. patron = patron.replace(colores[i][0],'<font color="' + colores[i][1] + '">');
  980. }
  981.  
  982. if(tipo == "OGame") {
  983.  
  984. marcas = [
  985. [/{B}/gi, '[B]'],
  986. [/{\/B}/gi, '[/B]'],
  987. [/{I}/gi, '[I]'],
  988. [/{\/I}/gi, '[/I]'],
  989. [/{NL}/gi, '\n'],
  990. [/{CENTER}/gi, '[ALIGN=CENTER]'],
  991. [/{\/CENTER}/gi, '[/ALIGN]'],
  992. [/{SIZE_PEQ}/gi, '[SIZE=10]'],
  993. [/{SIZE_MED}/gi, '[SIZE=14]'],
  994. [/{SIZE_GRA}/gi, '[SIZE=18]'],
  995. [/{\/SIZE}/gi, '[/SIZE]'],
  996. [/{\/COLOR}/gi, '[/COLOR]'] ];
  997.  
  998. patron = patron.replace(/{ENLACE_SCRIPT}/gi, '[url="' + url_script + '"]' + txt_firma + '[/URL]');
  999.  
  1000. for(var i = 0; i < colores.length; i++)
  1001. patron = patron.replace(colores[i][0],'[COLOR="' + colores[i][1] + '"]');
  1002. }
  1003.  
  1004.  
  1005. if(tipo == "phpBB") {
  1006.  
  1007. marcas = [
  1008. [/{B}/gi, '[b]'],
  1009. [/{\/B}/gi, '[/b]'],
  1010. [/{I}/gi, '[i]'],
  1011. [/{\/I}/gi, '[/i]'],
  1012. [/{NL}/gi, '\n'],
  1013. [/{CENTER}/gi, '[ALIGN=CENTER]'],
  1014. [/{\/CENTER}/gi, '[/ALIGN]'],
  1015. [/{SIZE_PEQ}/gi, '[size=9]'],
  1016. [/{SIZE_MED}/gi, '[size=14]'],
  1017. [/{SIZE_GRA}/gi, '[size=18]'],
  1018. [/{\/SIZE}/gi, '[/size]'],
  1019. [/{\/COLOR}/gi, '[/color]'] ];
  1020.  
  1021. patron = patron.replace(/{ENLACE_SCRIPT}/gi, '[url=' + url_script + ']' + txt_firma + '[/URL]');
  1022.  
  1023. for(var i = 0; i < colores.length; i++)
  1024. patron = patron.replace(colores[i][0],'[color=' + colores[i][1] + ']');
  1025. }
  1026.  
  1027.  
  1028. if(tipo == "phpBB3") {
  1029.  
  1030. marcas = [
  1031. [/{B}/gi, '[b]'],
  1032. [/{\/B}/gi, '[/b]'],
  1033. [/{I}/gi, '[i]'],
  1034. [/{\/I}/gi, '[/i]'],
  1035. [/{NL}/gi, '\n'],
  1036. [/{CENTER}/gi, '[center]'],
  1037. [/{\/CENTER}/gi, '[/center]'],
  1038. [/{SIZE_PEQ}/gi, '[size=90]'],
  1039. [/{SIZE_MED}/gi, '[size=140]'],
  1040. [/{SIZE_GRA}/gi, '[size=180]'],
  1041. [/{\/SIZE}/gi, '[/size]'],
  1042. [/{\/COLOR}/gi, '[/color]'] ];
  1043.  
  1044. patron = patron.replace(/{ENLACE_SCRIPT}/gi, '[url=' + url_script + ']' + txt_firma + '[/URL]');
  1045.  
  1046. for(var i = 0; i < colores.length; i++)
  1047. patron = patron.replace(colores[i][0],'[color=' + colores[i][1] + ']');
  1048. }
  1049.  
  1050.  
  1051. for(var i = 0; i < marcas.length; i++)
  1052. patron = patron.replace(marcas[i][0],marcas[i][1]);
  1053.  
  1054.  
  1055. return patron;
  1056. }
  1057.  
  1058.  
  1059.  
  1060. // ============================================================
  1061. // ============================================================
  1062.  
  1063.  
  1064. function getLuna() {
  1065. var salida = "";
  1066. var ret = new Array();
  1067.  
  1068. var cresult = document.getElementById('combat_result');
  1069.  
  1070. var str_luna = getElementsByClass('action',cresult)[1].innerHTML.split('<br>');
  1071. if(str_luna.length >= 5) {
  1072. salida = str_luna[3].replace(/(^s*)|(s*$)/g,"");
  1073. }
  1074.  
  1075. if(str_luna.length >= 6) {
  1076. if(str_luna[4].indexOf("lunar") != -1) {
  1077. salida += '{NL}' + str_luna[4].replace(/(^s*)|(s*$)/g,"");
  1078. }
  1079. }
  1080.  
  1081. return salida;
  1082. }
  1083.  
  1084.  
  1085. function getEscombros() {
  1086. var ret = new Array();
  1087. var cresult = document.getElementById('combat_result');
  1088. var str_escombros = getElementsByClass('action',cresult)[1].innerHTML.split('<br>')[2];
  1089. ret[0] = parseInt(str_escombros.split('y')[0].replace(/\D*/g,''));
  1090. ret[1] = parseInt(str_escombros.split('y')[1].replace(/\D*/g,''));
  1091. ret[2] = parseInt(ret[0]) + parseInt(ret[1]);
  1092. return ret;
  1093. }
  1094.  
  1095. function getCaptura() {
  1096. var ret = [0, 0, 0, 0];
  1097.  
  1098. if(getMensajeConclusion().indexOf("atacante") != -1) {
  1099. var cresult = document.getElementById('combat_result');
  1100. var str_captura = getElementsByClass('action',cresult)[0].innerHTML;
  1101. var str_metal = str_captura.substring(str_captura.indexOf('captura'), str_captura.indexOf('Metal'));
  1102. var str_cristal = str_captura.substring(str_captura.indexOf(','), str_captura.indexOf('Cristal'));
  1103. var str_deu = str_captura.substring(str_captura.indexOf('y'), str_captura.indexOf('Deuterio'));
  1104.  
  1105. if(str_metal.length == 0) str_metal = '0';
  1106. if(str_cristal.length == 0) str_cristal = '0';
  1107. if(str_deu.length == 0) str_deu = "0";
  1108.  
  1109. ret[0] = parseInt(str_metal.replace(/\D/g,''));
  1110. ret[1] = parseInt(str_cristal.replace(/\D/g,''));
  1111. ret[2] = parseInt(str_deu.replace(/\D/g,''));
  1112. ret[3] = parseInt(ret[0]) + parseInt(ret[1]) + parseInt(ret[2]);
  1113. }
  1114.  
  1115. return ret;
  1116. }
  1117.  
  1118.  
  1119. function getFecha() {
  1120. var strFecha = getElementsByClass("start")[0].innerHTML;
  1121. strFecha = strFecha.substring(strFecha.indexOf('(')+1, strFecha.indexOf(')'));
  1122. var fecha = strFecha.split(" ")[0];
  1123. var hora = strFecha.split(" ")[1];
  1124. return fecha;
  1125. }
  1126.  
  1127. function getHora() {
  1128. var strFecha = getElementsByClass("start")[0].innerHTML;
  1129. strFecha = strFecha.substring(strFecha.indexOf('(')+1, strFecha.indexOf(')'));
  1130. var fecha = strFecha.split(" ")[0];
  1131. var hora = strFecha.split(" ")[1];
  1132. return hora;
  1133. }
  1134.  
  1135.  
  1136. function getMensajeConclusion() {
  1137. var ret = '';
  1138. var cresult = document.getElementById('combat_result');
  1139. var str = getElementsByClass('action',cresult)[0].innerHTML;
  1140.  
  1141. if(str.indexOf('atacante') != -1)
  1142. ret = '¡El atacante ha ganado la batalla!';
  1143.  
  1144. if(str.indexOf('defensor') != -1)
  1145. ret = '¡El defensor ha ganado la batalla!';
  1146.  
  1147. if(str.indexOf('empate') != -1)
  1148. ret = '¡La batalla ha terminado en empate!';
  1149.  
  1150.  
  1151. return ret;
  1152. }
  1153.  
  1154.  
  1155. function calcularRecicladores(escombros) {
  1156. if(escombros > 0)
  1157. return (parseInt(escombros)/20000)+1;
  1158. else
  1159. return 0;
  1160. }
  1161.  
  1162.  
  1163. function getRondas() {
  1164. var rondas = new Array;
  1165.  
  1166. var item = getElementsByClass("combat_round");
  1167.  
  1168. for(var i = 0; i < item.length; i++) {
  1169. var insertado = false;
  1170. for(var r = 0; r < rondas.length && !insertado; r++) {
  1171. if(item[i].innerHTML == rondas[r].innerHTML) {
  1172. insertado = true;
  1173. }
  1174. }
  1175. if(!insertado) {
  1176. rondas.push(item[i]);
  1177. }
  1178. }
  1179.  
  1180. return (rondas);
  1181. }
  1182.  
  1183.  
  1184. function getCuadrosBBCode(patron, patronCC, titulo) {
  1185.  
  1186. var html = "";
  1187.  
  1188. // cuadros de texto
  1189. html += '<table cellspacing="0" cellpadding="0">';
  1190. html += '<b><font color=#FE9A2E>Titulo:</font></b><br>';
  1191. html += '<tr><td colspan="2"><input type="text" size="80" style="background-color:#1F273C;border: 2px solid #FFFFFF;color:#FFFFFF" onclick="this.focus();this.select()" readonly="readonly" value="' + titulo + '">';
  1192. html += '<br><br>';
  1193. html += '</td><td>'
  1194. html += '<tr><td>'
  1195. // foro ogame
  1196. html += '<b><font color=#FE9A2E>Foro OGame:</font></b><br>';
  1197. html += '<textarea style="background-color:#1F273C;width:200px;height:100px;border: 2px solid #FFFFFF;color:#FFFFFF" onclick="this.focus();this.select()" readonly="readonly">';
  1198. html += codificar(patron, "OGame", SCRIPT.version);
  1199. html += '</textarea><br><br>';
  1200. html += '</td><td>'
  1201. // foro phpBB
  1202. html += '<b><font color=#FE9A2E>Foro phpBB:</font></b><br>';
  1203. html += '<textarea style="background-color:#1F273C;width:200px;height:100px;border: 2px solid #FFFFFF;color:#FFFFFF" onclick="this.focus();this.select()" readonly="readonly">';
  1204. html += codificar(patron, "phpBB", SCRIPT.version);
  1205. html += '</textarea><br><br>';
  1206. html += '</td></tr><tr><td>'
  1207. // foro phpBB3
  1208. html += '<b><font color=#FE9A2E>Foro phpBB 3:</font></b><br>';
  1209. html += '<textarea style="background-color:#1F273C;width:200px;height:100px;border: 2px solid #FFFFFF;color:#FFFFFF" onclick="this.focus();this.select()" readonly="readonly">';
  1210. html += codificar(patron, "phpBB3", SCRIPT.version);
  1211. html += '</textarea><br><br>';
  1212. html += '</td><td>'
  1213. // html
  1214. html += '<b><font color=#FE9A2E>HTML:</font></b><br>';
  1215. html += '<textarea style="background-color:#1F273C;width:200px;height:100px;border: 2px solid #FFFFFF;color:#FFFFFF" onclick="this.focus();this.select()" readonly="readonly">';
  1216. html += codificar(patron, "HTML", SCRIPT.version);
  1217. html += '</textarea><br><br>';
  1218. html += '</td></tr>'
  1219. // bbcode-cc
  1220. html += '<tr><td colspan="2">'
  1221. html += '<b><font color=#FE9A2E>Version reducida (para correo circular):</font></b><br>';
  1222. html += '<textarea style="background-color:#1F273C;width:400px;height:100px;border: 2px solid #FFFFFF;color:#FFFFFF" onclick="this.focus();this.select()" readonly="readonly">';
  1223. html += codificar(patronCC, "phpBB", SCRIPT.version, true);
  1224. html += '</textarea><br><br>';
  1225. html += '</td></tr></table>';
  1226. return html;
  1227.  
  1228. }
  1229.  
  1230. // ============================================================
  1231. // ============================================================
  1232.  
  1233. function getColumnas(tabla){
  1234. return tabla.rows[0].cells.length;
  1235. }
  1236.  
  1237. function getFilas(tabla){
  1238. return tabla.rows.length;
  1239. }
  1240.  
  1241. function getContenido(tabla, fila, col)
  1242. {
  1243. var rowElem = tabla.rows[fila];
  1244. var tdValue = rowElem.cells[col].innerHTML;
  1245. return tdValue;
  1246. }
  1247.  
  1248.  
  1249. // ============================================================
  1250.  
  1251.  
  1252.  
  1253. function getFlotas(numRonda, ataque) {
  1254.  
  1255. var ret = new SAC();
  1256.  
  1257. var cround = getRondas();
  1258. var maxRondas = cround.length-1;
  1259.  
  1260. if(ronda > maxRondas) return 0 // excede el num de rondas
  1261.  
  1262. var idTipoBando = (ataque)? 'round_attacker':'round_defender'; // ronda de ataque o defensa
  1263.  
  1264. var ronda = cround[numRonda];
  1265.  
  1266. var rondaBando = getElementsByClass(idTipoBando, ronda)[0];
  1267. var newBack = getElementsByClass("newBack", rondaBando);
  1268.  
  1269. for(var i = 0; i < newBack.length ; i++ ) {
  1270. var destroyed = getElementsByClass("destroyed", newBack[i])[0];
  1271. if(typeof destroyed != 'undefined') {
  1272. var nombre = destroyed.innerHTML;
  1273. nombre = nombre.replace('El defensor ', '');
  1274. nombre = nombre.replace('ha sido destruido.', '');
  1275. ret.add(nombre);
  1276. }
  1277. else {
  1278.  
  1279. var nombre = getElementsByClass("name", newBack[i])[0].firstChild.textContent;
  1280. var tabla = newBack[i].getElementsByTagName("TABLE")[0];
  1281.  
  1282. nombre = nombre.replace('Atacante ', '');
  1283. nombre = nombre.replace('Defensor ', '');
  1284.  
  1285. for(var j = 1; j < getColumnas(tabla); j++) {
  1286. nave = getContenido(tabla, 0, j);
  1287. cantidad = getContenido(tabla, 1, j).replace(/\./gi, '');
  1288. ret.add(nombre, nave, cantidad);
  1289. }
  1290. }
  1291. }
  1292.  
  1293.  
  1294. return ret;
  1295. }
  1296.  
  1297.  
  1298. // ============================================================
  1299.  
  1300. function compactar() {
  1301.  
  1302. var comp = document.getElementById("compactado");
  1303. if (comp != null ) return 0;
  1304.  
  1305. if( getElementsByClass('combat_round') == null) return 0;
  1306.  
  1307. var patron = '';
  1308. var patronCC = '';
  1309. var compactador = document.createElement('div');
  1310.  
  1311.  
  1312. var rondas = getRondas();
  1313. var numRondas = rondas.length-1;
  1314.  
  1315. // atacantes
  1316. var lstAtaq = getFlotas(0, true);
  1317. var lstAtaq_final = getFlotas(numRondas, true);
  1318. lstAtaq.addSupervivientes(lstAtaq_final);
  1319.  
  1320.  
  1321. // defensores
  1322. var lstDef = getFlotas(0, false);
  1323. var lstDef_final = getFlotas(numRondas, false);
  1324. lstDef.addSupervivientes(lstDef_final);
  1325.  
  1326.  
  1327. lstAtaq.ordenar();
  1328. lstDef.ordenar();
  1329.  
  1330. // *****************************************************************************************************************
  1331. // titulo batalla
  1332.  
  1333. var tituloBatalla = "";
  1334.  
  1335. for(var i = 0; i < lstAtaq.length(); i++){
  1336. if (i != 0) patronMini += ' &amp; ';
  1337. tituloBatalla += lstAtaq.getNombre(i);
  1338. }
  1339.  
  1340. tituloBatalla += ' .vs. ';
  1341.  
  1342. for(var i = 0; i < lstDef.length(); i++){
  1343. if (i != 0) patronMini += ' &amp; ';
  1344. tituloBatalla += lstDef.getNombre(i);
  1345. }
  1346.  
  1347.  
  1348.  
  1349.  
  1350. // *****************************************************************************************************************
  1351. // ***** GENERA PATRON *********************************************************************************************
  1352.  
  1353. var iddefensores = "";
  1354.  
  1355. patron = '';
  1356.  
  1357. if(numRondas < 1) numRondas= 1;
  1358.  
  1359. if(numRondas == 1) {
  1360. patron += '{SIZE_PEQ}La batalla duró 1 ronda el día ' + getFecha() + '{/SIZE}{NL}';
  1361. }
  1362. else {
  1363. patron += '{SIZE_PEQ}La batalla duró ' + numRondas + ' rondas el día ' + getFecha() + '{/SIZE}{NL}';
  1364. }
  1365.  
  1366. patronCC += getFecha() + '{NL}';
  1367.  
  1368.  
  1369. // ATACANTES
  1370. patron += '{COLOR_T1}{B}{SIZE_GRA}Atacantes (' + lstAtaq.length() + '):{/SIZE}{/B}{/COLOR}{NL}';
  1371. patronCC += 'Atacantes (' + lstAtaq.length() + '):{NL}';
  1372.  
  1373. for(var i = 0; i < lstAtaq.length(); i++){
  1374. patron += '{COLOR_A1}{B}{SIZE_MED}'+ lstAtaq.getNombre(i) + '{/SIZE}{/B}{/COLOR}{NL}';
  1375. patronCC += '{COLOR_A1}'+ lstAtaq.getNombre(i) + '{/COLOR}{NL}';
  1376. for(var j = 0; j < lstAtaq.getFlotas(i).length(); j++) {
  1377. var nombre = lstAtaq.getFlotas(i).getNombre(j);
  1378. var unidades = N(lstAtaq.getFlotas(i).getUnidades(j));
  1379. var perdidas = N(lstAtaq.getFlotas(i).getPerdidas(j));
  1380. patron += nombre + " {COLOR_A1}" + unidades + "{/COLOR} {COLOR_A2}perdió " + perdidas + "{/COLOR}{NL}";
  1381. patronCC += lstAtaq.getFlotas(i).getNombre(j, true) + " {B}" + unidades + "{/B} ( -" + perdidas + " ){NL}";
  1382. }
  1383. patron += '{NL}';
  1384.  
  1385. if(lstAtaq.getCostePerdidas(i)[3] != 0) {
  1386. var coste = N(lstAtaq.getCostePerdidas(i));
  1387. patron += 'Pérdidas: {COLOR_R1}' + coste[3] + '{/COLOR}{NL}';
  1388. patron += '( {COLOR_R2}' + coste[0] + '{/COLOR} Metal, {COLOR_R2}' + coste[1] + '{/COLOR} Cristal, {COLOR_R2}' + coste[2] + '{/COLOR} Deuterio ){NL}{NL}';
  1389. patronCC += 'Pérdidas: {COLOR_R1}' + numeroReducido(coste[3]) + '{/COLOR}';
  1390. patronCC += ' ({COLOR_R2}' + numeroReducido(coste[0]) + '{/COLOR} M, {COLOR_R2}' + numeroReducido(coste[1]) + '{/COLOR} C, {COLOR_R2}' + numeroReducido(coste[2]) + '{/COLOR} D ){NL}{NL}';
  1391. }
  1392.  
  1393. }
  1394.  
  1395.  
  1396.  
  1397. // DEFENSOR
  1398. patron += '{COLOR_T1}{B}{SIZE_GRA}Defensores (' + lstDef.length() + '):{/SIZE}{/B}{/COLOR} {NL}';
  1399. patronCC += 'Defensores (' + lstDef.length() + '):{NL}';
  1400.  
  1401. for(var i = 0; i < lstDef.length(); i++){
  1402. patron += '{COLOR_D1}{B}{SIZE_MED}'+ lstDef.getNombre(i) + '{/SIZE}{/B}{/COLOR}{NL}';
  1403. patronCC += '{COLOR_D1}'+ lstDef.getNombre(i) + '{/COLOR}{NL}';
  1404. for(var j = 0; j < lstDef.getFlotas(i).length(); j++) {
  1405. var nombre = lstDef.getFlotas(i).getNombre(j);
  1406. var unidades = N(lstDef.getFlotas(i).getUnidades(j));
  1407. var perdidas = N(lstDef.getFlotas(i).getPerdidas(j));
  1408. patron += nombre + " {COLOR_D1}" + unidades + "{/COLOR} {COLOR_D2}perdió " + perdidas + "{/COLOR}{NL}";
  1409. patronCC += lstDef.getFlotas(i).getNombre(j, true) + " {B}" + unidades + "{/B} ( -" + perdidas + " ){NL}";
  1410. }
  1411.  
  1412. if(lstDef.getFlotas(i).length() == 0) {
  1413. patron += "{I}Sin defensas{/I}{NL}";
  1414. patronCC += "{I}Sin defensas{/I}{NL}";
  1415. }
  1416.  
  1417. patron += '{NL}';
  1418.  
  1419. if(lstDef.getCostePerdidas(i)[3] != 0) {
  1420. var coste = N(lstDef.getCostePerdidas(i));
  1421. patron += 'Pérdidas: {COLOR_R1}' + coste[3] + '{/COLOR}{NL}';
  1422. patron += '( {COLOR_R2}' + coste[0] + '{/COLOR} Metal, {COLOR_R2}' + coste[1] + '{/COLOR} Cristal, {COLOR_R2}' + coste[2] + '{/COLOR} Deuterio ){NL}{NL}';
  1423. patronCC += 'Pérdidas: {COLOR_R1}' + numeroReducido(coste[3]) + '{/COLOR}';
  1424. patronCC += '({COLOR_R2}' + numeroReducido(coste[0]) + '{/COLOR} M, {COLOR_R2}' + numeroReducido(coste[1]) + '{/COLOR} C, {COLOR_R2}' + numeroReducido(coste[2]) + '{/COLOR} D ){NL}{NL}';
  1425. }
  1426. }
  1427.  
  1428. patron += '{SIZE_MED}{COLOR_RB}{B}' + getMensajeConclusion() + '{/B}{/COLOR}{/SIZE}{NL}{NL}';
  1429. patronCC += '{COLOR_RB}{B}' + getMensajeConclusion() + '{/B}{/COLOR}{NL}{NL}';
  1430.  
  1431.  
  1432.  
  1433. // RESUMEN (robos, escombros, perdidas, rentabilidad...)
  1434.  
  1435.  
  1436. var perdidasAtaq = lstAtaq.getCostePerdidas(-1);
  1437. var perdidasDef = lstDef.getCostePerdidas(-1);
  1438. var N_perdidasAtaq = N(perdidasAtaq);
  1439. var N_perdidasDef = N(perdidasDef);
  1440.  
  1441. var perdidasTotales = new Array();
  1442. perdidasTotales[0] = (perdidasAtaq[0] + perdidasDef[0]);
  1443. perdidasTotales[1] = (perdidasAtaq[1] + perdidasDef[1]);
  1444. perdidasTotales[2] = (perdidasAtaq[2] + perdidasDef[2]);
  1445. perdidasTotales[3] = (perdidasAtaq[0] + perdidasDef[0]) + (perdidasAtaq[1] + perdidasDef[1]) + (perdidasAtaq[2] + perdidasDef[2]);
  1446. var N_perdidasTotales = N(perdidasTotales);
  1447.  
  1448.  
  1449. var escombros = getEscombros();
  1450. var N_escombros = N(escombros);
  1451.  
  1452. var captura = getCaptura();
  1453. var N_captura = N(captura);
  1454.  
  1455.  
  1456. // RENTABILIDAD Y PORCENTAJE: ATACANTE CON RECICLAJE
  1457. var renta_ataq_conReci = new Array();
  1458. renta_ataq_conReci[0] = (-1*perdidasAtaq[0])+captura[0]+escombros[0];
  1459. renta_ataq_conReci[1] = (-1*perdidasAtaq[1])+captura[1]+escombros[1];
  1460. renta_ataq_conReci[2] = (-1*perdidasAtaq[2])+captura[2];
  1461. renta_ataq_conReci[3] = (-1*perdidasAtaq[3])+captura[3]+escombros[2];
  1462. var N_renta_ataq_conReci = N(renta_ataq_conReci);
  1463.  
  1464. var p_renta_ataq_conReci = new Array();
  1465. p_renta_ataq_conReci[3] = Math.floor((renta_ataq_conReci[3]/perdidasAtaq[3])*100);
  1466. p_renta_ataq_conReci[0] = Math.floor((renta_ataq_conReci[0]/perdidasAtaq[0])*100);
  1467. p_renta_ataq_conReci[1] = Math.floor((renta_ataq_conReci[1]/perdidasAtaq[1])*100);
  1468. p_renta_ataq_conReci[2] = Math.floor((renta_ataq_conReci[2]/perdidasAtaq[2])*100);
  1469. var p_renta_ataq_conReci = N(p_renta_ataq_conReci);
  1470.  
  1471.  
  1472. // RENTABILIDAD Y PORCENTAJE: ATACANTE SIN RECICLAJE
  1473. var renta_ataq_sinReci = new Array();
  1474. renta_ataq_sinReci[0] = (-1*perdidasAtaq[0])+captura[0];
  1475. renta_ataq_sinReci[1] = (-1*perdidasAtaq[1])+captura[1];
  1476. renta_ataq_sinReci[2] = (-1*perdidasAtaq[2])+captura[2];
  1477. renta_ataq_sinReci[3] = (-1*perdidasAtaq[3])+captura[3];
  1478. var N_renta_ataq_sinReci = N(renta_ataq_sinReci);
  1479.  
  1480. var p_renta_ataq_sinReci = new Array();
  1481. p_renta_ataq_sinReci[3] = Math.floor((renta_ataq_sinReci[3]/perdidasAtaq[3])*100);
  1482. p_renta_ataq_sinReci[0] = Math.floor((renta_ataq_sinReci[0]/perdidasAtaq[0])*100);
  1483. p_renta_ataq_sinReci[1] = Math.floor((renta_ataq_sinReci[1]/perdidasAtaq[1])*100);
  1484. p_renta_ataq_sinReci[2] = Math.floor((renta_ataq_sinReci[2]/perdidasAtaq[2])*100);
  1485. p_renta_ataq_sinReci = N(p_renta_ataq_sinReci);
  1486.  
  1487.  
  1488. // RENTABILIDAD Y PORCENTAJE: DEFENSOR CON RECICLAJE
  1489. var renta_def_conReci = new Array();
  1490. renta_def_conReci[0] = (-1*perdidasDef[0])+escombros[0];
  1491. renta_def_conReci[1] = (-1*perdidasDef[1])+escombros[1];
  1492. renta_def_conReci[2] = (-1*perdidasDef[2]);
  1493. renta_def_conReci[3] = (-1*perdidasDef[3])+escombros[2];
  1494. var N_renta_def_conReci = N(renta_def_conReci);
  1495.  
  1496. var p_renta_def_conReci = new Array();
  1497. p_renta_def_conReci[3] = Math.floor((renta_def_conReci[3]/perdidasDef[3])*100);
  1498. p_renta_def_conReci[0] = Math.floor((renta_def_conReci[0]/perdidasDef[0])*100);
  1499. p_renta_def_conReci[1] = Math.floor((renta_def_conReci[1]/perdidasDef[1])*100);
  1500. p_renta_def_conReci[2] = Math.floor((renta_def_conReci[2]/perdidasDef[2])*100);
  1501. p_renta_def_conReci = N(p_renta_def_conReci);
  1502.  
  1503.  
  1504.  
  1505. patron += '{B}Robo:{/B} {COLOR_R4}{SIZE_MED}' + N_captura[0] + '{/SIZE}{/COLOR} Metal, {COLOR_R4}{SIZE_MED}' + N_captura[1] + '{/SIZE}{/COLOR} Cristal y {COLOR_R4}{SIZE_MED}' + N_captura[2] + '{/SIZE}{/COLOR} Deuterio{NL}';
  1506. patron += '{B}Escombros:{/B} {COLOR_R3}{SIZE_GRA}{B}' + N_escombros[0] + '{/B}{/SIZE}{/COLOR} Metal y {COLOR_R3}{SIZE_GRA}{B}' + N_escombros[1] + '{/B}{/SIZE}{/COLOR} Cristal ( {COLOR_R3}' + N(calcularRecicladores(escombros[2])) + "{/COLOR} recicladores ){NL}";
  1507. patron += '{NL}{NL}';
  1508. patron += '{COLOR_T1}PÉRDIDAS{/COLOR} Atacantes: {COLOR_R1}' + N_perdidasAtaq[3] + '{/COLOR}{NL}';
  1509. patron += '( {COLOR_R2}' + N_perdidasAtaq[0] + "{/COLOR} metal , {COLOR_R2}" + N_perdidasAtaq[1] + "{/COLOR} cristal, {COLOR_R2}" + N_perdidasAtaq[2] + "{/COLOR} deuterio ){NL}{NL}";
  1510. patron += '{COLOR_T1}PÉRDIDAS{/COLOR} Defensores: {COLOR_R1}' + N_perdidasDef[3] + '{/COLOR}{NL}';
  1511. patron += '( {COLOR_R2}' + N_perdidasDef[0] + "{/COLOR} metal , {COLOR_R2}" + N_perdidasDef[1] + "{/COLOR} cristal, {COLOR_R2}" + N_perdidasDef[2] + "{/COLOR} deuterio ){NL}{NL}";
  1512. patron += '{NL}';
  1513.  
  1514. patronCC += '{B}Robo:{/B} {COLOR_R4}' + numeroReducido(N_captura[0]) + '{/COLOR} M, {COLOR_R4}' + numeroReducido(N_captura[1]) + '{/COLOR} C y {COLOR_R4}' + numeroReducido(N_captura[2]) + '{/COLOR} D{NL}';
  1515. patronCC += '{B}Escombros:{/B} {COLOR_R3}{B}' + numeroReducido(N_escombros[0]) + '{/B}{/COLOR} M y {COLOR_R3}{B}' + numeroReducido(N_escombros[1]) + '{/B}{/COLOR} C ( {COLOR_R3}' + N(calcularRecicladores(escombros[2])) + "{/COLOR} recis ){NL}";
  1516. patronCC += '{NL}{NL}';
  1517.  
  1518.  
  1519. if(escombros[2] > 0) {
  1520. patron += '{COLOR_T1}{SIZE_MED}{B}RENTABILIDAD{/B}{/SIZE}{/COLOR} Atacantes {COLOR_RECI}reciclando{/COLOR}: {COLOR_R1}{B}' + N_renta_ataq_conReci[3] + '{/B}{/COLOR} [' + p_renta_ataq_conReci[3] + '%]{NL}';
  1521. patron += 'Metal: {COLOR_R2}' + N_renta_ataq_conReci[0] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_conReci[0] + '%]{/SIZE}{NL}';
  1522. patron += 'Cristal: {COLOR_R2}' + N_renta_ataq_conReci[1] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_conReci[1] + '%]{/SIZE}{NL}';
  1523. patron += 'Deuterio: {COLOR_R2}' + N_renta_ataq_conReci[2] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_conReci[2] + '%]{/SIZE}{NL}';
  1524. patronCC += '{COLOR_T1}{SIZE_MED}{B}RENTA{/B}{/SIZE}{/COLOR} Atacantes reciclando: {COLOR_R1}{B}' + numeroReducido(N_renta_ataq_conReci[3]) + '{/B}{/COLOR} [' + p_renta_ataq_conReci[3] + '%]{NL}';
  1525. patronCC += 'M: {COLOR_R2}' + numeroReducido(N_renta_ataq_conReci[0]) + '{/COLOR}, ';
  1526. patronCC += 'C: {COLOR_R2}' + numeroReducido(N_renta_ataq_conReci[1]) + '{/COLOR}, ';
  1527. patronCC += 'D: {COLOR_R2}' + numeroReducido(N_renta_ataq_conReci[2]) + '{/COLOR}{NL}';
  1528.  
  1529. patron += '{COLOR_T1}{SIZE_MED}{B}RENTABILIDAD{/B}{/SIZE}{/COLOR} Atacantes {COLOR_SINRECI}sin reciclar{/COLOR}: {COLOR_R1}{B}' + N_renta_ataq_sinReci[3] + '{/B}{/COLOR} [' + p_renta_ataq_sinReci[3] + '%]{NL}';
  1530. patron += 'Metal: {COLOR_R2}' + N_renta_ataq_sinReci[0] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_sinReci[0] + '%]{/SIZE}{NL}';
  1531. patron += 'Cristal: {COLOR_R2}' + N_renta_ataq_sinReci[1] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_sinReci[1] + '%]{/SIZE}{NL}';
  1532. patron += 'Deuterio: {COLOR_R2}' + N_renta_ataq_sinReci[2] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_sinReci[2] + '%]{/SIZE}{NL}';
  1533. patronCC += '{COLOR_T1}{SIZE_MED}{B}RENTA{/B}{/SIZE}{/COLOR} Atacantes sin reciclar: {COLOR_R1}{B}' + numeroReducido(N_renta_ataq_sinReci[3]) + '{/B}{/COLOR} [' + p_renta_ataq_sinReci[3] + '%]{NL}';
  1534. patronCC += 'M: {COLOR_R2}' + numeroReducido(N_renta_ataq_sinReci[0]) + '{/COLOR}, ';
  1535. patronCC += 'C: {COLOR_R2}' + numeroReducido(N_renta_ataq_sinReci[1]) + '{/COLOR}, ';
  1536. patronCC += 'D: {COLOR_R2}' + numeroReducido(N_renta_ataq_sinReci[2]) + '{/COLOR}{NL}';
  1537.  
  1538. patron += '{COLOR_T1}{SIZE_MED}{B}RENTABILIDAD{/B}{/SIZE}{/COLOR} Defensores {COLOR_RECIDEF}reciclando{/COLOR}: {COLOR_R1}{B}' + N_renta_def_conReci[3] + '{/B}{/COLOR} [' + p_renta_def_conReci[3] + '%]{NL}';
  1539. patron += 'Metal: {COLOR_R2}' + N_renta_def_conReci[0] + '{/COLOR} {SIZE_PEQ}[' + p_renta_def_conReci[0] + '%]{/SIZE}{NL}';
  1540. patron += 'Cristal: {COLOR_R2}' + N_renta_def_conReci[1] + '{/COLOR} {SIZE_PEQ}[' + p_renta_def_conReci[1] + '%]{/SIZE}{NL}';
  1541. patron += 'Deuterio: {COLOR_R2}' + N_renta_def_conReci[2] + '{/COLOR} {SIZE_PEQ}[' + p_renta_def_conReci[2] + '%]{/SIZE}{NL}';
  1542. patronCC += '{COLOR_T1}{SIZE_MED}{B}RENTA{/B}{/SIZE}{/COLOR} Defensores reciclando: {COLOR_R1}{B}' + numeroReducido(N_renta_def_conReci[3]) + '{/B}{/COLOR} [' + p_renta_def_conReci[3] + '%]{NL}';
  1543. patronCC += 'M: {COLOR_R2}' + numeroReducido(N_renta_def_conReci[0]) + '{/COLOR}, ';
  1544. patronCC += 'C: {COLOR_R2}' + numeroReducido(N_renta_def_conReci[1]) + '{/COLOR}, ';
  1545. patronCC += 'D: {COLOR_R2}' + numeroReducido(N_renta_def_conReci[2]) + '{/COLOR}{NL}';
  1546. }
  1547. else {
  1548. patron += '{COLOR_T1}{B}RENTABILIDAD{/B}{/COLOR} Atacantes {COLOR_R1}' + N_renta_ataq_sinReci[3] + '{/COLOR} [' + p_renta_ataq_sinReci[3] + '%]{NL}';
  1549. patron += 'Metal: {COLOR_R2}' + N_renta_ataq_sinReci[0] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_sinReci[0] + '%]{/SIZE}{NL}';
  1550. patron += 'Cristal: {COLOR_R2}' + N_renta_ataq_sinReci[1] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_sinReci[1] + '%]{/SIZE}{NL}';
  1551. patron += 'Deuterio: {COLOR_R2}' + N_renta_ataq_sinReci[2] + '{/COLOR} {SIZE_PEQ}[' + p_renta_ataq_sinReci[2] + '%]{/SIZE}{NL}';
  1552. patronCC += '{COLOR_T1}{B}RENTA{/B}{/COLOR} Atacantes {COLOR_R1}' + numeroReducido(N_renta_ataq_sinReci[3]) + '{/COLOR} [' + p_renta_ataq_sinReci[3] + '%]{NL}';
  1553. patronCC += 'M: {COLOR_R2}' + numeroReducido(N_renta_ataq_sinReci[0]) + '{/COLOR}, ';
  1554. patronCC += 'C: {COLOR_R2}' + numeroReducido(N_renta_ataq_sinReci[1]) + '{/COLOR}, ';
  1555. patronCC += 'D: {COLOR_R2}' + numeroReducido(N_renta_ataq_sinReci[2]) + '{/COLOR}{NL}';
  1556. }
  1557.  
  1558. // si rentabilidad = infinita, lo cambia por MAX
  1559. patron = patron.replace(/infinity\%/gi, "Máx.");
  1560. patron = patron.replace(/NaN\%/gi, "Máx.");
  1561. patronCC = patronCC.replace(/infinity\%/gi, "Máx.");
  1562. patronCC = patronCC.replace(/NaN\%/gi, "Máx.");
  1563.  
  1564.  
  1565. if(getLuna().length > 4) {
  1566. patron += '{NL}' + getLuna() + '{NL}';
  1567. patronCC += '{NL}' + getLuna() + '{NL}';
  1568. }
  1569.  
  1570.  
  1571. patron += '{NL}{SIZE_MED} Perdidas {COLOR_T1}TOTALES{/COLOR}: {B}{COLOR_R3}' + N(perdidasTotales[3]) + '{/COLOR}{/B}{/SIZE}{NL}';
  1572. patron += '{NL}{SIZE_PEQ}{ENLACE_SCRIPT}{/SIZE}{NL}';
  1573. patronCC += '{NL}Perdidas {COLOR_T1}TOTALES{/COLOR}: {B}{COLOR_R3}' + numeroReducido(N(perdidasTotales[3])) + '{/COLOR}{/B}{NL}';
  1574. patronCC += '{NL}{SIZE_PEQ}{ENLACE_SCRIPT}{/SIZE}{NL}';
  1575.  
  1576.  
  1577. // *****************************************************************************************************************
  1578. // ***** PATRON MINI ***********************************************************************************************
  1579.  
  1580.  
  1581. var patronMini = "{COLOR_T1}{B}Ataque-Granjeo{/B}{/COLOR} [ {COLOR_A1}";
  1582. patronMini += tituloBatalla;
  1583. patronMini += '{/COLOR} ]{NL}{COLOR_T1}{B}Renta atacante: {/B}{/COLOR} {COLOR_R4}' + N_renta_ataq_conReci[0] + '{/COLOR} Metal, {COLOR_R4}' + N_renta_ataq_conReci[1] + '{/COLOR} Cristal, {COLOR_R4}' + N_renta_ataq_conReci[2] + '{/COLOR} Deuterio {NL}';
  1584.  
  1585.  
  1586.  
  1587. // *** perdidas totales para titulo
  1588. var procesado = false;
  1589. var pt = perdidasTotales[3];
  1590.  
  1591.  
  1592. if(!procesado && pt > 1000000000) {
  1593. pt = redondeo(pt/1000000000, 2) + " B";
  1594. procesado = true;
  1595. }
  1596.  
  1597. if(!procesado && pt > 1000000) {
  1598. pt = redondeo(pt/1000000, 2) + " M";
  1599. procesado = true;
  1600. }
  1601.  
  1602. if(!procesado && pt > 1000) {
  1603. pt = redondeo(pt/1000, 2) + " K";
  1604. procesado = true;
  1605. }
  1606.  
  1607. tituloBatalla += "{PT " + pt + " }";
  1608.  
  1609.  
  1610. // *****************************************************************************************************************
  1611. // ***** MOSTRAR ***************************************************************************************************
  1612.  
  1613. var html = '';
  1614.  
  1615. html += '<div style="font-size:14px;font-family:Verdana,sans-serif;"><br>';
  1616. html += '<br><center><table border="0" width="90%" style="">';
  1617. html += '<tr><td colspan="2" height="450" bgcolor="#1F273C" style="border: 2px solid #FFFFFF;"><br><br>'
  1618. html += '<div id="codHTML">' + codificar(patron, 'HTML', SCRIPT.version) + '<br></div>';
  1619. html += '</td></tr>';
  1620. html += '<tr><td><br>' + btndonate + '</td></tr>';
  1621. html += '<tr><td><br><center>';
  1622. html += getCuadrosBBCode(patron, patronCC, tituloBatalla);
  1623. html += '</center></td></tr></table></center><br>'
  1624.  
  1625.  
  1626.  
  1627. // patron mini
  1628. //cabecera
  1629. html += '<div><table border="0" width="100%" style="">';
  1630. html += '<tr><td colspan="2" height="30" bgcolor="#000000" style="border: 2px solid #000000;">';
  1631. html += '<p align="center"><font style="font-size:12pt;" color="#FF6600">';
  1632. html += '<b>COMPACTADO MINIMO</b>';
  1633. html += '</font></p></td></tr></table></div>';
  1634. html += '<br><center><table border="0" width="90%" style="">';
  1635. html += '<tr><td colspan="2" height="100" bgcolor="#1F273C" style="border: 2px solid #FFFFFF;"><br><br>'
  1636. html += '<div id="codHTML">' + codificar(patronMini, 'HTML', SCRIPT.version) + '</div>';
  1637. html += '</td></tr>';
  1638. html += '<tr><td><br><center>';
  1639. html += getCuadrosBBCode(patronMini, patronMini, tituloBatalla);
  1640. html += '</center></td></tr></table></center><br>'
  1641. html += '</div>';
  1642.  
  1643. compactador.innerHTML = html;
  1644. master = getElementsByClass("combatreport")[0];
  1645.  
  1646.  
  1647.  
  1648. if (!(typeof(master) === "undefined")) {
  1649. compactador.innerHTML = compactador.innerHTML + master.innerHTML;
  1650. master.innerHTML = compactador.innerHTML;
  1651. master.id = "compactado";
  1652. }
  1653.  
  1654.  
  1655. // historico ganancias batallas
  1656.  
  1657. var renta = renta_ataq_conReci;
  1658. var playername = options.get("playername");
  1659. for(var i = 0; i < lstDef.length(); i++){
  1660. if(lstDef.getNombre(i).trim() == playername) {
  1661. renta = renta_def_conReci;
  1662. }
  1663. }
  1664.  
  1665. var tests = Array.filter( document.getElementsByClassName('infohead'), function(elem){
  1666. var divganancia = document.getElementById("resumengananciabatalla");
  1667. var htmlganancia = '<table><tr><th scope="row">+GananciasBatallas:</th><td> <font color="#5858FA">' + N(renta[0]) + '</font> metal, <font color="#00ff00">' + N(renta[1]) + '</font> cristal, <font color="#ff00ff">' + N(renta[2]) + '</font> deuterio</td></tr></table>';
  1668. if(divganancia == null) {
  1669. elem.innerHTML += '<div id="resumengananciabatalla">' + htmlganancia + '</div>';
  1670. }
  1671. else {
  1672. divganancia.innerHTML = htmlganancia;
  1673. }
  1674. });
  1675.  
  1676. var id = getFecha() + "*" + getHora() + "*" + lstDef.getNombre(0);
  1677.  
  1678. var almacenado_dia = new HashTable();
  1679. var almacenado_mes = new HashTable();
  1680.  
  1681. almacenado_dia.parse(options.get("almacenado_dia"));
  1682. almacenado_mes.parse(options.get("almacenado_mes"));
  1683.  
  1684.  
  1685. if ( (((new Date()).getTime()) - soloN(options.get("purgue_timestamp_dia"))) > 345600000) {
  1686. options.set("purgue_timestamp_dia", (new Date()).getTime());
  1687. almacenado_dia.purgue();
  1688. options.set("almacenado_dia", almacenado_dia.getString());
  1689. }
  1690.  
  1691. if ( (((new Date()).getTime()) - soloN(options.get("purgue_timestamp_mes"))) > 345600000) {
  1692. options.set("purgue_timestamp_mes", (new Date()).getTime());
  1693. almacenado_mes.purgue();
  1694. options.set("almacenado_mes", almacenado_mes.getString());
  1695. }
  1696.  
  1697. // historico diario
  1698. if(typeof(almacenado_dia.getItem(id)) === "undefined") {
  1699. almacenado_dia.setItem(id, (new Date()).getTime());
  1700. options.set("almacenado_dia", almacenado_dia.getString());
  1701.  
  1702. var diario_timestamp = soloN(options.get("diario_timestamp"));
  1703. if(diario_timestamp <= 0) options.set("diario_timestamp", (new Date()).getTime());
  1704.  
  1705. var diario_metal = new HashTable();
  1706. diario_metal.parse(options.get("diario_metal"));
  1707.  
  1708. var diario_cristal = new HashTable();
  1709. diario_cristal.parse(options.get("diario_cristal"));
  1710.  
  1711. var diario_deu = new HashTable();
  1712. diario_deu.parse(options.get("diario_deu"));
  1713.  
  1714. var diario_batallas = new HashTable();
  1715. diario_batallas.parse(options.get("diario_batallas"));
  1716.  
  1717. var id_dia = (new Date()).getFullYear() + "-" + ((new Date()).getMonth()+1) + "-" + (new Date()).getDate();
  1718.  
  1719. diario_metal.setItem(id_dia, renta[0]);
  1720. diario_cristal.setItem(id_dia, renta[1]);
  1721. diario_deu.setItem(id_dia, renta[2]);
  1722. diario_batallas.setItem(id_dia, 1);
  1723.  
  1724. options.set("diario_metal", diario_metal.getString());
  1725. options.set("diario_cristal", diario_cristal.getString());
  1726. options.set("diario_deu", diario_deu.getString());
  1727. options.set("diario_batallas", diario_batallas.getString());
  1728. }
  1729.  
  1730.  
  1731. // historico mensual
  1732. if(typeof(almacenado_mes.getItem(id)) === "undefined") {
  1733. almacenado_mes.setItem(id, (new Date()).getTime());
  1734. options.set("almacenado_mes", almacenado_mes.getString());
  1735.  
  1736. var mensual_timestamp = soloN(options.get("mensual_timestamp"));
  1737. if(mensual_timestamp <= 0) options.set("mensual_timestamp", (new Date()).getTime());
  1738.  
  1739. var mensual_metal = new HashTable();
  1740. mensual_metal.parse(options.get("mensual_metal"));
  1741.  
  1742. var mensual_cristal = new HashTable();
  1743. mensual_cristal.parse(options.get("mensual_cristal"));
  1744.  
  1745. var mensual_deu = new HashTable();
  1746. mensual_deu.parse(options.get("mensual_deu"));
  1747.  
  1748. var mensual_batallas = new HashTable();
  1749. mensual_batallas.parse(options.get("mensual_batallas"));
  1750.  
  1751. var id_mes = (new Date()).getFullYear() + "-" + ((new Date()).getMonth()+1);
  1752.  
  1753. mensual_metal.setItem(id_mes, renta[0]);
  1754. mensual_cristal.setItem(id_mes, renta[1]);
  1755. mensual_deu.setItem(id_mes, renta[2]);
  1756. mensual_batallas.setItem(id_mes, 1);
  1757.  
  1758. options.set("mensual_metal", mensual_metal.getString());
  1759. options.set("mensual_cristal", mensual_cristal.getString());
  1760. options.set("mensual_deu", mensual_deu.getString());
  1761. options.set("mensual_batallas", mensual_batallas.getString());
  1762.  
  1763. }
  1764.  
  1765. var resphttprequest = document.getElementById("resphttprequest");
  1766. if(resphttprequest != null) resphttprequest.innerHTML = "";
  1767.  
  1768. }
  1769.  
  1770. // ------------
  1771.  
  1772. if (location.href.indexOf('/game/index.php?page=combatreport') != -1 ) {
  1773. compactar();
  1774. } else {
  1775. var ogMenu = new MenuLib();
  1776. ogMenu.menuButton_create();
  1777.  
  1778. function comprobar () {
  1779. var cr = document.getElementsByClassName("round_attacker");
  1780. var shortreport = document.getElementById("shortreport");
  1781.  
  1782.  
  1783. if(shortreport != null) {
  1784. var elements = shortreport.getElementsByTagName("a");
  1785.  
  1786. for(var i = 0; i < elements.length; i++) {
  1787. if(elements[i].href.indexOf("game/index.php?page=combatreport&nID=") != -1) {
  1788. var url = elements[i].href;
  1789. var resphttprequest = document.getElementById("resphttprequest");
  1790. if(cr != null & cr.length <= 0 && resphttprequest == null) {
  1791. gethttprequest(url);
  1792. }
  1793.  
  1794. if(resphttprequest != null && resphttprequest.tag != url) {
  1795. resphttprequest.parentNode.removeChild(resphttprequest);
  1796. gethttprequest(url);
  1797. }
  1798. }
  1799. }
  1800. }
  1801.  
  1802. if (cr != null && cr.length > 0){
  1803. compactar();
  1804. }
  1805.  
  1806. }
  1807. }
  1808.  
  1809.  
  1810. setInterval(comprobar, 500);
  1811.  
  1812. var playername = document.getElementsByName("ogame-player-name")[0].content.trim();
  1813. options.set("playername", playername);
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821. }) ();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement