From d2c018aecfe657c5bfa5f1cb54337ef6400ba60a Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 26 Feb 2026 01:58:11 +0000 Subject: [PATCH] Alpha V1.2 --- admin.php | 323 ++++---------- db/add_is_blinking_to_statuses.php | 11 - db/add_is_playable_to_factions.php | 11 - db/migrate_status_rules.php | 30 -- gm_console.php | 14 +- includes/status_helper.php | 53 --- index.php | 676 ++++++++++++++++++++--------- 7 files changed, 565 insertions(+), 553 deletions(-) delete mode 100644 db/add_is_blinking_to_statuses.php delete mode 100644 db/add_is_playable_to_factions.php delete mode 100644 db/migrate_status_rules.php delete mode 100644 includes/status_helper.php diff --git a/admin.php b/admin.php index e6c5c9c..9c2fcb4 100644 --- a/admin.php +++ b/admin.php @@ -92,20 +92,28 @@ if (isset($_GET['delete_object'])) { } // Handle Status CRUD -if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_status') { - $id = (int)$_POST['id']; - $name = $_POST['name']; - $slug = $_POST['slug']; - $color = $_POST['color']; - $description = $_POST['description']; - $is_blinking = isset($_POST['is_blinking']) ? 1 : 0; +if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["action"]) && $_POST["action"] === "upsert_status") { + $id = (int)$_POST["id"]; + $name = $_POST["name"]; + $slug = $_POST["slug"]; + $color = $_POST["color"]; + $description = $_POST["description"]; + + // Gérer le clignotement + if (isset($_POST["is_blinking"]) && $_POST["is_blinking"] === "on") { + if (strpos($color, ";blink") === false) { + $color .= ";blink"; + } + } else { + $color = str_replace(";blink", "", $color); + } if ($id > 0) { - $stmt = $db->prepare("UPDATE celestial_object_statuses SET name = ?, slug = ?, color = ?, description = ?, is_blinking = ? WHERE id = ?"); - $stmt->execute([$name, $slug, $color, $description, $is_blinking, $id]); + $stmt = $db->prepare("UPDATE celestial_object_statuses SET name = ?, slug = ?, color = ?, description = ? WHERE id = ?"); + $stmt->execute([$name, $slug, $color, $description, $id]); } else { - $stmt = $db->prepare("INSERT INTO celestial_object_statuses (name, slug, color, description, is_blinking) VALUES (?, ?, ?, ?, ?)"); - $stmt->execute([$name, $slug, $color, $description, $is_blinking]); + $stmt = $db->prepare("INSERT INTO celestial_object_statuses (name, slug, color, description) VALUES (?, ?, ?, ?)"); + $stmt->execute([$name, $slug, $color, $description]); } header("Location: admin.php?tab=statuses&success=1"); exit; @@ -118,37 +126,6 @@ if (isset($_GET['delete_status'])) { exit; } -// Handle Status Rules CRUD -if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_status_rule') { - $id = (int)$_POST['id']; - $name = $_POST['name']; - $status_id = (int)$_POST['status_id']; - $object_type_id = $_POST['object_type_id'] !== "" ? (int)$_POST['object_type_id'] : null; - $priority = (int)$_POST['priority']; - $is_active = isset($_POST['is_active']) ? 1 : 0; - $condition_type = $_POST['condition_type']; - $min_control_value = $_POST['min_control_value'] !== "" ? (float)$_POST['min_control_value'] : null; - $max_control_value = $_POST['max_control_value'] !== "" ? (float)$_POST['max_control_value'] : null; - $description = $_POST['description']; - - if ($id > 0) { - $stmt = $db->prepare("UPDATE celestial_object_status_rules SET name = ?, status_id = ?, object_type_id = ?, priority = ?, is_active = ?, condition_type = ?, min_control_value = ?, max_control_value = ?, description = ? WHERE id = ?"); - $stmt->execute([$name, $status_id, $object_type_id, $priority, $is_active, $condition_type, $min_control_value, $max_control_value, $description, $id]); - } else { - $stmt = $db->prepare("INSERT INTO celestial_object_status_rules (name, status_id, object_type_id, priority, is_active, condition_type, min_control_value, max_control_value, description) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); - $stmt->execute([$name, $status_id, $object_type_id, $priority, $is_active, $condition_type, $min_control_value, $max_control_value, $description]); - } - header("Location: admin.php?tab=status_rules&success=1"); - exit; -} - -if (isset($_GET['delete_status_rule'])) { - $id = (int)$_GET['delete_status_rule']; - $db->prepare("DELETE FROM celestial_object_status_rules WHERE id = ?")->execute([$id]); - header("Location: admin.php?tab=status_rules&success=1"); - exit; -} - // Handle Settlement Type CRUD if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_settlement_type') { $id = (int)$_POST['id']; @@ -207,7 +184,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST[' $slug = $_POST['slug']; $fa_icon = $_POST['fa_icon']; $color = $_POST['color']; - $is_playable = isset($_POST['is_playable']) ? 1 : 0; $image_url = null; $alliance_ids = isset($_POST['alliances']) ? $_POST['alliances'] : []; @@ -225,11 +201,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST[' } } if ($id > 0) { - $stmt = $db->prepare("UPDATE factions SET name = ?, slug = ?, image_url = ?, fa_icon = ?, color = ?, is_playable = ? WHERE id = ?"); - $stmt->execute([$name, $slug, $image_url, $fa_icon, $color, $is_playable, $id]); + $stmt = $db->prepare("UPDATE factions SET name = ?, slug = ?, image_url = ?, fa_icon = ?, color = ? WHERE id = ?"); + $stmt->execute([$name, $slug, $image_url, $fa_icon, $color, $id]); } else { - $stmt = $db->prepare("INSERT INTO factions (name, slug, image_url, fa_icon, color, is_playable) VALUES (?, ?, ?, ?, ?, ?)"); - $stmt->execute([$name, $slug, $image_url, $fa_icon, $color, $is_playable]); + $stmt = $db->prepare("INSERT INTO factions (name, slug, image_url, fa_icon, color) VALUES (?, ?, ?, ?, ?)"); + $stmt->execute([$name, $slug, $image_url, $fa_icon, $color]); $id = $db->lastInsertId(); } @@ -385,7 +361,6 @@ if (isset($_GET["delete_project_log"])) { $users_list = []; $objects_list = []; $statuses_list = []; -$status_rules_list = []; $settlement_types_list = []; $modifiers_list = []; $factions_list = []; @@ -406,14 +381,6 @@ if ($tab === 'users') { $modifiers_list = $db->query("SELECT * FROM modifiers ORDER BY type, name ASC")->fetchAll(); } elseif ($tab === 'statuses') { $statuses_list = $db->query("SELECT * FROM celestial_object_statuses ORDER BY name ASC")->fetchAll(); -} elseif ($tab === 'status_rules') { - $status_rules_list = $db->query("SELECT r.*, s.name as status_name, s.color as status_color, t.name as object_type_name - FROM celestial_object_status_rules r - JOIN celestial_object_statuses s ON r.status_id = s.id - LEFT JOIN celestial_object_types t ON r.object_type_id = t.id - ORDER BY r.priority DESC, r.name ASC")->fetchAll(); - $statuses_list = $db->query("SELECT id, name FROM celestial_object_statuses ORDER BY name ASC")->fetchAll(); - $objects_list = $db->query("SELECT id, name FROM celestial_object_types ORDER BY name ASC")->fetchAll(); } elseif ($tab === 'settlement_types') { $settlement_types_list = $db->query("SELECT * FROM settlement_types ORDER BY name ASC")->fetchAll(); } elseif ($tab === 'modifiers') { @@ -443,6 +410,8 @@ if ($tab === 'users') { $lb['items'] = $stmt_i->fetchAll(); } unset($lb); +} elseif ($tab === "project_logs") { + $project_logs_list = $db->query("SELECT * FROM project_logs ORDER BY created_at DESC")->fetchAll(); } ?> @@ -454,7 +423,6 @@ if ($tab === 'users') {
-
- $r): ?> -
- - <?php echo $name; ?> - - - -
- - +
+ +
+ $res): ?> +
+
+ + ?v="> + + "> + +
+
+
+
+ + +
- + +
-
- - Connecté en tant que - Profil - Déconnexion - - Connexion - S'inscrire - +
- -
- + +
+ + -
+
+
+
+ +
Faction:
+ +
+ + + +
Contrôle Orbital:
+
+
+ $lvl): + if ($lvl <= 0) continue; + $fName = $factions_map[$fid]['name'] ?? 'Inconnue'; + $fColor = $factions_map[$fid]['color'] ?? '#88c0d0'; + ?> +
+ + % +
+
+
+
+ +
+
+ + + +
Établissements:
+ +
+
+ + +
+ + +
+ $lvl): + if ($lvl <= 0) continue; + $fName = $factions_map[$fid]['name'] ?? 'Inconnue'; + $fColor = $factions_map[$fid]['color'] ?? '#88c0d0'; + ?> +
+ + % +
+
+
+
+ +
+ +
+ + + + +
+ +
+ + : +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + +
+ +
+ +
+ +
- +
@@ -342,7 +612,7 @@ function isStatusBlinking($status, $statuses_map) { $dotColor = 'rgba(255,255,255,0.05)'; if (isset($sector_data[$s][$p])) { $dotColor = getStatusColor($sector_data[$s][$p]['status'], $statuses_map); } ?> -
+
SECTEUR
@@ -357,7 +627,7 @@ function isStatusBlinking($status, $statuses_map) {
-
+
@@ -415,118 +685,120 @@ function isStatusBlinking($status, $statuses_map) { const statusesMap = ; function openPlanetModal(data) { - document.getElementById('m-planet-name').innerText = data.name; - const typeInfo = typesMap[data.type] || {}; - document.getElementById('m-planet-type').innerText = typeInfo.name || data.type; + if (!data) return; + const typeInfo = typesMap[data.type] || {}; const statusInfo = statusesMap[data.status] || {}; - const statusBadge = document.getElementById('m-planet-status'); - statusBadge.innerText = statusInfo.name || data.status; - statusBadge.style.background = statusInfo.color || '#4c566a'; - if (statusInfo.is_blinking == 1) statusBadge.classList.add('blink'); - else statusBadge.classList.remove('blink'); + const factionInfo = factionsMap[data.faction_id] || { name: 'Aucune', color: '#8c92a3' }; - const img = document.getElementById('m-planet-img'); - img.src = typeInfo.image_url ? typeInfo.image_url + '?v=' + Date.now() : ''; - img.style.display = typeInfo.image_url ? 'block' : 'none'; - - // Faction (Simple logic: majority control) - let dominantFaction = 'Aucune'; - let maxOrb = 0; - for (let fid in data.orbital_controls) { - if (data.orbital_controls[fid] > maxOrb) { - maxOrb = data.orbital_controls[fid]; - dominantFaction = factionsMap[fid] ? factionsMap[fid].name : 'Inconnue'; - } - } - document.getElementById('m-planet-faction').innerText = 'Faction dominante (Orbital): ' + dominantFaction; - - // Modifiers + document.getElementById('m-planet-name').innerText = data.name; + document.getElementById('m-planet-type').innerText = typeInfo.name || data.type; + document.getElementById('m-planet-img').src = typeInfo.image_url || ''; + document.getElementById('m-planet-status').innerText = statusInfo.name || data.status; + document.getElementById('m-planet-status').style.background = statusInfo.color || 'rgba(255,255,255,0.1)'; + document.getElementById('m-planet-faction').innerText = 'Faction dominante: ' + factionInfo.name; + document.getElementById('m-planet-faction').style.color = factionInfo.color || '#fff'; + + // Display modifiers instead of description const modContainer = document.getElementById('m-planet-mods'); modContainer.innerHTML = ''; - if (typeInfo.modifiers) { - typeInfo.modifiers.forEach(mod => { - const span = document.createElement('span'); - span.className = 'mod-badge'; - span.innerText = mod.name; - modContainer.appendChild(span); - }); - } - - // Orbital Bar - renderControlBar('m-orbital-bar', 'm-orbital-legend', data.orbital_controls); - // Terrestrial Bar - renderControlBar('m-terrestrial-bar', 'm-terrestrial-legend', data.terrestrial_controls); - - // Cities - const cityContainer = document.getElementById('m-cities-container'); - cityContainer.innerHTML = ''; - if (data.cities && data.cities.length > 0) { - data.cities.forEach(city => { - const div = document.createElement('div'); - div.className = 'city-item'; - let controlDesc = ''; - for (let fid in city.controls) { - if (factionsMap[fid]) { - controlDesc += `${factionsMap[fid].name}: ${city.controls[fid]}% `; - } - } - div.innerHTML = ` -
- ${city.name} - ${city.type_name || 'Établissement'} -
-
${controlDesc}
+ if (typeInfo.modifiers && typeInfo.modifiers.length > 0) { + typeInfo.modifiers.forEach(m => { + const modDiv = document.createElement('div'); + modDiv.className = 'mod-item ' + (m.type === 'bonus' ? 'mod-bonus' : 'mod-malus'); + modDiv.innerHTML = ` + + ${m.name}: ${m.description} `; - cityContainer.appendChild(div); + modContainer.appendChild(modDiv); }); } else { - cityContainer.innerHTML = '
Aucun établissement répertorié.
'; + modContainer.innerHTML = '
Aucun modificateur particulier.
'; + } + + // Orbital Control + const orbitalBar = document.getElementById('m-orbital-bar'); + const orbitalLegend = document.getElementById('m-orbital-legend'); + orbitalBar.innerHTML = ''; + orbitalLegend.innerHTML = ''; + + if (typeInfo.orbital_control_enabled == 1 && data.orbital_controls && Object.keys(data.orbital_controls).length > 0) { + document.getElementById('m-orbital-section').style.display = 'block'; + renderMultiBar(data.orbital_controls, orbitalBar, orbitalLegend); + } else { + document.getElementById('m-orbital-section').style.display = 'none'; + } + + // Terrestrial Control (Summary) + const terrestrialBar = document.getElementById('m-terrestrial-bar'); + const terrestrialLegend = document.getElementById('m-terrestrial-legend'); + terrestrialBar.innerHTML = ''; + terrestrialLegend.innerHTML = ''; + + if (typeInfo.terrestrial_control_enabled == 1 && data.terrestrial_controls && Object.keys(data.terrestrial_controls).length > 0) { + document.getElementById('m-terrestrial-section').style.display = 'block'; + renderMultiBar(data.terrestrial_controls, terrestrialBar, terrestrialLegend); + } else { + document.getElementById('m-terrestrial-section').style.display = 'none'; + } + + // Cities + const citiesContainer = document.getElementById('m-cities-container'); + citiesContainer.innerHTML = ''; + + if (typeInfo.terrestrial_control_enabled == 1 && data.cities && data.cities.length > 0) { + document.getElementById('m-cities-section').style.display = 'block'; + data.cities.forEach(city => { + const card = document.createElement('div'); + card.className = 'settlement-card'; + + const header = document.createElement('div'); + header.className = 'settlement-header'; + header.innerHTML = `${city.name}${city.type_name}`; + card.appendChild(header); + + if (city.controls && Object.keys(city.controls).length > 0) { + const bar = document.createElement('div'); + bar.className = 'multi-control-bar'; + const legend = document.createElement('div'); + legend.className = 'control-legend'; + + renderMultiBar(city.controls, bar, legend); + + card.appendChild(bar); + card.appendChild(legend); + } + + citiesContainer.appendChild(card); + }); + } else { + document.getElementById('m-cities-section').style.display = 'none'; } document.getElementById('planetModal').style.display = 'flex'; } - function renderControlBar(barId, legendId, controls) { - const bar = document.getElementById(barId); - const legend = document.getElementById(legendId); - bar.innerHTML = ''; - legend.innerHTML = ''; + function renderMultiBar(controls, barElement, legendElement) { + Object.entries(controls).forEach(([fid, lvl]) => { + const level = parseInt(lvl); + const fac = factionsMap[fid] || { name: 'Inconnue', color: '#88c0d0' }; + + if (level <= 0) return; - let total = 0; - for (let fid in controls) { - const val = parseInt(controls[fid]); - if (val > 0) { - total += val; - const faction = factionsMap[fid] || { name: 'Inconnue', color: '#4c566a' }; - const segment = document.createElement('div'); - segment.className = 'control-segment'; - segment.style.width = val + '%'; - segment.style.backgroundColor = faction.color; - segment.title = `${faction.name}: ${val}%`; - bar.appendChild(segment); - - const tag = document.createElement('div'); - tag.className = 'legend-tag'; - tag.innerHTML = ` ${faction.name}: ${val}%`; - legend.appendChild(tag); - } - } - - if (total < 100) { - const remain = 100 - total; + // Segment const segment = document.createElement('div'); segment.className = 'control-segment'; - segment.style.width = remain + '%'; - segment.style.backgroundColor = '#2e3440'; - segment.title = `Incontesté: ${remain}%`; - bar.appendChild(segment); + segment.style.width = level + '%'; + segment.style.backgroundColor = fac.color || '#88c0d0'; + segment.title = `${fac.name}: ${level}%`; + barElement.appendChild(segment); + // Legend const tag = document.createElement('div'); tag.className = 'legend-tag'; - tag.innerHTML = ` Incontesté: ${remain}%`; - legend.appendChild(tag); - } + tag.innerHTML = ` ${fac.name}: ${level}%`; + legendElement.appendChild(tag); + }); } function closePlanetModal() { @@ -534,4 +806,4 @@ function isStatusBlinking($status, $statuses_map) { } - \ No newline at end of file +