summaryrefslogtreecommitdiff
path: root/DSACore/Auxiliary/WeaponImporter.cs
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-05-19 16:03:38 +0200
committerDennis Kobert <d-kobert@web.de>2019-05-19 16:03:38 +0200
commitf89f308c525e9deebc6d2cf6416e27dfe1a299dc (patch)
tree7097ef871ead0245efda696198443eab8e443d3a /DSACore/Auxiliary/WeaponImporter.cs
parentf3983341be939235c1a6cd522b3bb5cc318a6d1a (diff)
Cleanup DiscoBot Project
Diffstat (limited to 'DSACore/Auxiliary/WeaponImporter.cs')
-rw-r--r--DSACore/Auxiliary/WeaponImporter.cs53
1 files changed, 26 insertions, 27 deletions
diff --git a/DSACore/Auxiliary/WeaponImporter.cs b/DSACore/Auxiliary/WeaponImporter.cs
index 635d477..ab51efb 100644
--- a/DSACore/Auxiliary/WeaponImporter.cs
+++ b/DSACore/Auxiliary/WeaponImporter.cs
@@ -20,13 +20,13 @@ namespace DSACore.Auxiliary
{
var client = new HttpClient();
-
- for (int i = 1; i <= 25; i++)
+ for (var i = 1; i <= 25; i++)
{
- var responseString = await client.GetStringAsync("http://diarium.eu/dsa4-forge/ajax/categoryChanged/" + i);
+ var responseString =
+ await client.GetStringAsync("http://diarium.eu/dsa4-forge/ajax/categoryChanged/" + i);
- Regex talentRegex = new Regex(@"(?<=<option value="")([0-9]*)("">)(.*?)(?=<)");
+ var talentRegex = new Regex(@"(?<=<option value="")([0-9]*)("">)(.*?)(?=<)");
//Regex idsRegex = new Regex(@"(?<=<option value=\"")([0-9]*)");
@@ -37,25 +37,25 @@ namespace DSACore.Auxiliary
var ids = new List<int>();
foreach (var matchGroup in talentMatch.ToList())
- {
if (matchGroup.Success)
{
lines.Add(matchGroup.Groups[3].Value);
ids.Add(int.Parse(matchGroup.Groups[1].Value));
}
- }
-
- for (int j = 0; j < lines.Count; j++)
+ for (var j = 0; j < lines.Count; j++)
{
var talent = lines[j];
- var values = await client.GetStringAsync($"http://diarium.eu/dsa4-forge/ajax/calculate/" + i + "/" + ids[j] + "/0/0/0/0/0/10/0/0/0");
+ var values = await client.GetStringAsync($"http://diarium.eu/dsa4-forge/ajax/calculate/" + i + "/" +
+ ids[j] + "/0/0/0/0/0/10/0/0/0");
values = Regex.Unescape(values.Replace(@"\t", ""));
// ... Use named group in regular expression.
- Regex expression = new Regex(@"(((?<=(<td>))|(?<=(<td style=\""padding:2px\"">))).*?(?=<\/td>))|((?<=<span style=\""font-weight:bold;text-decoration:underline;\"">).*?(?=<\/span>))");
+ var expression =
+ new Regex(
+ @"(((?<=(<td>))|(?<=(<td style=\""padding:2px\"">))).*?(?=<\/td>))|((?<=<span style=\""font-weight:bold;text-decoration:underline;\"">).*?(?=<\/span>))");
// ... See if we matched.
var matches = expression.Matches(values).Select(x => x.ToString()).ToList();
@@ -64,7 +64,6 @@ namespace DSACore.Auxiliary
await AddMelee(i, talent, matches);
Console.Write(j + ",");
//await Task.Delay(TimeSpan.FromSeconds(5));
-
}
Console.WriteLine($"{i}: {ids.Count} => {Weapons.Count}");
@@ -76,17 +75,17 @@ namespace DSACore.Auxiliary
private async Task AddMelee(int i, string talent, List<string> matches)
{
- string name = talent.Replace(' ', '_').Replace(".", "");
+ var name = talent.Replace(' ', '_').Replace(".", "");
if (!matches[1].Equals(string.Empty))
{
var temp = new MeleeWeapon(
name,
matches[1],
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- INI = int.TryParse(matches[3], out int ini) ? ini : 0,
+ INI = int.TryParse(matches[3], out var ini) ? ini : 0,
MW = matches[4],
TpKK = matches[2]
};
@@ -94,6 +93,7 @@ namespace DSACore.Auxiliary
Weapons.Add(temp);
await Database.AddWeapon(temp);
}
+
/*if (i > 23)
{
var range = new RangedWeapon(
@@ -118,15 +118,15 @@ namespace DSACore.Auxiliary
var range = new RangedWeapon(
name,
matches[13].Replace(' ', '+'),
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- AtMod = int.TryParse(matches[18], out int atMod) ? atMod : 0,
- KKMod = int.TryParse(matches[17], out int kkMod) ? kkMod : 0,
+ AtMod = int.TryParse(matches[18], out var atMod) ? atMod : 0,
+ KKMod = int.TryParse(matches[17], out var kkMod) ? kkMod : 0,
AtReach = matches[14],
TpReach = matches[15],
- LoadTime = int.TryParse(matches[18], out int loadTime) ? loadTime : 0
+ LoadTime = int.TryParse(matches[18], out var loadTime) ? loadTime : 0
};
Range.Add(range);
await Database.AddWeapon(range);
@@ -135,17 +135,17 @@ namespace DSACore.Auxiliary
private async Task AddRanged(int i, string talent, List<string> matches)
{
- string name = talent.Replace(' ', '_').Replace(".", "");
+ var name = talent.Replace(' ', '_').Replace(".", "");
if (!matches[1].Equals(string.Empty))
{
var temp = new MeleeWeapon(
name,
matches[1],
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- INI = int.TryParse(matches[3], out int ini) ? ini : 0,
+ INI = int.TryParse(matches[3], out var ini) ? ini : 0,
MW = matches[4],
TpKK = matches[2]
};
@@ -159,20 +159,19 @@ namespace DSACore.Auxiliary
var range = new RangedWeapon(
name,
matches[13].Replace(' ', '+'),
- int.TryParse(matches[10], out int weight) ? weight : 0,
+ int.TryParse(matches[10], out var weight) ? weight : 0,
matches[0].Split(':', StringSplitOptions.RemoveEmptyEntries).First(),
matches[11])
{
- AtMod = int.TryParse(matches[18], out int atMod) ? atMod : 0,
- KKMod = int.TryParse(matches[17], out int kkMod) ? kkMod : 0,
+ AtMod = int.TryParse(matches[18], out var atMod) ? atMod : 0,
+ KKMod = int.TryParse(matches[17], out var kkMod) ? kkMod : 0,
AtReach = matches[14],
TpReach = matches[15],
- LoadTime = int.TryParse(matches[18], out int loadTime) ? loadTime : 0
+ LoadTime = int.TryParse(matches[18], out var loadTime) ? loadTime : 0
};
Range.Add(range);
await Database.AddWeapon(range);
}
}
}
-}
-
+} \ No newline at end of file