Conditions | 10 |
Paths | 384 |
Total Lines | 51 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php namespace Xaoc303\BattleCalc; |
||
136 | private function damageSquad(&$i) |
||
137 | { |
||
138 | $unitsDef = $this->unitsDef; |
||
139 | $ManDamageAll = 0; |
||
140 | $ManDamageShield = 0; |
||
141 | $ManDamageHP = 0; |
||
142 | if ($unitsDef[$i]['All']['ManCountVisible'] > 0) { |
||
143 | if ($unitsDef[$i]['All']['UT'] == 0) { |
||
144 | $ManDamageAll = ($this->ManDamageT-(($this->ManDamageT* $unitsDef[$i]['Base']['Armor'])/100))* $unitsDef[$i]['All']['ManCount']; |
||
145 | } else { |
||
146 | $ManDamageAll = ($this->ManDamageA-(($this->ManDamageA* $unitsDef[$i]['Base']['Armor'])/100))* $unitsDef[$i]['All']['ManCount']; |
||
147 | } |
||
148 | } |
||
149 | if ($this->DamageMagicAll > 0) { |
||
150 | $ManDamageAll += $this->DamageMagicAll -(($this->DamageMagicAll * $unitsDef[$i]['Base']['Armor'])/100); |
||
151 | } |
||
152 | if ($this->DamageMagicShield > 0) { |
||
153 | $ManDamageShield += $this->DamageMagicShield -(($this->DamageMagicShield* $unitsDef[$i]['Base']['Armor'])/100); |
||
154 | } |
||
155 | if ($this->DamageMagicHP > 0) { |
||
156 | $ManDamageHP += $this->DamageMagicHP -(($this->DamageMagicHP * $unitsDef[$i]['Base']['Armor'])/100); |
||
157 | } |
||
158 | |||
159 | $unitsDef[$i]['All']['Shield'] -= $ManDamageShield; |
||
160 | if ($unitsDef[$i]['All']['Shield'] < 0) { |
||
161 | $unitsDef[$i]['All']['Shield'] = 0; |
||
162 | } |
||
163 | |||
164 | |||
165 | $HPmax = $unitsDef[$i]['Base']['HP'] * $unitsDef[$i]['All']['ManCount']; |
||
166 | |||
167 | $unitsDef[$i]['All']['HP'] -= $ManDamageHP; |
||
168 | if ($unitsDef[$i]['All']['HP'] < 0) { |
||
169 | $unitsDef[$i]['All']['HP'] = 0; |
||
170 | } |
||
171 | |||
172 | $unitsDef[$i]['All']['Shield'] -= $ManDamageAll; |
||
173 | if ($unitsDef[$i]['All']['Shield'] < 0) { |
||
174 | $unitsDef[$i]['All']['HP'] += $unitsDef[$i]['All']['Shield']; |
||
175 | $unitsDef[$i]['All']['Shield'] = 0; |
||
176 | } |
||
177 | |||
178 | $this->healingLive($unitsDef, $i, $HPmax); |
||
179 | $this->healingTech($unitsDef, $i, $HPmax); |
||
180 | |||
181 | if ($unitsDef[$i]['All']['HP'] < 0) { |
||
182 | $unitsDef[$i]['All']['HP'] = 0; |
||
183 | } |
||
184 | |||
185 | $this->unitsDef = $unitsDef; |
||
186 | } |
||
187 | |||
218 |