1
1
using GrandHeroFarmer . Modules ;
2
- using SharpAdbClient ;
3
2
using System ;
4
3
using System . Collections . Generic ;
5
- using System . Diagnostics ;
4
+ using System . IO ;
6
5
using System . Linq ;
7
- using System . Text ;
8
6
using System . Threading ;
9
- using System . Threading . Tasks ;
10
- using System . Xml ;
11
7
using System . Xml . Linq ;
12
8
13
9
namespace GrandHeroFarmer
14
10
{
15
- class Program
11
+ internal class Program
16
12
{
17
13
private static readonly List < string > puns = new List < string >
18
14
{
@@ -26,22 +22,21 @@ class Program
26
22
27
23
public static readonly Random rnd = new Random ( ) ;
28
24
29
- static void Main ( string [ ] args )
25
+ private static void Main ( string [ ] args )
30
26
{
31
- Console . Title = "Grand Hero Farmer v" + Helpers . GetProgramVersion ( ) ;
27
+ Console . Title = string . Format ( "Grand Hero Farmer v{0}" , Helpers . GetProgramVersion ( ) ) ;
32
28
Console . Clear ( ) ;
33
29
34
30
Console . WriteLine ( ) ;
35
31
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
-
32
+ ConsoleLogger . WriteCenter ( puns [ rnd . Next ( puns . Count ) ] , newLine : true , textColor : ConsoleColor . Magenta ) ;
39
33
ConsoleLogger . WriteTime ( "Starting program..." ) ;
34
+
40
35
try
41
36
{
42
37
Android phone = new Android ( ) ;
43
38
44
- //Initializing Service Configurations
39
+ // Initializing Service Configurations
45
40
ConsoleLogger . WriteTime ( "Loading service configurations from xml... " , false ) ;
46
41
XDocument doc = XDocument . Load ( "Configurations/Default.xml" ) ;
47
42
ClickArea startGBHButton = new ClickArea ( doc . Descendants ( "StartGHBButton" ) . FirstOrDefault ( ) ) ;
@@ -50,25 +45,25 @@ static void Main(string[] args)
50
45
ClickArea autoBattleButton = new ClickArea ( doc . Descendants ( "AutoBattleButton" ) . FirstOrDefault ( ) ) ;
51
46
ClickArea acceptAutoBattleButton = new ClickArea ( doc . Descendants ( "AcceptAutoBattleButton" ) . FirstOrDefault ( ) ) ;
52
47
53
- int communicateServerTimer = ( ( int ) ( doc . Descendants ( "CommunicateServerTimer" ) . FirstOrDefault ( ) ) * 1000 ) ;
54
- int stageTimer = ( ( int ) ( doc . Descendants ( "StageTimer" ) . FirstOrDefault ( ) ) * 1000 ) ;
48
+ int communicateServerTimer = ( int ) doc . Descendants ( "CommunicateServerTimer" ) . FirstOrDefault ( ) * 1000 ;
49
+ int stageTimer = ( int ) doc . Descendants ( "StageTimer" ) . FirstOrDefault ( ) * 1000 ;
55
50
ConsoleLogger . Write ( "OK" , textColor : ConsoleColor . Cyan ) ;
56
51
57
52
ConsoleLogger . WriteTime ( "Setup is done, press enter to start earning feathers." , textColor : ConsoleColor . Cyan ) ;
58
53
ConsoleLogger . WriteTime ( "Press 'Ctrl + C' to exit the application." , newLine : false , textColor : ConsoleColor . Cyan ) ;
59
54
Console . ReadLine ( ) ;
60
55
61
- int cicles = 1 ;
56
+ int ciclesCompleted = 1 ;
62
57
63
- Thread thread = new Thread ( ( ) => {
64
-
65
- Console . Title = "Grand Hero Farmer - Farming";
58
+ Thread thread = new Thread ( ( ) =>
59
+ {
60
+ Console . Title = string . Format ( "{0} - Farming", Console . Title ) ;
66
61
67
62
while ( true )
68
63
{
69
64
Console . WriteLine ( ) ;
70
65
ConsoleLogger . WriteTime ( "Starting cicle " , false ) ;
71
- ConsoleLogger . Write ( "[" + cicles . ToString ( ) + "]" , textColor : ConsoleColor . Cyan ) ;
66
+ ConsoleLogger . Write ( string . Format ( "[{0}]" , ciclesCompleted . ToString ( ) ) , textColor : ConsoleColor . Cyan ) ;
72
67
73
68
// Click Lunatic Button
74
69
phone . Tap ( startGBHButton . GenerateRandomCoords ( ) ) ;
@@ -108,19 +103,18 @@ static void Main(string[] args)
108
103
109
104
// All done!
110
105
ConsoleLogger . WriteTime ( "Finished cicle " , false ) ;
111
- ConsoleLogger . Write ( "[" + cicles . ToString ( ) + "]" , textColor : ConsoleColor . Cyan ) ;
106
+ ConsoleLogger . Write ( string . Format ( "[{0}]" , ciclesCompleted . ToString ( ) ) , textColor : ConsoleColor . Cyan ) ;
112
107
113
108
// Wait to send result to server
114
109
Thread . Sleep ( communicateServerTimer + 1000 ) ;
115
110
116
- cicles ++ ;
111
+ ciclesCompleted ++ ;
117
112
}
118
113
} ) ;
119
114
120
115
thread . Start ( ) ;
121
-
122
116
}
123
- catch ( System . IO . FileNotFoundException )
117
+ catch ( FileNotFoundException )
124
118
{
125
119
ConsoleLogger . Write ( "FAILED" , textColor : ConsoleColor . Red ) ;
126
120
ConsoleLogger . WriteTime ( "Couldn't Load XML File. Press Enter to exit the application." ) ;
@@ -140,4 +134,4 @@ static void Main(string[] args)
140
134
}
141
135
}
142
136
}
143
- }
137
+ }
0 commit comments