Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Updated to reflect R67 changes
- //Edited to make changes to TerraForm easier to deal with
- //fixed pph for TF
- //RMagician 22 Dec 2014
- //written by RMagician, 23 Dec 2014
- //Uses bonus % to confirm is Planet Type is Terra Form
- //Note: Will return False Negative if no bonus is taking advantage of max extra research
- //there seems to be some sort of error calling the function
- /*
- function AreWeTerraForm(minr, maxr, textcheck)
- {
- var l = '';
- for (var k = minr+1; k <= maxr; k++) {
- l = k.toString() + '%';
- if (textcheck.match(l)) {
- return true;
- }
- }
- }
- */
- function MaxScis()
- {
- var tds = document.getElementsByTagName("form")[0]
- if(tds)
- {
- var maintable = tds
- var cellHTML = tds.parentNode.innerHTML;
- var lead = cellHTML.indexOf("scientists.<br>You have <b>");
- var posStart = lead + 27;
- var without_resource = cellHTML.substring(posStart, cellHTML.length);
- var posEnd = without_resource.indexOf("</b>");
- var maxScis = without_resource.substring(0, posEnd).replace(/,/g , "");
- var forms = document.getElementsByTagName('input');
- for(var i = 0; i< forms.length; i++)
- {
- if(forms[i].name)
- {
- forms[i].parentNode.innerHTML += ' - <a href="javascript:Empty();Fill(' + forms[i].name + ',' + maxScis + ')">Max</a>';
- }
- }
- }
- }
- MaxScis();
- function SciStatusLink()
- {
- var newElement = '<div id="scidiv" style="display:inline;">( <a href="javascript:ResearchStatus()" id="scilink" onclick="">Scientists Status</a> )</div>'
- var trs = document.getElementsByTagName("div")
- for(var i = 0; i< trs.length; i++)
- {
- if(trs[i].innerHTML.match("2000-2012 - BSG Online Games") && !trs[i].innerHTML.match("can get your scientists"))
- {
- trs[i].innerHTML = newElement + " " + trs[i].innerHTML;
- }
- }
- }
- function ResearchStatus()
- {
- var rLand = fLand();
- var pph = 1;
- pph = (Math.floor(pph * 100) / 100);
- //Doesn't take Oceanic nor Research Station into account
- //var OCEANIC_DISADVANTAGE = 25; //not being used
- var TERRA_MAX_BONUS = 20;
- var TERRA_R_EFFIENCE = 50;
- var TerraF = false;
- //Bonus when maxed
- var POP_BONUS = 20;
- var POWER_BONUS = 50;
- var MILI_BONUS = 30;
- var MONEY_BONUS = 25;
- var FDC_BONUS = 25;
- var RWCE_BONUS = 20;
- //Research Factors
- //Factor * intended bonus * land * land
- var POP_FACTOR = 0.000466;
- var POWER_FACTOR = 0.000124;
- var MILI_FACTOR = 0.0002;
- var MONEY_FACTOR = 0.000436;
- var FDC_FACTOR = 0.00068;
- var RWCE_FACTOR = 0.00051;
- var xBonus = 0; //will be used to store multiplier for TF/Oc
- //using these for loops
- var k = 0;
- var l = 0;
- var tds = document.getElementsByTagName("div");
- for(var j = 0; j< tds.length; j++)
- {
- if(tds[j].innerHTML.match("you can get your scientists to research new technologies to better improve your kingdom")&&!tds[j].innerHTML.match("<div class=\"gameDiv\""))
- {
- var maintable = tds[j];
- var srows = maintable.getElementsByTagName("tr");
- if(srows)
- {
- for(var i = 0; i< srows.length; i++)
- {
- var cellrow = srows[i];
- var cells = cellrow.cells;
- if(cellrow.innerHTML.match("<td colspan=\"6\">"))
- {
- cellrow.innerHTML = '<td colspan="7"><input value="Research" class="button" type="submit"></td>';
- }
- if(cells[1])
- {
- var prequired = 0;
- var leeway = 0;
- var newElement = document.createElement("TD");
- var currentPoints = cells[2].innerHTML.replace(/,/g , "");
- if(cellrow.innerHTML.match("Population Bonus"))
- {
- /* this would be better if it were a function on its own */
- //checking if PT = TF
- if (! (TerraF)) {
- //TerraF = AreWeTerraForm(20,40,cellrow.innerHTML);
- //notice 21 to 40 is pop bonus + TF research bonus
- for (k = POP_BONUS + 1; k <= (POP_BONUS + TERRA_MAX_BONUS); k++) {
- l = k.toString();
- l += "%";
- if (cellrow.innerHTML.match(l)) {
- TerraF = true;
- xBonus = TERRA_MAX_BONUS;
- pph = 1+(TERRA_R_EFFIENCE/100);
- }
- }
- }
- leeway = Math.floor(Math.sqrt((currentPoints) / (POP_FACTOR * (POP_BONUS+xBonus))) - rLand);
- prequired = Math.floor(rLand * rLand * (POP_FACTOR * (POP_BONUS+xBonus)));
- if(cells[2].innerHTML.replace(/,/g , "") < prequired)
- {
- cells[3].style.color = "#FF0000";
- }
- } else if(cellrow.innerHTML.match("Power Bonus")) {
- /* this would be better if it were a function on its own */
- //checking if PT = TF
- if (! (TerraF)) {
- //notice 51 to 70 is power bonus + TF research bonus
- for (k = POWER_BONUS+1; k <= (POWER_BONUS+TERRA_MAX_BONUS); k++) {
- l = k.toString();
- l += "%";
- if (cellrow.innerHTML.match(l)) {
- TerraF = true;
- xBonus = TERRA_MAX_BONUS;
- pph = 1+(TERRA_R_EFFIENCE/100);
- }
- }
- }
- leeway = Math.floor(Math.sqrt((currentPoints) / (POWER_FACTOR * (POWER_BONUS+xBonus))) - rLand);
- prequired = Math.floor(rLand * rLand * (POWER_FACTOR * (POWER_BONUS+xBonus)));
- if(cells[2].innerHTML.replace(/,/g , "") < prequired)
- {
- cells[3].style.color = "#FF0000";
- }
- } else if(cellrow.innerHTML.match("Military Bonus")) {
- /* this would be better if it were a function on its own */
- //checking if PT = TF
- if (! (TerraF)) {
- //notice 51 to 70 is power bonus + TF research bonus
- for (k = MILI_BONUS+1; k <= (MILI_BONUS+TERRA_MAX_BONUS); k++) {
- l = k.toString();
- l += "%";
- if (cellrow.innerHTML.match(l)) {
- TerraF = true;
- xBonus = TERRA_MAX_BONUS;
- pph = 1+(TERRA_R_EFFIENCE/100);
- }
- }
- }
- leeway = Math.floor(Math.sqrt((currentPoints) / (MILI_FACTOR * (MILI_BONUS+xBonus))) - rLand);
- prequired = Math.floor(rLand * rLand * (MILI_FACTOR * (MILI_BONUS+xBonus)));
- if(cells[2].innerHTML.replace(/,/g , "") < prequired)
- {
- cells[3].style.color = "#FF0000";
- }
- } else if(cellrow.innerHTML.match("Money Bonus")) {
- /* this would be better if it were a function on its own */
- //checking if PT = TF
- if (! (TerraF)) {
- //notice 51 to 70 is power bonus + TF research bonus
- for (k = MONEY_BONUS+1; k <= (MONEY_BONUS+TERRA_MAX_BONUS); k++) {
- l = k.toString();
- l += "%";
- if (cellrow.innerHTML.match(l)) {
- TerraF = true;
- xBonus = TERRA_MAX_BONUS;
- pph = 1+(TERRA_R_EFFIENCE/100);
- }
- }
- }
- leeway = Math.floor(Math.sqrt((currentPoints) / (MONEY_FACTOR * (MONEY_BONUS+xBonus))) - rLand);
- prequired = Math.floor(rLand * rLand * (MONEY_FACTOR * (MONEY_BONUS+xBonus)));
- if(cells[2].innerHTML.replace(/,/g , "") < prequired)
- {
- cells[3].style.color = "#FF0000";
- }
- } else if(cellrow.innerHTML.match("Frequency Decryption Center")) {
- /* this would be better if it were a function on its own */
- //checking if PT = TF
- if (! (TerraF)) {
- //notice 51 to 70 is power bonus + TF research bonus
- for (k = FDC_BONUS+1; k <= (FDC_BONUS+TERRA_MAX_BONUS); k++) {
- l = k.toString();
- l += "%";
- if (cellrow.innerHTML.match(l)) {
- TerraF = true;
- xBonus = TERRA_MAX_BONUS;
- pph = 1+(TERRA_R_EFFIENCE/100);
- }
- }
- }
- leeway = Math.floor(Math.sqrt((currentPoints) / (FDC_FACTOR * (FDC_BONUS+xBonus))) - rLand);
- prequired = Math.floor(rLand * rLand * (FDC_FACTOR * (FDC_BONUS+xBonus)));
- if(cells[2].innerHTML.replace(/,/g , "") < prequired)
- {
- cells[3].style.color = "#FF0000";
- }
- } else if(cellrow.innerHTML.match("Reactor Warp Core Efficiency")) {
- /* this would be better if it were a function on its own */
- //checking if PT = TF
- if (! (TerraF)) {
- //notice 51 to 70 is power bonus + TF research bonus
- for (k = RWCE_BONUS+1; k <= (RWCE_BONUS+TERRA_MAX_BONUS); k++) {
- l = k.toString();
- l += "%";
- if (cellrow.innerHTML.match(l)) {
- TerraF = true;
- xBonus = TERRA_MAX_BONUS;
- pph = 1+(TERRA_R_EFFIENCE/100);
- }
- }
- }
- leeway = Math.floor(Math.sqrt((currentPoints) / (RWCE_FACTOR * (RWCE_BONUS+xBonus))) - rLand);
- prequired = Math.floor(rLand * rLand * (RWCE_FACTOR * (RWCE_BONUS+xBonus)));
- if(cells[2].innerHTML.replace(/,/g , "") < prequired)
- {
- cells[3].style.color = "#FF0000";
- }
- }
- else if(cellrow.innerHTML.match("Dragoons") && ! cellrow.innerHTML.match("Laser"))
- {
- prequired = 60000
- }
- else if(cellrow.innerHTML.match("Laser Dragoons"))
- {
- prequired = 72000
- }
- else if(cellrow.innerHTML.match("Fighters"))
- {
- prequired = 150000
- }
- else if(cellrow.innerHTML.match("S.C.O.U.T.E.R."))
- {
- prequired = 15000
- }
- else if(cellrow.innerHTML.match("Vesudian Core"))
- {
- prequired = 500000
- }
- else if(cellrow.innerHTML.match("Fusion Technology"))
- {
- prequired = 30000
- }
- else if(cellrow.innerHTML.match("Energy Core"))
- {
- prequired = 50000
- }
- else if(cellrow.innerHTML.match("Probe"))
- {
- prequired = 92000
- }
- else if(cellrow.innerHTML.match("Longevity"))
- {
- prequired = 100000
- }
- if(prequired>0)
- {
- var scis = cells[1].innerHTML.replace(/,/g , "");
- var points = cells[2].innerHTML.replace(/,/g , "");
- cells[2].innerHTML = currentPoints + ' / ' + CommaFormatted(prequired);
- var hleft = CommaFormatted(Math.ceil((prequired - points) / (scis * pph)));
- if(!hleft)
- {
- hleft = "Infinite";
- }
- if(points >= prequired)
- {
- hleft = "Completed";
- }
- if(leeway > 0)
- {
- hleft = leeway + " Land";
- } else {
- if(hleft!="Infinite" && hleft!="Completed")
- {
- hleft += " Hours";
- }
- }
- newElement.innerHTML = hleft;
- cells[2].parentNode.insertBefore(newElement, cells[3].nextSibling);
- }
- if(cellrow.innerHTML.match("Number of scientists"))
- {
- cells[1].innerHTML = "Number of Scis";
- cells[2].innerHTML = "Points / Required";
- newElement.innerHTML = 'Hours Left/Leeway';
- cells[2].parentNode.insertBefore(newElement, cells[3].nextSibling);
- }
- }
- }
- }
- }
- }
- document.getElementById("scilink").href = "http://www.starkingdoms.com/game/terranova/research/"
- }
- var script2 = document.createElement("script");
- script2.type = "application/javascript";
- script2.innerHTML = ";" + SciStatusLink + ResearchStatus + ";ResearchStatus(); ";
- document.body.appendChild(script2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement