@@ -175,7 +175,7 @@ Func lblTotalCountTroop2()
175175 Local $NbrOfDarkBarrack = 2 ; For the moment fix to 2 until fine detect level of each Barrack
176176 For $i = $eTroopBarbarian To $eTroopElectroDragon
177177 Local $NbrOfTroop = GUICtrlRead ($g_ahTxtTrainArmyTroopCount [$i ])
178- Local $LevOfTroop = $g_aiTrainArmyTroopLevel [$i ]
178+ Local $LevOfTroop = $g_aiTrainArmyTroopLevel [$i ] > 0 ? $g_aiTrainArmyTroopLevel [ $i ] : $g_aiTroopCostPerLevel [ $i ][ 0 ]
179179
180180 If $NbrOfTroop > 0 And $LevOfTroop > 0 Then
181181 If IsInt ($NbrOfTroop / $NbrOfBarrack ) = 1 Then
@@ -189,7 +189,7 @@ Func lblTotalCountTroop2()
189189
190190 For $i = $eTroopMinion To $eTroopIceGolem
191191 Local $NbrOfTroop = GUICtrlRead ($g_ahTxtTrainArmyTroopCount [$i ])
192- Local $LevOfTroop = $g_aiTrainArmyTroopLevel [$i ]
192+ Local $LevOfTroop = $g_aiTrainArmyTroopLevel [$i ] > 0 ? $g_aiTrainArmyTroopLevel [ $i ] : $g_aiTroopCostPerLevel [ $i ][ 0 ]
193193
194194 If $NbrOfTroop > 0 And $LevOfTroop > 0 Then
195195 If IsInt ($NbrOfTroop / $NbrOfDarkBarrack ) = 1 Then
@@ -228,12 +228,13 @@ EndFunc ;==>lblTotalCountSpell2
228228
229229Func lblTotalCountSiege()
230230 ; calculate total space and time for Siege composition
231- Local $iTotalTotalTimeSiege = 0
231+ Local $iTotalTotalTimeSiege = 0 , $indexLevel = 0
232232 $g_iTotalTrainSpaceSiege = 0
233233
234234 For $i = 0 To $eSiegeMachineCount - 1
235235 $g_iTotalTrainSpaceSiege += $g_aiArmyCompSiegeMachine [$i ] * $g_aiSiegeMachineSpace [$i ]
236- $iTotalTotalTimeSiege += $g_aiArmyCompSiegeMachine [$i ] * $g_aiSiegeMachineTrainTimePerLevel [$i ][$g_aiTrainArmySiegeMachineLevel [$i ]]
236+ $indexLevel = $g_aiTrainArmySiegeMachineLevel [$i ] > 0 ? $g_aiTrainArmySiegeMachineLevel [$i ] : $g_aiSiegeMachineCostPerLevel [$i ][0 ]
237+ $iTotalTotalTimeSiege += $g_aiArmyCompSiegeMachine [$i ] * $g_aiSiegeMachineTrainTimePerLevel [$i ][$indexLevel ]
237238 Next
238239
239240 GUICtrlSetData ($g_hLblTotalTimeSiege , CalculTimeTo($iTotalTotalTimeSiege ))
@@ -249,6 +250,7 @@ Func lblTotalCountSiege()
249250 GUICtrlSetData ($g_hLblGoldCostSiege , " 0" )
250251 GUICtrlSetData ($g_hLblCountTotalSiege , $g_iTotalTrainSpaceSiege )
251252 GUICtrlSetData ($g_hLblTotalTimeSiege , " 0s" )
253+ _GUI_Value_STATE(" HIDE" , $groupListSieges )
252254 EndIf
253255EndFunc ; ==>lblTotalCountSiege
254256
@@ -258,7 +260,7 @@ Func TotalSpellCountClick()
258260 $g_iTownHallLevel = Int ($g_iTownHallLevel )
259261
260262 If $g_iTownHallLevel > 4 Or $g_iTownHallLevel = 0 Then
261- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [ $eSpellLightning ] > 0 ? $g_aGroupLightning : $groupIcnLightning )
263+ _GUI_Value_STATE(" SHOW" , $groupLightning )
262264 Else
263265 For $i = 0 To $eSpellCount - 1
264266 GUICtrlSetData ($g_ahTxtTrainArmySpellCount [$i ], 0 )
@@ -268,7 +270,7 @@ Func TotalSpellCountClick()
268270 EndIf
269271
270272 If $g_iTownHallLevel > 5 Or $g_iTownHallLevel = 0 Then
271- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [ $eSpellHeal ] > 0 ? $ groupHeal : $groupIcnHeal )
273+ _GUI_Value_STATE(" SHOW" , $groupHeal )
272274 Else
273275 For $i = $eSpellRage To $eSpellBat
274276 GUICtrlSetData ($g_ahTxtTrainArmySpellCount [$i ], 0 )
@@ -277,7 +279,7 @@ Func TotalSpellCountClick()
277279 EndIf
278280
279281 If $g_iTownHallLevel > 6 Or $g_iTownHallLevel = 0 Then
280- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [ $eSpellRage ] > 0 ? $ groupRage : $groupIcnRage )
282+ _GUI_Value_STATE(" SHOW" , $groupRage )
281283 Else
282284 For $i = $eSpellJump To $eSpellBat
283285 GUICtrlSetData ($g_ahTxtTrainArmySpellCount [$i ], 0 )
@@ -286,8 +288,8 @@ Func TotalSpellCountClick()
286288 EndIf
287289
288290 If $g_iTownHallLevel > 7 Or $g_iTownHallLevel = 0 Then
289- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [ $eSpellPoison ] > 0 ? $g_aGroupPoison : $groupIcnPoison )
290- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [ $eSpellEarthquake ] > 0 ? $ groupEarthquake : $groupIcnEarthquake )
291+ _GUI_Value_STATE(" SHOW" , $groupPoison )
292+ _GUI_Value_STATE(" SHOW" , $groupEarthquake )
291293 Else
292294 GUICtrlSetData ($g_ahTxtTrainArmySpellCount [$eSpellJump ], 0 )
293295 GUICtrlSetData ($g_ahTxtTrainArmySpellCount [$eSpellFreeze ], 0 )
@@ -304,18 +306,20 @@ Func TotalSpellCountClick()
304306 EndIf
305307
306308 If $g_iTownHallLevel > 8 Or $g_iTownHallLevel = 0 Then
307- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [$eSpellJump ] > 0 ? $groupJumpSpell : $groupIcnJumpSpell )
308- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [$eSpellFreeze ] > 0 ? $groupFreeze : $groupIcnFreeze )
309- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [$eSpellHaste ] > 0 ? $groupHaste : $groupIcnHaste )
310- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [$eSpellSkeleton ] > 0 ? $groupSkeleton : $groupIcnSkeleton )
311- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [$eSpellBat ] > 0 ? $groupSkeleton : $groupIcnBat )
309+ _GUI_Value_STATE(" SHOW" , $groupJump )
310+ _GUI_Value_STATE(" SHOW" , $groupFreeze )
311+ _GUI_Value_STATE(" SHOW" , $groupHaste )
312+ _GUI_Value_STATE(" SHOW" , $groupSkeleton )
312313 Else
313314 GUICtrlSetData ($g_ahTxtTrainArmySpellCount [$eSpellClone ], 0 )
315+ GUICtrlSetData ($g_ahTxtTrainArmySpellCount [$eSpellBat ], 0 )
314316 GUICtrlSetData ($g_ahLblTrainArmySpellLevel [$eSpellClone ], 0 )
317+ GUICtrlSetData ($g_ahLblTrainArmySpellLevel [$eSpellBat ], 0 )
315318 EndIf
316319
317320 If $g_iTownHallLevel > 9 Or $g_iTownHallLevel = 0 Then
318- _GUI_Value_STATE(" SHOW" , $g_aiTrainArmySpellLevel [$eSpellClone ] > 0 ? $groupClone : $groupIcnClone )
321+ _GUI_Value_STATE(" SHOW" , $groupClone )
322+ _GUI_Value_STATE(" SHOW" , $groupBat )
319323 EndIf
320324
321325 lblTotalCountSpell2()
@@ -863,19 +867,12 @@ Func LevUpDownTroop($iTroopIndex, $NoChangeLev = True)
863867 EndIf
864868
865869 Local $hLevel = $g_ahLblTrainArmyTroopLevel [$iTroopIndex ]
866- Local $hCount = $g_ahTxtTrainArmyTroopCount [$iTroopIndex ]
867870
868871 If $TempLev > $MaxLev Or $TempLev = 0 Then
869872 $TempLev = 0
870- GUICtrlSetData ($hCount , 0 )
871- $g_aiArmyCustomTroops [$iTroopIndex ] = 0
872- If IsGUICtrlHidden($hCount ) = False Then GUICtrlSetState ($hCount , $GUI_HIDE )
873873 If $NoChangeLev Then lblTotalCountTroop1()
874874 ElseIf $TempLev < 0 Then
875875 $TempLev = $MaxLev
876- If IsGUICtrlHidden($hCount ) Then GUICtrlSetState ($hCount , $GUI_SHOW )
877- ElseIf $TempLev > 0 And $TempLev < = $MaxLev And IsGUICtrlHidden($hCount ) Then
878- GUICtrlSetState ($hCount , $GUI_SHOW )
879876 EndIf
880877
881878 $g_aiTrainArmyTroopLevel [$iTroopIndex ] = $TempLev
@@ -900,19 +897,11 @@ Func LevUpDownSiege($iSiege, $NoChangeLev = True)
900897 EndIf
901898
902899 Local $hLevel = $g_ahLblTrainArmySiegeLevel [$iSiege ]
903- Local $hCount = $g_ahTxtTrainArmySiegeCount [$iSiege ]
904900
905901 If $TempLev > $MaxLev Or $TempLev = 0 Then
906902 $TempLev = 0
907- GUICtrlSetData ($hCount , 0 )
908- $g_aiArmyCompSiegeMachine [$iSiege ] = 0
909- If IsGUICtrlHidden($hCount ) = False Then GUICtrlSetState ($hCount , $GUI_HIDE )
910- ; If $NoChangeLev Then lblTotalCountSiege()
911903 ElseIf $TempLev < 0 Then
912904 $TempLev = $MaxLev
913- If IsGUICtrlHidden($hCount ) Then GUICtrlSetState ($hCount , $GUI_SHOW )
914- ElseIf $TempLev > 0 And $TempLev < = $MaxLev And IsGUICtrlHidden($hCount ) Then
915- GUICtrlSetState ($hCount , $GUI_SHOW )
916905 EndIf
917906
918907 $g_aiTrainArmySiegeMachineLevel [$iSiege ] = $TempLev
@@ -939,19 +928,12 @@ Func LevUpDownSpell($iSpellIndex, $NoChangeLev = True)
939928 EndIf
940929
941930 Local $hLevel = $g_ahLblTrainArmySpellLevel [$iSpellIndex ]
942- Local $hCount = $g_ahTxtTrainArmySpellCount [$iSpellIndex ]
943931
944932 If $TempLev > $MaxLev Or $TempLev = 0 Then
945933 $TempLev = 0
946- GUICtrlSetData ($hCount , 0 )
947- $g_aiArmyCustomSpells [$iSpellIndex ] = 0
948- If IsGUICtrlHidden($hCount ) = False Then GUICtrlSetState ($hCount , $GUI_HIDE )
949934 If $NoChangeLev Then lblTotalCountSpell2()
950935 ElseIf $TempLev < 0 Then
951936 $TempLev = $MaxLev
952- If IsGUICtrlHidden($hCount ) Then GUICtrlSetState ($hCount , $GUI_SHOW )
953- ElseIf $TempLev > 0 And $TempLev < = $MaxLev And IsGUICtrlHidden($hCount ) Then
954- GUICtrlSetState ($hCount , $GUI_SHOW )
955937 EndIf
956938
957939 $g_aiTrainArmySpellLevel [$iSpellIndex ] = $TempLev
@@ -1022,40 +1004,45 @@ Func TrainSpellLevelClick()
10221004EndFunc ; ==>TrainSpellLevelClick
10231005
10241006Func CalCostCamp()
1025- Local $iElixirCostCamp = 0 , $iDarkCostCamp = 0
1007+ Local $iElixirCostCamp = 0 , $iDarkCostCamp = 0 , $indexLevel = 0
10261008
10271009 For $i = $eTroopBarbarian To $eTroopElectroDragon
1028- $iElixirCostCamp += $g_aiArmyCustomTroops [$i ] * $g_aiTroopCostPerLevel [$i ][$g_aiTrainArmyTroopLevel [$i ]]
1010+ $indexLevel = $g_aiTrainArmyTroopLevel [$i ] > 0 ? $g_aiTrainArmyTroopLevel [$i ] : $g_aiTroopCostPerLevel [$i ][0 ]
1011+ $iElixirCostCamp += $g_aiArmyCustomTroops [$i ] * $g_aiTroopCostPerLevel [$i ][$indexLevel ]
10291012 Next
10301013
10311014 For $i = $eTroopMinion To $eTroopIceGolem
1032- $iDarkCostCamp += $g_aiArmyCustomTroops [$i ] * $g_aiTroopCostPerLevel [$i ][$g_aiTrainArmyTroopLevel [$i ]]
1015+ $indexLevel = $g_aiTrainArmyTroopLevel [$i ] > 0 ? $g_aiTrainArmyTroopLevel [$i ] : $g_aiTroopCostPerLevel [$i ][0 ]
1016+ $iDarkCostCamp += $g_aiArmyCustomTroops [$i ] * $g_aiTroopCostPerLevel [$i ][$indexLevel ]
10331017 Next
10341018
10351019 GUICtrlSetData ($g_hLblElixirCostCamp , _NumberFormat($iElixirCostCamp , True ))
10361020 GUICtrlSetData ($g_hLblDarkCostCamp , _NumberFormat($iDarkCostCamp , True ))
10371021EndFunc ; ==>CalCostCamp
10381022
10391023Func CalCostSpell()
1040- Local $iElixirCostSpell = 0 , $iDarkCostSpell = 0
1024+ Local $iElixirCostSpell = 0 , $iDarkCostSpell = 0 , $indexLevel = 0
10411025
10421026 For $i = $eSpellLightning To $eSpellClone
1043- $iElixirCostSpell += $g_aiArmyCustomSpells [$i ] * $g_aiSpellCostPerLevel [$i ][$g_aiTrainArmySpellLevel [$i ]]
1027+ $indexLevel = $g_aiTrainArmySpellLevel [$i ] > 0 ? $g_aiTrainArmySpellLevel [$i ] : $g_aiSpellCostPerLevel [$i ][0 ]
1028+ $iElixirCostSpell += $g_aiArmyCustomSpells [$i ] * $g_aiSpellCostPerLevel [$i ][$indexLevel ]
10441029 Next
10451030
10461031 For $i = $eSpellPoison To $eSpellBat
1047- $iDarkCostSpell += $g_aiArmyCustomSpells [$i ] * $g_aiSpellCostPerLevel [$i ][$g_aiTrainArmySpellLevel [$i ]]
1032+ $indexLevel = $g_aiTrainArmySpellLevel [$i ] > 0 ? $g_aiTrainArmySpellLevel [$i ] : $g_aiSpellCostPerLevel [$i ][0 ]
1033+ $iDarkCostSpell += $g_aiArmyCustomSpells [$i ] * $g_aiSpellCostPerLevel [$i ][$indexLevel ]
10481034 Next
10491035
10501036 GUICtrlSetData ($g_hLblElixirCostSpell , _NumberFormat($iElixirCostSpell , True ))
10511037 GUICtrlSetData ($g_hLblDarkCostSpell , _NumberFormat($iDarkCostSpell , True ))
10521038EndFunc ; ==>CalCostSpell
10531039
10541040Func CalCostSiege()
1055- Local $iGoldCostSiege = 0
1041+ Local $iGoldCostSiege = 0 , $indexLevel = 0
10561042
10571043 For $i = 0 To $eSiegeMachineCount - 1
1058- $iGoldCostSiege += $g_aiArmyCompSiegeMachine [$i ] * $g_aiSiegeMachineCostPerLevel [$i ][$g_aiTrainArmySiegeMachineLevel [$i ]]
1044+ $indexLevel = $g_aiTrainArmySiegeMachineLevel [$i ] > 0 ? $g_aiTrainArmySiegeMachineLevel [$i ] : $g_aiSiegeMachineCostPerLevel [$i ][0 ]
1045+ $iGoldCostSiege += $g_aiArmyCompSiegeMachine [$i ] * $g_aiSiegeMachineCostPerLevel [$i ][$indexLevel ]
10591046 Next
10601047
10611048 GUICtrlSetData ($g_hLblGoldCostSiege , _NumberFormat($iGoldCostSiege , True ))
0 commit comments