Golosomie

datmod vD

Mar 7th, 2017
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. A GAME Mod by Hitler
  4.  
  5.   javascript:var s=document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='//pastebin.com/raw.php?i=HALDOL';void(0);
  6.  
  7. */
  8.  
  9. 'use strict';
  10. function Mod(){
  11.     $('<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js">').appendTo('body')
  12.     jQuery.fn.outerHTML = function(s) { return s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html(); };
  13.     this.version = 433;
  14.     window.document.title='| A GAME';
  15.     this.initTimer = setInterval(function(){ this.checkInit(); }.bind(this), 20);
  16. }
  17.  
  18. Mod.prototype.checkInit = function(){
  19.     if(typeof(game) != "undefined"){
  20.         if(game.loaded){
  21.             if(game.adventure.stage > 0){console.log(game.adventure.stages - game.adventure.stage + " stages left");}
  22.             clearInterval(this.initTimer);
  23.             this.init();
  24.         }
  25.     }
  26. }
  27.  
  28. Mod.prototype.init = function(){
  29.     console.log("VERSION " + this.version);
  30.     // DISPLAY STUFF
  31.     $('div[name="character"]').show();
  32.     document.getElementById("employment").style['margin-top'] = "0px";
  33.     document.getElementById("employment").style['margin-bottom'] = "150px";
  34.     document.getElementsByName("items_holder")[0].style['margin-bottom'] = "0px";
  35.     $('div[id="upgrades_container"]').hide();  //////--------- remove at prestiging
  36.     $('td[colspan="4"]').hide();
  37.     var css = document.createElement("style");
  38.     css.type = "text/css";
  39.     css.innerHTML = "span[name=attackedSpan] { pointer-events: none; }";
  40.     document.body.appendChild(css);
  41.     // VARS
  42.     this.eff = 1;
  43.     this.GBstate = 7; // 0 = GBwait 1 = GBopen 2=GBlobby 3 = 3=GBrunning
  44.     this.RBstate = 0;  // 2 = RBcd  1 = RBwait 0 = RBgo 3 = lolwas
  45.     this.advarmy = 987654321000;
  46.     this.buystr = "";
  47.     this.ItemString = "";
  48.     this.forcedReward = this.getKeks("forcedReward");
  49.     this.retrying = this.getKeks("#retrying");
  50.     this.forcedWhisper = 2; // where 1 is built and 2 is equally
  51.     this.rewardDiff = 88;
  52.     this.donateMax = Math.pow(10,21)-65537;
  53.     this.donateOpt = 48516519540978990000;
  54.     this.mapstr = "";
  55.     this.newVilDelta = this.getKeks("newVilDelta");
  56.     this.oldmists = game.villages[game.currentVillage].employed.adv_miner[0];
  57.     this.oldGBM = game.villages[game.currentVillage].employed.gb_capturedminion[0];
  58.     this.savedMaps = 0;
  59.     this.startAdv = false;
  60.     this.waitForSave = false;
  61.     this.advStarted = false;
  62.     this.activateCL = false;
  63.     this.removeAttackBoost = false;
  64.     this.attackBoostLife = 0;
  65.     this.saveDiff = game.lastMine - game.lastSave;
  66.     this.mapState = (game.adventure.reward > 0) ? 2 : ((game.adventure.stage > 0) ? 1 : 0);
  67.     // TIMERS
  68.     this.timers = {
  69.         update: false,
  70.         lobby: 0,
  71.         GB: 0,
  72.     };
  73.     // Updater
  74.     this.timers.update = setInterval(function(){ this.update(); }.bind(this), 100);
  75.     // Elements
  76.     this.elements = {
  77.         aboutBox: $('<div style="float:left;width:250px"><h4><div style="display:inline-block;margin-left:3px;vertical-align:top;"></div><div id="mod"></div></h4></div>'),
  78.     };
  79.     $('#gamecontainer').prepend(this.elements.aboutBox);
  80. }
  81.  
  82. Mod.prototype.update = function(){
  83.     if("undefined" === typeof _) return;
  84.     if(game.money != this.oldMoney){
  85.         var newSaveDiff = game.lastMine - game.lastSave;
  86.         if(newSaveDiff < this.saveDiff){
  87.             this.waitForSave = false;
  88.             console.log("saved at "+(new Date()).toGMTString());
  89.         }
  90.         this.saveDiff = newSaveDiff;
  91.         this.oldMoney = game.money;
  92.         this.updateStats();
  93.         this.updateInventory();
  94.         this.updateMap();
  95.         this.updateTitle();
  96.         var addmists = game.villages[game.currentVillage].employed.adv_miner[0] - this.oldmists;
  97.         if((addmists > 0)&&(addmists < 21)){
  98.             clearInterval(this.timers.update);
  99.             location.reload();
  100.         }
  101.         if(game.villages[game.currentVillage].employed.gb_capturedminion[0] > this.oldGBM){
  102.             this.waitForSave = true;
  103.         }
  104.         this.oldGBM = game.villages[game.currentVillage].employed.gb_capturedminion[0];
  105.         this.oldmists = game.villages[game.currentVillage].employed.adv_miner[0];
  106.     }
  107. }
  108.  
  109. Mod.prototype.updateStats = function(){
  110.     var vil = game.villages[game.currentVillage];
  111.     var fact = (Math.pow(1.01,vil.buildings.library)-1)*(vil.setup.happiness/100) + 1;
  112.     var fontstr = "";
  113.     var fontstr2 = "";
  114.     for(var i = 0; i < $('span[name="item_details"]').length; i++){
  115.         if(($('span[name="item_details"]')[i].innerHTML.indexOf("Research Boost")>-1) && ($('span[name="item_details"]')[i].innerHTML.indexOf("activate")==-1)) {
  116.             fact *= 2;
  117.             fontstr = "<font color='#00FF00'>";
  118.             fontstr2 = "</font>";
  119.         }else if(($('span[name="item_details"]')[i].innerHTML.indexOf("Diminishing Research")>-1) && ($('span[name="item_details"]')[i].innerHTML.indexOf("activate")==-1)) {
  120.             fact *= 2;
  121.             fontstr = "<font color='#00FF00'>";
  122.             fontstr2 = "</font>";
  123.         }
  124.     }
  125.     var scnts = (game.scientists+game.scientistsBC)*fact;
  126.     var ropm = game.workerOPMResearch;
  127.     var bossCurrency = Math.floor(game.bossCurrency);
  128.     this.eff = 1000*ropm/(game.scientistTime*scnts);
  129.     var buy = Math.ceil((Math.ceil(scnts*(this.eff/Math.floor(this.eff)-1)) - bossCurrency)/fact);
  130.     var rtime = Math.floor((Math.floor(game.scientistTime * scnts * Math.ceil(this.eff) / 1000) - ropm) * Math.ceil(this.eff) / 60);
  131.     var sas = 1000/(Math.floor(this.eff)*Math.ceil(this.eff)*game.scientistTime*fact);
  132.     var suus = (sas>=0.75) ? "NEVAR!" : Math.ceil(10*buy/(3600*(0.75-sas)))/10+"h";
  133.     /*
  134.     if(((buy<-133.7)||this.hasActive("cheap_labor"))&&(bossCurrency>0)) {
  135.         if(this.hasActive("cheap_labor")){
  136.             this.buystr = "ยง";
  137.             document.getElementById("mod").innerHTML = "<br><br>" + fontstr + "eff: " + Math.round(100000*this.eff)/100000 + "s<br>" + fontstr2 + "<font color='#FF0000'>" + rtime + "min<br>KAUF MIT BC</font><br>"+Math.round(140*sas)+"% / d<br>";
  138.         }else{
  139.             this.activateCL = true;}
  140.     }else{
  141.     */
  142.         this.buystr = "";
  143.         document.getElementById("mod").innerHTML = "<br><br>" + fontstr + "eff: " + Math.round(100000*this.eff)/100000 + "s<br>" + fontstr2 + rtime + "min<br>"+buy+" - "+suus+"<br>"+Math.round(140*sas)+"% / d<br>";
  144.     //}
  145. }
  146. Mod.prototype.updateInventory = function(){
  147.     this.ItemString = "";
  148.     var items_activate = false;
  149.     var items_delete = false;
  150.     var new_actives = {}
  151.     new_actives.diminishing_research = this.hasActive("diminishing_research");
  152.     new_actives.speed_research = this.hasActive("speed_research");
  153.     new_actives.godspear_fragment = this.hasActive("godspear_fragment");
  154.     new_actives.attack_boost = this.hasActive("attack_boost");
  155.     new_actives.ring_of_efficiency = this.hasActive("ring_of_efficiency");
  156.     new_actives.cheap_labor = this.hasActive("cheap_labor");
  157.     new_actives.map = (this.mapState > 0);
  158.     var new_savedMaps = this.savedMaps;
  159.     var dels = 0;
  160.     if($('[type="tab"]:visible').length){
  161.     if((this.removeAttackBoost && !this.hasActive("attack_boost"))||(this.getLife("attack_boost")>this.attackBoostLife)){
  162.         if(this.attackBoostLife<66.6){
  163.             this.attackBoostLife += 600;
  164.         } else {
  165.             this.removeAttackBoost = false;
  166.         }
  167.     }
  168.     var colorItems = $('span[name="item_details"][style*="rgb"]')
  169.     for(var i = 0; i < colorItems.length; i++){
  170.         colorItems[i].style.background = "";
  171.     }
  172.     if(this.activateCL && this.hasActive("cheap_labor")){this.activateCL = false;}
  173.     for(var i = 0; i < game.inventory.length; i++){
  174.         if(game.inventory[i].item == "diminishing_research" && !game.inventory[i].activated){
  175.             if(new_actives.diminishing_research){
  176.                 dels++;
  177.             } else {
  178.                 new_actives.diminishing_research = true;
  179.             }
  180.             items_activate = true;
  181.             $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  182.         } else if(game.inventory[i].item == "speed_research" && !game.inventory[i].activated){
  183.             if(new_actives.speed_research){
  184.                 dels++;
  185.             } else {
  186.                 new_actives.speed_research = true;
  187.             }
  188.             items_activate = true;
  189.             $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  190.         } else if(game.inventory[i].item == "map" && !new_actives.map){
  191.             if(new_savedMaps > 0){
  192.                 new_savedMaps--;
  193.             } else {
  194.                 if((game.villages[game.currentVillage].employedSoldiers.knight >= Math.pow(10,12))&&(game.adventure.reward == 0)&&(game.adventure.stage == 0)){
  195.                     new_actives.map = true;
  196.                     dels++;
  197.                     $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  198.                 }
  199.             }
  200.         } else if(game.inventory[i].item == "cheap_labor" && this.activateCL && !new_actives.cheap_labor){
  201.             new_actives.cheap_labor = true;
  202.             items_activate = true;
  203.             $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  204.         } else if(game.inventory[i].item == "godspear_fragment" && (game.bossScenario.active || (game.adventure.stage > 0)) && !new_actives.godspear_fragment){
  205.             new_actives.godspear_fragment = true;
  206.             items_activate = true;
  207.             $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  208.         } else if(game.inventory[i].item == "double_exp"){
  209.             dels++;
  210.             items_delete = true;
  211.             $('span[name="item_details"]')[i].style.background = "rgb(255, 88, 88)";
  212.         } else if((game.inventory[i].item == "attack_boost") && (Math.pow(this.GBstate-2.5,2)<0.5) && !new_actives.attack_boost){
  213.             new_actives.attack_boost = true;
  214.             items_activate = true;
  215.             $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  216.         } else if((game.inventory[i].item == "attack_boost") && this.removeAttackBoost && game.inventory[i].activated){
  217.             new_actives.attack_boost = false;
  218.             dels++;
  219.             items_delete = true;
  220.             $('span[name="item_details"]')[i].style.background = "rgb(255, 88, 88)";
  221.         }
  222.         if(game.inventory[i].activated){
  223.             $('button[name*="dropitem"]')[i].innerHTML = game.inventory[i].life/1000;
  224.         }
  225.     }
  226.  
  227.     if((game.villages[game.currentVillage].employedSoldiers.knight < Math.pow(10,12))||(game.adventure.reward > 0)||(game.adventure.stage > 0)){
  228.         $('span[class="item"]:contains("territories") button:contains("Activate")').hide();
  229.     }else{
  230.         $('span[class="item"]:contains("territories") button:contains("Activate")').show();
  231.     }
  232.     $('span[class="item"]:contains("time by half") button:contains("Drop")').hide();
  233.     $('span[class="item"]:contains("scientist research") button:contains("Drop")').hide();
  234.     $('span[class="item"]:contains("Doubles all workers") button:contains("Drop")').hide();
  235.     $('span[class="item"]:contains("double the XP") button:contains("Activate")').hide();
  236.     $('span[class="item"]:contains("territories") button:contains("Drop")').hide();
  237.  
  238.     if(game.bossScenario.active || ((this.GBstate > 0) && (this.GBstate < 6))){
  239.     var rest = game.inventory.length-dels;
  240.     if(rest > 26){
  241.         var fall_a = rest +1 - $('span[name="item_details"]:contains("Godspear")').length;
  242.         var fall_b = fall_a + 1 - $('span[name="item_details"]:contains("Attack")').length;
  243.         if((fall_a < 27)||(fall_b < 27)){
  244.             if($('span[name="item_details"]:contains("Godspear")').length){
  245.                 rest += (1-this.hasActive("godspear_fragment"));
  246.             }
  247.             for(var i = 0; i < game.inventory.length; i++){
  248.                 if(game.inventory[i].item == "godspear_fragment" && !game.inventory[i].activated){
  249.                     items_activate = true;
  250.                     $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  251.                     rest--;
  252.                     if(rest < 27){ break; }
  253.                 }
  254.             }
  255.             if(fall_a>26){
  256.                 if($('span[name="item_details"]:contains("Attack")').length){
  257.                     rest += (1-this.hasActive("attack_boost"));
  258.                 }
  259.                 for(var i = 0; i < game.inventory.length; i++){
  260.                     if(game.inventory[i].item == "attack_boost" && !game.inventory[i].activated){
  261.                         items_activate = true;
  262.                         $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  263.                         rest--;
  264.                         if(rest < 27){ break; }
  265.                     }
  266.                 }
  267.             }
  268.         } else {
  269.             for(var i = 0; i < game.inventory.length; i++){
  270.                 if(game.inventory[i].item == "attack_boost"){
  271.                     items_delete = true;
  272.                     $('span[name="item_details"]')[i].style.background = "rgb(255, 88, 88)";
  273.                     rest--;
  274.                 }
  275.             }
  276.             if((fall_b < 28) && ($('span[name="item_details"]:contains("Godspear")').length > 1)){
  277.                 for(var i = 0; i < game.inventory.length; i++){
  278.                     if(game.inventory[i].item == "godspear_fragment" && !game.inventory[i].activated){
  279.                         items_activate = true;
  280.                         $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  281.                     }
  282.                 }
  283.             } else {
  284.                 for(var i = 0; i < game.inventory.length; i++){
  285.                     if(game.inventory[i].item == "godspear_fragment"){
  286.                         items_delete = true;
  287.                         $('span[name="item_details"]')[i].style.background = "rgb(255, 88, 88)";
  288.                         rest--;
  289.                     }
  290.                 }
  291.                 if(rest > 26){
  292.                     if($('span[name="item_details"]:contains("Ring")').length){
  293.                         rest += (1-this.hasActive("ring_of_efficiency"));
  294.                     }
  295.                     for(var i = 0; i < game.inventory.length; i++){
  296.                         if(game.inventory[i].item == "ring_of_efficiency" && !game.inventory[i].activated){
  297.                             items_activate = true;
  298.                             $('span[name="item_details"]')[i].style.background = "rgb(88, 255, 88)";
  299.                             rest--;
  300.                             if(rest < 27){
  301.                                 break;
  302.                             }
  303.                         }
  304.                     }
  305.                 }
  306.             }
  307.         }
  308.     }
  309.     }
  310.     if(items_activate && items_delete){
  311.         this.ItemString = "=";
  312.     } else if(items_activate){
  313.         this.ItemString = "+";
  314.     } else if(items_delete){
  315.         this.ItemString = "-";
  316.     }
  317.     }
  318. }
  319.  
  320.  
  321. Mod.prototype.updateTitle = function(){
  322.     //RB
  323.     var RBstr = '';
  324.     if(game.bossScenario.active){
  325.         RBstr = "R1";
  326.     }else if($('span[name="timer"][style="font-size: 19px; display: inline;"').length){
  327.         RBstr = "R2";
  328.     } else {
  329.         RBstr = "R0";
  330.     }
  331.     var popupHTML = $('div[id="popup"]')[0].innerHTML;
  332.     //GB
  333.     if($('img[name="globalBossImg"]:visible').length){
  334.         this.GBstate = 3;
  335.     } else if ($('img[src="game/img/icons/globalBoss_big.png"]:visible').length){
  336.         this.GBstate = 2;
  337.     } else if (($('span[name="timeRemaining"]').text()==("JOINTHE FIGHT"))&&((this.GBstate==2)||(this.GBstate==0))){
  338.         if(this.GBstate==0){this.timers.lobby = +new Date;}
  339.         this.GBstate = 1;
  340.     } else if (($('span[name="timeRemaining"]').text().indexOf("min")>-1)||($('span[name="timeRemaining"]').text().indexOf("sec")>-1)){
  341.         if((this.GBstate > 0) && this.hasActive("attack_boost") && (this.getLife("attack_boost")<666) && (this.GBstate < 7)){
  342.             this.removeAttackBoost = true;
  343.             this.attackBoostLife = this.getLife("attack_boost");
  344.         }
  345.         this.GBstate = 0;
  346.     } else if ((popupHTML.indexOf("You cannot join the event lobby")>-1)||((this.GBstate>0)&&(this.GBstate<5)&&((+new Date-this.timers.lobby)>60000))){
  347.         this.GBstate = 6;
  348.     }
  349.     var GBstr = '';
  350.     if(this.GBstate==0){
  351.         GBstr = 'G0';
  352.     }else if(this.GBstate==1){
  353.         GBstr = 'G1';
  354.         if((+new Date-this.timers.lobby)>50000){GBstr='G3';}
  355.     }else if(this.GBstate==2){
  356.         GBstr = 'G2';
  357.         if((+new Date-this.timers.lobby)>50000){GBstr='G4';}
  358.     }else if(this.GBstate==3){
  359.         GBstr = 'G5';
  360.     }else if(this.GBstate==6){
  361.         GBstr = 'G6';
  362.     }
  363.     //popup
  364.     var vikings = game.villages[game.currentVillage].employedSoldiers.knight;
  365.     var templars = game.villages[game.currentVillage].employedSoldiers.templar;
  366.     var startAdv = false;
  367.     if($('div[id="popup"]:visible').length==1){
  368.         if(popupHTML.indexOf("ll send to the adventure")>-1){
  369.             startAdv = true;
  370.             if(($('input[id="advArmy-knight"]')[0].value!=this.advarmy)&&(vikings>=Math.pow(10,12))&&((this.forcedReward == 0)||(this.rewardDiff < 12))){
  371.                 $('input[id="advArmy-knight"]')[0].value = this.advarmy;
  372.             }
  373.             if(this.forcedReward > 0){
  374.                 if(this.rewardDiff < 12){
  375.                     $('p[name="title"]')[0].innerHTML = ("<font color='#00BB00'>" + this.rewardDiff + "</font>");
  376.                     $('button:contains("Continue")').show();
  377.                 } else {
  378.                     $('p[name="title"]')[0].innerHTML = this.rewardDiff;
  379.                     $('button:contains("Continue")').hide();
  380.                 }
  381.             }          
  382.         } else if(popupHTML.indexOf("A whisper is heard: ")>-1){
  383.             if ((this.forcedWhisper == 2)&&($('div[name="content"]')[0].innerHTML.slice(20,666).indexOf("equally helped")<0)){
  384.                 clearInterval(this.timers.update);
  385.                 location.reload();
  386.             } else if ((this.forcedWhisper == 1)&&($('div[name="content"]')[0].innerHTML.slice(20,666).indexOf("built")<0)){
  387.                 clearInterval(this.timers.update);
  388.                 location.reload();
  389.             }
  390.         } else if(popupHTML.indexOf("Do you want to offer some of your")>-1){
  391.             if(this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))){
  392.                 $('button:contains("No")').hide();
  393.                 $('button:contains("Yes")').hide();
  394.             } else {
  395.                 $('button:contains("No")').show();
  396.                 $('button:contains("Yes")').show();
  397.             }
  398.         } else if(popupHTML.indexOf("How much will you offer")>-1){
  399.             this.forcedWhisper = (game.money < (this.donateMax + this.donateOpt)) ? 2 : 1;
  400.             var donation = game.money.toLocaleString().replace(/\./g,"");//(this.forcedWhisper > 1) ? this.donateMax : this.donateOpt;
  401.             if(!this.waitForSave &&((this.GBstate < 2) || (this.GBstate > 5))){
  402.                 if($('input[id="adventureOffer"]')[0].value!=donation){
  403.                     $('input[id="adventureOffer"]')[0].value = donation;
  404.                 }
  405.             }
  406.         } else if(popupHTML.indexOf("What will you offer")>-1){
  407.             if(!this.waitForSave &&((this.GBstate < 2) || (this.GBstate > 5))){
  408.                 if($('input[id="advArmy-templar"]')[0].value!=game.villages[game.currentVillage].employedSoldiers.templar.toLocaleString().replace(/\./g,"")){
  409.                     $('input[id="advArmy-templar"]')[0].value = game.villages[game.currentVillage].employedSoldiers.templar.toLocaleString().replace(/\./g,"");
  410.                 }
  411.             }
  412.         }
  413.     }
  414.     if(this.startAdv && !startAdv){
  415.         this.advStarted = true;
  416.     }
  417.     this.startAdv = startAdv;
  418.     if((templars == 0)||(vikings < Math.pow(10,12))){this.buystr = "$"+this.buystr;}
  419.     if(this.retrying){
  420.         window.document.title = '~~' + (game.adventure.stages-game.adventure.stage) + '| A GAME';
  421.     } else if(((popupHTML.indexOf("to offer some")>-1)||(popupHTML.indexOf("send to the")>-1)||(popupHTML.indexOf("will you offer")>-1))&&(this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6)))){
  422.         window.document.title = (this.ItemString + "|" + GBstr + this.mapstr + '| A GAME');
  423.     } else {
  424.         window.document.title = (this.buystr + this.ItemString + "|" + GBstr + RBstr + this.mapstr + '| A GAME');
  425.     }
  426. }
  427.  
  428. Mod.prototype.updateMap = function(){
  429.     this.mapstr = '';
  430.     if(game.adventure.stage > 0){
  431.         this.rewardDiff = Math.floor((((game.lastMine-game.lastSave)/1000)+2+20*((game.adventure.stages-1) % 3))%60);
  432.     }
  433.     if((game.adventure.stage > 1)||((game.adventure.stage == 1)&&this.advStarted)) {
  434.         this.mapState = 1;
  435.         this.mapstr = 'M1';
  436.     } else if(game.adventure.stage == 1){
  437.         this.mapstr = ((this.rewardDiff < 12)||!this.startAdv) ? 'M0' : 'Mx';
  438.     } else {
  439.         if(this.mapState == 1){
  440.             this.advStarted = false;
  441.             if(game.adventure.reward == 3){
  442.                
  443.                 this.waitForSave = true;
  444.                 this.retrying = 0;
  445.                 this.setKeks("#retrying",0);
  446.             } else if(this.forcedReward > 0){
  447.                 var resultTotal = this.getKeks("result"+this.newVilDelta+"d#")
  448.                 this.setKeks("result"+this.newVilDelta+"d#",resultTotal+1);
  449.             this.setKeks("result"+this.newVilDelta+"d"+game.adventure.reward,this.getKeks("result"+this.newVilDelta+"d"+game.adventure.reward)+1);  
  450.                 if(resultTotal >= 9001){   
  451.                     this.setKeks("forcedReward",1)
  452.                     this.forcedReward = 1;
  453.                 }
  454.                 if((game.adventure.reward != this.forcedReward)&&(game.adventure.army.knight > 0)){
  455.                     this.setKeks("#retrying",1);
  456.                     clearInterval(this.timers.update);
  457.                     location.reload();
  458.                 } else {
  459.                     if(this.forcedReward != 3){
  460.                         this.setKeks("newVilDelta",this.getKeks("newVilDelta")+1)
  461.                         this.newVilDelta++;
  462.                     }
  463.                     this.waitForSave = true;
  464.                     this.retrying = 0;
  465.                     this.setKeks("#retrying",0);
  466.                 }
  467.             }
  468.         }
  469.        
  470.         if(game.adventure.reward > 0){
  471.             this.mapState = 2
  472.             if(game.adventure.reward == 5) {
  473.                 this.mapstr = (this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))) ? 'Mw' : 'MV';
  474.             } else if(game.adventure.reward > 2){
  475.                 this.mapstr = (this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))) ? 'Mw' : 'M#';
  476.             } else {
  477.                 this.mapstr = (this.waitForSave || ((this.GBstate > 1) && (this.GBstate < 6))) ? 'Mw' : 'MS';
  478.             }
  479.         } else {
  480.             this.mapState = 0;
  481.             var maps = 0;
  482.             for(var i = 0; i < game.inventory.length; i++){
  483.                 if(game.inventory[i].item == "map"){
  484.                     maps++;
  485.                 }
  486.             }
  487.             this.mapstr = ((game.villages[game.currentVillage].employedSoldiers.knight > Math.pow(10,12)) && (maps > this.savedMaps)) ? 'M0' : 'Mx';
  488.         }
  489.     }
  490. }
  491. Mod.prototype.setReward = function(reward){
  492.     this.setKeks("forcedReward",reward)
  493.     this.forcedReward = reward;
  494. }
  495. Mod.prototype.hasActive = function(item){
  496.     for(var i = 0; i<game.inventory.length; i++){
  497.         if(game.inventory[i].item == item && game.inventory[i].activated){
  498.             return true;
  499.         }
  500.     }
  501.     return false;
  502. }
  503. Mod.prototype.getLife = function(item){
  504.     if(!this.hasActive(item)){return 0;}
  505.     for(var i = 0; i<game.inventory.length; i++){
  506.         if((game.inventory[i].item == item) && game.inventory[i].activated){
  507.             return (game.inventory[i].life / 1000);
  508.         }
  509.     }
  510.     return false;
  511. }
  512. Mod.prototype.terminate = function(){
  513.         _.each(this.elements, function(element){
  514.                 if(_.isArray(element)){
  515.                         _.each(element, function(el){ el.remove(); });
  516.                 }else{
  517.                         element.remove();
  518.                 }
  519.         });
  520.         clearInterval(this.timers.update);
  521.         window.m = undefined;
  522. }
  523. Mod.prototype.getKeks = function(name){
  524.     var parts = document.cookie.split(name + "=");
  525.     if(parts.length == 2){
  526.         return parseInt(parts.pop().split(";").shift());
  527.     }
  528.     return 0;
  529. }
  530. Mod.prototype.setKeks = function(Bezeichner,Wert){
  531.     var expire = (new Date(Math.pow(13,11))).toGMTString();
  532.     document.cookie=Bezeichner+"="+Wert+";expires="+expire+";";
  533. }
  534. // Start
  535. if(window.m) window.m.terminate();
  536. window.m = new Mod();
Add Comment
Please, Sign In to add comment