getProfileVillages($session->uid); foreach ($varray as $vil) { $vid = $vil['wref']; // Date sat $vdata = $database->getVillage($vid); // Lucrări construcții în desfășurare $jobs = $database->getJobs($vid); // Unități în training $units = $database->getTraining($vid); // ========================================================== // AGRUPARE UNITĂȚI (SAFE INIT) // ========================================================== $unitsArray = []; foreach ($units as $unit) { if (!isset($unitsArray[$unit['unit']])) { $unitsArray[$unit['unit']] = 0; } $unitsArray[$unit['unit']] += $unit['amt']; } // ========================================================== // MERCHANTS // ========================================================== $totalmerchants = $building->getTypeLevel(17, $vid); $usedmerchants = $database->totalMerchantUsed($vid); $availmerchants = $totalmerchants - $usedmerchants; // ========================================================== // INCOMING ATTACKS // ========================================================== $incoming_attacks = $database->getMovement(3, $vid, 1); $att = ''; if (!empty($incoming_attacks)) { $total_attacks = count($incoming_attacks); $inc_atts = $total_attacks; // filtrare atacuri ignorate (logică originală păstrată) for ($i = 0; $i < $total_attacks; $i++) { if ( $incoming_attacks[$i]['attack_type'] == 1 || $incoming_attacks[$i]['attack_type'] == 2 ) { $inc_atts -= 1; } } if ($inc_atts > 0) { $att = ' '.$total_attacks.' incoming attack'.($total_attacks > 1 ? 's' : '').' '; } } // ========================================================== // BUILDING JOBS ICONS // ========================================================== $bui = ''; foreach ($jobs as $b) { $bui .= ' '.Building::procResType($b['type']).' '; } // ========================================================== // TROOPS DISPLAY // ========================================================== $tro = ''; foreach ($unitsArray as $key => $c) { // normalizare specială (păstrată din original) if ($key == 99) $key = 51; // determinare categorie unități $gid = in_array($key, $unitsbytype['infantry']) ? 19 : (in_array($key, $unitsbytype['cavalry']) ? 20 : (in_array($key, $unitsbytype['siege']) ? 21 : (in_array(($key - 60), $unitsbytype['infantry']) ? 29 : (in_array(($key - 60), $unitsbytype['cavalry']) ? 30 : ($key == 51 ? 36 : ($building->getTypeLevel(26) > 0 ? 26 : 25)))))); // ajustare offset unități if ($key > 60) { $key -= 60; } $unitName = $technology->getUnitName($key); $tro .= ' '.$c.'x '.$unitName.' '; } // ========================================================== // HIGHLIGHT VILLAGE CURENT // ========================================================== $class = ($vid == $village->wid) ? 'hl' : ''; // ========================================================== // OUTPUT ROW // ========================================================== echo ' '; } ?>
Overview
Village Attacks Building Troops Merchants
'.$vdata['name'].' '.$att.' '.$bui.' '.$tro.' '.($totalmerchants > 0 ? '' : '').' '.$availmerchants.'/'.$totalmerchants.'