jaggerid

CB winrate v1.3

Jul 24th, 2021 (edited)
1,114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Eyeke LamboSquad
  3. // @namespace anonDeveloper
  4. // @description This script will automagically blah blah blah
  5. // @include https://app.cryptoblades.io/*
  6. // ==/UserScript==
  7.  
  8. var type = [".int",".str",".dex",".pwr",".cha"]
  9. var url = new URL(window.location.href);
  10. var oracle = 10333333333333333;
  11. var fight = 0;
  12.  
  13. function winRate(){
  14.     var m, hpow, epow, wele, hele, weles, rollhero, rollenemy, enemyele;
  15.     var wbonus = 0;
  16.     var wpow = 1;
  17.     var trait = 1;
  18.     for(k = 0; k < document.querySelector(".bonus-power").children.length; k++){
  19.         var bonus = document.querySelector(".bonus-power").children[k].innerText;
  20.         bonus = parseInt(bonus.substring(0, bonus.length-3));
  21.         if(k == 0){wbonus = wbonus + (bonus * 15);}
  22.         else if(k == 1){wbonus = wbonus + (bonus * 30);}
  23.         else if(k == 2){wbonus = wbonus + (bonus * 60);}
  24.     }
  25.    
  26.     if(url == "https://app.cryptoblades.io/#/combat" && document.querySelector("#gtag-link-others") != null){
  27.         weles = document.querySelector(".trait").firstChild.className.trim();
  28.         hele = document.querySelector(".name.bold.character-name").lastChild.classList[0].trim();
  29.         hpow = document.querySelector(".subtext.subtext-stats").children[3].innerText.trim();
  30.         hpow = parseInt(hpow.replace(',','').replace(/\s/g, ''));
  31.         for (j = 0; j < type.length; j++){
  32.             var divs = document.querySelectorAll(type[j]), i
  33.             for (i = 0; i < divs.length; ++i) {
  34.                 var stat = divs[i].innerText.trim();
  35.                 var ele = stat.substring(0, 3);
  36.                 stat = parseInt(stat.substring(stat.length - 3, stat.length));
  37.                
  38.                 if(ele = "CHA"){wele = "lightning-icon";}
  39.                 else if(ele = "INT"){wele = "water-icon";}
  40.                 else if(ele = "DEX"){wele = "earth-icon";}
  41.                 else if(ele = "STR"){wele = "fire-icon";}
  42.  
  43.                 if(hele == wele){
  44.                     wpow = wpow + stat * 0.002675;
  45.                 }
  46.                 else if(ele == "PWR"){
  47.                     wpow = wpow + stat * 0.002575;
  48.                 }
  49.                 else{
  50.                     wpow = wpow + stat * 0.0025;
  51.                 }
  52.             }
  53.         }
  54.         if(hele == weles){
  55.             trait += 0.075;
  56.         }
  57.        
  58.         var enemy = document.querySelectorAll(".enemy-character")
  59.         for (i = 0; i < enemy.length; ++i) {
  60.             var traitbonus = 0;
  61.            
  62.             enemyele = enemy[i].children[0].firstElementChild.className.trim();
  63.             epow = enemy[i].children[2].innerText.trim();
  64.             epow = parseInt(epow.substring(0, epow.length - 6));
  65.            
  66.             if(hele == "lightning-icon" && enemyele == "water-icon"){traitbonus = 0.075;}
  67.             else if(hele == "water-icon" && enemyele == "fire-icon"){traitbonus = 0.075;}
  68.             else if(hele == "fire-icon" && enemyele == "earth-icon"){traitbonus = 0.075;}
  69.             else if(hele == "earth-icon" && enemyele == "lightning-icon"){traitbonus = 0.075;}
  70.             else if(hele == "lightning-icon" && enemyele == "earth-icon"){traitbonus = -0.075;}
  71.             else if(hele == "water-icon" && enemyele == "lightning-icon"){traitbonus = -0.075;}
  72.             else if(hele == "fire-icon" && enemyele == "water-icon"){traitbonus = -0.075;}
  73.             else if(hele == "earth-icon" && enemyele == "fire-icon"){traitbonus = -0.075;}
  74.            
  75.             function roll(min, max) {
  76.                 return min = Math.ceil(min),
  77.                 max = Math.floor(max),
  78.                 Math.floor(Math.random() * (max - min + 1)) + min
  79.             }
  80.             var basedmg = hpow * wpow + wbonus;
  81.             var minhero = Math.round(basedmg * 0.9 * (trait + traitbonus));
  82.             var maxhero = Math.round(basedmg * 1.1 * (trait + traitbonus));
  83.             rollenemy = epow;
  84.  
  85.             var usd = 1000000000000000000 / oracle;
  86.             var reward = ((0.0539 * 4.3) / usd) + ((0.08 * 4.3) / usd) * (Math.sqrt(epow/1000));
  87.             var minenemy = Math.round(rollenemy * 0.9);
  88.             var maxenemy = Math.round(rollenemy * 1.1);
  89.            
  90.             var j = 0;
  91.             for (let t = 0; t < 500; t++){
  92.                 rollhero = roll(basedmg * 0.9, basedmg * 1.1) * (trait + traitbonus)
  93.                 rollenemy = roll(minenemy, maxenemy);
  94.                
  95.                 if(rollhero >= rollenemy){
  96.                     j++;
  97.                 }
  98.             }
  99.             console.log(minhero + " & " + maxhero)
  100.             // console.log(basedmg)
  101.             var winrate = (j / 500 * 100).toFixed(2);
  102.             enemy[i].parentElement.children[1].innerText = "Winrate : " + winrate + "%";
  103.             enemy[i].parentElement.children[2].children[0].innerText  = "MinHero: " + minhero + " MaxEnemy: " + maxenemy;
  104.             // div.innerText = "Hero roll : " + minhero + " - " + maxhero;
  105.             // div2.innerText = "Enemy roll : " + minenemy + " - " + maxenemy;
  106.         }
  107.        
  108.         if(document.querySelector(".roll") != null && fight == 0){
  109.             playSound();
  110.             fight = 1;
  111.         }
  112.         else if(document.querySelector(".roll") == null && fight == 1){
  113.             fight = 0;
  114.         }
  115.     }
  116. }
  117.  
  118. var playSound = (function beep() {
  119.     var snd = new Audio("https://media.geeksforgeeks.org/wp-content/uploads/20190531135120/beep.mp3");  
  120.     return function() {    
  121.         snd.play();
  122.     }
  123. })();
  124.  
  125. var timer = setInterval(winRate, 5000);
RAW Paste Data