Efficiency Stat Script

Shows efficiency (attack per piece + downstack per piece)

As of 19.04.2020. See ბოლო ვერსია.

  1. // ==UserScript==
  2. // @name Efficiency Stat Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.7
  5. // @description Shows efficiency (attack per piece + downstack per piece)
  6. // @author Oki
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Efficiency Stat Script
  13. **************************/
  14.  
  15.  
  16. (function() {
  17. window.addEventListener('load', function(){
  18.  
  19. STAT_POS = 970;
  20. STAT_NAME = "Eff"
  21.  
  22. STAT_POS2 = 1000;
  23. STAT_NAME2 = "VS"
  24.  
  25. enable_playing = true
  26. enable_replay = true
  27. display_vsscore = true
  28. display_eff = false
  29.  
  30.  
  31. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  32. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  33.  
  34. x = true
  35.  
  36. function afterPlaceBlock() {
  37. if(this.clock == 0 && x){
  38. cat = this["v"]["kppElement"].id.slice(-1)
  39. if((GameCore['oldPieces'+cat] < this['placedBlocks']) || GameCore['oldPieces'+cat] == undefined){
  40. GameCore['downstack'+cat] += (GameCore['currentGarbage'+cat] - (JSON.stringify(this.matrix).split(8).length-1)/9)
  41. pieces = this['placedBlocks']
  42. GameCore['oldPieces'+cat] = pieces
  43. APP = this["gamedata"]["attack"] / pieces
  44. DPP = GameCore['downstack'+cat] / pieces
  45. EFF = (APP + DPP)
  46. time = this['actions'][this['ptr']]["t"]
  47. GameCore[STAT_NAME + "Timestamps"+cat] = GameCore[STAT_NAME + "Timestamps"+cat] || []
  48. GameCore[STAT_NAME + "Timestamps"+cat].push([(EFF).toFixed(2), time])
  49. } else {
  50. x = false
  51. }
  52. } else {
  53. x = false;
  54. ["1","2","P"].map(y=>{
  55. GameCore['downstack'+y] = 0;
  56. })
  57. }
  58.  
  59. }
  60.  
  61. function afterCheckLineClears() {
  62. GameCore['downstack'] += (GameCore['currentGarbageP'] - (JSON.stringify(this.matrix).split(8).length-1)/9)
  63. pieces = this["GameStats"]["stats"]["BLOCKS"].value
  64. APP = this["gamedata"]["attack"] / pieces
  65. DPP = GameCore['downstack'] / pieces
  66. if(display_vsscore){
  67. PPS = this['getPPS']()
  68. if(this['GameStats'].get('VS'))this['GameStats'].get('VS').set(((APP + DPP)*PPS).toFixed(2));
  69. }
  70. if(display_eff){
  71. if(this['GameStats'].get('EFF'))this['GameStats'].get('EFF').set((APP + DPP).toFixed(2));
  72. }
  73. }
  74.  
  75. function beforeCheckLineClears() {
  76. cat = this["v"]["kppElement"] ? this["v"]["kppElement"].id.slice(-1) : "P"
  77. GameCore['currentGarbage'+cat] = (JSON.stringify(this.matrix).split(8).length-1)/9;
  78. }
  79.  
  80. if(enable_playing | enable_replay){
  81. var checkLineClearsFunc = GameCore['prototype']['checkLineClears'].toString()
  82. var params = getParams(checkLineClearsFunc)
  83. checkLineClearsFunc = trim(beforeCheckLineClears.toString()) + trim(checkLineClearsFunc)
  84. GameCore['prototype']['checkLineClears'] = new Function(...params, checkLineClearsFunc);
  85. }
  86.  
  87.  
  88.  
  89. if(enable_playing){
  90. if(typeof Game != "undefined"){
  91.  
  92. checkLineClearsFunc = GameCore['prototype']['checkLineClears'].toString()
  93. checkLineClearsFunc = trim(checkLineClearsFunc) + trim(afterCheckLineClears.toString())
  94. GameCore['prototype']['checkLineClears'] = new Function(...params, checkLineClearsFunc);
  95.  
  96. var readyGoFunc = Game['prototype']["startReadyGo"].toString()
  97. readyGoFunc = `
  98. GameCore['downstack']=0;
  99. if(display_eff){
  100. this['GameStats'].addStat(new StatLine('EFF', '`+STAT_NAME+`', `+STAT_POS+`),true);
  101. }
  102. if(display_vsscore){
  103. this['GameStats'].addStat(new StatLine('VS', '`+STAT_NAME2+`', `+STAT_POS2+`),true);}` + trim(readyGoFunc)
  104. Game['prototype']["startReadyGo"] = new Function(readyGoFunc);
  105.  
  106. }
  107. }
  108.  
  109.  
  110. if(enable_replay){
  111.  
  112. var website = "jstris.jezevec10.com"
  113. var url = window.location.href
  114. var parts = url.split("/")
  115.  
  116. if(typeof Replayer != "undefined"){
  117. Replayer["addStat"] = function(id,into,name) {
  118. var newStat = document.createElement("tr");
  119. newStat.innerHTML = '<td class="ter">'+name+'</td><td class="sval"><span id="'+id+'">0</span></td>'
  120. into.appendChild(newStat);
  121. }
  122. }
  123.  
  124. if(parts[3]=="replay" && parts[2].endsWith(website) && parts.length>4){
  125.  
  126. ["1","2","P"].map(y=>{GameCore['downstack'+y] = 0});
  127. var placeBlockFunc = GameCore['prototype']['placeBlock'].toString()
  128. var params2 = getParams(placeBlockFunc)
  129. placeBlockFunc = trim(placeBlockFunc) + trim(afterPlaceBlock.toString())
  130. GameCore['prototype']['placeBlock'] = new Function(...params2, placeBlockFunc);
  131.  
  132. if(parts[4]=="1v1"){
  133. if(display_eff){
  134. Replayer["addStat"](STAT_NAME+"Element1",document.getElementsByTagName("tbody")[0],STAT_NAME)
  135. Replayer["addStat"](STAT_NAME+"Element2",document.getElementsByTagName("tbody")[2],STAT_NAME)
  136. }
  137. if(display_vsscore){
  138. Replayer["addStat"](STAT_NAME2+"Element1",document.getElementsByTagName("tbody")[0],STAT_NAME2)
  139. Replayer["addStat"](STAT_NAME2+"Element2",document.getElementsByTagName("tbody")[2],STAT_NAME2)
  140. }
  141. } else {
  142. if(display_eff){
  143. Replayer["addStat"](STAT_NAME+"ElementP",document.getElementsByClassName("moreStats")[0],STAT_NAME)
  144. }
  145. if(display_vsscore){
  146. Replayer["addStat"](STAT_NAME2+"ElementP",document.getElementsByClassName("moreStats")[0],STAT_NAME2)
  147. }
  148. }
  149.  
  150. Replayer['prototype']['getStat'] = function(cat) {
  151. if(stamps=GameCore[STAT_NAME+"Timestamps"+cat]){
  152. for (var i = 1; i < stamps.length; i++) {
  153. if(stamps[i][1]>this['clock']){
  154. return stamps[i-1][0]
  155. }
  156. }
  157. return stamps[stamps.length-1][0]
  158. }
  159. return 0
  160. };
  161.  
  162. var oldTextBar = View.prototype.updateTextBar.toString();
  163. oldTextBar = trim(oldTextBar) + `;
  164. var cat = this.kppElement.id.slice(-1);
  165. if(display_eff){
  166. eval("`+STAT_NAME+`Element"+cat+"&&(`+STAT_NAME+`Element"+cat+".innerHTML = this.g.getStat(cat))");}
  167. if(display_vsscore){
  168. eval("`+STAT_NAME2+`Element"+cat+"&&(`+STAT_NAME2+`Element"+cat+".innerHTML = (PPS"+(cat=='P'?'':cat)+".innerHTML*this.g.getStat(cat)).toFixed(2))");
  169. }`
  170.  
  171. View.prototype.updateTextBar = new Function(oldTextBar);
  172.  
  173. }
  174. }
  175.  
  176. });
  177. })();