@@ -232,26 +232,26 @@ private static bool BuildingIsOnLevel(BuildingEnum building, int lvl, Village vi
232
232
/// </summary>
233
233
/// <param name="vill"></param>
234
234
/// <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
+ }
255
255
256
256
/// <summary>
257
257
/// Used by building task to get the url for navigation
@@ -440,10 +440,14 @@ internal static bool UpgradeBuildingForOneLvl(Account acc, Village vill, Buildin
440
440
} , bottom ) ;
441
441
}
442
442
443
+ // Current lvl in bot's data
443
444
var currentLvl = ( int ) upgrade . Level ;
444
445
445
- // RemoveFinishedCB(vill);
446
- currentLvl += vill . Build . CurrentlyBuilding . Count ( x => x . Building == building ) ;
446
+ RemoveFinishedCB ( vill ) ;
447
+
448
+ // Current lvl in current building list
449
+ var currentBuilding = vill . Build . CurrentlyBuilding . FirstOrDefault ( x => x . Building == building ) ;
450
+ if ( currentBuilding != null ) currentLvl = currentBuilding . Level ;
447
451
448
452
if ( BuildingsData . MaxBuildingLevel ( acc , building ) == currentLvl )
449
453
{
@@ -479,7 +483,7 @@ internal static bool UpgradeBuildingForOneLvl(Account acc, Village vill, Buildin
479
483
/// <returns>Whether we have all prerequisite buildings</returns>
480
484
public static bool AddBuildingPrerequisites ( Account acc , Village vill , BuildingEnum building , bool bottom = true )
481
485
{
482
- // RemoveFinishedCB(vill);
486
+ RemoveFinishedCB ( vill ) ;
483
487
484
488
( var tribe , var prereqs ) = BuildingsData . GetBuildingPrerequisites ( building ) ;
485
489
if ( acc . AccInfo . Tribe != tribe && tribe != TribeEnum . Any ) return false ;
0 commit comments