iFarbod

muh rank table

Sep 28th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static int roundUp(int numToRound, int multiple)
  12.         {
  13.             if (multiple == 0)
  14.                 return numToRound;
  15.  
  16.             int remainder = numToRound % multiple;
  17.             if (remainder == 0)
  18.                 return numToRound;
  19.  
  20.             return numToRound + multiple - remainder;
  21.         }
  22.  
  23.         static void Main(string[] args)
  24.         {
  25.             //Console.WriteLine("Please enter the constant:");
  26.             //float con = float.Parse(Console.ReadLine());
  27.  
  28.             const int rankCount = 10000;
  29.             const int roundVal = 50;
  30.  
  31.             double[] table = new double[rankCount + 1];
  32.             double[] changeFP = new double[rankCount + 1];
  33.             double[] diffOC = new double[rankCount + 1];
  34.            
  35.  
  36.             for (int i = 1; i <= rankCount; i++)
  37.             {
  38.                 table[i] = roundUp((int)(1000 * Math.Pow(i, 1.582)), roundVal);
  39.             }
  40.  
  41.             // change from previous
  42.             for (int i = 1; i <= rankCount; i++)
  43.             {
  44.                 if (i == 0)
  45.                 {
  46.                     continue;
  47.                 }
  48.                 else
  49.                 {
  50.                     changeFP[i] = roundUp((int)(table[i] - table[i - 1]), roundVal);
  51.                 }
  52.  
  53.             }
  54.  
  55.             // difference of change
  56.             for (int i = 1; i <= rankCount; i++)
  57.             {
  58.                 if (i == 0)
  59.                 {
  60.                     continue;
  61.                 }
  62.                 else
  63.                 {
  64.                     diffOC[i] = roundUp((int)(changeFP[i] - changeFP[i - 1]), roundVal);
  65.                 }
  66.  
  67.             }
  68.  
  69.             System.IO.File.Delete("ranktable.html");
  70.  
  71.             System.IO.File.AppendAllText("ranktable.html", "<!DOCTYPE html>"+
  72. "<html>"+
  73. "<head>"+
  74. "<style>"+
  75. "table {"+
  76.     "font-family: arial, sans-serif;"+
  77.     "border-collapse: collapse;"+
  78.     "width: 100%;"+
  79. "}"+
  80. ""+
  81. "td, th {"+
  82.     "border: 1px solid #aaaaaa;"+
  83.     "text-align: left;"+
  84.     "padding: 8px;"+
  85. "}"+
  86. ""+
  87. "tr:nth-child(even) {"+
  88.     "background-color: #dddddd;"+
  89. "}"+
  90. "</style>"+
  91. "</head>"+
  92. "<body>"+
  93. ""+
  94. "<table>"+
  95.   "<tr>"+
  96.   "<th>Level</th>"+
  97.     "<th>XP Required</th>"+
  98.     "<th>Change from previous</th>"+
  99.     "<th>Difference of change</th>"+
  100.   "</tr>");
  101.  
  102.             for (int i = 0; i <= rankCount; i++)
  103.             {
  104.                 string format = "  <tr>" +
  105.     "<td>{0}</td>" +
  106.     "<td>{1}</td>" +
  107.     "<td>+{2}</td>" +
  108.     "<td>{3}{4}</td>" +
  109.   "</tr>";
  110.  
  111.                 string output = String.Format(
  112.                     format, i + 1,
  113.                     String.Format("{0:n0}", table[i]),
  114.                     String.Format("{0:n0}", changeFP[i]),
  115.                     (diffOC[i] > 0) ? "+" : "",
  116.                     String.Format("{0:n0}", diffOC[i])
  117.                     );
  118.                
  119.                 System.IO.File.AppendAllText("ranktable.html", output + "\n");
  120.             }
  121.             System.IO.File.AppendAllText("ranktable.html", "</table></ body ></ html > ");
  122.             Console.WriteLine("DONE");
  123.             Console.ReadKey();
  124.         }
  125.     }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment