@@ -43,10 +43,10 @@ public static Village GetHeroHomeVillage(Account acc) =>
43
43
/// <param name="acc">Account</param>
44
44
public static void AutoEquipHero ( Account acc )
45
45
{
46
- foreach ( Classificator . HeroItemCategory category
47
- in ( Classificator . HeroItemCategory [ ] ) Enum . GetValues ( typeof ( Classificator . HeroItemCategory ) ) )
46
+ foreach ( HeroItemCategory category
47
+ in ( HeroItemCategory [ ] ) Enum . GetValues ( typeof ( HeroItemCategory ) ) )
48
48
{
49
- if ( category == Classificator . HeroItemCategory . Others ) continue ; // Don't equip into hero bag
49
+ if ( category == HeroItemCategory . Others ) continue ; // Don't equip into hero bag
50
50
int currentTier = 0 ;
51
51
if ( acc . Hero . Equipt . TryGetValue ( category , out var item ) )
52
52
{
@@ -66,7 +66,7 @@ public static void AutoEquipHero(Account acc)
66
66
acc . Tasks . Add ( new HeroEquip ( )
67
67
{
68
68
ExecuteAt = DateTime . Now ,
69
- Items = new List < ( Classificator . HeroItemEnum , int ) > ( )
69
+ Items = new List < ( HeroItemEnum , int ) > ( )
70
70
{
71
71
( equipWith . Item , 0 )
72
72
}
@@ -80,35 +80,74 @@ public static void AutoEquipHero(Account acc)
80
80
/// </summary>
81
81
/// <param name="item">Hero item enum</param>
82
82
/// <returns>Hero item (category, name, tier)</returns>
83
- public static ( Classificator . HeroItemCategory , string , int ) ParseHeroItem ( Classificator . HeroItemEnum item )
83
+ public static ( HeroItemCategory , string , int ) ParseHeroItem ( HeroItemEnum item )
84
84
{
85
85
var attr = item . ToString ( ) . Split ( '_' ) ;
86
86
87
- Enum . TryParse ( attr [ 0 ] , out Classificator . HeroItemCategory category ) ;
87
+ Enum . TryParse ( attr [ 0 ] , out HeroItemCategory category ) ;
88
88
string name = attr [ 1 ] ;
89
89
int tier = int . Parse ( attr [ 2 ] ) ;
90
90
91
91
return ( category , name , tier ) ;
92
92
}
93
93
94
+ /// <summary>
95
+ /// Parses hero weapon
96
+ /// </summary>
97
+ /// <param name="item">Hero item</param>
98
+ /// <returns>(Troop boost, boost)</returns>
99
+ public static ( TroopsEnum , int ) ParseWeapon ( HeroItemEnum item )
100
+ {
101
+ var ( _, name , tier ) = ParseHeroItem ( item ) ;
102
+ if ( Enum . TryParse ( name , out TroopsEnum troop ) )
103
+ {
104
+ return ( troop , GetWeaponBoost ( troop , tier ) ) ;
105
+ }
106
+ return ( TroopsEnum . None , 0 ) ;
107
+ }
108
+
109
+ public static int GetArmorStrength ( string name )
110
+ {
111
+ switch ( name )
112
+ {
113
+ case "Breastplate" : return 500 ;
114
+ case "Segmented" : return 250 ;
115
+ default : return 0 ;
116
+ }
117
+ }
118
+
119
+ public static int GetArmorDmgReduce ( string name , int tier )
120
+ {
121
+ switch ( name )
122
+ {
123
+ case "Scale" : return 2 + 2 * tier ;
124
+ case "Segmented" : return 2 + tier ;
125
+ default : return 0 ;
126
+ }
127
+ }
128
+
129
+ private static int GetWeaponBoost ( TroopsEnum troop , int tier )
130
+ {
131
+ var upkeep = TroopsData . GetTroopUpkeep ( troop ) ;
132
+ return ( tier + 2 ) * upkeep ;
133
+ }
134
+
94
135
/// <summary>
95
136
/// Gets the tier of the hero item
96
137
/// </summary>
97
138
/// <param name="item">HeroItem</param>
98
139
/// <returns>Tier</returns>
99
- public static int GetHeroItemTier ( Classificator . HeroItemEnum item )
140
+ public static int GetHeroItemTier ( HeroItemEnum item )
100
141
{
101
142
var ( _, _, itemTier ) = ParseHeroItem ( item ) ;
102
143
return itemTier ;
103
144
}
104
-
105
- public static string GetHeroItemName ( Classificator . HeroItemEnum item )
145
+ public static string GetHeroItemName ( HeroItemEnum item )
106
146
{
107
147
var ( _, name , _) = ParseHeroItem ( item ) ;
108
148
return name ;
109
149
}
110
-
111
- public static Classificator . HeroItemCategory GetHeroItemCategory ( Classificator . HeroItemEnum item )
150
+ public static HeroItemCategory GetHeroItemCategory ( HeroItemEnum item )
112
151
{
113
152
var ( category , _, _) = ParseHeroItem ( item ) ;
114
153
return category ;
@@ -129,7 +168,7 @@ public static void ParseHeroPage(Account acc)
129
168
130
169
if ( acc . Hero . Settings . AutoEquip )
131
170
{
132
- HeroHelper . AutoEquipHero ( acc ) ;
171
+ AutoEquipHero ( acc ) ;
133
172
}
134
173
}
135
174
@@ -140,11 +179,10 @@ public static void UpdateHeroVillage(Account acc)
140
179
141
180
switch ( acc . AccInfo . ServerVersion )
142
181
{
143
- case Classificator . ServerVersionEnum . T4_4 :
182
+ case ServerVersionEnum . T4_4 :
144
183
acc . Hero . HomeVillageId = hrefId ?? 0 ;
145
184
return ;
146
-
147
- case Classificator . ServerVersionEnum . T4_5 :
185
+ case ServerVersionEnum . T4_5 :
148
186
// Convert from coordinates id -> coordinates -> villageId
149
187
var coordinates = MapHelper . CoordinatesFromKid ( hrefId ?? 0 , acc ) ;
150
188
var vill = acc . Villages . FirstOrDefault ( x => x . Coordinates . Equals ( coordinates ) ) ;
@@ -159,10 +197,10 @@ public static long[] GetHeroResources(Account acc)
159
197
var heroItems = acc . Hero . Items ;
160
198
return new long [ ]
161
199
{
162
- heroItems . FirstOrDefault ( x => x . Item == Classificator . HeroItemEnum . Others_Wood_0 ) ? . Count ?? 0 ,
163
- heroItems . FirstOrDefault ( x => x . Item == Classificator . HeroItemEnum . Others_Clay_0 ) ? . Count ?? 0 ,
164
- heroItems . FirstOrDefault ( x => x . Item == Classificator . HeroItemEnum . Others_Iron_0 ) ? . Count ?? 0 ,
165
- heroItems . FirstOrDefault ( x => x . Item == Classificator . HeroItemEnum . Others_Crop_0 ) ? . Count ?? 0
200
+ heroItems . FirstOrDefault ( x => x . Item == HeroItemEnum . Others_Wood_0 ) ? . Count ?? 0 ,
201
+ heroItems . FirstOrDefault ( x => x . Item == HeroItemEnum . Others_Clay_0 ) ? . Count ?? 0 ,
202
+ heroItems . FirstOrDefault ( x => x . Item == HeroItemEnum . Others_Iron_0 ) ? . Count ?? 0 ,
203
+ heroItems . FirstOrDefault ( x => x . Item == HeroItemEnum . Others_Crop_0 ) ? . Count ?? 0
166
204
} ;
167
205
}
168
206
@@ -172,21 +210,21 @@ public static long[] GetHeroResources(Account acc)
172
210
/// <param name="acc">Account</param>
173
211
/// <param name="troop">Troop to train</param>
174
212
/// <returns>Whether to switch helmets first</returns>
175
- public static bool SwitchHelmet ( Account acc , Village trainVill , Classificator . BuildingEnum building , TrainTroops task )
213
+ public static bool SwitchHelmet ( Account acc , Village trainVill , BuildingEnum building , TrainTroops task )
176
214
{
177
215
if ( ! acc . Hero . Settings . AutoSwitchHelmets ) return false ;
178
216
179
217
// In T4.5, helmet will only have effect in hero home village
180
218
// In TTWars, helmets have acc-wide effect
181
219
// TODO: for T4.5, add auto-move hero feature (for helmet effect purposes)
182
220
if ( GetHeroHomeVillage ( acc ) != trainVill &&
183
- acc . AccInfo . ServerVersion != Classificator . ServerVersionEnum . T4_4 ) return false ;
221
+ acc . AccInfo . ServerVersion != ServerVersionEnum . T4_4 ) return false ;
184
222
185
223
string type = "" ;
186
- if ( building == Classificator . BuildingEnum . Barracks ||
187
- building == Classificator . BuildingEnum . GreatBarracks ) type = "Infantry" ;
188
- if ( building == Classificator . BuildingEnum . Stable ||
189
- building == Classificator . BuildingEnum . GreatStable ) type = "Cavalry" ;
224
+ if ( building == BuildingEnum . Barracks ||
225
+ building == BuildingEnum . GreatBarracks ) type = "Infantry" ;
226
+ if ( building == BuildingEnum . Stable ||
227
+ building == BuildingEnum . GreatStable ) type = "Cavalry" ;
190
228
191
229
// No helmet helps us for training in workshop
192
230
if ( string . IsNullOrEmpty ( type ) ) return false ;
@@ -199,7 +237,7 @@ public static bool SwitchHelmet(Account acc, Village trainVill, Classificator.Bu
199
237
200
238
var ( equipCategory , equipName , equipTier ) = ParseHeroItem ( equipWith . Item ) ;
201
239
202
- if ( acc . Hero . Equipt . TryGetValue ( Classificator . HeroItemCategory . Helmet , out var equiped ) )
240
+ if ( acc . Hero . Equipt . TryGetValue ( HeroItemCategory . Helmet , out var equiped ) )
203
241
{
204
242
var ( category , name , tier ) = ParseHeroItem ( equiped ) ;
205
243
if ( name == type &&
0 commit comments