'scan-rarity-L', 'E' => 'scan-rarity-E', 'R' => 'scan-rarity-R', 'U' => 'scan-rarity-U', 'C' => 'scan-rarity-C', default => 'scan-rarity-none', }; } function index_scan_rarity_label(?string $rarity): string { return match (index_scan_normalize_rarity($rarity)) { 'L' => 'Légendaire', 'E' => 'Épique', 'R' => 'Rare', 'U' => 'Peu commun', 'C' => 'Commun', default => 'Non définie', }; } function index_itemcustom_display_value($value): string { if ($value === null || $value === '') { return '0'; } if (is_numeric($value)) { $formatted = number_format((float) $value, 2, '.', ''); $formatted = rtrim(rtrim($formatted, '0'), '.'); return $formatted === '' ? '0' : $formatted; } return trim((string) $value) !== '' ? trim((string) $value) : '0'; } function index_itemcustom_stat_preview(?string $sign, $value, ?string $unit): string { $prefix = $sign === '-' ? '-' : ($sign === '+' ? '+' : ''); $displayValue = index_itemcustom_display_value($value); $displayUnit = trim((string) ($unit ?? '')); return trim($prefix . $displayValue . ($displayUnit !== '' ? ' ' . $displayUnit : '')); } function index_vanilla_description_html(?string $description): string { $description = trim((string) $description); if ($description === '') { return 'Aucune description.'; } if ($description !== strip_tags($description)) { return $description; } return nl2br(htmlspecialchars($description, ENT_QUOTES, 'UTF-8')); } function index_vanilla_uex_normalize_whitespace(string $value): string { return trim((string) preg_replace('/\s+/u', ' ', html_entity_decode(strip_tags($value), ENT_QUOTES | ENT_HTML5, 'UTF-8'))); } function index_vanilla_uex_normalize_search_text(string $value): string { $value = function_exists('mb_strtolower') ? mb_strtolower($value, 'UTF-8') : strtolower($value); $value = preg_replace('/[^[:alnum:]]+/u', ' ', $value); return trim((string) preg_replace('/\s+/u', ' ', $value)); } function index_vanilla_uex_normalize_compact_search_text(string $value): string { $value = function_exists('mb_strtolower') ? mb_strtolower($value, 'UTF-8') : strtolower($value); return trim((string) preg_replace('/[^[:alnum:]]+/u', '', $value)); } function index_vanilla_uex_tokenize_search_text(string $value): array { $normalizedValue = index_vanilla_uex_normalize_search_text($value); if ($normalizedValue === '') { return []; } $tokens = array_values(array_filter(explode(' ', $normalizedValue), static function (string $token): bool { return preg_match('/\d/u', $token) || strlen($token) >= 2; })); return array_values(array_unique($tokens)); } function index_vanilla_uex_extract_wts_subject(string $title): string { $normalizedTitle = index_vanilla_uex_normalize_search_text($title); if ($normalizedTitle === '') { return ''; } if (!preg_match('/\bwts\b/u', $normalizedTitle, $matches, PREG_OFFSET_CAPTURE)) { return ''; } $matchText = (string) ($matches[0][0] ?? 'wts'); $matchOffset = (int) ($matches[0][1] ?? 0); $subject = trim(substr($normalizedTitle, $matchOffset + strlen($matchText))); while ($subject !== '') { $updated = trim((string) preg_replace('/^(?:wts|wtb|lts|ltb|sell|selling|trade|trading|for|offer|offering|looking|lf|want|wanted)\b[\s\-:]*/u', '', $subject)); if ($updated === $subject) { break; } $subject = $updated; } $subject = trim((string) preg_replace('/^(?:[a-z]{1,4}\s+)?\d+(?:\s+\d+)*(?:\s*[\-:])\s*/u', '', $subject)); return $subject; } function index_vanilla_uex_title_has_wts_marker(string $title): bool { return index_vanilla_uex_extract_wts_subject($title) !== ''; } function index_vanilla_uex_title_match_score(string $title, string $queryName): int { $normalizedTitle = index_vanilla_uex_extract_wts_subject($title); $normalizedQuery = index_vanilla_uex_normalize_search_text($queryName); $compactTitle = index_vanilla_uex_normalize_compact_search_text($normalizedTitle); $compactQuery = index_vanilla_uex_normalize_compact_search_text($normalizedQuery); if ($normalizedTitle === '' || $normalizedQuery === '' || $compactTitle === '' || $compactQuery === '') { return 0; } if ($normalizedTitle === $normalizedQuery || $compactTitle === $compactQuery) { return 3; } if (strpos($normalizedTitle, $normalizedQuery) !== false || strpos($compactTitle, $compactQuery) !== false) { return 2; } $queryTokens = index_vanilla_uex_tokenize_search_text($normalizedQuery); if ($queryTokens === []) { return 0; } foreach ($queryTokens as $token) { if (strpos($normalizedTitle, $token) === false) { return 0; } } return 1; } function index_vanilla_uex_title_matches_query(string $title, string $queryName): bool { return index_vanilla_uex_title_match_score($title, $queryName) > 0; } function index_vanilla_uex_extract_price_value(string $rawPrice): ?int { $rawPrice = trim($rawPrice); if ($rawPrice === '') { return null; } if (!preg_match('/([0-9][0-9\s,\.]*)((?:\s*[KMB])?)\s*(?:A?UEC)\b/i', $rawPrice, $matches)) { return null; } $numberPart = preg_replace('/\s+/', '', (string) ($matches[1] ?? '')); $suffix = strtoupper(trim((string) ($matches[2] ?? ''))); if ($numberPart === '') { return null; } if ($suffix !== '') { if (substr_count($numberPart, ',') === 1 && strpos($numberPart, '.') === false) { $numberPart = str_replace(',', '.', $numberPart); } else { $numberPart = str_replace(',', '', $numberPart); } } else { if (strpos($numberPart, ',') !== false && strpos($numberPart, '.') !== false) { if (strrpos($numberPart, ',') > strrpos($numberPart, '.')) { $numberPart = str_replace('.', '', $numberPart); $numberPart = str_replace(',', '.', $numberPart); } else { $numberPart = str_replace(',', '', $numberPart); } } else { $numberPart = str_replace(',', '', $numberPart); } } if (!is_numeric($numberPart)) { return null; } $value = (float) $numberPart; $multiplier = match ($suffix) { 'K' => 1000, 'M' => 1000000, 'B' => 1000000000, default => 1, }; return (int) round($value * $multiplier); } function index_vanilla_uex_parse_estimate_from_html(string $html, string $queryName, int $sampleLimit = 10): array { $candidates = []; $chunks = preg_split('/
La sécurité et la protection des intérêts impériaux sont des priorités absolues pour l’agence.
En tant que garante de l’ordre dans les zones sous juridiction de l’UEE, l’agence BOPS s'engage à prévenir, neutraliser et répondre efficacement à toutes les formes de menaces, qu'elles soient internes ou externes aux territoires de l'Empire.
Cette mission repose sur une approche combinant vigilance, réactivité et expertise tactique, afin d’assurer la stabilité, la sécurité des citoyens et le respect des lois impériales.
Chaque opération est conçue pour inspirer confiance aux populations locales tout en projetant une image de force et de discipline au sein de l’univers connu.
— Surveillance active des secteurs critiques pour dissuader les menaces potentielles. — Protection rapprochée de convois, personnalités importantes ou cargaisons sensibles. — Neutralisation de vaisseaux hostiles ou suspects, avec récupération d’actifs stratégiques. — Ciblage et capture ou élimination de fugitifs dangereux, conformément aux lois impériales. — Protection des civils en détresse et aide aux infrastructures endommagées. — Collecte et analyse d’informations sur des activités suspectes, incidents ou organisations hostiles.