Kittens Game Data output

enter something useful

当前为 2015-06-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Kittens Game Data output
  3. // @namespace https://greasyfork.org/en/scripts/10234-kittens-game-data-output
  4. // @version 0.1.2
  5. // @description enter something useful
  6. // @author Yuriy
  7. // @match http://bloodrizer.ru/games/kittens/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. function initiate_script() {
  12. var data_out = document.createElement('div');
  13. data_out.id = 'data_container';
  14. data_out.style.width = '100%';
  15. data_out.style.height = '150px';
  16. data_out.style.bottom = '0px';
  17. data_out.style.position = 'absolute';
  18. data_out.innerHTML = '<div style="float: left; width: 340px;"><table id="food_table" table-layout: fixed;></table></div><div style="float: left; width: 340px;"> <table id="food_table_season" table-layout: fixed;></table></div>';
  19. document.body.appendChild(data_out);
  20. document.getElementById('data_container').style.display = '';
  21. document.getElementById('game').style.marginBottom = '200px';
  22. document.getElementById('footerLinks').style.marginBottom = '150px';
  23. document.body.style.backgroundPosition = 'center bottom 30px';
  24. }
  25.  
  26. if (!document.getElementById('data_container')) {
  27. initiate_script();
  28. }
  29.  
  30. function calculate_food_data(weather_ratio_val, seconds) {
  31. var total_value = '';
  32. var total = 0;
  33. var subtotal = 0;
  34. total += gamePage.getEffect("catnip" + "PerTickBase")*5
  35. total *= 1+weather_ratio_val;
  36. var resMapProduction = gamePage.village.getResProduction();
  37. subtotal = resMapProduction['catnip']*5 || 0;
  38. subtotal *= (1 + gamePage.workshop.getEffect('catnip' + "Ratio"))
  39. total += subtotal;
  40. total *= (1 + gamePage.bld.getEffect('catnip' + "Ratio"))
  41. total *= (1 + gamePage.space.getEffect('catnip' + "Ratio"))
  42. total *= (1 + gamePage.religion.getEffect('catnip' + "Ratio"))
  43. var paragonRatio = gamePage.resPool.get("paragon").value * 0.01;
  44. paragonRatio = gamePage.bld.getHyperbolicEffect(paragonRatio, 2);
  45. total *= 1+paragonRatio
  46. if (gamePage.religion.getRU("solarRevolution").researched){
  47. total *= 1+(gamePage.religion.getProductionBonus() / 100)
  48. }
  49. var resMapConsumption = gamePage.village.getResConsumption();
  50. var resConsumption = resMapConsumption['catnip'] || 0;
  51. resConsumption = resConsumption * (1 + gamePage.bld.getEffect('catnip' + "DemandRatio", true));
  52. resConsumption *= 5;
  53. total += resConsumption;
  54. total *= seconds;
  55. if(total>1000){
  56. total = total / 1000;
  57. total = total.toFixed(1);
  58. total_value += total;
  59. total_value += ' k';
  60. }else{
  61. total = total.toFixed(2);
  62. total_value += total;
  63. }
  64. return total_value;
  65. }
  66.  
  67. function generate_food_table(seconds, label) {
  68. var contents = '';
  69. //Define the table colomn widths
  70. contents += '<col width="100">';
  71. contents += '<col width="60">';
  72. contents += '<col width="60">';
  73. contents += '<col width="60">';
  74. contents += '<col width="60">';
  75. //The top of the table, describing what it is showing. Leave once cell blank at the start
  76. contents += '<tr>';
  77. contents += '<td style="text-align:center">'
  78. contents += ' '
  79. contents += '</td>';
  80. contents += '<td style="text-align:center" colspan="4">'
  81. contents += label
  82. contents += '</td>';
  83. contents += '</tr>';
  84. //Second level of the top of the table, describing what it is showing. Leave once cell blank at the start
  85. contents += '<tr>';
  86. contents += '<td style="text-align:center">'
  87. contents += ' '
  88. contents += '</td>';
  89. contents += '<td style="text-align:center">'
  90. contents += 'Winter'
  91. contents += '</td> <td style="text-align:center">'
  92. contents += 'Spring'
  93. contents += '</td> <td style="text-align:center">'
  94. contents += 'Summer'
  95. contents += '</td> <td style="text-align:center">'
  96. contents += 'Fall'
  97. contents += '</td>';
  98. contents += '</tr>';
  99. //Data for a good season
  100. contents += '<tr>';
  101. contents += '<td style="text-align:center">'
  102. contents += 'Good season'
  103. contents += '</td>';
  104. contents += '<td style="text-align:center">'
  105. contents += calculate_food_data(-0.60, seconds)
  106. contents += '</td> <td style="text-align:center">'
  107. contents += calculate_food_data(0.65, seconds)
  108. contents += '</td> <td style="text-align:center">'
  109. contents += calculate_food_data(0.15, seconds)
  110. contents += '</td> <td style="text-align:center">'
  111. contents += calculate_food_data(0.15, seconds)
  112. contents += '</td>';
  113. contents += '</tr>';
  114. //Data for an average season
  115. contents += '<tr>';
  116. contents += '<td style="text-align:center">'
  117. contents += 'Normal season'
  118. contents += '</td>';
  119. contents += '<td style="text-align:center">'
  120. contents += calculate_food_data(-0.75, seconds)
  121. contents += '</td> <td style="text-align:center">'
  122. contents += calculate_food_data(0.50, seconds)
  123. contents += '</td> <td style="text-align:center">'
  124. contents += calculate_food_data(0.0, seconds)
  125. contents += '</td> <td style="text-align:center">'
  126. contents += calculate_food_data(0.0, seconds)
  127. contents += '</td>';
  128. contents += '</tr>';
  129. //Data for a bad season
  130. contents += '<tr>';
  131. contents += '<td style="text-align:center">'
  132. contents += 'Bad season'
  133. contents += '</td>';
  134. contents += '<td style="text-align:center">'
  135. contents += calculate_food_data(-0.90, seconds)
  136. contents += '</td> <td style="text-align:center">'
  137. contents += calculate_food_data(0.35, seconds)
  138. contents += '</td> <td style="text-align:center">'
  139. contents += calculate_food_data(-0.15, seconds)
  140. contents += '</td> <td style="text-align:center">'
  141. contents += calculate_food_data(-0.15, seconds)
  142. contents += '</td>';
  143. contents += '</tr>';
  144. return contents
  145. }
  146.  
  147. function output_data() {
  148. document.getElementById('food_table').innerHTML = generate_food_table(1, 'Food during seasons (/s)');
  149. document.getElementById('food_table_season').innerHTML = generate_food_table(200, 'Food during seasons (/season)');
  150. }
  151.  
  152. setInterval(output_data, 200);