refactor: last of foreach loops optimized

#313
This commit is contained in:
Martin Ambrus
2017-11-19 14:32:00 +01:00
parent 67d9a42506
commit 2a68b07704
4 changed files with 76 additions and 58 deletions
+32 -32
View File
@@ -251,38 +251,38 @@ class Village {
$crop = $clay = $wood = $iron = 0;
if (!empty($this->oasisowned)) {
foreach ($this->oasisowned as $oasis) {
switch($oasis['type']) {
case 1:
case 2:
$wood += 1;
break;
case 3:
$wood += 1;
$crop += 1;
break;
case 4:
case 5:
$clay += 1;
break;
case 6:
$clay += 1;
$crop += 1;
break;
case 7:
case 8:
$iron += 1;
break;
case 9:
$iron += 1;
$crop += 1;
break;
case 10:
case 11:
$crop += 1;
break;
case 12:
$crop += 2;
break;
switch ( $oasis['type'] ) {
case 1:
case 2:
$wood += 1;
break;
case 3:
$wood += 1;
$crop += 1;
break;
case 4:
case 5:
$clay += 1;
break;
case 6:
$clay += 1;
$crop += 1;
break;
case 7:
case 8:
$iron += 1;
break;
case 9:
$iron += 1;
$crop += 1;
break;
case 10:
case 11:
$crop += 1;
break;
case 12:
$crop += 2;
break;
}
}
}