joecot

CivHelper

Nov 4th, 2013
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.21 KB | None | 0 0
  1. if(typeof CHBuildingIncSize !='undefined'){
  2. alert("CivHelper already loaded. Reload page to reload");
  3. }
  4. else{
  5. var CHBuildingIncSize = 1000;
  6. var CHJobIncSize = 100;
  7. CHLoad();
  8. }
  9. function CHLoad(){
  10.  
  11.  
  12. /*$('#buildingsPane > h3').after('<p>Size of CivHelper incrementer <input size=5 type="test" id="CHBuildingIncSize" value="'+CHBuildingIncSize+'"/><input type="button" id="CHBuildingIncSubmit" value="Update"/></p>');
  13. $('#buildings .x1000').each(function(){
  14. var onclickval = $(this).attr('onclick');
  15. var item = onclickval.split('(')[1].split(',')[0];
  16. $(this).html('xCH');
  17. $(this).attr('onclick','CHcreateBuilding('+item+');');
  18. //$(this).after('<button class="x1000" onClick="CHcreateBuilding('+item+')">CH</button>');
  19. });
  20. $('#CHBuildingIncSubmit').click(CHupdateBuildingSize);
  21. $("#CHBuildingIncSize").keyup(function(event){
  22. if(event.keyCode == 13){
  23. CHupdateBuildingSize();
  24. }
  25. });
  26.  
  27. // $("#population > h3 :contains('Jobs')").after('<p>Size of CivHelper incrementer <input size=5 type="test" id="CHJobIncSize" value="'+CHJobIncSize+'"/><input type="button" id="CHJobIncSubmit" value="Update"/></p>');
  28. $("#jobs").before('<p>Size of CivHelper incrementer <input size=5 type="test" id="CHJobIncSize" value="'+CHJobIncSize+'"/><input type="button" id="CHJobIncSubmit" value="Update"/></p>');
  29. $('#jobs .job100 button').each(function(){
  30. var onclickval = $(this).attr('onclick');
  31. if(!onclickval) return;
  32. var itemtype = onclickval.split('(')[0];
  33. //var item = onclickval.split('(')[1].split(',')[0].replace("'","",'g');
  34. var item = onclickval.split('(')[1].split(',')[0];
  35. if(itemtype=='fire'){
  36. $(this).html('-CH');
  37. $(this).attr('onclick','CHfireJob('+item+');');
  38. //$(this).before('<button onClick="CHfireJob('+item+')">-CH</button>');
  39. }
  40. else{
  41. $(this).html('+CH');
  42. $(this).attr('onclick','CHhireJob('+item+');');
  43. //$(this).after('<button onClick="CHhireJob('+item+')">+CH</button>');
  44. }
  45. });
  46. $('#CHJobIncSubmit').click(CHupdateJobSize);
  47. $("#CHJobIncSize").keyup(function(event){
  48. if(event.keyCode == 13){
  49. CHupdateJobSize();
  50. }
  51. });*/
  52.  
  53. var Empire = $('#raidEmpire');
  54. Empire.after('<p>This is getting ridiculous. Continue at your own peril.</p><button id="CHraidPlanet" onClick="CHinvade(\'planet\')" disabled>Raid Planet</button>');
  55. $('#CHraidPlanet').after('<br/><button id="CHraidSystem" onClick="CHinvade(\'system\')" disabled>Raid Solar System</button>');
  56. $('#CHraidSystem').after('<br/><button id="CHraidSector" onClick="CHinvade(\'sector\')" disabled>Raid Planetary Sector</button>');
  57. $('#CHraidSector').after('<br/><button id="CHraidSSector" onClick="CHinvade(\'ssector\')" disabled>Raid Star Sector</button>');
  58. $('#CHraidSSector').after('<br/><button id="CHraidQuadrant" onClick="CHinvade(\'quadrant\')" disabled>Raid Galactic Quadrant</button>');
  59. $('#CHraidQuadrant').after('<br/><button id="CHraidGalaxy" onClick="CHinvade(\'galaxy\')" disabled>Raid Entire Galaxy!</button>');
  60. //alert(Empire.prop('disabled'));
  61. if(!Empire.prop('disabled')){
  62. $('#CHraidPlanet').removeAttr('disabled');
  63. $('#CHraidSystem').removeAttr('disabled');
  64. $('#CHraidSector').removeAttr('disabled');
  65. $('#CHraidSSector').removeAttr('disabled');
  66. $('#CHraidQuadrant').removeAttr('disabled');
  67. $('#CHraidGalaxy').removeAttr('disabled');
  68. }
  69. Empire.click(function(){
  70. if(!$(this).prop('disabled')){
  71. $('#CHraidPlanet').removeAttr('disabled');
  72. $('#CHraidSystem').removeAttr('disabled');
  73. $('#CHraidSector').removeAttr('disabled');
  74. $('#CHraidSSector').removeAttr('disabled');
  75. $('#CHraidQuadrant').removeAttr('disabled');
  76. $('#CHraidGalaxy').removeAttr('disabled');
  77. }
  78. });
  79.  
  80.  
  81. }
  82.  
  83. function CHinvade(ecivtype){
  84. //basically rewriting the invade function
  85. //I feel a little dirty doing this
  86. //invades a certain type of civilisation based on the button clicked
  87. var iterations = 0; //used to calculate random number of soldiers
  88. if (ecivtype == "planet"){
  89. raiding.raiding = true;
  90. raiding.last = 'planet';
  91. iterations = 1000000; //fuck it, planets have large armies, OK?
  92. }
  93. if (ecivtype == "system"){
  94. raiding.raiding = true;
  95. raiding.last = 'system';
  96. iterations = 5000000; //systems are even bigger.
  97. }
  98. if (ecivtype == "sector"){
  99. raiding.raiding = true;
  100. raiding.last = 'sector';
  101. iterations = 10000000; //you asked for it
  102. }
  103. if (ecivtype == "ssector"){
  104. raiding.raiding = true;
  105. raiding.last = 'ssector';
  106. iterations = 100000000; //you asked for it
  107. }
  108. if (ecivtype == "quadrant"){
  109. raiding.raiding = true;
  110. raiding.last = 'quadrant';
  111. iterations = 1000000000; //quadrants are way bigger than sectors
  112. }
  113. if (ecivtype == "galaxy"){
  114. raiding.raiding = true;
  115. raiding.last = 'galaxy';
  116. iterations = 4000000000; //galaxies only have 4 quadrants
  117. }
  118.  
  119. if (gloryTimer > 0) iterations = (iterations * 2); //doubles soldiers fought
  120. var esoldierRes = iterations + Math.floor(Math.random() * iterations * 4);
  121. var efortsRes = Math.floor(Math.random() * Math.pow(1.6,Math.log(iterations)));
  122. population.esoldiers += esoldierRes;
  123. population.esoldiersCas += esoldierRes;
  124. population.eforts += efortsRes;
  125. if (gloryTimer > 0) iterations = (iterations * 2); //quadruples rewards (doubled here because doubled already above)
  126. raiding.iterations = iterations;
  127. updateTargets(); //updates largest raid target
  128. updateParty();
  129. document.getElementById('raidGroup').style.display = 'none'; //Hides raid buttons until the raid is finished
  130. }
  131.  
  132. /*function CHupdateBuildingSize(){
  133. var newBuildingIncSize = parseInt($('#CHBuildingIncSize').val());
  134. if(newBuildingIncSize == CHBuildingIncSize) return;
  135. if(isNaN(newBuildingIncSize)){
  136. alert('Try Again');
  137. $('#CHBuildingIncSize').val(CHBuildingIncSize);
  138. }
  139. else{
  140. CHBuildingIncSize = newBuildingIncSize;
  141. }
  142. }
  143. function CHupdateJobSize(){
  144. var newJobIncSize = parseInt($('#CHJobIncSize').val());
  145. if(newJobIncSize == CHJobIncSize) return;
  146. if(isNaN(newJobIncSize)){
  147. alert('Try Again');
  148. $('#CHJobIncSize').val(CHJobIncSize);
  149. }
  150. else{
  151. CHJobIncSize = newJobIncSize;
  152. }
  153. }
  154. function CHcreateBuilding(building){
  155. createBuilding(building,CHBuildingIncSize);
  156. }
  157. function CHfireJob(job){
  158. fire(job,CHJobIncSize);
  159. }
  160. function CHhireJob(job){
  161. hire(job,CHJobIncSize);
  162. }*/
Advertisement
Add Comment
Please, Sign In to add comment