1
- using GrandHeroFarmer . Helpers ;
1
+ using GrandHeroFarmer . Modules ;
2
2
using SharpAdbClient ;
3
3
using System ;
4
4
using System . Collections . Generic ;
5
+ using System . Diagnostics ;
5
6
using System . Linq ;
6
7
using System . Text ;
7
8
using System . Threading ;
@@ -13,15 +14,35 @@ namespace GrandHeroFarmer
13
14
{
14
15
class Program
15
16
{
17
+ private static readonly List < string > puns = new List < string >
18
+ {
19
+ "Just for feathers and love" ,
20
+ "Just one more +10 and I'm done" ,
21
+ "We need more Armads in the game" ,
22
+ "Just Tiki." ,
23
+ "r/OrderOfHeroes is pretty neat" ,
24
+ "/feg/ is cozy sometimes"
25
+ } ;
26
+
27
+ public static readonly Random rnd = new Random ( ) ;
28
+
16
29
static void Main ( string [ ] args )
17
30
{
18
- ConsoleLogger . WriteLine ( "Welcome to Feh Farmer" , Helpers . Type . Info , true , ConsoleColor . DarkCyan ) ;
31
+ Console . Title = "Grand Hero Farmer v" + Helpers . GetProgramVersion ( ) ;
32
+ Console . Clear ( ) ;
33
+
34
+ Console . WriteLine ( ) ;
35
+ ConsoleLogger . WriteCenter ( "Grand Hero Farmer" , textColor : ConsoleColor . Cyan , backgroundColor : ConsoleColor . DarkCyan ) ;
36
+
37
+ ConsoleLogger . WriteCenter ( puns [ rnd . Next ( puns . Count ) ] , true , textColor : ConsoleColor . Magenta ) ;
38
+
39
+ ConsoleLogger . WriteTime ( "Starting program..." ) ;
19
40
try
20
41
{
21
42
Android phone = new Android ( ) ;
22
43
23
44
//Initializing Service Configurations
24
- ConsoleLogger . Write ( "Loading service configurations from xml... " , Helpers . Type . Default ) ;
45
+ ConsoleLogger . WriteTime ( "Loading service configurations from xml... " , false ) ;
25
46
XDocument doc = XDocument . Load ( "Configurations/Default.xml" ) ;
26
47
ClickArea startGBHButton = new ClickArea ( doc . Descendants ( "StartGHBButton" ) . FirstOrDefault ( ) ) ;
27
48
ClickArea fightButton = new ClickArea ( doc . Descendants ( "FightButton" ) . FirstOrDefault ( ) ) ;
@@ -31,21 +52,23 @@ static void Main(string[] args)
31
52
32
53
int communicateServerTimer = ( ( int ) ( doc . Descendants ( "CommunicateServerTimer" ) . FirstOrDefault ( ) ) * 1000 ) ;
33
54
int stageTimer = ( ( int ) ( doc . Descendants ( "StageTimer" ) . FirstOrDefault ( ) ) * 1000 ) ;
55
+ ConsoleLogger . Write ( "OK" , textColor : ConsoleColor . Cyan ) ;
34
56
35
- ConsoleLogger . WriteLine ( "OK" , Helpers . Type . Info , false ) ;
36
-
37
- ConsoleLogger . WriteLine ( "Setup is done, press enter to start earning feathers." , Helpers . Type . Info ) ;
38
- ConsoleLogger . Write ( "Press 'Ctrl + C' to exit the application." , Helpers . Type . Info ) ;
57
+ ConsoleLogger . WriteTime ( "Setup is done, press enter to start earning feathers." , textColor : ConsoleColor . Cyan ) ;
58
+ ConsoleLogger . WriteTime ( "Press 'Ctrl + C' to exit the application." , newLine : false , textColor : ConsoleColor . Cyan ) ;
39
59
Console . ReadLine ( ) ;
40
60
41
- int iterations = 1 ;
61
+ int cicles = 1 ;
42
62
43
63
Thread thread = new Thread ( ( ) => {
64
+
65
+ Console . Title = "Grand Hero Farmer - Farming" ;
66
+
44
67
while ( true )
45
68
{
46
69
Console . WriteLine ( ) ;
47
- ConsoleLogger . Write ( "Starting iteration " , Helpers . Type . Default , true ) ;
48
- ConsoleLogger . WriteLine ( iterations . ToString ( ) , Helpers . Type . Info , false ) ;
70
+ ConsoleLogger . WriteTime ( "Starting cicle " , false ) ;
71
+ ConsoleLogger . Write ( "[" + cicles . ToString ( ) + "]" , textColor : ConsoleColor . Cyan ) ;
49
72
50
73
// Click Lunatic Button
51
74
phone . Tap ( startGBHButton . GenerateRandomCoords ( ) ) ;
@@ -63,53 +86,52 @@ static void Main(string[] args)
63
86
Thread . Sleep ( 2000 ) ;
64
87
65
88
// Skip Dialog
66
- ConsoleLogger . WriteLine ( "Skipping initial dialog" , Helpers . Type . Default ) ;
89
+ ConsoleLogger . WriteTime ( "Skipping initial dialog" ) ;
67
90
phone . Tap ( skipDialogButton . GenerateRandomCoords ( ) ) ;
68
91
69
92
// Wait for initial animations
70
93
Thread . Sleep ( 3000 ) ;
71
94
72
95
// Click Auto Battle
73
- ConsoleLogger . WriteLine ( "Initializing Auto-Battle" , Helpers . Type . Default ) ;
96
+ ConsoleLogger . WriteTime ( "Initializing Auto-Battle" ) ;
74
97
phone . Tap ( autoBattleButton . GenerateRandomCoords ( ) ) ;
75
98
76
99
// CLick Accept
77
100
phone . Tap ( acceptAutoBattleButton . GenerateRandomCoords ( ) ) ;
78
101
79
102
// Wait for battle to end
80
- ConsoleLogger . WriteLine ( "Waiting for battle to end" , Helpers . Type . Default ) ;
103
+ ConsoleLogger . WriteTime ( "Waiting for battle to end" ) ;
81
104
Thread . Sleep ( stageTimer ) ;
82
105
83
106
// Click again to skip animations
84
107
phone . Tap ( fightButton . GenerateRandomCoords ( ) ) ;
85
108
109
+ // All done!
110
+ ConsoleLogger . WriteTime ( "Finished cicle " , false ) ;
111
+ ConsoleLogger . Write ( "[" + cicles . ToString ( ) + "]" , textColor : ConsoleColor . Cyan ) ;
112
+
86
113
// Wait to send result to server
87
114
Thread . Sleep ( communicateServerTimer + 1000 ) ;
88
115
89
- // All done!
90
- ConsoleLogger . Write ( "Finished iteration " , Helpers . Type . Default ) ;
91
- ConsoleLogger . WriteLine ( iterations . ToString ( ) , Helpers . Type . Info , false ) ;
92
-
93
- iterations ++ ;
116
+ cicles ++ ;
94
117
}
95
-
96
118
} ) ;
97
119
thread . Start ( ) ;
98
120
99
121
}
100
122
catch ( System . IO . FileNotFoundException )
101
123
{
102
- ConsoleLogger . WriteLine ( "FAILED" , Helpers . Type . Error , false ) ;
103
- ConsoleLogger . WriteLine ( "Couldn't Load XML File. Press Enter to exit the application." , Helpers . Type . Error , true ) ;
124
+ ConsoleLogger . Write ( "FAILED" , textColor : ConsoleColor . Red ) ;
125
+ ConsoleLogger . WriteTime ( "Couldn't Load XML File. Press Enter to exit the application." ) ;
104
126
}
105
127
catch ( NullReferenceException )
106
128
{
107
- ConsoleLogger . WriteLine ( "FAILED" , Helpers . Type . Error , false ) ;
108
- ConsoleLogger . WriteLine ( "Looks like your XML file is malformed. Press Enter to exit the application." , Helpers . Type . Error , true ) ;
129
+ ConsoleLogger . Write ( "FAILED" , textColor : ConsoleColor . Red ) ;
130
+ ConsoleLogger . WriteTime ( "Looks like your XML file is malformed. Press Enter to exit the application." ) ;
109
131
}
110
132
catch ( Exception ex )
111
133
{
112
- ConsoleLogger . WriteLine ( ex . ToString ( ) , Helpers . Type . Error , false ) ;
134
+ ConsoleLogger . Write ( ex . ToString ( ) , textColor : ConsoleColor . Red ) ;
113
135
}
114
136
finally
115
137
{
0 commit comments