@@ -53,6 +53,7 @@ public override async Task<TaskRes> Execute(Account acc)
53
53
if ( acc . AccInfo . ServerVersion == ServerVersionEnum . TTwars && ! _buildingTask . ConstructNew )
54
54
{
55
55
acc . Logger . Information ( "Try using TTWars fast build method" , this ) ;
56
+ await Task . Delay ( AccountHelper . Delay ( acc ) ) ;
56
57
var fastUpgrade = await TTWarsTryFastUpgrade ( acc , $ "{ acc . AccInfo . ServerUrl } /build.php?id={ _buildingTask . BuildingId } ") ;
57
58
if ( fastUpgrade ) continue ;
58
59
acc . Logger . Information ( "Using TTWars fast build method failed. Continue normal method" , this ) ;
@@ -99,11 +100,19 @@ private async Task<bool> Construct(Account acc)
99
100
// Check for prerequisites
100
101
if ( button == null )
101
102
{
103
+ Retry ( acc , "Button disappear." ) ;
102
104
return false ;
103
105
}
104
106
105
- await DriverHelper . ClickById ( acc , button . Id ) ;
106
-
107
+ await Task . Delay ( AccountHelper . Delay ( acc ) ) ;
108
+ acc . Logger . Information ( $ "Starting contruct { _buildingTask . Building } in { Vill . Name } ") ;
109
+ var element = acc . Wb . Driver . FindElement ( By . XPath ( button . XPath ) ) ;
110
+ if ( element == null )
111
+ {
112
+ Retry ( acc , "Button disappear." ) ;
113
+ return false ;
114
+ }
115
+ element . Click ( ) ;
107
116
_buildingTask . ConstructNew = false ;
108
117
109
118
acc . Logger . Warning ( $ "Started construction of { _buildingTask . Building } in { Vill . Name } ") ;
@@ -168,14 +177,14 @@ private async Task<bool> Upgrade(Account acc)
168
177
169
178
if ( upgradeButton == null )
170
179
{
171
- acc . Logger . Information ( $ "We wanted to upgrade { _buildingTask . Building } , but no 'upgrade' button was found!", this ) ;
180
+ Retry ( acc , $ "We wanted to upgrade { _buildingTask . Building } , but no 'upgrade' button was found!") ;
172
181
return false ;
173
182
}
174
183
175
184
// Not enough resources?
176
185
if ( acc . AccInfo . ServerVersion == ServerVersionEnum . T4_5 && errorMessage != null )
177
186
{
178
- acc . Logger . Information ( $ "We wanted to upgrade { _buildingTask . Building } , but there was an error message:\n { errorMessage . InnerText } ", this ) ;
187
+ Retry ( acc , $ "We wanted to upgrade { _buildingTask . Building } , but there was an error message:\n { errorMessage . InnerText } ") ;
179
188
return false ;
180
189
}
181
190
@@ -188,12 +197,23 @@ private async Task<bool> Upgrade(Account acc)
188
197
if ( acc . AccInfo . ServerVersion == ServerVersionEnum . T4_5 && buildDuration . TotalMinutes > acc . Settings . WatchAdAbove )
189
198
{
190
199
// watchAd = await TryFastUpgrade(acc);
200
+ acc . Logger . Information ( "Try using watch ads upgrade button" ) ;
201
+ acc . Logger . Information ( "Watch ads function is disable because of bugs from Chrome. We cannot do anything about this" ) ;
191
202
}
192
203
193
204
if ( ! watchAd )
194
205
{
206
+ acc . Logger . Information ( "Using normal upgrade button" ) ;
207
+
195
208
upgradeButton = buttons . FirstOrDefault ( x => x . HasClass ( "build" ) ) ;
196
- await DriverHelper . ClickById ( acc , upgradeButton . Id ) ; // Normal upgrade
209
+
210
+ var element = acc . Wb . Driver . FindElement ( By . XPath ( upgradeButton . XPath ) ) ;
211
+ if ( element == null )
212
+ {
213
+ Retry ( acc , "Button disappear." ) ;
214
+ return false ;
215
+ }
216
+ element . Click ( ) ;
197
217
}
198
218
199
219
acc . Logger . Information ( $ "Upgraded { _buildingTask . Building } to level { lvl + 1 } in { Vill . Name } ", this ) ;
@@ -440,11 +460,13 @@ private async Task<bool> FreeCropCondition(Account acc)
440
460
441
461
private async Task MoveIntoBuilding ( Account acc )
442
462
{
463
+ await Task . Delay ( AccountHelper . Delay ( acc ) ) ;
443
464
acc . Logger . Information ( $ "Move into building { _buildingTask . Building } ", this ) ;
444
465
await NavigationHelper . EnterBuilding ( acc , Vill , ( int ) _buildingTask . BuildingId ) ;
445
466
var build = Vill . Build . Buildings . FirstOrDefault ( x => x . Id == _buildingTask . BuildingId ) ;
446
467
if ( build . Type == BuildingEnum . Site )
447
468
{
469
+ await Task . Delay ( AccountHelper . Delay ( acc ) ) ;
448
470
acc . Logger . Information ( $ "This is contruct task, choose correct tab for building { _buildingTask . Building } ", this ) ;
449
471
await NavigationHelper . ToConstructionTab ( acc , _buildingTask . Building ) ;
450
472
}
0 commit comments