getProfileVillages($session->uid); ?> tribe - 1) * 10 + 1; $unit_end = ($session->tribe) * 10; $unit_total = []; for ($i = $unit_start; $i <= $unit_end; $i++) { echo ''; $unit_total['u'.$i] = 0; } // hero column $unit_total['hero'] = 0; echo ''; ?> wid) ? 'hl' : ''; // base + reinforcement troops $units = $database->getEnforceVillage($vid, 1); array_unshift($units, $database->getUnit($vid)); // movement troops (incoming/outgoing) $movement = $database->getVillageMovement($vid); // reset per village $uni = []; // init counters per unit type for ($i = $unit_start; $i <= $unit_end; $i++) { $key = 'u'.$i; $uni[$key] = 0; } $uni['hero'] = 0; // ========================================================== // SUM BASE + ENFORCEMENTS // ========================================================== foreach ($units as $unit) { for ($i = $unit_start; $i <= $unit_end; $i++) { $key = 'u'.$i; if (isset($unit[$key])) { $uni[$key] += $unit[$key]; $unit_total[$key] += $unit[$key]; } } // hero if (isset($unit['hero'])) { $uni['hero'] += $unit['hero']; $unit_total['hero'] += $unit['hero']; } } // ========================================================== // MOVEMENT ADDITION // ========================================================== for ($i = $unit_start; $i <= $unit_end; $i++) { $key = 'u'.$i; if (isset($movement[$key])) { $uni[$key] += $movement[$key]; $unit_total[$key] += $movement[$key]; } } if (isset($movement['hero'])) { $uni['hero'] += $movement['hero']; $unit_total['hero'] += $movement['hero']; } // ========================================================== // OUTPUT ROW // ========================================================== echo ''; echo ''; // units for ($i = $unit_start; $i <= $unit_end; $i++) { $key = 'u'.$i; $val = $uni[$key]; $cl = ($val != 0) ? '' : 'none'; echo ''; } // hero $heroVal = $uni['hero']; $cl = ($heroVal != 0) ? '' : 'none'; echo ''; echo ''; } ?> '.$val.''; } $heroTotal = $unit_total['hero']; $cl = ($heroTotal != 0) ? '' : 'none'; echo ''; ?>
'.$vil['name'].' '.$val.''.$heroVal.'
'.$heroTotal.'