|
1 |
| -using GrandHeroFarmer.Modules; |
| 1 | +using GrandHeroFarmer.Bot; |
| 2 | +using GrandHeroFarmer.Modules; |
2 | 3 | using System;
|
3 | 4 | using System.Collections.Generic;
|
4 | 5 | using System.IO;
|
@@ -34,81 +35,28 @@ private static void Main(string[] args)
|
34 | 35 |
|
35 | 36 | try
|
36 | 37 | {
|
37 |
| - Android phone = new Android(); |
| 38 | + AdbWrapper adb = new AdbWrapper(); |
38 | 39 |
|
39 |
| - // Initializing Service Configurations |
40 |
| - ConsoleLogger.WriteTime("Loading service configurations from xml... ", false); |
41 |
| - XDocument doc = XDocument.Load("Configurations/Default.xml"); |
42 |
| - ClickArea startGBHButton = new ClickArea(doc.Descendants("StartGHBButton").FirstOrDefault()); |
43 |
| - ClickArea fightButton = new ClickArea(doc.Descendants("FightButton").FirstOrDefault()); |
44 |
| - ClickArea skipDialogButton = new ClickArea(doc.Descendants("SkipDialogButton").FirstOrDefault()); |
45 |
| - ClickArea autoBattleButton = new ClickArea(doc.Descendants("AutoBattleButton").FirstOrDefault()); |
46 |
| - ClickArea acceptAutoBattleButton = new ClickArea(doc.Descendants("AcceptAutoBattleButton").FirstOrDefault()); |
| 40 | + // Initializing Bot Configurations |
| 41 | + ConsoleLogger.WriteTime("Loading bot configurations from xml... ", false); |
| 42 | + BotConfiguration botConfig = new BotConfiguration("configs"); |
| 43 | + ConsoleLogger.Write("OK", textColor: ConsoleColor.Cyan); |
47 | 44 |
|
48 |
| - int communicateServerTimer = (int)doc.Descendants("CommunicateServerTimer").FirstOrDefault() * 1000; |
49 |
| - int stageTimer = (int)doc.Descendants("StageTimer").FirstOrDefault() * 1000; |
| 45 | + ConsoleLogger.WriteTime("Initializing bot instance... ", false); |
| 46 | + FehBot bot = new FehBot(botConfig); |
50 | 47 | ConsoleLogger.Write("OK", textColor: ConsoleColor.Cyan);
|
51 | 48 |
|
52 | 49 | ConsoleLogger.WriteTime("Setup is done, press enter to start earning feathers.", textColor: ConsoleColor.Cyan);
|
53 | 50 | ConsoleLogger.WriteTime("Press 'Ctrl + C' to exit the application.", newLine: false, textColor: ConsoleColor.Cyan);
|
54 | 51 | Console.ReadLine();
|
55 | 52 |
|
56 |
| - int ciclesCompleted = 1; |
57 |
| - |
58 | 53 | Thread thread = new Thread(() =>
|
59 | 54 | {
|
60 | 55 | Console.Title = string.Format("{0} - Farming", Console.Title);
|
61 | 56 |
|
62 | 57 | while (true)
|
63 | 58 | {
|
64 |
| - Console.WriteLine(); |
65 |
| - ConsoleLogger.WriteTime("Starting cicle ", false); |
66 |
| - ConsoleLogger.Write(string.Format("[{0}]", ciclesCompleted.ToString()), textColor: ConsoleColor.Cyan); |
67 |
| - |
68 |
| - // Click Lunatic Button |
69 |
| - phone.Tap(startGBHButton.GenerateRandomCoords()); |
70 |
| - |
71 |
| - // Click Fight Button |
72 |
| - phone.Tap(fightButton.GenerateRandomCoords()); |
73 |
| - |
74 |
| - // Communicate Server |
75 |
| - Thread.Sleep(communicateServerTimer); |
76 |
| - |
77 |
| - // Click to skip initial animations |
78 |
| - phone.Tap(fightButton.GenerateRandomCoords()); |
79 |
| - |
80 |
| - // Wait until Dialog starts |
81 |
| - Thread.Sleep(2000); |
82 |
| - |
83 |
| - // Skip Dialog |
84 |
| - ConsoleLogger.WriteTime("Skipping initial dialog"); |
85 |
| - phone.Tap(skipDialogButton.GenerateRandomCoords()); |
86 |
| - |
87 |
| - // Wait for initial animations |
88 |
| - Thread.Sleep(3000); |
89 |
| - |
90 |
| - // Click Auto Battle |
91 |
| - ConsoleLogger.WriteTime("Initializing Auto-Battle"); |
92 |
| - phone.Tap(autoBattleButton.GenerateRandomCoords()); |
93 |
| - |
94 |
| - // CLick Accept |
95 |
| - phone.Tap(acceptAutoBattleButton.GenerateRandomCoords()); |
96 |
| - |
97 |
| - // Wait for battle to end |
98 |
| - ConsoleLogger.WriteTime("Waiting for battle to end"); |
99 |
| - Thread.Sleep(stageTimer); |
100 |
| - |
101 |
| - // Click again to skip animations |
102 |
| - phone.Tap(fightButton.GenerateRandomCoords()); |
103 |
| - |
104 |
| - // All done! |
105 |
| - ConsoleLogger.WriteTime("Finished cicle ", false); |
106 |
| - ConsoleLogger.Write(string.Format("[{0}]", ciclesCompleted.ToString()), textColor: ConsoleColor.Cyan); |
107 |
| - |
108 |
| - // Wait to send result to server |
109 |
| - Thread.Sleep(communicateServerTimer + 1000); |
110 |
| - |
111 |
| - ciclesCompleted++; |
| 59 | + bot.Run(adb); |
112 | 60 | }
|
113 | 61 | });
|
114 | 62 |
|
|
0 commit comments