public static string Main(InfoArray infoList) { var outputArr = new string[6]; /* * outputArr[0] = ExportStart.Main(infoList); * outputArr[1] = ExportBasic.Main(infoList); * outputArr[2] = ExportWeapon.Main(infoList); * outputArr[3] = ExportDamage.Main(infoList); * outputArr[4] = ExportArmorPen.Main(infoList); * outputArr[5] = ExportBeltContents.Main(infoList); */ Parallel.Invoke(() => { outputArr[0] = ExportStart.Main(infoList); }, () => { outputArr[1] = ExportBasic.Main(infoList); }, () => { outputArr[2] = ExportWeapon.Main(infoList); }, () => { outputArr[3] = ExportDamage.Main(infoList); }, () => { outputArr[4] = ExportArmorPen.Main(infoList); }, () => { outputArr[5] = ExportBeltContents.Main(infoList); }); return(string.Join("", outputArr)); }
public static InfoArray CompletedArr(Dictionary <string, object> rawBlk, FileInfo fileInfo) { var infoList = new InfoArray(GetSpadedBelts(rawBlk), GetStockBelts(rawBlk)); infoList.SetGunInfo(GunInfo(rawBlk)); infoList.SetNameInfo(NameCleaning(fileInfo)); return(infoList); }
public static string Main(InfoArray infoList) { var barOMatic = $@"<div style = ""text-align:center;font-size:1.5rem;"">RoF Bar-o-matic:</div> <div style = ""background: linear-gradient(to right, red, yellow, green);font-size:3rem;width:auto;height:auto;padding:0 0 0 {PaddingLeft(infoList.Rof)}%;margin:0.3rem 19.5% 0.25rem""> | </div> "; var wikiTable = $@"{{|class=""wikitable"" style=""width:75%;margin:0 auto 1rem;font-size:1.2rem"" |+ style=""width:auto;font-size:2.0rem;margin:1rem 0"" | Rate of Fire: {infoList.Rof} rounds per minute ! style=""width:33%"" | Cannon ! style=""width:33%"" | Caliber ! style=""width:33%"" | Effective Distance |- | style=""text-align:center"" | {infoList.Cannon} | style=""text-align:center"" | {infoList.Caliber}mm | style=""text-align:center"" | {infoList.EffectiveDistance}m |}} {{|class=""wikitable"" style=""width:75%;margin:0 auto 1rem;font-size:1.2rem"" ! style=""width:50%"" | Spaded Disp @ 500m ! style=""width:50%"" | Stock Disp @ 500m |- | style=""text-align:center"" | {infoList.GunDispersion.SpadedDis}m | style=""text-align:center"" | {infoList.GunDispersion.StockDis}m |}}"; var exportFile = $@"<div class=""mw-customtoggle-weaponInfo_{infoList.FileName}"" style=""text-align:center;width:auto;overflow:auto;border:solid green;border-radius: 0.625rem;background:lightgreen;""> <span style=""font-size:1.2rem;font-style:italic;font-weight:bold"">Weapon Information</span> </div> <div class=""mw-collapsible"" id=""mw-customcollapsible-weaponInfo_{infoList.FileName}"" style=""width:99%;overflow:auto;""> <div class = ""mw-collapsible-content"" style = ""border:solid lightgray;background:white;margin-left:1%;padding:1%;overflow:auto""> {barOMatic} {wikiTable} </div> </div> "; string PaddingLeft(decimal rof) { var tempPadLeft = (rof * 30) / 800; if (tempPadLeft > 60) { tempPadLeft = 60; } else if (tempPadLeft < 0) { tempPadLeft = 0; } return(tempPadLeft.ToString(CultureInfo.InvariantCulture)); } return(exportFile); }
public static string Main(InfoArray infoList) { var internalFile = new StringBuilder(); // Default internalFile.Append("<b>Default</b>\n\n "); infoList.StockIDs.ForEach(bullet => { if (!((Dictionary <string, object>)infoList.UniqueBullets[infoList.UniqueIDs.IndexOf(bullet)]) .ContainsKey("bulletType")) { return; } internalFile.Append( NameCleaning((string)((Dictionary <string, object>)infoList.UniqueBullets[infoList.UniqueIDs.IndexOf(bullet)])[ "bulletType"])); internalFile.Append(", "); }); internalFile.Remove(internalFile.Length - 2, 2); // Spaded for (var belt = 0; belt < infoList.SpadedNames.Count; belt++) { internalFile.Append($"\n\n<b>{NameCleaning(infoList.SpadedNames[belt])}</b>\n\n "); for (var bullet = 0; bullet < infoList.SpadedIDs[belt].Count; bullet++) { if (!((Dictionary <string, object>)infoList.UniqueBullets[infoList.UniqueIDs.IndexOf(infoList.SpadedIDs[belt][bullet])]) .ContainsKey("bulletType")) { continue; } internalFile.Append( NameCleaning((string)((Dictionary <string, object>)infoList.UniqueBullets[ infoList.UniqueIDs.IndexOf(infoList.SpadedIDs[belt][bullet])])["bulletType"])); internalFile.Append(", "); } internalFile.Remove(internalFile.Length - 2, 2); } var exportFile = $@"<div class = ""mw-customtoggle-belts_{infoList.FileName}"" style=""text-align:center;width:auto;overflow:auto;border:solid purple;border-radius: 0.625rem;background:lavender""> <span style=""font-size:1.2rem;font-style:italic;font-weight:bold"">Belt Contents</span> </div> <div class=""mw-collapsible"" id=""mw-customcollapsible-belts_{infoList.FileName}"" style=""width:99%;overflow:auto;""> <div class=""mw-collapsible-content"" style=""border:solid lightgray;background:white;margin-left:1%;padding:0 1%;overflow:auto""> {internalFile} </div> </div>"; return(exportFile); }
public static string Main(InfoArray infoList) { var infoText = $@"<strong style = ""font-size:2rem;""> Created by Kmsxkuse. </strong> Bot Version: [1.0 Alpha (C# Edition)]. Bot Last Run: [{DateTime.UtcNow.ToLongDateString()}]. Bot sources: (Typescript Version): https://github.com/Kmsxkuse/War-Thunder-Wiki-Bot (C# Version): https://github.com/Kmsxkuse/WT-Wiki-Bot-in-CSharp Database last updated: [{infoList.LastModified}]. War Thunder Version: [1.85]. The following information should be taken with a block of salt. If the numbers don't make sense, assume bugs or missing data. I have no access to server side information that may be modifying the shell data. If you need to contact the creator, please private message /u/Kmsxkuse on www.reddit.com."; /* * var exportFile = * $@"<div class = ""mw-customtoggle-{infoList.FileName}"" style=""border:mediumturquoise; border-radius: 0.625rem; background:lightcyan; padding:0.5% 1% 0; padding-right:1%; display:inline-block""> * <p><strong style = ""line-height:1rem; font-size:1.5rem"">Click here for {infoList.GunName} Belts!</strong></p> * </div> * <div class = ""mw-collapsible mw-collapsed"" id=""mw-customcollapsible-{infoList.FileName}"" style = ""width:100%""> * <div class = ""mw-collapsible-content"" style = ""border:solid lightgray; background:white; padding:1%""> * <div class = ""mw-customtoggle-glossary_{infoList.FileName}"" style=""font-size:1.2rem; text-align:center; width:auto; border:solid crimson; border-radius: 0.625rem; background:lightpink""> * <strong>Information Page</strong> * </div> * <div class = ""mw-collapsible mw-collapsed"" id = ""mw-customcollapsible-glossary_{infoList.FileName}"" style = ""width:99%;""> * <div class = ""mw-collapsible-content"" style = ""border:solid lightgray; margin-left:1%; padding:1%; font-size:1rem; overflow:auto""> * {infoText} * </div> * </div> * "; */ var exportFile = $@"<div class = ""mw-customtoggle-glossary_{infoList.FileName}"" style=""font-size:1.2rem; text-align:center; width:auto; border:solid crimson; border-radius: 0.625rem; background:lightpink""> <strong>Information Page</strong> </div> <div class = ""mw-collapsible mw-collapsed"" id = ""mw-customcollapsible-glossary_{infoList.FileName}"" style = ""width:99%;""> <div class = ""mw-collapsible-content"" style = ""border:solid lightgray; margin-left:1%; padding:1%; font-size:1rem; overflow:auto""> {infoText} </div> "; return(exportFile); }
public static string Main(InfoArray infoList) { const decimal tableSize = 40; var intSize = Math.Round(tableSize * 17 / 20, 2); const int maxLines = 11; // - 1 for actual number of lines const string chartEnd = "</div>"; var chartStart = $@"<div style=""position:relative;width:{tableSize}rem;height:{tableSize}rem;background:#f0f0f0;border:solid;margin:1rem auto""> <div style=""position:absolute;left:{Math.Round(tableSize / 10, 2)}rem;top:{Math.Round(tableSize / 20, 2)}rem;width:{intSize}rem;height:{intSize}rem;background:white;border:solid;"">"; var chartLines = new StringBuilder(); for (var lineNum = 1; lineNum < maxLines; lineNum++) { // Originating from Y Lines chartLines.Append($@"<div style=""position:absolute;top:{Math.Round(intSize / maxLines * lineNum, 2)}rem; width:{intSize}rem;border-bottom:dashed 2px lightgray;""></div>"); // X Lines chartLines.Append($@"<div style=""position:absolute;height:{intSize}rem;left:{Math.Round(intSize / maxLines * lineNum, 2)}rem;border-right:dashed 2px lightgray;""></div>"); } var armorPowerArr = new List <List <object> >(); infoList.UniqueBullets.ForEach(bullet => { if (!((Dictionary <string, object>)bullet).ContainsKey("armorpower")) { return; } armorPowerArr.Add(((Dictionary <string, object>)((Dictionary <string, object>)bullet)["armorpower"]).Values.ToList()); }); var maxPen = new float(); armorPowerArr.ForEach(bullet => { bullet.ForEach(coordinate => { if (((float[])coordinate)[0] < maxPen) { return; } maxPen = ((float[])coordinate)[0]; }); }); maxPen = (float)Math.Ceiling(maxPen); var chartUnits = new StringBuilder(); for (var lineNum = maxLines; lineNum > 0; lineNum--) { // Y Values chartUnits.Append($@"<div style=""position:absolute;top:{Math.Round((double) intSize / maxLines * (lineNum + 0.5), 2)}rem;width:{Math.Round(tableSize / 12, 2)}rem"" align=""right"">{Math.Round(maxPen / (maxLines - 1) * (maxLines - lineNum))}</div>"); // X Values chartUnits.Append($@"<div style=""position:absolute;top:{Math.Round(intSize + tableSize * 3 / 40 - 0.3M, 2)}rem;left:{Math.Round((double) intSize / maxLines * lineNum + 0.6, 2)}rem;width:{Math.Round(tableSize / lineNum, 2)}"" align=""center"">{(lineNum - 1) * 100}</div>"); } var penBox = $@"<div style=""position:absolute;width:{Math.Round((1 - 1 / (double) (maxLines - 1)) * 100, 2)}%;height:{Math.Round((1 - 1 / (decimal) (maxLines - 1)) * 100, 2)}%;bottom:0;left:0"">"; var penCoords = new StringBuilder(); var penLines = new StringBuilder(); var penLegend = new StringBuilder(); var prevPoint = new[] { 0d, 0d }; for (var bullet = 0; bullet < armorPowerArr.Count; bullet++) { for (var coordinate = 0; coordinate < armorPowerArr[bullet].Count; coordinate++) { if (((float[])armorPowerArr[bullet][coordinate])[1] > (maxLines - 1) * 100) { break; } const decimal boxSize = 0.25M; /* Vertical (bottom) Offset: (1 - boxSize / 2 / intSize ) * Experimentally Determined. * Reduced by half the height (aka length) of the box. * Then converted to % of box. */ var boxPointX = Math.Round(((float[])armorPowerArr[bullet][coordinate])[1] / (maxLines - 1), 2); var boxPointY = Math.Round(((float[])armorPowerArr[bullet][coordinate])[0] / maxPen * (double)(1 - boxSize / 2 / intSize) * 100, 2); if (coordinate != 0) { var lineLength = Math.Round(Math.Sqrt(Math.Pow(prevPoint[0] - boxPointX, 2) + Math.Pow(prevPoint[1] - boxPointY, 2))); var rotate = Math.Round(Math.Atan((prevPoint[0] - boxPointX) / (prevPoint[1] - boxPointY)), 2); // Lines penLines.Append($@"<div style=""position:absolute;transform:rotate({rotate}rad);left:{(boxPointX + prevPoint[0]) / 2}%;bottom:{(boxPointY + prevPoint[1]) / 2 - lineLength / 2 + 1}%;height:{lineLength}%;border-right:solid #{ColourValues[bullet]}""></div>"); } prevPoint[0] = boxPointX; prevPoint[1] = boxPointY; // Points penCoords.Append($@"<div style=""position:absolute;left:{boxPointX}%;bottom:{boxPointY}%;width:{boxSize}rem;height:{boxSize}rem;border:solid #{ColourValues[bullet]};border-radius:50%;background:white;""></div>"); } if (!((Dictionary <string, object>)infoList.UniqueBullets[bullet]).ContainsKey("bulletType")) { break; } string Capitalizing(Match m) { return(m.Groups[1].Value.ToUpper()); } var cleanedName = ((string)((Dictionary <string, object>)infoList.UniqueBullets[bullet])["bulletType"]).Replace('_', ' '); cleanedName = Regex.Replace(cleanedName, @"(\b[a-z])", Capitalizing); // Legend penLegend.Append($@"<div style=""position:relative;padding:0.2rem;border:solid #{ColourValues[bullet]};width:20%;top:1%;margin:0 0 0 75%;background:white;text-align:center"">{cleanedName}</div>"); } // First is X Axis, second is Y Axis. var chartWords = $@"<b><div style=""position:absolute;width:100%"" align=""center"">{infoList.GunName} ArmorPower</div> <div style=""position:absolute;width:100%;top:{tableSize - 1.5M}rem"" align=""center"">Distance in meters</div> <div style=""transform:rotate(90deg);position:relative;left:-{tableSize - 1.5M}rem;height:100%;"" align=""center"">Penetration in millimeters</div></b>"; // To prevent people from saying my poor chart is bugged. const string chartWarning = @"<div style=""position:relative;text-align:center;font-weight:bold;top:0.5rem"">Colors indicated in the legend that do not appear in the graph may be hidden behind another line.<br />Numbers along Y Axis are not precise. They have been rounded to the nearest integer.</div>"; var exportFile = $@"<div class=""mw-customtoggle-armor_{infoList.FileName}"" style=""text-align:center;width:auto;overflow:auto;border:solid orange;border-radius:0.625rem;background:mistyrose""> <span style=""font-size:1.2rem;font-style:italic;font-weight:bold"">Armor Penetration Chart</span> </div> <div class=""mw-collapsible"" id=""mw-customcollapsible-armor_{infoList.FileName}"" style=""width:99%;""> <div class=""mw-collapsible-content"" style=""border:solid lightgray;background:white;margin-left:1%;padding:0 1%;overflow:auto""> {chartWarning} {chartStart} {chartLines} {penBox} {penLines} {penCoords} {chartEnd} {penLegend} {chartEnd} {chartWords} {chartUnits} {chartEnd} </div> </div> "; return(exportFile); }
public static string Main(InfoArray infoList) { string PhysicalTable(Dictionary <string, object> bullet) { var wikiTable = $@"{{|class=""wikitable"" style=""width:75%;margin:0 auto 0.5rem"" |+ style=""width:auto;font-size:1.2rem;margin:0.5rem 0"" | {NameCleaning((string) bullet["bulletType"])} ! style=""width:25%"" | Mass ! style=""width:25%"" | Velocity ! style=""width:25%"" | Fire Multiplier ! style=""width:25%"" | HitPower Multiplier |- | style=""text-align:center"" | {Math.Round((decimal) bullet["mass"] * 1000M)}g | style=""text-align:center"" | {bullet["speed"]}m/s | style=""text-align:center"" | {BulletCheck(bullet, "onHitChanceMultFire")} | style=""text-align:center"" | {BulletCheck(bullet, "hitPowerMult")} |}} "; return(wikiTable); } object BulletCheck(IReadOnlyDictionary <string, object> bullet, string checker) { return(!bullet.ContainsKey(checker) ? "N/A" : bullet[checker]); } string ExplosiveTable(Dictionary <string, object> bullet) { var explosives = (from x in bullet where x.Key.Contains("explode") || x.Key.Contains("explosive") select x).ToDictionary(obj => obj.Key, obj => obj.Value); var tableHeaders = new StringBuilder(); var tableInfo = new StringBuilder(); foreach (var keyValuePair in explosives) { tableHeaders.Append($@"! style=""width:{Math.Round(100M / explosives.Count(), 2)}%"" |{HeaderSplitter(keyValuePair.Key)} "); tableInfo.Append($@"| style=""text-align:center"" | {ManualExpUnits(keyValuePair)} "); } var wikiTable = $@"{{|class=""wikitable"" style=""width:75%;margin:0 auto 0.5rem"" |+ style=""width:auto;font-style:italic"" | Explosive Data {tableHeaders} |- {tableInfo} |}} "; return(wikiTable); } string HeaderSplitter(string header) { // Removing the redundant explosive/explode/shutter in header. header = NameCleaning(Regex.Replace(header, @"(^[a-z]+(?=[A-Z]))", "")); return(header); } string ManualExpUnits(KeyValuePair <string, object> col) { switch (col.Key) { case "explosiveMass": return($"{Math.Round((decimal) col.Value * 1000M)}g"); case "explosiveType": return(NameCleaning((string)col.Value)); case "explodeTreshold": case "explodeArmorPower": return($"{col.Value}mm"); case "explodeRadius": return($"[{Math.Round(((float[]) col.Value)[0], 2)}, {Math.Round(((float[]) col.Value)[1], 2)}]"); default: return(col.Value.ToString()); } } string FragTable(Dictionary <string, object> bullet) { var fragmentation = (from x in bullet where x.Key.Contains("shutter") && !x.Key.Equals("shutterDamage") select x).ToDictionary(obj => obj.Key, obj => obj.Value); var tableHeaders = new StringBuilder(); var tableInfo = new StringBuilder(); foreach (var keyValuePair in fragmentation) { tableHeaders.Append($@"! style=""width:{Math.Round(100M / fragmentation.Count(), 2)}%"" |{HeaderSplitter(keyValuePair.Key)} "); tableInfo.Append($@"| style=""text-align:center"" | {ManualFragUnits(keyValuePair)} "); } var wikiTable = $@"{{|class=""wikitable"" style=""width:75%;margin:0 auto 0.5rem"" |+ style=""width:auto;font-style:italic"" | Fragmentation Data {tableHeaders} |- {tableInfo} |}} "; return(wikiTable); } string ManualFragUnits(KeyValuePair <string, object> col) { switch (col.Key) { case "shutterArmorPower": return($"{col.Value}mm"); default: return(col.Value.ToString()); } } var internalFile = new StringBuilder(); infoList.UniqueBullets.ForEach(bullet => { internalFile.Append(PhysicalTable((Dictionary <string, object>)bullet)); if (((Dictionary <string, object>)bullet).ContainsKey("explosiveMass")) { internalFile.Append(ExplosiveTable((Dictionary <string, object>)bullet)); } if (((Dictionary <string, object>)bullet).ContainsKey("shutterDamage")) { internalFile.Append(FragTable((Dictionary <string, object>)bullet)); } internalFile.Append("\n\n<hr/>\n"); }); var exportFile = $@"<div class=""mw-customtoggle-damage_{infoList.FileName}"" style=""text-align:center;width:auto;overflow:auto;border:solid blue;border-radius:0.625rem;background:lightskyblue""> <span style=""font-size:1.2rem;font-style:italic;font-weight:bold"">Bullet Information</span> </div> <div class=""mw-collapsible"" id=""mw-customcollapsible-damage_{infoList.FileName}"" style=""width:99%;""> <div class=""mw-collapsible-content"" style=""border:solid lightgray;background:white;margin-left:1%;padding:0 1%;overflow:auto""> {internalFile} </div> </div>"; return(exportFile); }