Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.                    
  4. public class Program
  5. {
  6.     // variables
  7.     // you can use https://leagueoflegends.fandom.com/wiki/Kayle as a reference for base stats
  8.     const double frequencyOfAbilityDamage = 0.60; // how often are you using your abilities to deal damage?
  9.     const double frequencyOfAutoAttackDamage = 0.40; // how often are you using auto attacks to deal damage?
  10.     const int level = 5; // what level are you?
  11.     const double basedmg = 61.3; // what's your base damage (from leveling up/runes)?
  12.     const int averageExaltedStacks = 2; // on average, how many stacks of exalted do you have?
  13.     const double speedLevelModifier = 0.062; // what is your bonus attack speed percentage (from leveling up/runes)?
  14.     const double opponentarmor = 54; // what is your opponent's armor likely to be by this level?
  15.     const double opponentmr = 44; // what is your opponent's mr likely to be by this level?
  16.     const double opponenthealth = 998; // what is your opponent's health likely to be by this level?
  17.     const double resistanceshredfrequency = 0.75; // how often are you landing your Q? multiply that by the percentage of damage you think you're dealing while the Q's shred is in effect.
  18.     const int ptsInQ = 2; // how many points have you put in Q?
  19.     const int ptsInW = 1; // how many points have you put in W?
  20.     const int ptsInE = 2; // how many points have you put in E?
  21.     const int ptsInR = 0; // how many points have you put in R?
  22.     const bool isSupport = false; // are you playing the support role?
  23.    
  24.     public static void Main()
  25.     {
  26.         Dictionary<string, double> costOf = new Dictionary<string, double>()
  27.         {
  28.             { "dmg", 35.0 },
  29.             { "speed", 25.0 },
  30.             { "power", 21.75 },
  31.             { "crit", 40.0 },
  32.             { "cdr", 26.7 }
  33.         };
  34.        
  35.         double speedLimit = 1.1512; // Kayle gets a lot of natural bonus attack speed, this amount would make her hit cap at level 18.
  36.         double critLimit = 1.0; // duh
  37.         double cdrLimit = 0.40; // this is the max cdr in league
  38.        
  39.         // find the max total damage and report what values were at that damage
  40.         double maxtotal = 0.0;
  41.         double aaAtMax = 0.0;
  42.         double abAtMax = 0.0;
  43.         double maxdmg = 0.0;
  44.         double maxspeed = 0.0;
  45.         double maxpower = 0.0;
  46.         double maxcrit = 0.0;
  47.         double maxcdr = 0.0;
  48.        
  49.         int gold = 2000; // your gold earned at level 5
  50.         for (int dmgGold = 0; dmgGold < gold; dmgGold += 100)
  51.         {
  52.             double dmg = dmgGold / costOf["dmg"];
  53.            
  54.             for (int speedGold = 0; speedGold < gold - dmgGold; speedGold += 100)
  55.             {
  56.                 double speed = (speedGold / costOf["speed"]) / 100; // divide by 100 to make it by decimal instead of percentage
  57.                 if (speed >= speedLimit)
  58.                     break;
  59.                
  60.                 for (int powerGold = 0; powerGold < gold - dmgGold - speedGold; powerGold += 100)
  61.                 {
  62.                     double power = powerGold / costOf["power"];
  63.                    
  64.                     for (int critGold = 0; critGold < gold - dmgGold - speedGold - powerGold; critGold += 100)
  65.                     {
  66.                         double crit = (critGold / costOf["crit"]) / 100; // divide by 100 to make it by decimal instead of percentage
  67.                         if (crit >= critLimit)
  68.                             break;
  69.                        
  70.                         for (int cdrGold = 0; cdrGold < gold - dmgGold - speedGold - powerGold - critGold; cdrGold += 100)
  71.                         {
  72.                             double cdr = (cdrGold / costOf["cdr"]) / 100; // divide by 100 to make it by decimal instead of percentage
  73.                             if (cdr >= cdrLimit)
  74.                                 break;
  75.                            
  76.                             // calculation
  77.                             double aadmg = frequencyOfAutoAttackDamage * CalculateAutoAttackDamage(dmg, speed, power, crit, cdr);
  78.                             double abdmg = frequencyOfAbilityDamage * CalculateAbilityDamage(dmg, power, cdr);
  79.                             double totaldmg = aadmg + abdmg;
  80.                             if (totaldmg > maxtotal)
  81.                             {
  82.                                 maxtotal = totaldmg;
  83.                                 aaAtMax = aadmg;
  84.                                 abAtMax = abdmg;
  85.                                 maxdmg = dmg;
  86.                                 maxspeed = speed;
  87.                                 maxpower = power;
  88.                                 maxcrit = crit;
  89.                                 maxcdr = cdr;
  90.                             }
  91.                         }
  92.                     }
  93.                 }
  94.             }
  95.         }
  96.        
  97.         Console.WriteLine("Max total damage per second calculated to be: " + maxtotal);
  98.         Console.WriteLine("Auto attack damage at max calculated to be: " + aaAtMax);
  99.         Console.WriteLine("Ability damage at max calculated to be: " + abAtMax);
  100.         Console.WriteLine();
  101.         Console.WriteLine("Bonus AD at this point was " + maxdmg.ToString());
  102.         Console.WriteLine("Bonus Attack Speed at this point was " + (maxspeed * 100).ToString() + "%");
  103.         Console.WriteLine("Bonus AP at this point was " + maxpower.ToString());
  104.         Console.WriteLine("Bonus Crit Chance at this point was " + (maxcrit * 100).ToString() + "%");
  105.         Console.WriteLine("Bonus CDR at this point was " + (maxcdr * 100).ToString() + "%");
  106.         Console.WriteLine();
  107.        
  108.         Console.WriteLine("Total default dps: " + CalculateTotalDamagePerSecond(0.0, 0.0, 0.0, 0.0, 0.0).ToString());
  109.         Console.WriteLine();
  110.        
  111.         // first partial item options
  112.         Console.WriteLine("Total dps with Caulfield's Warhammer: " + CalculateTotalDamagePerSecond(25, 0.0, 0.0, 0.0, 0.10).ToString());
  113.         Console.WriteLine("Total dps with Zeal: " + CalculateTotalDamagePerSecond(0.0, 0.15, 0.0, 0.15, 0.0).ToString());
  114.         Console.WriteLine("Total dps with Stinger: " + CalculateTotalDamagePerSecond(0.0, 0.35, 0.0, 0.0, 0.10).ToString());
  115.         Console.WriteLine("Total dps with Fiendish Codex: " + CalculateTotalDamagePerSecond(0.0, 0.0, 35, 0.0, 0.10).ToString());
  116.         Console.WriteLine("Total dps with Hextech Revolver: " + CalculateTotalDamagePerSecond(0.0, 0.0, 40, 0.0, 0.0).ToString());
  117.         Console.WriteLine();
  118.        
  119.         // first full item options
  120.         Console.WriteLine("Total dps with Nashor's Tooth (not counting passive): " + CalculateTotalDamagePerSecond(0.0, 0.5, 80, 0.0, 0.20).ToString());
  121.         Console.WriteLine("Total dps with Hextech Gunblade (not counting passive): " + CalculateTotalDamagePerSecond(40, 0.0, 80, 0.0, 0.0).ToString());
  122.         Console.WriteLine("Total dps with Guinsoo's Rageblade (not counting some passives): " + CalculateTotalDamagePerSecond(25, 0.25 + 0.24,25, 0.0, 0.0).ToString());
  123.         Console.WriteLine("Total dps with Essence Reaver: " + CalculateTotalDamagePerSecond(65, 0.0, 0.0, 0.25, 0.0 + 0.20).ToString());
  124.         Console.WriteLine("Total dps with Blade of the Ruined King (not counting lifesteal): " + CalculateTotalDamagePerSecond(40, 0.25, 0.0, 0.0, 0.0).ToString());
  125.         Console.WriteLine();
  126.        
  127.         // full builds
  128.         Console.WriteLine("Total dps with Nashor's Tooth + Essence Reaver + Infinity Edge + Runaan's Hurricane + Hextech Gunblade: " +
  129.                           CalculateTotalDamagePerSecond(65 + 80 + 40, 0.50 + 0.40, 80 + 80, 0.25 + 0.25 + 0.25, 0.20 + 0.20).ToString());
  130.         Console.WriteLine("Total dps with Nashor's Tooth + Essence Reaver + Infinity Edge + Runaan's Hurricane + Guinsoo's Rageblade: " +
  131.                           CalculateTotalDamagePerSecond(65 + 80 + 25, 0.50 + 0.40 + 0.25, 80 + 25, 0.25 + 0.25 + 0.25, 0.20 + 0.20).ToString());
  132.         Console.WriteLine("Total dps with Nashor's Tooth + Guinsoo's Rageblade + Hextech Gunblade + Lich Bane + Zhonya's Hourglass: " +
  133.                           CalculateTotalDamagePerSecond(25 + 40, 0.50 + 0.25, 80 + 25 + 80 + 80 + 75, 0.0, 0.20 + 0.10 + 0.10).ToString());
  134.     }
  135.    
  136.     public static double CalculateTotalDamagePerSecond(double dmg, double speed, double power, double crit, double cdr)
  137.     {  
  138.         // calculation
  139.         return (frequencyOfAutoAttackDamage * CalculateAutoAttackDamage(dmg, speed, power, crit, cdr)) + (frequencyOfAbilityDamage * CalculateAbilityDamage(dmg, power, cdr));
  140.     }
  141.    
  142.     public static double CalculateAutoAttackDamage(double dmg, double speed, double power, double crit, double cdr)
  143.     {
  144.         // calculations of damage per second
  145.         double exaltedspeed = 0.695 * averageExaltedStacks * (level > 10 ? 0.10 : 0.06);
  146.         double basespeed = 0.695 + (0.695 * speedLevelModifier) + exaltedspeed + 0.07;
  147.         double armormodifier = 100 / (100 + (opponentarmor - (resistanceshredfrequency * opponentarmor * 0.20)));
  148.         double mrmodifier = 100 / (100 + (opponentmr - (resistanceshredfrequency * opponentmr * 0.20)));
  149.        
  150.         double rateOfAttack = basespeed + (0.695 * speed); // attacks per second
  151.         double baseautoattackdps = (rateOfAttack * ((armormodifier * (basedmg + dmg)) * (1 + (2 * crit))));
  152.        
  153.         double spellbladeDamage = ((5 + (5 * ptsInE) + (0.10 * (basedmg + dmg)) + (0.20 * power)) * mrmodifier);
  154.         double spellbladedps = spellbladeDamage * rateOfAttack;
  155.        
  156.         double cleaveRate = (double)averageExaltedStacks / 6;
  157.         double cleavedamage = level < 16 ? spellbladeDamage : (spellbladeDamage / mrmodifier);
  158.         double cleavedps = cleaveRate * (spellbladeDamage * (1 + crit)) * rateOfAttack;
  159.        
  160.         double totalAutoAttackDps = baseautoattackdps + spellbladedps + (level > 5 ? cleavedps : 0);
  161.        
  162.         int ultRank = level / 6;
  163.         double ultRate = (double)1 / ((200 - (ultRank * 40)) * (1 - cdr));
  164.         double damageLostToUlt = totalAutoAttackDps * 1.5 * ultRate;
  165.        
  166.         // TODO: recalculate after removing crit chance from basic attacks after an E activation
  167.        
  168.         return totalAutoAttackDps - damageLostToUlt;
  169.     }
  170.    
  171.     public static double CalculateAbilityDamage(double dmg, double power, double cdr)
  172.     {  
  173.         // calculations of damage per second
  174.         double mrmodifierWithShred = 100 / (100 + (opponentmr - (resistanceshredfrequency * opponentmr * 0.20)));
  175.         double mrmodifierWithoutShred = 100 / (100 + opponentmr);
  176.        
  177.         double qActivationsPerSecond = 1 / ((13 - ptsInQ) * (1 - cdr));
  178.         double wActivationsPerSecond = 1 / (15 * (1 - cdr));
  179.         double eActivationsPerSecond = 1 / (8 * (1 - cdr));
  180.         double rActivationsPerSecond = 1 / ((200 - (ptsInR * 40)) * (1 - cdr));
  181.        
  182.         double q = (qActivationsPerSecond * ((25 + (45 * ptsInQ)) + (0.6 * (basedmg + dmg)) + (0.5 * power)) * mrmodifierWithoutShred);
  183.         double w = (wActivationsPerSecond * ((30 + (30 * ptsInW)) + (0.3 * power)));
  184.         w = isSupport ? w * 2 : w;
  185.         double e = (eActivationsPerSecond * ((5 + (5 * ptsInE)) + ((0.075 + (0.025 * ptsInE)) * (opponenthealth / 2))) * mrmodifierWithShred);
  186.         double r = (rActivationsPerSecond * (50 + (150 * ptsInR) + dmg + (0.80 * power)));
  187.        
  188.         return q + w + e + (ptsInR > 0 ? r : 0);
  189.     }
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement