Efficiency Stat Script

Shows efficiency (attack per piece + downstack per piece)

2020-04-06 기준 버전입니다. 최신 버전을 확인하세요.

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