Skip to content

Commit 4e9facc

Browse files
committed
remove location from CurrentBuilding list
1 parent a22696d commit 4e9facc

File tree

4 files changed

+39
-42
lines changed

4 files changed

+39
-42
lines changed

TbsCore/Helpers/BuildingHelper.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -232,26 +232,26 @@ private static bool BuildingIsOnLevel(BuildingEnum building, int lvl, Village vi
232232
/// </summary>
233233
/// <param name="vill"></param>
234234
/// <returns>Whether there were some tasks removed</returns>
235-
public static bool RemoveFinishedCB(Village vill)
236-
{
237-
var tasksDone = vill.Build
238-
.CurrentlyBuilding
239-
.Where(x => x.Duration < DateTime.Now)
240-
.ToList();
241-
242-
if (tasksDone.Count == 0) return false;
243-
244-
foreach (var taskDone in tasksDone)
245-
{
246-
var building = vill.Build.Buildings.FirstOrDefault(x => x.Id == taskDone.Location);
247-
if (building == null) building = vill.Build.Buildings.FirstOrDefault(x => x.Type == taskDone.Building);
248-
if (building == null || building.Type != taskDone.Building) continue;
249-
250-
if (building.Level < taskDone.Level) building.Level = taskDone.Level;
251-
vill.Build.CurrentlyBuilding.Remove(taskDone);
252-
}
253-
return true;
254-
}
235+
//public static bool RemoveFinishedCB(Village vill)
236+
//{
237+
// var tasksDone = vill.Build
238+
// .CurrentlyBuilding
239+
// .Where(x => x.Duration < DateTime.Now)
240+
// .ToList();
241+
242+
// if (tasksDone.Count == 0) return false;
243+
244+
// foreach (var taskDone in tasksDone)
245+
// {
246+
// var building = vill.Build.Buildings.FirstOrDefault(x => x.Id == taskDone.Location);
247+
// if (building == null) building = vill.Build.Buildings.FirstOrDefault(x => x.Type == taskDone.Building);
248+
// if (building == null || building.Type != taskDone.Building) continue;
249+
250+
// if (building.Level < taskDone.Level) building.Level = taskDone.Level;
251+
// vill.Build.CurrentlyBuilding.Remove(taskDone);
252+
// }
253+
// return true;
254+
//}
255255

256256
/// <summary>
257257
/// Used by building task to get the url for navigation
@@ -294,11 +294,11 @@ public static bool IsTaskCompleted(Village vill, Account acc, BuildingTask task)
294294
if (task.Level <= building.Level) return true;
295295

296296
// If the building is being upgraded to the desired level, task is complete
297-
var cb = vill.Build
298-
.CurrentlyBuilding
299-
.OrderByDescending(x => x.Level)
300-
.FirstOrDefault(x => x.Location == task.BuildingId);
301-
if (cb != null && task.Level <= cb.Level) return true;
297+
//var cb = vill.Build
298+
// .CurrentlyBuilding
299+
// .OrderByDescending(x => x.Level)
300+
// .FirstOrDefault(x => x.Location == task.BuildingId);
301+
//if (cb != null && task.Level <= cb.Level) return true;
302302
break;
303303

304304
case BuildingType.AutoUpgradeResFields:
@@ -442,7 +442,7 @@ internal static bool UpgradeBuildingForOneLvl(Account acc, Village vill, Buildin
442442

443443
var currentLvl = (int)upgrade.Level;
444444

445-
RemoveFinishedCB(vill);
445+
// RemoveFinishedCB(vill);
446446
currentLvl += vill.Build.CurrentlyBuilding.Count(x => x.Building == building);
447447

448448
if (BuildingsData.MaxBuildingLevel(acc, building) == currentLvl)
@@ -479,7 +479,7 @@ internal static bool UpgradeBuildingForOneLvl(Account acc, Village vill, Buildin
479479
/// <returns>Whether we have all prerequisite buildings</returns>
480480
public static bool AddBuildingPrerequisites(Account acc, Village vill, BuildingEnum building, bool bottom = true)
481481
{
482-
RemoveFinishedCB(vill);
482+
// RemoveFinishedCB(vill);
483483

484484
(var tribe, var prereqs) = BuildingsData.GetBuildingPrerequisites(building);
485485
if (acc.AccInfo.Tribe != tribe && tribe != TribeEnum.Any) return false;

TbsCore/Models/VillageModels/BuildingCurrently.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public class BuildingCurrently
88
public DateTime Duration { get; set; }
99
public byte Level { get; set; }
1010
public BuildingEnum Building { get; set; }
11-
public int Location { get; set; }
11+
//public int Location { get; set; }
1212
}
1313
}

TbsCore/Parsers/InfrastructureParser.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public static List<BuildingCurrently> CurrentlyBuilding(HtmlDocument htmlDoc, Ac
8282
Building = name,
8383
Duration = DateTime.Now.Add(duration),
8484
Level = (byte)Parser.RemoveNonNumeric(level),
85-
Location = -1,
8685
});
8786
}
8887
return ret;

TbsCore/Tasks/LowLevel/UpgradeBuilding.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ private async Task<TaskRes> Upgrade(Account acc, HtmlNode node)
150150
var building = Vill.Build.Buildings.FirstOrDefault(x => x.Id == this.Task.BuildingId);
151151
lvl = building.Level;
152152
// Check if building is under construction
153-
if (building.UnderConstruction)
154-
{
155-
// Check currently building
156-
var cb = Vill.Build.CurrentlyBuilding.OrderByDescending(x => x.Level).FirstOrDefault(x => x.Location == building.Id);
157-
if (cb != null && lvl < cb.Level) lvl = cb.Level;
158-
}
153+
//if (building.UnderConstruction)
154+
//{
155+
// // Check currently building
156+
// var cb = Vill.Build.CurrentlyBuilding.OrderByDescending(x => x.Level).FirstOrDefault(x => x.Location == building.Id);
157+
// if (cb != null && lvl < cb.Level) lvl = cb.Level;
158+
//}
159159

160160
if (Task.Level <= lvl)
161161
{
@@ -248,11 +248,11 @@ private async Task PostTaskCheckDorf(Account acc)
248248
}
249249

250250
// Check if the task is completed
251-
var taskCb = Vill.Build
252-
.CurrentlyBuilding
253-
.OrderByDescending(x => x.Level)
254-
.FirstOrDefault(x => x.Location == this.Task.BuildingId);
255-
if (taskCb != null && this.Task.TaskType == BuildingType.General && this.Task.Level <= taskCb.Level) RemoveCurrentTask();
251+
//var taskCb = Vill.Build
252+
// .CurrentlyBuilding
253+
// .OrderByDescending(x => x.Level)
254+
// .FirstOrDefault(x => x.Location == this.Task.BuildingId);
255+
//if (taskCb != null && this.Task.TaskType == BuildingType.General && this.Task.Level <= taskCb.Level) RemoveCurrentTask();
256256
}
257257

258258
/// <summary>
@@ -347,8 +347,6 @@ public async Task<bool> TTWarsTryFastUpgrade(Account acc, string url)
347347
/// <param name="acc">Account</param>
348348
public void ConfigNextExecute(Account acc, bool restart = true)
349349
{
350-
RemoveFinishedCB(Vill);
351-
352350
if (Vill.Build.AutoBuildResourceBonusBuildings) CheckResourceBonus(acc, Vill, restart);
353351

354352
// Checks if we have enough FreeCrop (above 0)

0 commit comments

Comments
 (0)