Skip to content

Commit a22696d

Browse files
committed
change back to parse string to get name building instead of bld obj
1 parent 24d5300 commit a22696d

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

TbsCore/Core/TaskExecutor.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,8 @@ private static void UpdateCurrentlyBuilding(Account acc, Village vill)
232232
var cb = InfrastructureParser.CurrentlyBuilding(acc.Wb.Html, acc);
233233
if (cb == null) return; // Nothing is currently building
234234

235-
var bldJson = DriverHelper.GetJsObj<string>(acc, "JSON.stringify(bld);");
236-
if (string.IsNullOrEmpty(bldJson)) return;
237-
var bldJs = JsonConvert.DeserializeObject<List<Bld>>(bldJson);
238-
239-
// Combine data from two sources about currently building (JS object and HTML table)
240-
// We get time duration and level from HTML
241-
// and build location, level and building (type) from JSON
242235
for (int i = 0; i < cb.Count; i++)
243236
{
244-
cb[i].Building = bldJs[i].Building;
245-
cb[i].Location = bldJs[i].Location;
246-
cb[i].Level = (byte)bldJs[i].Level;
247-
248237
vill.Build.CurrentlyBuilding.Add(cb[i]);
249238
}
250239
}

TbsCore/Parsers/InfrastructureParser.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,16 @@ public static List<BuildingCurrently> CurrentlyBuilding(HtmlDocument htmlDoc, Ac
7373
{
7474
var duration = TimeParser.ParseTimer(row);
7575
var level = row.Descendants("span").FirstOrDefault(x => x.HasClass("lvl")).InnerText;
76+
var strName = row.Descendants("div").FirstOrDefault(x => x.HasClass("name")).ChildNodes[0].InnerText.Trim(new[] { '\t', '\n', '\r', ' ' });
77+
strName = string.Join("", strName.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));
78+
Enum.TryParse(strName, out Classificator.BuildingEnum name);
7679

7780
ret.Add(new BuildingCurrently()
7881
{
82+
Building = name,
7983
Duration = DateTime.Now.Add(duration),
8084
Level = (byte)Parser.RemoveNonNumeric(level),
85+
Location = -1,
8186
});
8287
}
8388
return ret;

0 commit comments

Comments
 (0)