From 8bf3a87e428093d6071312062cc0d0febd931536 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 16 Apr 2026 10:18:11 +0000 Subject: [PATCH] V1.3.1 --- sccharacters.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/sccharacters.php b/sccharacters.php index c614cfe..fc3fcd5 100644 --- a/sccharacters.php +++ b/sccharacters.php @@ -83,6 +83,28 @@ function sccharacters_excerpt(string $value, int $limit = 120): string return rtrim(substr($value, 0, max(0, $limit - 1))) . '…'; } +function sccharacters_display_stat_value($value): string +{ + if (!is_numeric((string) $value)) { + return '0'; + } + + $formatted = number_format((float) $value, 2, '.', ''); + $formatted = rtrim(rtrim($formatted, '0'), '.'); + + return $formatted === '' ? '0' : $formatted; +} + +function sccharacters_custom_stat_preview(array $stat_row): string +{ + $sign = (string) ($stat_row['cl_scitemcustomstat_sign'] ?? ''); + $prefix = $sign === '-' ? '-' : ($sign === '+' ? '+' : ''); + $value = sccharacters_display_stat_value($stat_row['cl_scitemcustomstat_value'] ?? 0); + $unit = trim((string) ($stat_row['cl_scstatsitem_unit'] ?? '')); + + return trim((string) ($stat_row['cl_scstatsitem_name'] ?? '') . ' : ' . $prefix . $value . ($unit !== '' ? ' ' . $unit : '')); +} + function sccharacters_share_url(string $token): string { $is_https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') @@ -1381,6 +1403,7 @@ $item_panel_open = (string) ($_GET['item_panel'] ?? '') === '1'; $item_page = max(1, (int) ($_GET['item_page'] ?? 1)); $item_per_page = sccharacters_normalize_item_per_page($_GET['item_per_page'] ?? 50); $item_results = []; +$item_result_custom_stats = []; $item_total_results = 0; $item_total_pages = 1; $item_result_offset_start = 0; @@ -1439,6 +1462,40 @@ if ($selected_character) { $stmt_item_results = $db->prepare($sql); $stmt_item_results->execute($params); $item_results = $stmt_item_results->fetchAll(); + + $item_result_custom_ids = []; + foreach ($item_results as $item_result_row) { + $itemcustom_id = (int) ($item_result_row['cl_scitemcustom_id'] ?? 0); + if ($itemcustom_id > 0) { + $item_result_custom_ids[] = $itemcustom_id; + } + } + $item_result_custom_ids = array_values(array_unique($item_result_custom_ids)); + + if ($item_result_custom_ids !== []) { + $placeholders = implode(',', array_fill(0, count($item_result_custom_ids), '?')); + $stmt_item_stats = $db->prepare( + "SELECT + cs.cl_scitemcustomstat_itemcustom_id, + st.cl_scstatsitem_name, + st.cl_scstatsitem_unit, + cs.cl_scitemcustomstat_sign, + cs.cl_scitemcustomstat_value + FROM tbl_scitemcustomstat cs + INNER JOIN tbl_scstatsitem st ON st.cl_scstatsitem_id = cs.cl_scitemcustomstat_stat_id + WHERE cs.cl_scitemcustomstat_itemcustom_id IN ({$placeholders}) + ORDER BY st.cl_scstatsitem_name ASC, cs.cl_scitemcustomstat_id ASC" + ); + $stmt_item_stats->execute($item_result_custom_ids); + + foreach ($stmt_item_stats->fetchAll() as $item_stat_row) { + $itemcustom_id = (int) ($item_stat_row['cl_scitemcustomstat_itemcustom_id'] ?? 0); + if (!isset($item_result_custom_stats[$itemcustom_id])) { + $item_result_custom_stats[$itemcustom_id] = []; + } + $item_result_custom_stats[$itemcustom_id][] = $item_stat_row; + } + } } else { $count_sql = "SELECT COUNT(*) FROM tbl_scobjs @@ -2569,6 +2626,10 @@ if ($selected_character) { .search-result strong { display: block; margin-bottom: 0.25rem; } + .search-result-stats { + margin-top: 0.1rem; + } + .search-result-main { min-width: 0; display: flex; @@ -3370,6 +3431,7 @@ if ($selected_character) { $item_id_field = $result_is_custom ? 'custom_item_id' : 'base_obj_id'; $item_uuid = (string) ($item_result_row['cl_scobjs_uuid'] ?? ''); $item_image_url = $item_uuid !== '' ? 'https://cstone.space/uifimages/' . rawurlencode($item_uuid) . '.png' : ''; + $result_stats = $result_is_custom ? ($item_result_custom_stats[$result_id] ?? []) : []; ?>
@@ -3399,6 +3461,14 @@ if ($selected_character) { stat(s)
+ + +
+ + + +
+