diff --git a/hwe/sammo/API/Global/GetNationList.php b/hwe/sammo/API/Global/GetNationList.php new file mode 100644 index 00000000..f3bd80aa --- /dev/null +++ b/hwe/sammo/API/Global/GetNationList.php @@ -0,0 +1,65 @@ + $lhs['power']; + }); + + $nations[0] = getNationStaticInfo(0); + + foreach ($db->query('SELECT npc,name,nation,officer_level,permission FROM `general` ORDER BY dedication DESC') as $general) { + $nationID = $general['nation']; + + $permission = $general['permission']; + if($permission != 'auditor' && $permission != 'ambassador'){ + unset($general['permission']); + } + + if($general['officer_level'] < 5){ + $general['officer_level'] = 1; + } + + if (!key_exists('generals', $nations[$nationID])) { + $nations[$nationID]['generals'] = []; + } + $nations[$nationID]['generals'][] = $general; + } + + foreach ($db->queryAllLists('SELECT city, name, nation FROM city') as [$cityID, $cityName, $nationID]) { + if (!key_exists('cities', $nations[$nationID])) { + $nations[$nationID]['cities'] = []; + } + $nations[$nationID]['cities'][$cityID] = $cityName; + } + + return [ + 'result' => true, + 'nations' => $nations, + ]; + } +}