5
5
using TbsCore . Models . AccModels ;
6
6
using TbsCore . Models . JsObjects ;
7
7
using TbsCore . Models . VillageModels ;
8
- using TravBotSharp . Files . Helpers ;
9
- using TravBotSharp . Files . Parsers ;
10
- using TravBotSharp . Files . Tasks . LowLevel ;
11
- using static TravBotSharp . Files . Tasks . BotTask ;
8
+ using TbsCore . Helpers ;
9
+ using TbsCore . Parsers ;
10
+ using TbsCore . Tasks . LowLevel ;
11
+ using static TbsCore . Tasks . BotTask ;
12
12
13
13
namespace TbsCore . Helpers
14
14
{
@@ -78,7 +78,7 @@ public static List<Action> GetPostLoadTasks(Account acc)
78
78
villExpansionReady != null )
79
79
{
80
80
villExpansionReady . Expansion . ExpansionAvailable = false ;
81
- TaskExecutor . AddTaskIfNotExists ( acc , new SendSettlers ( ) { ExecuteAt = DateTime . Now , Vill = villExpansionReady } ) ;
81
+ acc . Tasks . Add ( new SendSettlers ( ) { ExecuteAt = DateTime . Now , Vill = villExpansionReady } , true ) ;
82
82
}
83
83
} ,
84
84
// 4: claim Beginner Quests:
@@ -90,7 +90,7 @@ public static List<Action> GetPostLoadTasks(Account acc)
90
90
acc . Wb . Html . GetElementbyId ( "mentorTaskList" ) == null &&
91
91
acc . Quests . ClaimBeginnerQuests )
92
92
{
93
- TaskExecutor . AddTaskIfNotExists ( acc , new ClaimBeginnerTask2021 ( ) { ExecuteAt = DateTime . Now } ) ;
93
+ acc . Tasks . Add ( new ClaimBeginnerTask2021 ( ) { ExecuteAt = DateTime . Now } , true ) ;
94
94
return ;
95
95
}
96
96
@@ -100,12 +100,12 @@ public static List<Action> GetPostLoadTasks(Account acc)
100
100
acc . Quests . ClaimBeginnerQuests
101
101
)
102
102
{
103
- TaskExecutor . AddTaskIfNotExists ( acc , new ClaimBeginnerTask ( )
103
+ acc . Tasks . Add ( new ClaimBeginnerTask ( )
104
104
{
105
105
ExecuteAt = DateTime . Now ,
106
106
QuestToClaim = claimQuest ,
107
107
Vill = VillageHelper . VillageFromId ( acc , acc . Quests . VillToClaim )
108
- } ) ;
108
+ } , true ) ;
109
109
}
110
110
} ,
111
111
// 5: claim Daily Quest:
@@ -115,11 +115,11 @@ public static List<Action> GetPostLoadTasks(Account acc)
115
115
RightBarParser . CheckDailyQuest ( html ) &&
116
116
acc . Quests . ClaimDailyQuests )
117
117
{
118
- TaskExecutor . AddTaskIfNotExists ( acc , new ClaimDailyTask ( )
118
+ acc . Tasks . Add ( new ClaimDailyTask ( )
119
119
{
120
120
ExecuteAt = DateTime . Now ,
121
121
Vill = VillageHelper . VillageFromId ( acc , acc . Quests . VillToClaim )
122
- } ) ;
122
+ } , true ) ;
123
123
}
124
124
} ,
125
125
// 6: Parse gold/silver
@@ -139,11 +139,11 @@ public static List<Action> GetPostLoadTasks(Account acc)
139
139
&& ! acc . Wb . CurrentUrl . Contains ( "messages.php" )
140
140
&& acc . Settings . AutoReadIgms )
141
141
{
142
- TaskExecutor . AddTaskIfNotExists ( acc , new ReadMessage ( )
142
+ acc . Tasks . Add ( new ReadMessage ( )
143
143
{
144
144
ExecuteAt = DateTime . Now . AddSeconds ( ran . Next ( 10 , 600 ) ) , // Read msg in next 10-600 seconds
145
145
Priority = TaskPriority . Low
146
- } ) ;
146
+ } , true ) ;
147
147
}
148
148
} ,
149
149
// 9: JS resources
@@ -176,18 +176,18 @@ public static List<Action> GetPostLoadTasks(Account acc)
176
176
vill . Market . Npc . Enabled &&
177
177
( vill . Market . Npc . NpcIfOverflow || ! MarketHelper . NpcWillOverflow ( vill ) ) )
178
178
{ //npc crop!
179
- TaskExecutor . AddTaskIfNotExistInVillage ( acc , vill , new NPC ( )
179
+ acc . Tasks . Add ( new NPC ( )
180
180
{
181
181
ExecuteAt = DateTime . MinValue ,
182
182
Vill = vill
183
- } ) ;
183
+ } , true , vill ) ;
184
184
}
185
185
} ,
186
186
// 14: TTwars plus and boost
187
187
( ) => {
188
188
if ( acc . Settings . AutoActivateProductionBoost && CheckProductionBoost ( acc ) )
189
189
{
190
- TaskExecutor . AddTask ( acc , new TTWarsPlusAndBoost ( ) {
190
+ acc . Tasks . Add ( new TTWarsPlusAndBoost ( ) {
191
191
ExecuteAt = DateTime . Now . AddSeconds ( 1 )
192
192
} ) ;
193
193
}
@@ -201,11 +201,11 @@ public static List<Action> GetPostLoadTasks(Account acc)
201
201
vill . Build . CurrentlyBuilding . LastOrDefault ( ) . Duration
202
202
>= DateTime . Now . AddMinutes ( vill . Build . InstaBuildMinutes ) )
203
203
{
204
- TaskExecutor . AddTaskIfNotExistInVillage ( acc , vill , new InstaUpgrade ( )
204
+ acc . Tasks . Add ( new InstaUpgrade ( )
205
205
{
206
206
Vill = vill ,
207
207
ExecuteAt = DateTime . Now . AddHours ( - 1 )
208
- } ) ;
208
+ } , true , vill ) ;
209
209
}
210
210
} ,
211
211
// 16: Adventure num
@@ -226,29 +226,29 @@ public static List<Action> GetPostLoadTasks(Account acc)
226
226
// Update adventures
227
227
if ( homeVill == null )
228
228
{
229
- TaskExecutor . AddTask ( acc , new HeroUpdateInfo ( ) { ExecuteAt = DateTime . Now } ) ;
229
+ acc . Tasks . Add ( new HeroUpdateInfo ( ) { ExecuteAt = DateTime . Now } ) ;
230
230
}
231
231
else if ( heroReady &&
232
232
( homeVill . Build . Buildings . Any ( x => x . Type == Classificator . BuildingEnum . RallyPoint && 0 < x . Level ) ) &&
233
233
( acc . Hero . AdventureNum != acc . Hero . Adventures . Count ( ) || HeroHelper . AdventureInRange ( acc ) ) )
234
234
{
235
235
// Update adventures
236
- TaskExecutor . AddTaskIfNotExists ( acc , new StartAdventure ( ) { ExecuteAt = DateTime . Now . AddSeconds ( 10 ) } ) ;
236
+ acc . Tasks . Add ( new StartAdventure ( ) { ExecuteAt = DateTime . Now . AddSeconds ( 10 ) } , true ) ;
237
237
}
238
238
if ( acc . Hero . AdventureNum == 0 && acc . Hero . Settings . BuyAdventures ) //for UNL servers, buy adventures
239
239
{
240
- TaskExecutor . AddTaskIfNotExists ( acc , new TTWarsBuyAdventure ( ) { ExecuteAt = DateTime . Now . AddSeconds ( 5 ) } ) ;
240
+ acc . Tasks . Add ( new TTWarsBuyAdventure ( ) { ExecuteAt = DateTime . Now . AddSeconds ( 5 ) } , true ) ;
241
241
}
242
242
if ( acc . Hero . Status == Hero . StatusEnum . Dead && acc . Hero . Settings . AutoReviveHero ) //if hero is dead, revive him
243
243
{
244
- TaskExecutor . AddTaskIfNotExists ( acc , new ReviveHero ( ) {
244
+ acc . Tasks . Add ( new ReviveHero ( ) {
245
245
ExecuteAt = DateTime . Now . AddSeconds ( 5 ) ,
246
246
Vill = AccountHelper . GetHeroReviveVillage ( acc )
247
- } ) ;
247
+ } , true ) ;
248
248
}
249
249
if ( HeroParser . LeveledUp ( html , acc . AccInfo . ServerVersion ) && acc . Hero . Settings . AutoSetPoints )
250
250
{
251
- TaskExecutor . AddTaskIfNotExists ( acc , new HeroSetPoints ( ) { ExecuteAt = DateTime . Now } ) ;
251
+ acc . Tasks . Add ( new HeroSetPoints ( ) { ExecuteAt = DateTime . Now } , true ) ;
252
252
}
253
253
} ,
254
254
// 20: build more storage
@@ -259,7 +259,7 @@ public static List<Action> GetPostLoadTasks(Account acc)
259
259
acc . Wb . Html . GetElementbyId ( "sidebarBoxInfobox" ) . Descendants ( "button" ) . Any ( x=> x . GetAttributeValue ( "value" , "" ) == "Extend" ) )
260
260
{
261
261
// infoType_25 ?
262
- TaskExecutor . AddTaskIfNotExists ( acc , new ExtendProtection ( ) { ExecuteAt = DateTime . Now } ) ;
262
+ acc . Tasks . Add ( new ExtendProtection ( ) { ExecuteAt = DateTime . Now } , true ) ;
263
263
}
264
264
}
265
265
} ;
0 commit comments