Autosave: 20260226-030438
This commit is contained in:
parent
d2c018aecf
commit
cebb15e66d
27
db/migrate_status_profiles.php
Normal file
27
db/migrate_status_profiles.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
$db = db();
|
||||
|
||||
try {
|
||||
// 1. Create Profiles table
|
||||
$db->exec("CREATE TABLE IF NOT EXISTS celestial_object_status_profiles (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
slug VARCHAR(255) NOT NULL UNIQUE,
|
||||
enabled TINYINT(1) DEFAULT 1,
|
||||
priority INT DEFAULT 0,
|
||||
scope_object_type VARCHAR(50) NULL,
|
||||
config JSON NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
)");
|
||||
echo "Table 'celestial_object_status_profiles' created or already exists.\n";
|
||||
|
||||
// 2. Add status_profile_id to planets
|
||||
$db->exec("ALTER TABLE planets ADD COLUMN IF NOT EXISTS status_profile_id INT NULL AFTER status");
|
||||
echo "Column 'status_profile_id' added to 'planets' table.\n";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
822
gm_console.php
822
gm_console.php
@ -20,10 +20,10 @@ if (!$current_user || ($current_user['role'] !== 'admin' && $current_user['role'
|
||||
|
||||
$is_admin = ($current_user['role'] === 'admin');
|
||||
|
||||
// Fetch Dynamic Types, Statuses, Settlement Types, and Factions
|
||||
// Fetch Dynamic Types, Statuses, Profiles, Settlement Types, and Factions
|
||||
$object_types_db = $db->query("SELECT * FROM celestial_object_types ORDER BY name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$object_types_map = []; foreach($object_types_db as $ot) { $object_types_map[$ot["slug"]] = $ot; }
|
||||
$statuses_db = $db->query("SELECT * FROM celestial_object_statuses ORDER BY id ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$status_profiles_db = $db->query("SELECT * FROM celestial_object_status_profiles WHERE enabled = 1 ORDER BY priority DESC, name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$settlement_types_db = $db->query("SELECT * FROM settlement_types ORDER BY name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$factions_db = $db->query("SELECT * FROM factions ORDER BY name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@ -31,6 +31,36 @@ $object_types_map = []; foreach($object_types_db as $ot) $object_types_map[$ot['
|
||||
$statuses_map = []; foreach($statuses_db as $s) $statuses_map[$s['slug']] = $s;
|
||||
$factions_map = []; foreach($factions_db as $f) $factions_map[$f['id']] = $f;
|
||||
|
||||
function resolvePlanetStatus($planet, $profiles, $statuses_db, $object_types_map) {
|
||||
// 1. Determine which profile to use (Individual first, then Type default)
|
||||
$profile_id = $planet['status_profile_id'] ?: ($object_types_map[$planet['type']]['status_profile_id'] ?? null);
|
||||
|
||||
if (!empty($profile_id)) {
|
||||
foreach ($profiles as $prof) {
|
||||
if ($prof['id'] == $profile_id) {
|
||||
$config = json_decode($prof['config'], true);
|
||||
if (isset($config['rules']) && is_array($config['rules'])) {
|
||||
foreach ($config['rules'] as $rule) {
|
||||
$match = false; $cond = $rule['condition_type'];
|
||||
if ($cond === 'fixed') $match = true;
|
||||
elseif ($cond === 'orbital_control') { $val = (float)($planet['orbital_control'] ?? 0); if ($val >= ($rule['min_value'] ?? 0) && $val <= ($rule['max_value'] ?? 100)) $match = true; }
|
||||
elseif ($cond === 'terrestrial_control') { $val = (float)($planet['terrestrial_control'] ?? 0); if ($val >= ($rule['min_value'] ?? 0) && $val <= ($rule['max_value'] ?? 100)) $match = true; }
|
||||
elseif ($cond === 'uncontrolled') { if ((float)($planet['orbital_control'] ?? 0) == 0 && (float)($planet['terrestrial_control'] ?? 0) == 0) $match = true; }
|
||||
|
||||
if ($match) {
|
||||
foreach ($statuses_db as $s) {
|
||||
if ($s['id'] == $rule['status_id']) return $s['slug'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $planet['status'];
|
||||
}
|
||||
|
||||
// Handle Planet/Slot Update
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_slot') {
|
||||
$slot_id = (int)($_POST['slot_id'] ?? 0);
|
||||
@ -40,768 +70,212 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
|
||||
$name = $_POST['name'] ?? 'Inconnu';
|
||||
$type = $_POST['type'] ?? 'empty';
|
||||
$manual_status = $_POST['manual_status'] ?? '';
|
||||
|
||||
// Orbital control is now detailed by faction
|
||||
$status_profile_id = !empty($_POST['status_profile_id']) ? (int)$_POST['status_profile_id'] : null;
|
||||
$orbital_controls = $_POST['orbital_controls'] ?? [];
|
||||
$dominant_orbital_val = 0;
|
||||
$dominant_orbital_faction = null;
|
||||
foreach($orbital_controls as $fid => $val) {
|
||||
if ((int)$val > $dominant_orbital_val && (int)$fid != 1) { // Not "Aucune"
|
||||
$dominant_orbital_val = (int)$val;
|
||||
$dominant_orbital_faction = (int)$fid;
|
||||
}
|
||||
}
|
||||
|
||||
// Derive Status and Faction from Settlements
|
||||
$status = 'sta_inhabited';
|
||||
$faction_id = null;
|
||||
$total_non_aucun = 0;
|
||||
$active_factions = [];
|
||||
$num_cities = 0;
|
||||
$avg_terrestrial_control = 0;
|
||||
|
||||
$dominant_orbital_val = 0; foreach($orbital_controls as $fid => $val) { if ((int)$val > $dominant_orbital_val && (int)$fid != 1) $dominant_orbital_val = (int)$val; }
|
||||
$status = 'sta_inhabited'; $faction_id = null; $total_non_aucun = 0; $active_factions = []; $num_cities = 0; $avg_terrestrial_control = 0;
|
||||
if (isset($_POST['cities']) && is_array($_POST['cities'])) {
|
||||
foreach ($_POST['cities'] as $city_data) {
|
||||
if (empty($city_data['name'])) continue;
|
||||
$num_cities++;
|
||||
if (isset($city_data['controls']) && is_array($city_data['controls'])) {
|
||||
foreach ($city_data['controls'] as $f_id => $lvl) {
|
||||
$lvl = (int)$lvl;
|
||||
if ($lvl > 0 && $f_id != 1) { // 1 is "Aucune"
|
||||
$total_non_aucun += $lvl;
|
||||
$active_factions[$f_id] = ($active_factions[$f_id] ?? 0) + $lvl;
|
||||
$avg_terrestrial_control += $lvl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($city_data['name'])) continue; $num_cities++;
|
||||
if (isset($city_data['controls']) && is_array($city_data['controls'])) { foreach ($city_data['controls'] as $f_id => $lvl) { if ((int)$lvl > 0 && $f_id != 1) { $total_non_aucun += (int)$lvl; $active_factions[$f_id] = ($active_factions[$f_id] ?? 0) + (int)$lvl; $avg_terrestrial_control += (int)$lvl; } } }
|
||||
}
|
||||
}
|
||||
|
||||
if ($num_cities > 0) {
|
||||
$avg_terrestrial_control = round($avg_terrestrial_control / $num_cities);
|
||||
}
|
||||
|
||||
if ($num_cities > 0) $avg_terrestrial_control = round($avg_terrestrial_control / $num_cities);
|
||||
if ($num_cities > 0 && $total_non_aucun > 0) {
|
||||
arsort($active_factions);
|
||||
$faction_id = (int)key($active_factions);
|
||||
|
||||
if (count($active_factions) > 1) {
|
||||
$status = 'sta_hostile';
|
||||
} else {
|
||||
if ($total_non_aucun >= ($num_cities * 100)) {
|
||||
$status = 'sta_controlled';
|
||||
} else {
|
||||
$status = 'sta_contested';
|
||||
}
|
||||
}
|
||||
} else if ($type !== 'empty') {
|
||||
$status = 'sta_inhabited';
|
||||
$faction_id = null;
|
||||
}
|
||||
|
||||
// Manual status override
|
||||
if (!empty($manual_status)) {
|
||||
$status = $manual_status;
|
||||
}
|
||||
|
||||
if ($type === 'empty') {
|
||||
if ($slot_id > 0) {
|
||||
$db->prepare("DELETE FROM cities WHERE planet_id = ?")->execute([$slot_id]);
|
||||
$db->prepare("DELETE FROM planet_faction_control WHERE planet_id = ?")->execute([$slot_id]);
|
||||
$db->prepare("DELETE FROM planets WHERE id = ?")->execute([$slot_id]);
|
||||
}
|
||||
} else {
|
||||
if ($slot_id > 0) {
|
||||
$stmt = $db->prepare("UPDATE planets SET name = ?, type = ?, status = ?, faction_id = ?, orbital_control = ?, terrestrial_control = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $type, $status, $faction_id, $dominant_orbital_val, $avg_terrestrial_control, $slot_id]);
|
||||
$planet_id = $slot_id;
|
||||
} else {
|
||||
$stmt = $db->prepare("INSERT INTO planets (galaxy_id, sector_id, slot, name, type, status, faction_id, orbital_control, terrestrial_control) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$galaxy_id, $sector_id, $slot_num, $name, $type, $status, $faction_id, $dominant_orbital_val, $avg_terrestrial_control]);
|
||||
$planet_id = $db->lastInsertId();
|
||||
}
|
||||
|
||||
// Handle Orbital Faction Control
|
||||
arsort($active_factions); $faction_id = (int)key($active_factions);
|
||||
if (count($active_factions) > 1) { $status = 'sta_hostile'; } else { $status = ($total_non_aucun >= ($num_cities * 100)) ? 'sta_controlled' : 'sta_contested'; }
|
||||
} else if ($type !== 'empty') { $status = 'sta_inhabited'; }
|
||||
if (!empty($manual_status)) $status = $manual_status;
|
||||
if ($type === 'empty') { if ($slot_id > 0) { $db->prepare("DELETE FROM cities WHERE planet_id = ?")->execute([$slot_id]); $db->prepare("DELETE FROM planet_faction_control WHERE planet_id = ?")->execute([$slot_id]); $db->prepare("DELETE FROM planets WHERE id = ?")->execute([$slot_id]); } }
|
||||
else {
|
||||
if ($slot_id > 0) { $db->prepare("UPDATE planets SET name = ?, type = ?, status = ?, faction_id = ?, orbital_control = ?, terrestrial_control = ?, status_profile_id = ? WHERE id = ?")->execute([$name, $type, $status, $faction_id, $dominant_orbital_val, $avg_terrestrial_control, $status_profile_id, $slot_id]); $planet_id = $slot_id; }
|
||||
else { $db->prepare("INSERT INTO planets (galaxy_id, sector_id, slot, name, type, status, faction_id, orbital_control, terrestrial_control, status_profile_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")->execute([$galaxy_id, $sector_id, $slot_num, $name, $type, $status, $faction_id, $dominant_orbital_val, $avg_terrestrial_control, $status_profile_id]); $planet_id = $db->lastInsertId(); }
|
||||
$db->prepare("DELETE FROM planet_faction_control WHERE planet_id = ?")->execute([$planet_id]);
|
||||
foreach($orbital_controls as $fid => $lvl) {
|
||||
if ((int)$lvl > 0) {
|
||||
$db->prepare("INSERT INTO planet_faction_control (planet_id, faction_id, control_level) VALUES (?, ?, ?)")->execute([$planet_id, (int)$fid, (int)$lvl]);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Multiple Settlements
|
||||
$sent_city_ids = [];
|
||||
foreach($orbital_controls as $fid => $lvl) { if ((int)$lvl > 0) $db->prepare("INSERT INTO planet_faction_control (planet_id, faction_id, control_level) VALUES (?, ?, ?)")->execute([$planet_id, (int)$fid, (int)$lvl]); }
|
||||
if (isset($_POST['cities']) && is_array($_POST['cities'])) {
|
||||
$sent_city_ids = [];
|
||||
foreach ($_POST['cities'] as $city_data) {
|
||||
if (empty($city_data['name'])) continue;
|
||||
|
||||
$c_id = (int)($city_data['id'] ?? 0);
|
||||
$c_name = $city_data['name'];
|
||||
$c_type_id = !empty($city_data['type_id']) ? (int)$city_data['type_id'] : null;
|
||||
|
||||
if ($c_id > 0) {
|
||||
$stmt = $db->prepare("UPDATE cities SET name = ?, settlement_type_id = ? WHERE id = ? AND planet_id = ?");
|
||||
$stmt->execute([$c_name, $c_type_id, $c_id, $planet_id]);
|
||||
$city_id = $c_id;
|
||||
} else {
|
||||
$stmt = $db->prepare("INSERT INTO cities (planet_id, name, settlement_type_id) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$planet_id, $c_name, $c_type_id]);
|
||||
$city_id = $db->lastInsertId();
|
||||
}
|
||||
$sent_city_ids[] = $city_id;
|
||||
|
||||
// Handle Faction Control
|
||||
$db->prepare("DELETE FROM city_faction_control WHERE city_id = ?")->execute([$city_id]);
|
||||
if (isset($city_data['controls']) && is_array($city_data['controls'])) {
|
||||
foreach ($city_data['controls'] as $fac_id => $control_lvl) {
|
||||
$control_lvl = (int)$control_lvl;
|
||||
if ($control_lvl > 0) {
|
||||
$stmt = $db->prepare("INSERT INTO city_faction_control (city_id, faction_id, control_level) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$city_id, (int)$fac_id, $control_lvl]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($planet_id > 0) {
|
||||
if (empty($sent_city_ids)) {
|
||||
$db->prepare("DELETE FROM cities WHERE planet_id = ?")->execute([$planet_id]);
|
||||
} else {
|
||||
$placeholders = implode(',', array_fill(0, count($sent_city_ids), '?'));
|
||||
$stmt = $db->prepare("DELETE FROM cities WHERE planet_id = ? AND id NOT IN ($placeholders)");
|
||||
$params = array_merge([$planet_id], $sent_city_ids);
|
||||
$stmt->execute($params);
|
||||
if (empty($city_data['name'])) continue; $c_id = (int)($city_data['id'] ?? 0);
|
||||
if ($c_id > 0) { $db->prepare("UPDATE cities SET name = ?, settlement_type_id = ? WHERE id = ?")->execute([$city_data['name'], !empty($city_data['type_id'])?(int)$city_data['type_id']:null, $c_id]); $city_id = $c_id; }
|
||||
else { $db->prepare("INSERT INTO cities (planet_id, name, settlement_type_id) VALUES (?, ?, ?)")->execute([$planet_id, $city_data['name'], !empty($city_data['type_id'])?(int)$city_data['type_id']:null]); $city_id = $db->lastInsertId(); }
|
||||
$sent_city_ids[] = $city_id; $db->prepare("DELETE FROM city_faction_control WHERE city_id = ?")->execute([$city_id]);
|
||||
if (isset($city_data['controls']) && is_array($city_data['controls'])) { foreach ($city_data['controls'] as $f_id => $l) { if ((int)$l > 0) $db->prepare("INSERT INTO city_faction_control (city_id, faction_id, control_level) VALUES (?, ?, ?)")->execute([$city_id, (int)$f_id, (int)$l]); } }
|
||||
}
|
||||
if ($planet_id > 0) { if (empty($sent_city_ids)) { $db->prepare("DELETE FROM cities WHERE planet_id = ?")->execute([$planet_id]); } else { $placeholders = implode(',', array_fill(0, count($sent_city_ids), '?')); $db->prepare("DELETE FROM cities WHERE planet_id = ? AND id NOT IN ($placeholders)")->execute(array_merge([$planet_id], $sent_city_ids)); } }
|
||||
}
|
||||
}
|
||||
header("Location: gm_console.php?view=sector&galaxy_id=$galaxy_id§or_id=$sector_id&success=1");
|
||||
exit;
|
||||
header("Location: gm_console.php?view=sector&galaxy_id=$galaxy_id§or_id=$sector_id&success=1"); exit;
|
||||
}
|
||||
|
||||
// Handle Sector Update
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_sector') {
|
||||
$sector_id = (int)$_POST['sector_id'];
|
||||
$galaxy_id = (int)$_POST['galaxy_id'];
|
||||
$s_name = $_POST['sector_name'] ?? "Secteur $sector_id";
|
||||
$s_status = $_POST['sector_status'] ?? 'unexplored';
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO sectors (id, galaxy_id, name, status) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE name = ?, status = ?");
|
||||
$stmt->execute([$sector_id, $galaxy_id, $s_name, $s_status, $s_name, $s_status]);
|
||||
|
||||
header("Location: gm_console.php?view=sector&galaxy_id=$galaxy_id§or_id=$sector_id&success=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
$view = isset($_GET['view']) ? $_GET['view'] : 'galaxy';
|
||||
$galaxy_id = isset($_GET['galaxy_id']) ? (int)$_GET['galaxy_id'] : 1;
|
||||
$sector_id = isset($_GET['sector_id']) ? (int)$_GET['sector_id'] : 1;
|
||||
$grid_size = 36;
|
||||
|
||||
$view = isset($_GET['view']) ? $_GET['view'] : 'galaxy'; $galaxy_id = (int)($_GET['galaxy_id'] ?? 1); $sector_id = (int)($_GET['sector_id'] ?? 1); $grid_size = 36;
|
||||
if ($view === 'sector') {
|
||||
$stmt = $db->prepare("SELECT * FROM planets WHERE galaxy_id = ? AND sector_id = ? AND slot BETWEEN 1 AND ?");
|
||||
$stmt->execute([$galaxy_id, $sector_id, $grid_size]);
|
||||
$objects_raw = $stmt->fetchAll();
|
||||
|
||||
$grid = array_fill(1, $grid_size, null);
|
||||
$planet_ids = [];
|
||||
foreach ($objects_raw as $obj) {
|
||||
$grid[$obj['slot']] = $obj;
|
||||
$planet_ids[] = $obj['id'];
|
||||
$grid[$obj['slot']]['cities'] = [];
|
||||
$grid[$obj['slot']]['orbital_controls'] = [];
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM planets WHERE galaxy_id = ? AND sector_id = ? AND slot BETWEEN 1 AND ?"); $stmt->execute([$galaxy_id, $sector_id, $grid_size]);
|
||||
$grid = array_fill(1, $grid_size, null); $planet_ids = [];
|
||||
foreach ($stmt->fetchAll() as $obj) { $obj['status'] = resolvePlanetStatus($obj, $status_profiles_db, $statuses_db, $object_types_map); $grid[$obj['slot']] = $obj; $planet_ids[] = $obj['id']; $grid[$obj['slot']]['cities'] = []; $grid[$obj['slot']]['orbital_controls'] = []; }
|
||||
if (!empty($planet_ids)) {
|
||||
// Fetch Orbital Controls
|
||||
$placeholders = implode(',', array_fill(0, count($planet_ids), '?'));
|
||||
$stmt = $db->prepare("SELECT * FROM planet_faction_control WHERE planet_id IN ($placeholders)");
|
||||
$stmt->execute($planet_ids);
|
||||
$orb_controls_raw = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($orb_controls_raw as $ocr) {
|
||||
foreach ($grid as &$slot_data) {
|
||||
if ($slot_data && $slot_data['id'] == $ocr['planet_id']) {
|
||||
$slot_data['orbital_controls'][$ocr['faction_id']] = $ocr['control_level'];
|
||||
}
|
||||
}
|
||||
$p_list = implode(',', array_fill(0, count($planet_ids), '?'));
|
||||
$stmt = $db->prepare("SELECT * FROM planet_faction_control WHERE planet_id IN ($p_list)"); $stmt->execute($planet_ids);
|
||||
foreach ($stmt->fetchAll() as $ocr) { foreach ($grid as &$s) { if ($s && $s['id'] == $ocr['planet_id']) $s['orbital_controls'][$ocr['faction_id']] = $ocr['control_level']; } }
|
||||
unset($s);
|
||||
$stmt = $db->prepare("SELECT * FROM cities WHERE planet_id IN ($p_list)"); $stmt->execute($planet_ids);
|
||||
$cities = $stmt->fetchAll(); $c_ids = array_column($cities, 'id');
|
||||
if (!empty($c_ids)) {
|
||||
$c_list = implode(',', array_fill(0, count($c_ids), '?'));
|
||||
$c_stmt = $db->prepare("SELECT * FROM city_faction_control WHERE city_id IN ($c_list)"); $c_stmt->execute($c_ids);
|
||||
$c_ctrls = []; foreach ($c_stmt->fetchAll() as $cr) $c_ctrls[$cr['city_id']][$cr['faction_id']] = $cr['control_level'];
|
||||
foreach ($cities as $c) { $c['controls'] = $c_ctrls[$c['id']] ?? []; foreach ($grid as &$s) { if ($s && $s['id'] == $c['planet_id']) $s['cities'][] = $c; } }
|
||||
unset($s);
|
||||
}
|
||||
|
||||
// Fetch Cities
|
||||
unset($slot_data);
|
||||
$stmt = $db->prepare("SELECT * FROM cities WHERE planet_id IN ($placeholders)");
|
||||
$stmt->execute($planet_ids);
|
||||
$all_cities = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$city_ids = array_column($all_cities, 'id');
|
||||
$city_controls = [];
|
||||
if (!empty($city_ids)) {
|
||||
$c_placeholders = implode(',', array_fill(0, count($city_ids), '?'));
|
||||
$c_stmt = $db->prepare("SELECT * FROM city_faction_control WHERE city_id IN ($c_placeholders)");
|
||||
$c_stmt->execute($city_ids);
|
||||
$controls_raw = $c_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($controls_raw as $cr) {
|
||||
$city_controls[$cr['city_id']][$cr['faction_id']] = $cr['control_level'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($all_cities as $city) {
|
||||
$city['controls'] = $city_controls[$city['id']] ?? [];
|
||||
foreach ($grid as &$slot_data) {
|
||||
if ($slot_data && $slot_data['id'] == $city['planet_id']) {
|
||||
$slot_data['cities'][] = $city;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($slot_data);
|
||||
}
|
||||
$stmt = $db->prepare("SELECT name, status FROM sectors WHERE id = ?");
|
||||
$stmt->execute([$sector_id]);
|
||||
$sector_info = $stmt->fetch();
|
||||
$stmt = $db->prepare("SELECT name, status FROM sectors WHERE id = ?"); $stmt->execute([$sector_id]); $sector_info = $stmt->fetch();
|
||||
} else {
|
||||
$stmt = $db->prepare("SELECT sector_id, slot, status, type FROM planets WHERE galaxy_id = ? ORDER BY sector_id, slot ASC");
|
||||
$stmt->execute([$galaxy_id]);
|
||||
$all_planets = $stmt->fetchAll();
|
||||
$sector_data = [];
|
||||
$active_sectors = [];
|
||||
foreach ($all_planets as $p) {
|
||||
$sector_data[$p['sector_id']][$p['slot']] = ['status' => $p['status'], 'type' => $p['type']];
|
||||
if (!in_array($p['sector_id'], $active_sectors)) { $active_sectors[] = (int)$p['sector_id']; }
|
||||
}
|
||||
}
|
||||
|
||||
function getStatusColor($status, $type, $statuses_map, $object_types_map) {
|
||||
if ($type === 'empty') return 'rgba(255,255,255,0.05)';
|
||||
$c = $statuses_map[$status]['color'] ?? 'rgba(255,255,255,0.05)'; return str_replace(';blink', '', $c);
|
||||
$stmt = $db->prepare("SELECT id, sector_id, slot, status, type, orbital_control, terrestrial_control, status_profile_id FROM planets WHERE galaxy_id = ? ORDER BY sector_id, slot ASC"); $stmt->execute([$galaxy_id]);
|
||||
$sector_data = []; foreach ($stmt->fetchAll() as $p) { $p['status'] = resolvePlanetStatus($p, $status_profiles_db, $statuses_db, $object_types_map); $sector_data[$p['sector_id']][$p['slot']] = ['status' => $p['status'], 'type' => $p['type']]; }
|
||||
}
|
||||
function getStatusColor($status, $type, $statuses_map) { if ($type === 'empty') return 'rgba(255,255,255,0.05)'; $c = $statuses_map[$status]['color'] ?? 'rgba(255,255,255,0.05)'; return str_replace(';blink', '', $c); }
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Console MJ - Nexus</title>
|
||||
<meta charset="UTF-8"><title>Console MJ - Nexus</title>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||
<link href="assets/css/custom.css?v=<?php echo time(); ?>" rel="stylesheet">
|
||||
<style>
|
||||
body { background: #0b0f19; color: #fff; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; }
|
||||
body { background: #0b0f19; color: #fff; font-family: 'Segoe UI', sans-serif; margin: 0; }
|
||||
header { background: #1a202c; padding: 10px 20px; border-bottom: 2px solid #2d3545; display: flex; justify-content: space-between; align-items: center; }
|
||||
.container { padding: 40px; display: flex; flex-direction: column; align-items: center; }
|
||||
|
||||
.galaxy-map {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 140px);
|
||||
grid-template-rows: repeat(6, 140px);
|
||||
gap: 10px;
|
||||
padding: 15px;
|
||||
background: rgba(10, 15, 30, 0.5);
|
||||
border: 1px solid #2d3545;
|
||||
}
|
||||
.slot {
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
background: rgba(46, 52, 64, 0.3);
|
||||
border: 1px solid #3b4252;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
overflow: hidden;
|
||||
}
|
||||
.galaxy-map { display: grid; grid-template-columns: repeat(6, 140px); gap: 10px; padding: 15px; background: rgba(10, 15, 30, 0.5); border: 1px solid #2d3545; }
|
||||
.slot { width: 140px; height: 140px; background: rgba(46, 52, 64, 0.3); border: 1px solid #3b4252; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; overflow: hidden; }
|
||||
.slot:hover { background: rgba(136, 192, 208, 0.1); border-color: #88c0d0; }
|
||||
.slot-id { position: absolute; top: 5px; left: 8px; font-size: 9px; color: #4c566a; font-weight: bold; z-index: 5; }
|
||||
|
||||
.slot-icons {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
align-items: center;
|
||||
z-index: 6;
|
||||
}
|
||||
|
||||
.faction-icon-sm {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
filter: drop-shadow(0 0 2px rgba(0,0,0,0.8));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.info-icon-sm {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 14px;
|
||||
color: #ebcb8b;
|
||||
filter: drop-shadow(0 0 2px rgba(0,0,0,0.8));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.object-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1;
|
||||
font-size: 90px;
|
||||
z-index: 2;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
.object-image { width: 90px; height: 90px; object-fit: contain; margin: 0; }
|
||||
.slot-id { position: absolute; top: 5px; left: 8px; font-size: 9px; color: #4c566a; font-weight: bold; }
|
||||
.object-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90px; height: 90px; display: flex; align-items: center; justify-content: center; font-size: 90px; z-index: 2; transition: 0.3s; }
|
||||
.object-image { width: 90px; height: 90px; object-fit: contain; }
|
||||
.object-name { position: absolute; bottom: 8px; font-size: 11px; font-weight: bold; color: #eceff4; text-align: center; width: 95%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; z-index: 3; text-shadow: 0 0 4px #000; }
|
||||
.slot:hover .object-icon { transform: translate(-50%, -50%) scale(1.1); }
|
||||
|
||||
.object-name {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
color: #eceff4;
|
||||
text-align: center;
|
||||
width: 95%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
z-index: 3;
|
||||
text-shadow: 0 0 4px rgba(0,0,0,0.8);
|
||||
}
|
||||
.faction-badge { position: absolute; top: 5px; right: 8px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid #fff; display: flex; align-items: center; justify-content: center; z-index: 5; font-size: 10px; background: rgba(0,0,0,0.8); }
|
||||
.building-badge { position: absolute; bottom: 25px; right: 8px; color: #ebcb8b; z-index: 5; font-size: 12px; text-shadow: 0 0 3px #000; }
|
||||
|
||||
#editModal, #sectorModal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 1000; align-items: center; justify-content: center; }
|
||||
.modal-content { background: #1e293b; padding: 30px; border: 1px solid #88c0d0; width: 650px; max-height: 90vh; overflow-y: auto; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
|
||||
.modal-content { background: #1e293b; padding: 30px; border: 1px solid #88c0d0; width: 650px; max-height: 90vh; overflow-y: auto; border-radius: 8px; }
|
||||
.form-group { margin-bottom: 20px; }
|
||||
.form-group label { display: block; font-size: 12px; color: #8c92a3; margin-bottom: 8px; font-weight: bold; }
|
||||
.form-group input, .form-group select, .form-group textarea { width: 100%; background: #0f172a; border: 1px solid #334155; color: #fff; padding: 10px; box-sizing: border-box; border-radius: 4px; font-size: 14px; }
|
||||
|
||||
.btn-save { background: #a3be8c; border: none; padding: 12px 25px; color: #000; font-weight: bold; cursor: pointer; border-radius: 4px; font-size: 14px; width: 100%; }
|
||||
.btn-cancel { background: #4c566a; border: none; padding: 12px 25px; color: #fff; font-weight: bold; cursor: pointer; border-radius: 4px; font-size: 14px; width: 100%; margin-top: 10px; }
|
||||
|
||||
.form-group input, .form-group select, .form-group textarea { width: 100%; background: #0f172a; border: 1px solid #334155; color: #fff; padding: 10px; border-radius: 4px; }
|
||||
.btn-save { background: #a3be8c; border: none; padding: 12px 25px; color: #000; font-weight: bold; cursor: pointer; border-radius: 4px; width: 100%; }
|
||||
.btn-cancel { background: #4c566a; border: none; padding: 12px 25px; color: #fff; font-weight: bold; cursor: pointer; border-radius: 4px; width: 100%; margin-top: 10px; }
|
||||
.settlement-item { background: #1e293b; border: 1px solid #334155; padding: 15px; margin-bottom: 10px; position: relative; border-radius: 6px; }
|
||||
.btn-remove-settlement { position: absolute; right: 8px; top: 8px; background: #bf616a; color: #fff; border: none; width: 22px; height: 22px; cursor: pointer; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; }
|
||||
.btn-add-settlement { background: #81a1c1; color: #000; border: none; padding: 8px 15px; cursor: pointer; font-size: 11px; font-weight: bold; border-radius: 4px; width: 100%; margin-bottom: 15px; transition: 0.2s; }
|
||||
.btn-add-settlement:hover { background: #88c0d0; }
|
||||
.compact-row { display: flex; gap: 15px; align-items: flex-end; margin-bottom: 15px; }
|
||||
.compact-row .form-group { margin-bottom: 0; }
|
||||
|
||||
.control-bars { margin-top: 15px; display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px dashed #334155; }
|
||||
.btn-remove-settlement { position: absolute; right: 8px; top: 8px; background: #bf616a; color: #fff; border: none; width: 22px; height: 22px; cursor: pointer; border-radius: 50%; }
|
||||
.btn-add-settlement { background: #81a1c1; color: #000; border: none; padding: 8px 15px; cursor: pointer; font-size: 11px; font-weight: bold; border-radius: 4px; width: 100%; margin-bottom: 15px; }
|
||||
.control-bars { margin-top: 15px; display: flex; flex-direction: column; gap: 10px; border-top: 1px dashed #334155; padding-top: 10px; }
|
||||
.control-bar-row { display: flex; align-items: center; gap: 10px; }
|
||||
.control-bar-label { width: 100px; font-size: 11px; color: #eceff4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
|
||||
.control-bar-input { flex: 1; -webkit-appearance: none; height: 8px; background: #0f172a; border-radius: 4px; outline: none; }
|
||||
.control-bar-label { width: 100px; font-size: 11px; color: #eceff4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
|
||||
.control-bar-input { flex: 1; height: 8px; background: #0f172a; border-radius: 4px; outline: none; -webkit-appearance: none; }
|
||||
.control-bar-input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: #88c0d0; border-radius: 50%; cursor: pointer; }
|
||||
.control-bar-value { width: 35px; text-align: right; font-size: 11px; color: #88c0d0; font-weight: bold; }
|
||||
|
||||
.sector-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 180px);
|
||||
grid-template-rows: repeat(6, 180px);
|
||||
gap: 15px;
|
||||
}
|
||||
.sector-card { background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: #fff; transition: all 0.2s; width: 180px; height: 180px; box-sizing: border-box; }
|
||||
.sector-grid { display: grid; grid-template-columns: repeat(6, 180px); gap: 15px; }
|
||||
.sector-card { background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 20px; display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #fff; transition: 0.2s; width: 180px; height: 180px; box-sizing: border-box; }
|
||||
.sector-card:hover { border-color: #88c0d0; background: #1a202c; transform: translateY(-3px); }
|
||||
.mini-map { display: grid; grid-template-columns: repeat(6, 12px); gap: 4px; margin-bottom: 10px; background: #000; padding: 6px; }
|
||||
.mini-dot { width: 12px; height: 12px; border-radius: 1px; }
|
||||
|
||||
.mini-dot { width: 12px; height: 12px; }
|
||||
.faction-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div style="display: flex; align-items: center; gap: 20px;">
|
||||
<h2 style="margin: 0; color: #ebcb8b;"><i class="fa-solid fa-headset"></i> CONSOLE MJ</h2>
|
||||
<nav style="display: flex; gap: 20px;">
|
||||
<a href="project_log.php" style="color: #ebcb8b; text-decoration: none; font-size: 14px; font-weight: bold;"><i class="fa-solid fa-clipboard-list"></i> Journal</a> <a href="index.php" style="color: #88c0d0; text-decoration: none; font-size: 14px; font-weight: bold;"><i class="fa-solid fa-eye"></i> Vue Joueur</a>
|
||||
<?php if ($is_admin): ?>
|
||||
<a href="admin.php" style="color: #bf616a; text-decoration: none; font-size: 14px; font-weight: bold;"><i class="fa-solid fa-shield-halved"></i> Console Admin</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
</div>
|
||||
<div style="font-size: 14px;">Connecté en tant que MJ: <strong style="color: #ebcb8b;">@<?php echo htmlspecialchars($_SESSION['username'] ?? 'MJ'); ?></strong></div>
|
||||
<div style="display: flex; align-items: center; gap: 20px;"><h2 style="margin: 0; color: #ebcb8b;"><i class="fa-solid fa-headset"></i> CONSOLE MJ</h2><nav style="display: flex; gap: 20px;"><a href="index.php" style="color: #88c0d0; text-decoration: none; font-size: 14px; font-weight: bold;"><i class="fa-solid fa-eye"></i> Vue Joueur</a><?php if ($is_admin): ?><a href="admin.php" style="color: #bf616a; text-decoration: none; font-size: 14px; font-weight: bold;"><i class="fa-solid fa-shield-halved"></i> Admin</a><?php endif; ?></nav></div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<?php if (isset($_GET["success"])): ?>
|
||||
<div style="background: rgba(163, 190, 140, 0.2); border: 1px solid #a3be8c; color: #a3be8c; padding: 15px; border-radius: 4px; margin-bottom: 20px; width: 100%; max-width: 840px; text-align: center;">
|
||||
<i class="fa-solid fa-circle-check"></i> Modifications enregistrées avec succès !
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($_GET["success"])): ?><div style="background: rgba(163, 190, 140, 0.2); border: 1px solid #a3be8c; color: #a3be8c; padding: 15px; border-radius: 4px; margin-bottom: 20px; width: 100%; max-width: 840px; text-align: center;"><i class="fa-solid fa-circle-check"></i> Succès !</div><?php endif; ?>
|
||||
<?php if ($view === 'galaxy'): ?>
|
||||
<h3 style="color: #88c0d0; margin-bottom: 30px;">Navigateur de Galaxie</h3>
|
||||
<div class="sector-grid">
|
||||
<?php for($s=1; $s<=$grid_size; $s++): ?>
|
||||
<a href="?view=sector&galaxy_id=<?php echo $galaxy_id; ?>§or_id=<?php echo $s; ?>" class="sector-card">
|
||||
<div class="mini-map">
|
||||
<?php for($p=1; $p<=$grid_size; $p++):
|
||||
$dotColor = 'rgba(255,255,255,0.05)';
|
||||
if (isset($sector_data[$s][$p])) { $dotColor = getStatusColor($sector_data[$s][$p]['status'], $sector_data[$s][$p]['type'], $statuses_map, $object_types_map); }
|
||||
?>
|
||||
<div class="mini-dot" style="background-color: <?php echo $dotColor; ?>;"></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<div style="font-size: 14px; font-weight: bold; margin-top: 5px;">SECTEUR <?php echo $s; ?></div>
|
||||
<div class="mini-map"><?php for($p=1; $p<=$grid_size; $p++): $dotColor = 'rgba(255,255,255,0.05)'; if (isset($sector_data[$s][$p])) $dotColor = getStatusColor($sector_data[$s][$p]['status'], $sector_data[$s][$p]['type'], $statuses_map); ?><div class="mini-dot" style="background-color: <?php echo $dotColor; ?>;"></div><?php endfor; ?></div>
|
||||
<div style="font-size: 14px; font-weight: bold;">SECTEUR <?php echo $s; ?></div>
|
||||
</a>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
|
||||
<?php elseif ($view === 'sector'): ?>
|
||||
<div style="display: flex; justify-content: space-between; width: 100%; max-width: 840px; align-items: center; margin-bottom: 20px;">
|
||||
<div style="display: flex; align-items: center; gap: 15px;">
|
||||
<a href="?view=galaxy" style="color: #88c0d0; text-decoration: none;"><i class="fa-solid fa-arrow-left"></i> Retour</a>
|
||||
<h3 style="color: #88c0d0; margin: 0;">Secteur <?php echo $sector_id; ?>: <?php echo htmlspecialchars($sector_info['name'] ?? "Secteur $sector_id"); ?></h3>
|
||||
</div>
|
||||
<button onclick="editSector()" style="background: #5e81ac; border: none; color: #fff; padding: 8px 15px; cursor: pointer; font-size: 12px; font-weight: bold; border-radius: 4px;"><i class="fa-solid fa-pen-to-square"></i> MODIFIER SECTEUR</button>
|
||||
</div>
|
||||
|
||||
<div class="galaxy-map">
|
||||
<?php for($i=1; $i<=$grid_size; $i++): ?>
|
||||
<div class="slot" onclick='editSlot(<?php echo $i; ?>, <?php echo json_encode($grid[$i] ?? null); ?>)'>
|
||||
<span class="slot-id"><?php echo $i; ?></span>
|
||||
<?php if (isset($grid[$i])): $obj = $grid[$i];
|
||||
$type_info = $object_types_map[$obj['type']] ?? null;
|
||||
$fac_info = isset($obj['faction_id']) ? ($factions_map[$obj['faction_id']] ?? null) : null;
|
||||
?>
|
||||
<div class="slot-icons">
|
||||
<?php if ($fac_info): ?>
|
||||
<div class="faction-icon-sm">
|
||||
<?php if (!empty($fac_info['image_url'])): ?>
|
||||
<img src="<?php echo htmlspecialchars($fac_info['image_url']); ?>?v=<?php echo time(); ?>" style="width: 100%; height: 100%; object-fit: contain;" title="<?php echo htmlspecialchars($fac_info['name']); ?>">
|
||||
<?php elseif (!empty($fac_info['fa_icon'])): ?>
|
||||
<i class="fa-solid <?php echo htmlspecialchars($fac_info['fa_icon']); ?>" style="color: <?php echo htmlspecialchars($fac_info['color'] ?? '#fff'); ?>; font-size: 16px;" title="<?php echo htmlspecialchars($fac_info['name']); ?>"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($obj['cities'])): ?>
|
||||
<div class="info-icon-sm" title="Établissements présents">
|
||||
<i class="fa-solid fa-city"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="slot" onclick='editSlot(<?php echo $i; ?>, <?php echo json_encode($grid[$i] ?? null); ?>)'><span class="slot-id"><?php echo $i; ?></span><?php if (isset($grid[$i])): $obj = $grid[$i]; $type_info = $object_types_map[$obj['type']] ?? null; $fac = $factions_map[$obj['faction_id']] ?? null; ?>
|
||||
|
||||
<?php if ($fac && $obj['faction_id'] != 1): ?>
|
||||
<div class="faction-badge" style="border-color: <?php echo $fac['color']; ?>; color: <?php echo $fac['color']; ?>;">
|
||||
<i class="fa-solid <?php echo htmlspecialchars($fac['fa_icon'] ?: 'fa-flag'); ?>"></i>
|
||||
</div>
|
||||
|
||||
<div class="object-icon">
|
||||
<?php
|
||||
$icon = $type_info['icon'] ?? 'fa-circle';
|
||||
$color = getStatusColor($obj['status'], $obj['type'], $statuses_map, $object_types_map);
|
||||
$imageUrl = $type_info['image_url'] ?? null;
|
||||
?>
|
||||
<?php if ($imageUrl): ?>
|
||||
<img src="<?php echo htmlspecialchars($imageUrl); ?>?v=<?php echo time(); ?>" class="object-image">
|
||||
<?php else: ?>
|
||||
<i class="fa-solid <?php echo $icon; ?>" style="color: <?php echo $color; ?>;"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<span class="object-name"><?php echo htmlspecialchars($obj['name']); ?></span>
|
||||
<?php else: ?>
|
||||
<div style="opacity: 0.1;"><i class="fa-solid fa-plus"></i></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($obj['cities'])): ?>
|
||||
<div class="building-badge"><i class="fa-solid fa-city"></i></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="object-icon"><?php $icon = $type_info['icon'] ?? 'fa-circle'; $color = getStatusColor($obj['status'], $obj['type'], $statuses_map); $imageUrl = $type_info['image_url'] ?? null; if ($imageUrl): ?><img src="<?php echo htmlspecialchars($imageUrl); ?>?v=<?php echo time(); ?>" class="object-image"><?php else: ?><i class="fa-solid <?php echo $icon; ?>" style="color: <?php echo $color; ?>;"></i><?php endif; ?></div>
|
||||
<span class="object-name"><?php echo htmlspecialchars($obj['name']); ?></span>
|
||||
<?php else: ?><div style="opacity: 0.1;"><i class="fa-solid fa-plus"></i></div><?php endif; ?></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Edit Slot Modal -->
|
||||
<div id="editModal">
|
||||
<div class="modal-content">
|
||||
<h3 id="modalTitle">Éditer Case</h3>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="update_slot">
|
||||
<input type="hidden" name="slot_id" id="form_slot_id">
|
||||
<input type="hidden" name="slot_num" id="form_slot_num">
|
||||
<input type="hidden" name="galaxy_id" value="<?php echo $galaxy_id; ?>">
|
||||
<input type="hidden" name="sector_id" value="<?php echo $sector_id; ?>">
|
||||
|
||||
<form method="POST"><input type="hidden" name="action" value="update_slot"><input type="hidden" name="slot_id" id="form_slot_id"><input type="hidden" name="slot_num" id="form_slot_num"><input type="hidden" name="galaxy_id" value="<?php echo $galaxy_id; ?>"><input type="hidden" name="sector_id" value="<?php echo $sector_id; ?>">
|
||||
<div style="display: flex; gap: 15px;"><div class="form-group" style="flex: 2;"><label>Nom</label><input type="text" name="name" id="form_name"></div><div class="form-group" style="flex: 1;"><label>Type</label><select name="type" id="form_type" onchange="updateControlToggles()"><option value="empty">VIDE</option><?php foreach($object_types_db as $ot): ?><option value="<?php echo $ot['slug']; ?>"><?php echo $ot['name']; ?></option><?php endforeach; ?></select></div></div>
|
||||
<div style="display: flex; gap: 15px;">
|
||||
<div class="form-group" style="flex: 2;">
|
||||
<label>Nom de l'objet / Planète</label>
|
||||
<input type="text" name="name" id="form_name" placeholder="Ex: Terra Nova...">
|
||||
</div>
|
||||
<div class="form-group" style="flex: 1;">
|
||||
<label>Type d'objet</label>
|
||||
<select name="type" id="form_type" onchange="updateControlToggles()">
|
||||
<option value="empty">VIDE (Suppr)</option>
|
||||
<?php foreach($object_types_db as $ot): ?>
|
||||
<option value="<?php echo $ot['slug']; ?>"><?php echo $ot['name']; ?> (<?php echo $ot['slug']; ?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="flex: 1;"><label>Statut Manuel</label><select name="manual_status" id="form_status"><option value="">-- Automatique --</option><?php foreach($statuses_db as $s): ?><option value="<?php echo $s["slug"]; ?>"><?php echo $s["name"]; ?></option><?php endforeach; ?></select></div>
|
||||
<div class="form-group" style="flex: 1;"><label>Profil Automatique</label><select name="status_profile_id" id="form_profile_id"><option value="">-- Aucun --</option><?php foreach($status_profiles_db as $p): ?><option value="<?php echo $p["id"]; ?>"><?php echo $p["name"]; ?></option><?php endforeach; ?></select></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Statut (Automatique si non spécifié)</label>
|
||||
<select name="manual_status" id="form_status">
|
||||
<option value="">-- Automatique --</option>
|
||||
<?php foreach($statuses_db as $s): ?>
|
||||
<option value="<?php echo $s["slug"]; ?>"><?php echo $s["name"]; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div id="orbitalSectionWrapper" style="display:none; background: rgba(0,0,0,0.1); padding: 15px; border-radius: 6px; border: 1px solid #334155; margin-bottom: 20px;">
|
||||
<h4 style="margin:0 0 10px 0; font-size:12px; color:#88c0d0;">ZONE ORBITALE</h4>
|
||||
<div id="orbitalControlContainer" class="control-bars"></div>
|
||||
</div>
|
||||
|
||||
<!-- Orbital Faction Control Section -->
|
||||
<div id="orbitalSectionWrapper" style="background: rgba(0,0,0,0.1); padding: 15px; border-radius: 6px; border: 1px solid #334155; margin-bottom: 20px;">
|
||||
<label style="font-size: 11px; color: #88c0d0; font-weight: bold; display: block; margin-bottom: 15px; text-align: center; border-bottom: 1px solid #334155; padding-bottom: 8px;">CONTRÔLE ORBITAL PAR FACTION (%)</label>
|
||||
<div id="orbitalControlContainer" class="control-bars">
|
||||
<!-- Orbital sliders injected by JS -->
|
||||
</div>
|
||||
<div id="terrestrialSectionWrapper" style="display:none; background: rgba(0,0,0,0.1); padding: 15px; border-radius: 6px; border: 1px solid #334155; margin-bottom: 20px;">
|
||||
<h4 style="margin:0 0 10px 0; font-size:12px; color:#88c0d0;">ZONE TERRESTRE / AU SOL</h4>
|
||||
<div id="settlementsContainer"></div>
|
||||
<button type="button" class="btn-add-settlement" onclick="addSettlementRow()">+ AJOUTER ÉTABLISSEMENT</button>
|
||||
</div>
|
||||
|
||||
<div id="terrestrialSectionWrapper" style="background: rgba(0,0,0,0.1); padding: 15px; border-radius: 6px; border: 1px solid #334155; margin-bottom: 20px;">
|
||||
<label style="font-size: 11px; color: #88c0d0; font-weight: bold; display: block; margin-bottom: 15px; text-align: center; border-bottom: 1px solid #334155; padding-bottom: 8px;">ÉTABLISSEMENTS & PROGRESSIONS</label>
|
||||
<div id="settlementsContainer">
|
||||
<!-- Settlements will be injected here -->
|
||||
</div>
|
||||
<button type="button" class="btn-add-settlement" onclick="addSettlementRow()"><i class="fa-solid fa-plus"></i> AJOUTER UN ÉTABLISSEMENT</button>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-save">ENREGISTRER</button>
|
||||
<button type="button" class="btn-cancel" onclick="closeModal()">ANNULER</button>
|
||||
<button type="submit" class="btn-save">ENREGISTRER</button><button type="button" class="btn-cancel" onclick="closeModal()">ANNULER</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit Sector Modal -->
|
||||
<div id="sectorModal">
|
||||
<div class="modal-content">
|
||||
<h3>Paramètres du Secteur</h3>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="update_sector">
|
||||
<input type="hidden" name="sector_id" value="<?php echo $sector_id; ?>">
|
||||
<input type="hidden" name="galaxy_id" value="<?php echo $galaxy_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Nom du Secteur</label>
|
||||
<input type="text" name="sector_name" value="<?php echo htmlspecialchars($sector_info['name'] ?? "Secteur $sector_id"); ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Statut Global du Secteur</label>
|
||||
<select name="sector_status">
|
||||
<option value="unexplored" <?php echo ($sector_info['status'] ?? '') == 'unexplored' ? 'selected' : ''; ?>>Inexploré</option>
|
||||
<option value="stable" <?php echo ($sector_info['status'] ?? '') == 'stable' ? 'selected' : ''; ?>>Stable / Pacifique</option>
|
||||
<option value="hostile" <?php echo ($sector_info['status'] ?? '') == 'hostile' ? 'selected' : ''; ?>>Hostile / Contesté</option>
|
||||
<option value="war" <?php echo ($sector_info['status'] ?? '') == 'war' ? 'selected' : ''; ?>>Zone de Guerre Mondiale</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-save">METTRE À JOUR LE SECTEUR</button>
|
||||
<button type="button" class="btn-cancel" onclick="closeSectorModal()">ANNULER</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let settlementIndex = 0;
|
||||
const settlementTypes = <?php echo json_encode($settlement_types_db); ?>;
|
||||
const typesMap = <?php echo json_encode($object_types_map); ?>;
|
||||
const allFactions = <?php echo json_encode($factions_db); ?>;
|
||||
const AUCUN_ID = 1; // ID for "Aucune" faction
|
||||
|
||||
function initOrbitalSliders(orbitalData = null) {
|
||||
const container = document.getElementById('orbitalControlContainer');
|
||||
container.innerHTML = '';
|
||||
|
||||
const hasExisting = orbitalData && Object.keys(orbitalData).length > 0;
|
||||
|
||||
let settlementIndex = 0; const settlementTypes = <?php echo json_encode($settlement_types_db); ?>; const typesMap = <?php echo json_encode($object_types_map); ?>; const allFactions = <?php echo json_encode($factions_db); ?>; const AUCUN_ID = 1;
|
||||
function initOrbitalSliders(data = null) {
|
||||
const container = document.getElementById('orbitalControlContainer'); container.innerHTML = '';
|
||||
allFactions.forEach(f => {
|
||||
let val = 0;
|
||||
if (hasExisting) {
|
||||
val = orbitalData[f.id] !== undefined ? parseInt(orbitalData[f.id]) : 0;
|
||||
} else {
|
||||
val = (f.id == AUCUN_ID ? 100 : 0);
|
||||
}
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.className = 'control-bar-row';
|
||||
div.innerHTML = `
|
||||
<div class="control-bar-label" title="${f.name}">
|
||||
<span class="faction-dot" style="background: ${f.color || '#808080'}"></span>
|
||||
${f.name}
|
||||
</div>
|
||||
<input type="range" name="orbital_controls[${f.id}]"
|
||||
class="control-bar-input orbital-slider"
|
||||
data-faction-id="${f.id}"
|
||||
min="0" max="100" value="${val}"
|
||||
oninput="handleSliderChangeGeneric('orbital-slider', ${f.id}, this.value)">
|
||||
<div class="control-bar-value" id="val_orbital_${f.id}">${val}%</div>
|
||||
`;
|
||||
let val = (data && data[f.id] !== undefined) ? parseInt(data[f.id]) : (f.id == AUCUN_ID ? 100 : 0);
|
||||
const div = document.createElement('div'); div.className = 'control-bar-row';
|
||||
div.innerHTML = `<div class="control-bar-label"><span class="faction-dot" style="background: ${f.color || '#808080'}"></span> ${f.name}</div><input type="range" name="orbital_controls[${f.id}]" class="control-bar-input orbital-slider" data-faction-id="${f.id}" min="0" max="100" value="${val}" oninput="handleSliderChangeGeneric('orbital-slider', ${f.id}, this.value)"><div class="control-bar-value" id="val_orbital_${f.id}">${val}%</div>`;
|
||||
container.appendChild(div);
|
||||
});
|
||||
}
|
||||
|
||||
function addSettlementRow(data = null) {
|
||||
const container = document.getElementById('settlementsContainer');
|
||||
const index = settlementIndex++;
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.className = 'settlement-item';
|
||||
div.id = 'settlement_row_' + index;
|
||||
|
||||
let html = `<button type="button" class="btn-remove-settlement" onclick="document.getElementById('settlement_row_${index}').remove()" title="Supprimer">×</button>`;
|
||||
html += `<input type="hidden" name="cities[${index}][id]" value="${data ? data.id : 0}">`;
|
||||
|
||||
html += `<div class="compact-row">`;
|
||||
html += `<div class="form-group" style="flex: 2;"><label>Nom</label>`;
|
||||
html += `<input type="text" name="cities[${index}][name]" value="${data ? data.name : ''}" placeholder="Ex: New Hope"></div>`;
|
||||
|
||||
html += `<div class="form-group" style="flex: 1;"><label>Type</label><select name="cities[${index}][type_id]">`;
|
||||
settlementTypes.forEach(t => {
|
||||
const sel = (data && data.settlement_type_id == t.id) ? 'selected' : '';
|
||||
html += `<option value="${t.id}" ${sel}>${t.name}</option>`;
|
||||
});
|
||||
html += `</select></div></div>`;
|
||||
|
||||
// Progress bars for each faction
|
||||
html += `<div class="control-bars"><label style="font-size: 10px; color: #8c92a3; font-weight: bold; margin-bottom: 5px;">CONTRÔLE PAR FACTION (%)</label>`;
|
||||
|
||||
const initialControls = {};
|
||||
const hasAnyControls = data && data.controls && Object.keys(data.controls).length > 0;
|
||||
|
||||
const container = document.getElementById('settlementsContainer'); const index = settlementIndex++; const div = document.createElement('div'); div.className = 'settlement-item'; div.id = 'settlement_row_' + index;
|
||||
let html = `<button type="button" class="btn-remove-settlement" onclick="document.getElementById('settlement_row_${index}').remove()">×</button><input type="hidden" name="cities[${index}][id]" value="${data ? data.id : 0}"><div style="display:flex; gap:10px; margin-bottom:10px;"><div style="flex:2"><label>Nom</label><input type="text" name="cities[${index}][name]" value="${data ? data.name : ''}"></div><div style="flex:1"><label>Type</label><select name="cities[${index}][type_id]">${settlementTypes.map(t => `<option value="${t.id}" ${data && data.settlement_type_id == t.id ? 'selected' : ''}>${t.name}</option>`).join('')}</select></div></div><div class="control-bars">`;
|
||||
allFactions.forEach(f => {
|
||||
if (hasAnyControls) {
|
||||
initialControls[f.id] = (data.controls[f.id] !== undefined) ? parseInt(data.controls[f.id]) : 0;
|
||||
} else {
|
||||
initialControls[f.id] = (f.id == AUCUN_ID ? 100 : 0);
|
||||
}
|
||||
let val = (data && data.controls && data.controls[f.id] !== undefined) ? parseInt(data.controls[f.id]) : (f.id == AUCUN_ID ? 100 : 0);
|
||||
html += `<div class="control-bar-row"><div class="control-bar-label"><span class="faction-dot" style="background: ${f.color || '#808080'}"></span> ${f.name}</div><input type="range" name="cities[${index}][controls][${f.id}]" class="control-bar-input city-slider-${index}" data-faction-id="${f.id}" min="0" max="100" value="${val}" oninput="handleSliderChangeGeneric('city-slider-${index}', ${f.id}, this.value, ${index})"><div class="control-bar-value" id="val_${index}_${f.id}">${val}%</div></div>`;
|
||||
});
|
||||
|
||||
allFactions.forEach(f => {
|
||||
const controlVal = initialControls[f.id];
|
||||
html += `
|
||||
<div class="control-bar-row">
|
||||
<div class="control-bar-label" title="${f.name}">
|
||||
<span class="faction-dot" style="background: ${f.color || '#808080'}"></span>
|
||||
${f.name}
|
||||
</div>
|
||||
<input type="range" name="cities[${index}][controls][${f.id}]"
|
||||
class="control-bar-input city-slider-${index}"
|
||||
data-faction-id="${f.id}"
|
||||
min="0" max="100" value="${controlVal}"
|
||||
oninput="handleSliderChangeGeneric('city-slider-${index}', ${f.id}, this.value, ${index})">
|
||||
<div class="control-bar-value" id="val_${index}_${f.id}">${controlVal}%</div>
|
||||
</div>`;
|
||||
});
|
||||
html += `</div>`;
|
||||
|
||||
div.innerHTML = html;
|
||||
container.appendChild(div);
|
||||
div.innerHTML = html + '</div>'; container.appendChild(div);
|
||||
}
|
||||
|
||||
function handleSliderChangeGeneric(className, changedFid, newVal, rowIdx = null) {
|
||||
newVal = parseInt(newVal);
|
||||
const sliders = Array.from(document.querySelectorAll(`.${className}`));
|
||||
|
||||
let otherSum = 0;
|
||||
sliders.forEach(s => {
|
||||
if (parseInt(s.dataset.factionId) !== changedFid) {
|
||||
otherSum += parseInt(s.value);
|
||||
}
|
||||
});
|
||||
|
||||
let targetOtherSum = 100 - newVal;
|
||||
|
||||
if (otherSum === 0 && targetOtherSum > 0) {
|
||||
const aucun = sliders.find(s => parseInt(s.dataset.factionId) === AUCUN_ID);
|
||||
if (aucun && changedFid !== AUCUN_ID) {
|
||||
aucun.value = targetOtherSum;
|
||||
} else {
|
||||
const other = sliders.find(s => parseInt(s.dataset.factionId) !== AUCUN_ID);
|
||||
if (other) other.value = targetOtherSum;
|
||||
}
|
||||
} else {
|
||||
let diff = targetOtherSum - otherSum;
|
||||
if (diff < 0) {
|
||||
const aucun = sliders.find(s => parseInt(s.dataset.factionId) === AUCUN_ID);
|
||||
if (aucun && parseInt(aucun.dataset.factionId) !== changedFid && parseInt(aucun.value) > 0) {
|
||||
let take = Math.min(parseInt(aucun.value), Math.abs(diff));
|
||||
aucun.value = parseInt(aucun.value) - take;
|
||||
diff += take;
|
||||
}
|
||||
if (diff < 0) {
|
||||
sliders.forEach(s => {
|
||||
if (diff === 0 || parseInt(s.dataset.factionId) === changedFid || parseInt(s.dataset.factionId) === AUCUN_ID) return;
|
||||
let val = parseInt(s.value);
|
||||
let take = Math.min(val, Math.abs(diff));
|
||||
s.value = val - take;
|
||||
diff += take;
|
||||
});
|
||||
}
|
||||
} else if (diff > 0) {
|
||||
const aucun = sliders.find(s => parseInt(s.dataset.factionId) === AUCUN_ID);
|
||||
if (aucun && parseInt(aucun.dataset.factionId) !== changedFid) {
|
||||
aucun.value = parseInt(aucun.value) + diff;
|
||||
diff = 0;
|
||||
} else {
|
||||
const other = sliders.find(s => parseInt(s.dataset.factionId) !== changedFid);
|
||||
if (other) {
|
||||
other.value = parseInt(other.value) + diff;
|
||||
diff = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sliders.forEach(s => {
|
||||
const displayId = rowIdx !== null ? `val_${rowIdx}_${s.dataset.factionId}` : `val_orbital_${s.dataset.factionId}`;
|
||||
document.getElementById(displayId).innerText = s.value + '%';
|
||||
});
|
||||
newVal = parseInt(newVal); const sliders = Array.from(document.querySelectorAll(`.${className}`)); let otherSum = 0; sliders.forEach(s => { if (parseInt(s.dataset.factionId) !== changedFid) otherSum += parseInt(s.value); });
|
||||
let diff = (100 - newVal) - otherSum; if (diff !== 0) { const aucun = sliders.find(s => parseInt(s.dataset.factionId) === AUCUN_ID); if (aucun && parseInt(aucun.dataset.factionId) !== changedFid) { aucun.value = Math.max(0, Math.min(100, parseInt(aucun.value) + diff)); } }
|
||||
sliders.forEach(s => { document.getElementById(rowIdx !== null ? `val_${rowIdx}_${s.dataset.factionId}` : `val_orbital_${s.dataset.factionId}`).innerText = s.value + '%'; });
|
||||
}
|
||||
|
||||
function updateControlToggles() {
|
||||
const type = document.getElementById('form_type').value;
|
||||
const typeInfo = typesMap[type] || { orbital_control_enabled: 0, terrestrial_control_enabled: 0 };
|
||||
|
||||
const orbWrapper = document.getElementById('orbitalSectionWrapper');
|
||||
const terrWrapper = document.getElementById('terrestrialSectionWrapper');
|
||||
|
||||
orbWrapper.style.display = (typeInfo.orbital_control_enabled == 1) ? 'block' : 'none';
|
||||
terrWrapper.style.display = (typeInfo.terrestrial_control_enabled == 1) ? 'block' : 'none';
|
||||
|
||||
// Disable inputs in hidden sections to prevent them from being submitted
|
||||
orbWrapper.querySelectorAll('input, select, textarea').forEach(el => el.disabled = (typeInfo.orbital_control_enabled != 1));
|
||||
terrWrapper.querySelectorAll('input, select, textarea, button:not(.btn-cancel):not(.btn-save)').forEach(el => el.disabled = (typeInfo.terrestrial_control_enabled != 1));
|
||||
const type = document.getElementById('form_type').value; const typeInfo = typesMap[type] || { orbital_control_enabled: 0, terrestrial_control_enabled: 0 };
|
||||
document.getElementById('orbitalSectionWrapper').style.display = (typeInfo.orbital_control_enabled == 1) ? 'block' : 'none';
|
||||
document.getElementById('terrestrialSectionWrapper').style.display = (typeInfo.terrestrial_control_enabled == 1) ? 'block' : 'none';
|
||||
}
|
||||
|
||||
function editSlot(num, data) {
|
||||
document.getElementById('form_slot_num').value = num;
|
||||
document.getElementById('form_slot_id').value = data ? data.id : 0;
|
||||
document.getElementById('modalTitle').innerText = 'Éditer Case #' + num;
|
||||
|
||||
if (data) {
|
||||
document.getElementById('form_name').value = data.name;
|
||||
document.getElementById('form_type').value = data.type;
|
||||
document.getElementById('form_status').value = data.status;
|
||||
|
||||
// Load orbital sliders
|
||||
initOrbitalSliders(data.orbital_controls);
|
||||
|
||||
// Load settlements
|
||||
document.getElementById('settlementsContainer').innerHTML = '';
|
||||
settlementIndex = 0;
|
||||
if (data.cities && data.cities.length > 0) {
|
||||
data.cities.forEach(c => addSettlementRow(c));
|
||||
}
|
||||
} else {
|
||||
document.getElementById('form_name').value = '';
|
||||
document.getElementById('form_type').value = 'empty';
|
||||
document.getElementById('form_status').value = '';
|
||||
initOrbitalSliders(null);
|
||||
document.getElementById('settlementsContainer').innerHTML = '';
|
||||
}
|
||||
|
||||
updateControlToggles();
|
||||
document.getElementById('editModal').style.display = 'flex';
|
||||
document.getElementById('form_slot_num').value = num; document.getElementById('form_slot_id').value = data ? data.id : 0;
|
||||
if (data) { document.getElementById('form_name').value = data.name; document.getElementById('form_type').value = data.type; document.getElementById('form_status').value = data.status; document.getElementById('form_profile_id').value = data.status_profile_id || ""; initOrbitalSliders(data.orbital_controls); document.getElementById('settlementsContainer').innerHTML = ''; settlementIndex = 0; if (data.cities) data.cities.forEach(c => addSettlementRow(c)); }
|
||||
else { document.getElementById('form_name').value = ''; document.getElementById('form_type').value = 'empty'; document.getElementById('form_status').value = ''; document.getElementById('form_profile_id').value = ''; initOrbitalSliders(null); document.getElementById('settlementsContainer').innerHTML = ''; }
|
||||
updateControlToggles(); document.getElementById('editModal').style.display = 'flex';
|
||||
}
|
||||
|
||||
function closeModal() { document.getElementById('editModal').style.display = 'none'; }
|
||||
function editSector() { document.getElementById('sectorModal').style.display = 'flex'; }
|
||||
function closeSectorModal() { document.getElementById('sectorModal').style.display = 'none'; }
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</body></html>
|
||||
837
index.php
837
index.php
@ -15,27 +15,53 @@ $view = isset($_GET['view']) ? $_GET['view'] : 'sector';
|
||||
$galaxy_id = isset($_GET['galaxy_id']) ? (int)$_GET['galaxy_id'] : 1;
|
||||
$sector_id = isset($_GET['sector_id']) ? (int)$_GET['sector_id'] : 1;
|
||||
|
||||
// Fetch Dynamic Types, Statuses and Factions
|
||||
// Fetch Dynamic Types, Statuses, Profiles and Factions
|
||||
$object_types_db = $db->query("SELECT * FROM celestial_object_types")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$statuses_db = $db->query("SELECT * FROM celestial_object_statuses")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$status_profiles_db = $db->query("SELECT * FROM celestial_object_status_profiles WHERE enabled = 1 ORDER BY priority DESC, name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$factions_db = $db->query("SELECT * FROM factions")->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
function resolvePlanetStatus($planet, $profiles, $statuses_db, $object_types_map) {
|
||||
// 1. Determine which profile to use (Individual first, then Type default)
|
||||
$profile_id = $planet['status_profile_id'] ?: ($object_types_map[$planet['type']]['status_profile_id'] ?? null);
|
||||
|
||||
if (!empty($profile_id)) {
|
||||
foreach ($profiles as $prof) {
|
||||
if ($prof['id'] == $profile_id) {
|
||||
$config = json_decode($prof['config'], true);
|
||||
if (isset($config['rules']) && is_array($config['rules'])) {
|
||||
foreach ($config['rules'] as $rule) {
|
||||
$match = false; $cond = $rule['condition_type'];
|
||||
if ($cond === 'fixed') $match = true;
|
||||
elseif ($cond === 'orbital_control') { $val = (float)($planet['orbital_control'] ?? 0); if ($val >= ($rule['min_value'] ?? 0) && $val <= ($rule['max_value'] ?? 100)) $match = true; }
|
||||
elseif ($cond === 'terrestrial_control') { $val = (float)($planet['terrestrial_control'] ?? 0); if ($val >= ($rule['min_value'] ?? 0) && $val <= ($rule['max_value'] ?? 100)) $match = true; }
|
||||
elseif ($cond === 'uncontrolled') { if ((float)($planet['orbital_control'] ?? 0) == 0 && (float)($planet['terrestrial_control'] ?? 0) == 0) $match = true; }
|
||||
|
||||
if ($match) {
|
||||
foreach ($statuses_db as $s) {
|
||||
if ($s['id'] == $rule['status_id']) return $s['slug'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $planet['status'];
|
||||
}
|
||||
|
||||
$object_types_map = [];
|
||||
foreach($object_types_db as $ot) {
|
||||
// Get modifiers for this type
|
||||
$stmt = $db->prepare("SELECT m.* FROM modifiers m JOIN celestial_object_type_modifiers cotm ON m.id = cotm.modifier_id WHERE cotm.celestial_object_type_id = ?");
|
||||
$stmt->execute([$ot['id']]);
|
||||
$ot['modifiers'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$object_types_map[$ot['slug']] = $ot;
|
||||
}
|
||||
|
||||
$statuses_map = []; foreach($statuses_db as $s) $statuses_map[$s['slug']] = $s;
|
||||
$factions_map = []; foreach($factions_db as $f) $factions_map[$f['id']] = $f;
|
||||
|
||||
// Grid size: 6x6 = 36 slots per sector
|
||||
$grid_size = 36;
|
||||
|
||||
// Mock Resources
|
||||
$header_resources = $db->query("SELECT * FROM game_resources WHERE show_in_header = 1 ORDER BY CASE WHEN name = 'Crédits' THEN 1 WHEN name = 'Materials' THEN 2 WHEN name = 'Energie' THEN 3 WHEN name = 'Données' THEN 4 ELSE 5 END ASC, name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$resources = []; foreach($header_resources as $hr) { $resources[$hr["name"]] = ["val" => "0", "prod" => "", "icon" => $hr["icon"] ?: "fa-gem", "image" => $hr["image_url"]]; }
|
||||
|
||||
@ -43,767 +69,264 @@ if ($view === 'sector') {
|
||||
$stmt = $db->prepare("SELECT * FROM planets WHERE galaxy_id = ? AND sector_id = ? AND slot BETWEEN 1 AND ?");
|
||||
$stmt->execute([$galaxy_id, $sector_id, $grid_size]);
|
||||
$objects_raw = $stmt->fetchAll();
|
||||
|
||||
$grid = array_fill(1, $grid_size, null);
|
||||
$planet_ids = [];
|
||||
foreach ($objects_raw as $obj) {
|
||||
$grid[$obj['slot']] = $obj;
|
||||
$planet_ids[] = $obj['id'];
|
||||
$grid[$obj['slot']]['cities'] = [];
|
||||
$grid[$obj['slot']]['orbital_controls'] = [];
|
||||
$grid[$obj['slot']]['terrestrial_controls'] = [];
|
||||
$obj['status'] = resolvePlanetStatus($obj, $status_profiles_db, $statuses_db, $object_types_map);
|
||||
$grid[$obj['slot']] = $obj; $planet_ids[] = $obj['id'];
|
||||
$grid[$obj['slot']]['cities'] = []; $grid[$obj['slot']]['orbital_controls'] = []; $grid[$obj['slot']]['terrestrial_controls'] = [];
|
||||
}
|
||||
|
||||
if (!empty($planet_ids)) {
|
||||
$placeholders = implode(',', array_fill(0, count($planet_ids), '?'));
|
||||
|
||||
// Fetch Orbital Controls
|
||||
$stmt = $db->prepare("SELECT * FROM planet_faction_control WHERE planet_id IN ($placeholders)");
|
||||
$stmt->execute($planet_ids);
|
||||
$orb_controls_raw = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($orb_controls_raw as $ocr) {
|
||||
foreach ($grid as &$slot_data) {
|
||||
if ($slot_data && $slot_data['id'] == $ocr['planet_id']) {
|
||||
$slot_data['orbital_controls'][$ocr['faction_id']] = $ocr['control_level'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch Cities
|
||||
unset($slot_data);
|
||||
$stmt = $db->prepare("SELECT c.*, st.name as type_name
|
||||
FROM cities c
|
||||
LEFT JOIN settlement_types st ON c.settlement_type_id = st.id
|
||||
WHERE c.planet_id IN ($placeholders)");
|
||||
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $ocr) { foreach ($grid as &$slot_data) { if ($slot_data && $slot_data['id'] == $ocr['planet_id']) $slot_data['orbital_controls'][$ocr['faction_id']] = $ocr['control_level']; } }
|
||||
unset($slot_data);
|
||||
$stmt = $db->prepare("SELECT c.*, st.name as type_name FROM cities c LEFT JOIN settlement_types st ON c.settlement_type_id = st.id WHERE c.planet_id IN ($placeholders)");
|
||||
$stmt->execute($planet_ids);
|
||||
$all_cities = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$city_ids = array_column($all_cities, 'id');
|
||||
$city_controls = [];
|
||||
if (!empty($city_ids)) {
|
||||
$c_placeholders = implode(',', array_fill(0, count($city_ids), '?'));
|
||||
$c_stmt = $db->prepare("SELECT * FROM city_faction_control WHERE city_id IN ($c_placeholders)");
|
||||
$c_stmt->execute($city_ids);
|
||||
$controls_raw = $c_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($controls_raw as $cr) {
|
||||
$city_controls[$cr['city_id']][$cr['faction_id']] = $cr['control_level'];
|
||||
}
|
||||
foreach ($c_stmt->fetchAll(PDO::FETCH_ASSOC) as $cr) $city_controls[$cr['city_id']][$cr['faction_id']] = $cr['control_level'];
|
||||
}
|
||||
|
||||
$planet_terrestrial_agg = [];
|
||||
foreach ($all_cities as $city) {
|
||||
$pid = $city['planet_id'];
|
||||
$city['controls'] = $city_controls[$city['id']] ?? [];
|
||||
foreach ($city['controls'] as $fid => $lvl) {
|
||||
$planet_terrestrial_agg[$pid][$fid] = ($planet_terrestrial_agg[$pid][$fid] ?? 0) + $lvl;
|
||||
}
|
||||
|
||||
foreach ($grid as &$slot_data) {
|
||||
if ($slot_data && $slot_data['id'] == $pid) {
|
||||
$slot_data['cities'][] = $city;
|
||||
}
|
||||
}
|
||||
$pid = $city['planet_id']; $city['controls'] = $city_controls[$city['id']] ?? [];
|
||||
foreach ($city['controls'] as $fid => $lvl) { $planet_terrestrial_agg[$pid][$fid] = ($planet_terrestrial_agg[$pid][$fid] ?? 0) + $lvl; }
|
||||
foreach ($grid as &$slot_data) { if ($slot_data && $slot_data['id'] == $pid) $slot_data['cities'][] = $city; }
|
||||
}
|
||||
|
||||
// Calculate average terrestrial control per faction
|
||||
foreach ($grid as &$slot_data) {
|
||||
if ($slot_data && !empty($slot_data['cities'])) {
|
||||
$num_cities = count($slot_data['cities']);
|
||||
$pid = $slot_data['id'];
|
||||
if (isset($planet_terrestrial_agg[$pid])) {
|
||||
foreach ($planet_terrestrial_agg[$pid] as $fid => $total_lvl) {
|
||||
$slot_data['terrestrial_controls'][$fid] = round($total_lvl / $num_cities);
|
||||
}
|
||||
}
|
||||
$num_cities = count($slot_data['cities']); $pid = $slot_data['id'];
|
||||
if (isset($planet_terrestrial_agg[$pid])) { foreach ($planet_terrestrial_agg[$pid] as $fid => $total_lvl) { $slot_data['terrestrial_controls'][$fid] = round($total_lvl / $num_cities); } }
|
||||
}
|
||||
}
|
||||
unset($slot_data);
|
||||
}
|
||||
unset($slot_data);
|
||||
|
||||
$stmt = $db->prepare("SELECT name FROM sectors WHERE id = ?");
|
||||
$stmt->execute([$sector_id]);
|
||||
$sector_info = $stmt->fetch();
|
||||
$sector_display_name = $sector_info['name'] ?? "Secteur $sector_id";
|
||||
$stmt = $db->prepare("SELECT name FROM sectors WHERE id = ?"); $stmt->execute([$sector_id]);
|
||||
$sector_info = $stmt->fetch(); $sector_display_name = $sector_info['name'] ?? "Secteur $sector_id";
|
||||
$page_title = "$sector_display_name [G$galaxy_id]";
|
||||
} else {
|
||||
$stmt = $db->prepare("SELECT sector_id, slot, status, type FROM planets WHERE galaxy_id = ? ORDER BY sector_id, slot ASC");
|
||||
$stmt = $db->prepare("SELECT id, sector_id, slot, status, type, orbital_control, terrestrial_control, status_profile_id FROM planets WHERE galaxy_id = ? ORDER BY sector_id, slot ASC");
|
||||
$stmt->execute([$galaxy_id]);
|
||||
$all_planets = $stmt->fetchAll();
|
||||
$sector_data = [];
|
||||
$active_sectors = [];
|
||||
foreach ($all_planets as $p) {
|
||||
foreach ($stmt->fetchAll() as $p) {
|
||||
$p['status'] = resolvePlanetStatus($p, $status_profiles_db, $statuses_db, $object_types_map);
|
||||
$sector_data[$p['sector_id']][$p['slot']] = ['status' => $p['status'], 'type' => $p['type']];
|
||||
if (!in_array($p['sector_id'], $active_sectors)) { $active_sectors[] = (int)$p['sector_id']; }
|
||||
}
|
||||
$page_title = "Galaxie $galaxy_id";
|
||||
}
|
||||
|
||||
function getStatusColor($status, $statuses_map) {
|
||||
$c = $statuses_map[$status]['color'] ?? 'rgba(255,255,255,0.05)'; return str_replace(';blink', '', $c);
|
||||
}
|
||||
function getStatusColor($status, $statuses_map) { $c = $statuses_map[$status]['color'] ?? 'rgba(255,255,255,0.05)'; return str_replace(';blink', '', $c); }
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Nexus - <?php echo $page_title; ?></title>
|
||||
<meta charset="UTF-8"><title>Nexus - <?php echo $page_title; ?></title>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||
<link href="assets/css/custom.css?v=<?php echo time(); ?>" rel="stylesheet">
|
||||
<style>
|
||||
body { background: #000; color: #fff; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; }
|
||||
body { background: #000; color: #fff; font-family: 'Segoe UI', sans-serif; margin: 0; }
|
||||
#main-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
|
||||
.user-auth-bar { display: flex; justify-content: flex-end; gap: 20px; font-size: 11px; color: #8c92a3; margin-bottom: 10px; }
|
||||
.user-auth-bar { display: flex; justify-content: flex-end; gap: 20px; font-size: 11px; color: #8c92a3; padding: 10px 20px; }
|
||||
.user-auth-bar a { color: #88c0d0; text-decoration: none; font-weight: bold; }
|
||||
.user-auth-bar .username { color: #ebcb8b; }
|
||||
|
||||
#game-container { flex: 1; padding: 30px; display: flex; flex-direction: column; align-items: center; }
|
||||
.nav-panel { background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 20px; width: 180px; }
|
||||
.nav-panel h3 { margin: 0 0 15px 0; color: #88c0d0; font-size: 14px; text-transform: uppercase; border-bottom: 1px solid #2d3545; padding-bottom: 10px; }
|
||||
.nav-panel label { display: block; font-size: 10px; color: #8c92a3; margin-top: 10px; }
|
||||
.nav-panel input { width: 100%; background: #000; border: 1px solid #3b4252; color: #fff; padding: 5px; margin-top: 3px; font-size: 12px; }
|
||||
.nav-panel button { width: 100%; margin-top: 15px; background: #88c0d0; border: none; padding: 8px; color: #000; font-weight: bold; cursor: pointer; border-radius: 2px; }
|
||||
|
||||
.galaxy-map {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 140px);
|
||||
grid-template-rows: repeat(6, 140px);
|
||||
gap: 10px;
|
||||
padding: 15px;
|
||||
background: rgba(10, 15, 30, 0.5);
|
||||
border: 1px solid #2d3545;
|
||||
box-shadow: 0 0 30px rgba(0,0,0,0.5);
|
||||
}
|
||||
.slot {
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
background: rgba(46, 52, 64, 0.3);
|
||||
border: 1px solid #3b4252;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
overflow: hidden;
|
||||
}
|
||||
.slot:hover { background: rgba(136, 192, 208, 0.1); border-color: #88c0d0; z-index: 10; }
|
||||
.slot-id { position: absolute; top: 5px; left: 8px; font-size: 9px; color: #4c566a; font-weight: bold; z-index: 5; }
|
||||
|
||||
.slot-icons {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
align-items: center;
|
||||
z-index: 6;
|
||||
}
|
||||
|
||||
.faction-icon-sm {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
filter: drop-shadow(0 0 2px rgba(0,0,0,0.8));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.info-icon-sm {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 14px;
|
||||
color: #ebcb8b;
|
||||
filter: drop-shadow(0 0 2px rgba(0,0,0,0.8));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.object-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
line-height: 1;
|
||||
font-size: 90px;
|
||||
z-index: 2;
|
||||
}
|
||||
.object-image { width: 90px; height: 90px; object-fit: contain; margin: 0; }
|
||||
.galaxy-map { display: grid; grid-template-columns: repeat(6, 140px); gap: 10px; padding: 15px; background: rgba(10, 15, 30, 0.5); border: 1px solid #2d3545; }
|
||||
.slot { width: 140px; height: 140px; background: rgba(46, 52, 64, 0.3); border: 1px solid #3b4252; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; overflow: hidden; }
|
||||
.slot:hover { background: rgba(136, 192, 208, 0.1); border-color: #88c0d0; }
|
||||
.slot-id { position: absolute; top: 5px; left: 8px; font-size: 9px; color: #4c566a; font-weight: bold; }
|
||||
.object-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90px; height: 90px; display: flex; align-items: center; justify-content: center; font-size: 90px; transition: 0.3s; z-index: 2; }
|
||||
.object-image { width: 90px; height: 90px; object-fit: contain; }
|
||||
.object-name { position: absolute; bottom: 8px; font-size: 11px; font-weight: bold; color: #eceff4; text-align: center; width: 95%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 0 4px #000; z-index: 3; }
|
||||
.slot:hover .object-icon { transform: translate(-50%, -50%) scale(1.1); }
|
||||
.faction-badge { position: absolute; top: 5px; right: 8px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid #fff; display: flex; align-items: center; justify-content: center; z-index: 5; font-size: 10px; background: rgba(0,0,0,0.8); }
|
||||
.building-badge { position: absolute; bottom: 25px; right: 8px; color: #ebcb8b; z-index: 5; font-size: 12px; text-shadow: 0 0 3px #000; }
|
||||
|
||||
.object-name {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
color: #eceff4;
|
||||
text-align: center;
|
||||
width: 95%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
z-index: 3;
|
||||
text-shadow: 0 0 4px rgba(0,0,0,0.8);
|
||||
}
|
||||
|
||||
.sector-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 180px);
|
||||
grid-template-rows: repeat(6, 180px);
|
||||
gap: 15px;
|
||||
}
|
||||
.sector-card { background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: #fff; transition: all 0.2s; position: relative; width: 180px; height: 180px; box-sizing: border-box; }
|
||||
.sector-card:hover { border-color: #88c0d0; background: #1a202c; transform: translateY(-3px); }
|
||||
.sector-card.empty { opacity: 0.6; }
|
||||
|
||||
.mini-map { display: grid; grid-template-columns: repeat(6, 12px); gap: 4px; margin-bottom: 15px; background: #000; padding: 6px; border-radius: 2px; }
|
||||
.mini-dot { width: 12px; height: 12px; border-radius: 1px; }
|
||||
|
||||
/* MODAL STYLES */
|
||||
.modal-overlay {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0; left: 0;
|
||||
width: 100%; height: 100%;
|
||||
background: rgba(0, 0, 0, 0.85);
|
||||
backdrop-filter: blur(5px);
|
||||
z-index: 2000;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.modal-container {
|
||||
background: #0f172a;
|
||||
border: 1px solid #1e293b;
|
||||
border-radius: 12px;
|
||||
width: 600px;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
position: relative;
|
||||
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.modal-header {
|
||||
padding: 20px;
|
||||
border-bottom: 1px solid #1e293b;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: rgba(30, 41, 59, 0.5);
|
||||
}
|
||||
.modal-header h2 { margin: 0; font-size: 20px; color: #88c0d0; }
|
||||
.modal-close {
|
||||
background: none; border: none; color: #8c92a3; font-size: 24px; cursor: pointer;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
.modal-close:hover { color: #fff; }
|
||||
.sector-grid { display: grid; grid-template-columns: repeat(6, 180px); gap: 15px; }
|
||||
.sector-card { background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 20px; display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #fff; transition: 0.2s; width: 180px; height: 180px; box-sizing: border-box; }
|
||||
.mini-map { display: grid; grid-template-columns: repeat(6, 12px); gap: 4px; margin-bottom: 15px; background: #000; padding: 6px; }
|
||||
.mini-dot { width: 12px; height: 12px; }
|
||||
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 2000; align-items: center; justify-content: center; }
|
||||
.modal-container { background: #0f172a; border: 1px solid #1e293b; border-radius: 12px; width: 600px; max-height: 90vh; overflow-y: auto; }
|
||||
.modal-header { padding: 20px; border-bottom: 1px solid #1e293b; display: flex; justify-content: space-between; align-items: center; }
|
||||
.modal-header h2 { margin: 0; font-size: 24px; color: #fff; }
|
||||
.modal-close { background: none; border: none; color: #8c92a3; font-size: 24px; cursor: pointer; }
|
||||
.modal-body { padding: 25px; }
|
||||
.planet-hero {
|
||||
display: flex;
|
||||
gap: 25px;
|
||||
margin-bottom: 25px;
|
||||
align-items: center;
|
||||
}
|
||||
.planet-preview-img {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 0 15px rgba(136, 192, 208, 0.3));
|
||||
}
|
||||
.planet-meta { flex: 1; }
|
||||
.planet-status-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 10px;
|
||||
border-radius: 20px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.planet-description {
|
||||
font-size: 13px;
|
||||
color: #94a3b8;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.control-section {
|
||||
margin-bottom: 25px;
|
||||
padding: 15px;
|
||||
background: rgba(30, 41, 59, 0.3);
|
||||
border-radius: 8px;
|
||||
border: 1px solid rgba(136, 192, 208, 0.1);
|
||||
}
|
||||
.control-title {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #88c0d0;
|
||||
text-transform: uppercase;
|
||||
margin-bottom: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.control-title i { font-size: 14px; }
|
||||
|
||||
/* Multi-colored Progress Bar */
|
||||
.multi-control-bar {
|
||||
height: 14px;
|
||||
background: #1e293b;
|
||||
border-radius: 7px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
|
||||
}
|
||||
.control-segment {
|
||||
height: 100%;
|
||||
transition: width 0.3s ease;
|
||||
position: relative;
|
||||
}
|
||||
.control-legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.legend-tag {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 11px;
|
||||
color: #cbd5e1;
|
||||
}
|
||||
.planet-hero { display: flex; gap: 25px; margin-bottom: 25px; align-items: center; }
|
||||
.planet-preview-img { width: 120px; height: 120px; object-fit: contain; }
|
||||
.planet-status-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: bold; text-transform: uppercase; margin-bottom: 10px; }
|
||||
.control-section { margin-bottom: 25px; padding: 15px; background: rgba(30, 41, 59, 0.3); border-radius: 8px; border: 1px solid rgba(136, 192, 208, 0.1); }
|
||||
.control-section h4 { margin: 0 0 12px 0; color: #88c0d0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
|
||||
.multi-control-bar { height: 14px; background: #1e293b; border-radius: 7px; overflow: hidden; display: flex; margin-bottom: 10px; }
|
||||
.control-segment { height: 100%; transition: width 0.3s ease; }
|
||||
.control-legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 10px; }
|
||||
.legend-tag { display: flex; align-items: center; gap: 6px; font-size: 11px; }
|
||||
.legend-color { width: 10px; height: 10px; border-radius: 2px; }
|
||||
|
||||
.settlement-card {
|
||||
background: rgba(15, 23, 42, 0.6);
|
||||
border: 1px solid #1e293b;
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.settlement-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.settlement-name { font-weight: bold; font-size: 14px; color: #fff; }
|
||||
.settlement-type { font-size: 10px; color: #8c92a3; text-transform: uppercase; }
|
||||
|
||||
.tooltip-box { display: none; position: absolute; top: -10px; left: 105%; width: 240px; background: #1e293b; border: 1px solid #88c0d0; padding: 15px; z-index: 100; pointer-events: none; box-shadow: 10px 10px 20px rgba(0,0,0,0.5); }
|
||||
.modifier-badge { background: rgba(136, 192, 208, 0.1); border: 1px solid rgba(136, 192, 208, 0.3); padding: 5px 10px; border-radius: 4px; font-size: 11px; display: flex; align-items: center; gap: 8px; }
|
||||
.modifier-badge.bonus { border-color: #a3be8c; color: #a3be8c; }
|
||||
.modifier-badge.malus { border-color: #bf616a; color: #bf616a; }
|
||||
.tooltip-box { display: none; position: absolute; top: -10px; left: 105%; width: 240px; background: #1e293b; border: 1px solid #88c0d0; padding: 15px; z-index: 100; pointer-events: none; }
|
||||
.slot:hover .tooltip-box { display: block; }
|
||||
.tooltip-title { font-size: 14px; color: #88c0d0; font-weight: bold; border-bottom: 1px solid #334155; padding-bottom: 8px; margin-bottom: 8px; }
|
||||
.tooltip-desc { font-size: 11px; color: #d8dee9; line-height: 1.4; font-style: italic; margin-bottom: 10px; }
|
||||
.mod-list { display: flex; flex-direction: column; gap: 5px; }
|
||||
.mod-item { font-size: 10px; padding: 4px 8px; border-radius: 3px; display: flex; align-items: center; gap: 8px; }
|
||||
.mod-bonus { background: rgba(163, 190, 140, 0.15); color: #a3be8c; border: 1px solid rgba(163, 190, 140, 0.3); }
|
||||
.mod-malus { background: rgba(191, 97, 106, 0.15); color: #bf616a; border: 1px solid rgba(191, 97, 106, 0.3); }
|
||||
.mod-item i { font-size: 12px; }
|
||||
|
||||
.settlement-title { font-size: 10px; color: #ebcb8b; font-weight: bold; border-top: 1px solid #334155; margin-top: 8px; padding-top: 5px; margin-bottom: 5px; }
|
||||
.settlement-item-tool { font-size: 9px; color: #fff; margin-bottom: 10px; background: rgba(0,0,0,0.2); padding: 5px; border-radius: 3px; }
|
||||
.control-bars-mini { margin-top: 5px; display: flex; flex-direction: column; gap: 3px; }
|
||||
.control-bar-mini { height: 4px; background: #000; border-radius: 2px; overflow: hidden; display: flex; }
|
||||
.control-fill { height: 100%; }
|
||||
.control-label-mini { font-size: 7px; color: #8c92a3; display: flex; justify-content: space-between; margin-bottom: 1px; }
|
||||
|
||||
.legend { margin-top: 20px; background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 10px 20px; display: flex; gap: 15px; font-size: 10px; flex-wrap: wrap; max-width: 1000px; justify-content: center; }
|
||||
.legend-item { display: flex; align-items: center; gap: 5px; }
|
||||
.dot { width: 8px; height: 8px; border-radius: 1px; }
|
||||
.breadcrumb { margin-bottom: 20px; font-size: 14px; color: #88c0d0; }
|
||||
.breadcrumb a { color: #fff; text-decoration: none; }
|
||||
.breadcrumb a:hover { text-decoration: underline; }
|
||||
.admin-footer { position: fixed; bottom: 0; left: 0; width: 100%; background: rgba(0,0,0,0.8); padding: 5px 20px; display: flex; justify-content: flex-end; gap: 15px; border-top: 1px solid #2d3545; }
|
||||
.legend { margin-top: 20px; background: rgba(10, 15, 30, 0.95); border: 1px solid #2d3545; padding: 10px 20px; display: flex; gap: 15px; font-size: 10px; flex-wrap: wrap; justify-content: center; }
|
||||
.admin-footer { position: fixed; bottom: 0; left: 0; width: 100%; background: rgba(0,0,0,0.8); padding: 5px 20px; display: flex; justify-content: flex-end; gap: 15px; z-index: 1000; }
|
||||
.admin-footer a { color: #fff; text-decoration: none; font-size: 11px; font-weight: bold; padding: 5px 10px; border-radius: 3px; }
|
||||
.btn-mj { background: #ebcb8b; color: #000 !important; }
|
||||
.btn-adm { background: #bf616a; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main-wrapper">
|
||||
<header id="top-bar">
|
||||
<div class="user-auth-bar">
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<span>Bienvenue, <span class="username">@<?php echo htmlspecialchars($_SESSION['username']); ?></span></span>
|
||||
<a href="project_log.php"><i class="fa-solid fa-clipboard-list"></i> Journal</a> <a href="profile.php"><i class="fa-solid fa-user-gear"></i> Profil</a>
|
||||
<a href="auth.php?logout=1" style="color: #bf616a;"><i class="fa-solid fa-right-from-bracket"></i> Déconnexion</a>
|
||||
<?php else: ?>
|
||||
<a href="auth.php?page=login"><i class="fa-solid fa-right-to-bracket"></i> Connexion</a>
|
||||
<a href='project_log.php'><i class='fa-solid fa-clipboard-list'></i> Journal</a> <a href="auth.php?page=register"><i class="fa-solid fa-user-plus"></i> S'inscrire</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="user-auth-bar"><?php if (isset($_SESSION['user_id'])): ?><span>@<?php echo htmlspecialchars($_SESSION['username']); ?></span> <a href="project_log.php">Journal</a> <a href="profile.php">Profil</a> <a href="auth.php?logout=1">Déconnexion</a><?php else: ?><a href="auth.php?page=login">Connexion</a> <a href="auth.php?page=register">S'inscrire</a><?php endif; ?></div>
|
||||
<div class="resource-container">
|
||||
<?php foreach($resources as $name => $res): ?>
|
||||
<div class="resource-box">
|
||||
<div class="resource-icon">
|
||||
<?php if (!empty($res["image"])): ?>
|
||||
<img src="<?php echo htmlspecialchars($res["image"]); ?>?v=<?php echo time(); ?>">
|
||||
<?php else: ?>
|
||||
<i class="fa-solid <?php echo htmlspecialchars($res["icon"]); ?>"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="resource-info">
|
||||
<div class="resource-name"><?php echo htmlspecialchars($name); ?></div>
|
||||
<div class="resource-val-prod">
|
||||
<span class="resource-value"><?php echo htmlspecialchars($res['val']); ?></span>
|
||||
<span class="resource-prod"><?php echo htmlspecialchars($res['prod']); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="resource-box"><div class="resource-icon"><?php if (!empty($res["image"])): ?><img src="<?php echo htmlspecialchars($res["image"]); ?>?v=<?php echo time(); ?>"><?php else: ?><i class="fa-solid <?php echo htmlspecialchars($res["icon"]); ?>"></i><?php endif; ?></div><div class="resource-info"><div class="resource-name"><?php echo htmlspecialchars($name); ?></div><div class="resource-value"><?php echo htmlspecialchars($res['val']); ?></div></div></div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="game-container">
|
||||
<div class="breadcrumb">
|
||||
<a href="?view=galaxy&galaxy_id=<?php echo $galaxy_id; ?>">Galaxie <?php echo $galaxy_id; ?></a>
|
||||
<?php if($view === 'sector'): ?> > <?php echo htmlspecialchars($sector_display_name); ?> <?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 40px; align-items: flex-start; width: 100%; max-width: 1200px; justify-content: center;">
|
||||
<div class="nav-panel">
|
||||
<h3>Univers</h3>
|
||||
<form method="GET"><input type="hidden" name="view" value="<?php echo $view; ?>">
|
||||
<div><label>Galaxie</label><input type="number" name="galaxy_id" value="<?php echo $galaxy_id; ?>" min="1"></div>
|
||||
<?php if($view === 'sector'): ?><div><label>Secteur</label><input type="number" name="sector_id" value="<?php echo $sector_id; ?>" min="1"></div><?php endif; ?>
|
||||
<button type="submit">Localiser</button>
|
||||
</form>
|
||||
<?php if($view === 'sector'): ?><button onclick="location.href='?view=galaxy&galaxy_id=<?php echo $galaxy_id; ?>'" style="background: #3b4252; margin-top: 5px;">Vue Galaxie</button><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="breadcrumb"><a href="?view=galaxy&galaxy_id=<?php echo $galaxy_id; ?>">Galaxie <?php echo $galaxy_id; ?></a> <?php if($view === 'sector'): ?> > <?php echo htmlspecialchars($sector_display_name); ?><?php endif; ?></div>
|
||||
<div style="display: flex; gap: 40px; width: 100%; max-width: 1200px; justify-content: center;">
|
||||
<div class="nav-panel"><h3>Univers</h3><form><input type="hidden" name="view" value="<?php echo $view; ?>"><label>Galaxie</label><input type="number" name="galaxy_id" value="<?php echo $galaxy_id; ?>"><?php if($view === 'sector'): ?><label>Secteur</label><input type="number" name="sector_id" value="<?php echo $sector_id; ?>"><?php endif; ?><button type="submit">Aller</button></form></div>
|
||||
<?php if($view === 'sector'): ?>
|
||||
<div class="galaxy-map">
|
||||
<?php for($i=1; $i<=$grid_size; $i++): ?>
|
||||
<?php
|
||||
$obj = $grid[$i] ?? null;
|
||||
$json_data = $obj ? htmlspecialchars(json_encode($obj)) : 'null';
|
||||
?>
|
||||
<div class="slot" onclick="openPlanetModal(<?php echo $json_data; ?>)">
|
||||
<span class="slot-id"><?php echo $i; ?></span>
|
||||
<?php if ($obj):
|
||||
$type_info = $object_types_map[$obj['type']] ?? null;
|
||||
$fac_info = isset($obj['faction_id']) ? ($factions_map[$obj['faction_id']] ?? null) : null;
|
||||
?>
|
||||
<div class="tooltip-box">
|
||||
<div class="tooltip-title"><?php echo htmlspecialchars($obj['name']); ?></div>
|
||||
<div style="font-size: 10px; color: #88c0d0; margin-bottom: 5px;"><i class="fa-solid fa-circle-info"></i> <?php echo $statuses_map[$obj['status']]['name'] ?? ucfirst($obj['status']); ?></div>
|
||||
<?php if ($fac_info && $fac_info['name'] !== 'Aucune'): ?>
|
||||
<div style="font-size: 10px; color: <?php echo htmlspecialchars($fac_info['color'] ?? '#ebcb8b'); ?>; margin-bottom: 5px;"><i class="fa-solid fa-flag"></i> Faction: <?php echo htmlspecialchars($fac_info['name']); ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="tooltip-desc"><?php echo htmlspecialchars($type_info['description'] ?? ''); ?></div>
|
||||
|
||||
<!-- Orbital Control Breakdown -->
|
||||
<?php if (!empty($obj['orbital_controls'])): ?>
|
||||
<div class="settlement-title" style="color: #88c0d0;"><i class="fa-solid fa-satellite-dish"></i> Contrôle Orbital:</div>
|
||||
<div class="settlement-item-tool">
|
||||
<div class="control-bars-mini">
|
||||
<?php
|
||||
foreach ($obj['orbital_controls'] as $fid => $lvl):
|
||||
if ($lvl <= 0) continue;
|
||||
$fName = $factions_map[$fid]['name'] ?? 'Inconnue';
|
||||
$fColor = $factions_map[$fid]['color'] ?? '#88c0d0';
|
||||
?>
|
||||
<div class="control-label-mini">
|
||||
<span><?php echo htmlspecialchars($fName); ?></span>
|
||||
<span><?php echo $lvl; ?>%</span>
|
||||
</div>
|
||||
<div class="control-bar-mini">
|
||||
<div class="control-fill" style="width: <?php echo $lvl; ?>%; background: <?php echo htmlspecialchars($fColor); ?>;"></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($obj['cities'])): ?>
|
||||
<div class="settlement-title"><i class="fa-solid fa-city"></i> Établissements:</div>
|
||||
<?php foreach ($obj['cities'] as $c): ?>
|
||||
<div class="settlement-item-tool">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;">
|
||||
<strong><?php echo htmlspecialchars($c['name']); ?></strong>
|
||||
<span style="color: #8c92a3; font-size: 7px;"><?php echo htmlspecialchars($c['type_name']); ?></span>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($c['controls'])): ?>
|
||||
<div class="control-bars-mini">
|
||||
<?php
|
||||
foreach ($c['controls'] as $fid => $lvl):
|
||||
if ($lvl <= 0) continue;
|
||||
$fName = $factions_map[$fid]['name'] ?? 'Inconnue';
|
||||
$fColor = $factions_map[$fid]['color'] ?? '#88c0d0';
|
||||
?>
|
||||
<div class="control-label-mini">
|
||||
<span><?php echo htmlspecialchars($fName); ?></span>
|
||||
<span><?php echo $lvl; ?>%</span>
|
||||
</div>
|
||||
<div class="control-bar-mini">
|
||||
<div class="control-fill" style="width: <?php echo $lvl; ?>%; background: <?php echo htmlspecialchars($fColor); ?>;"></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($type_info['modifiers'])): ?>
|
||||
<div class="mod-list">
|
||||
<?php foreach ($type_info['modifiers'] as $m): ?>
|
||||
<div class="mod-item <?php echo $m['type'] === 'bonus' ? 'mod-bonus' : 'mod-malus'; ?>">
|
||||
<i class="fa-solid <?php echo $m['type'] === 'bonus' ? 'fa-circle-up' : 'fa-circle-down'; ?>"></i>
|
||||
<strong><?php echo htmlspecialchars($m['name']); ?>:</strong> <?php echo htmlspecialchars($m['description']); ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php for($i=1; $i<=$grid_size; $i++): $obj = $grid[$i] ?? null; ?>
|
||||
<div class="slot" onclick='openPlanetModal(<?php echo $obj ? json_encode($obj) : "null"; ?>)'><span class="slot-id"><?php echo $i; ?></span><?php if ($obj): $type_info = $object_types_map[$obj['type']] ?? null; $fac = $factions_map[$obj['faction_id']] ?? null; ?>
|
||||
<div class="tooltip-box"><div style="font-weight:bold; color:#88c0d0;"><?php echo htmlspecialchars($obj['name']); ?></div><div style="font-size:10px; margin-top:5px;"><?php echo $statuses_map[$obj['status']]['name'] ?? $obj['status']; ?></div></div>
|
||||
|
||||
<?php if ($fac && $obj['faction_id'] != 1): ?>
|
||||
<div class="faction-badge" style="border-color: <?php echo $fac['color']; ?>; color: <?php echo $fac['color']; ?>;">
|
||||
<i class="fa-solid <?php echo htmlspecialchars($fac['fa_icon'] ?: 'fa-flag'); ?>"></i>
|
||||
</div>
|
||||
|
||||
<div class="slot-icons">
|
||||
<?php if ($fac_info): ?>
|
||||
<div class="faction-icon-sm">
|
||||
<?php if (!empty($fac_info['image_url'])): ?>
|
||||
<img src="<?php echo htmlspecialchars($fac_info['image_url']); ?>?v=<?php echo time(); ?>" style="width: 100%; height: 100%; object-fit: contain;" title="<?php echo htmlspecialchars($fac_info['name']); ?>">
|
||||
<?php elseif (!empty($fac_info['fa_icon'])): ?>
|
||||
<i class="fa-solid <?php echo htmlspecialchars($fac_info['fa_icon']); ?>" style="color: <?php echo htmlspecialchars($fac_info['color'] ?? '#fff'); ?>; font-size: 16px;" title="<?php echo htmlspecialchars($fac_info['name']); ?>"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($obj['cities'])): ?>
|
||||
<div class="info-icon-sm" title="Établissements présents">
|
||||
<i class="fa-solid fa-city"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="object-icon">
|
||||
<?php
|
||||
$icon = $type_info['icon'] ?? 'fa-earth-europe';
|
||||
$color = getStatusColor($obj['status'], $statuses_map);
|
||||
$imageUrl = $type_info['image_url'] ?? null;
|
||||
?>
|
||||
<?php if ($imageUrl): ?>
|
||||
<img src="<?php echo htmlspecialchars($imageUrl); ?>?v=<?php echo time(); ?>" class="object-image">
|
||||
<?php else: ?>
|
||||
<i class="fa-solid <?php echo $icon; ?>" style="color: <?php echo $color; ?>;"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<span class="object-name"><?php echo htmlspecialchars($obj['name']); ?></span>
|
||||
<?php else: ?>
|
||||
<div style="opacity: 0.05;"><i class="fa-solid fa-circle fa-sm"></i></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($obj['cities'])): ?>
|
||||
<div class="building-badge"><i class="fa-solid fa-city"></i></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="object-icon"><?php $icon = $type_info['icon'] ?? 'fa-circle'; $color = getStatusColor($obj['status'], $statuses_map); $imageUrl = $type_info['image_url'] ?? null; if ($imageUrl): ?><img src="<?php echo htmlspecialchars($imageUrl); ?>?v=<?php echo time(); ?>" class="object-image"><?php else: ?><i class="fa-solid <?php echo $icon; ?>" style="color: <?php echo $color; ?>;"></i><?php endif; ?></div>
|
||||
<span class="object-name"><?php echo htmlspecialchars($obj['name']); ?></span>
|
||||
<?php endif; ?></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="sector-grid">
|
||||
<?php for($s=1; $s<=$grid_size; $s++): $isActive = in_array($s, $active_sectors); ?>
|
||||
<a href="?view=sector&galaxy_id=<?php echo $galaxy_id; ?>§or_id=<?php echo $s; ?>" class="sector-card <?php echo $isActive ? '' : 'empty'; ?>">
|
||||
<div class="mini-map">
|
||||
<?php for($p=1; $p<=$grid_size; $p++):
|
||||
$dotColor = 'rgba(255,255,255,0.05)';
|
||||
if (isset($sector_data[$s][$p])) { $dotColor = getStatusColor($sector_data[$s][$p]['status'], $statuses_map); }
|
||||
?>
|
||||
<div class="mini-dot" style="background-color: <?php echo $dotColor; ?>;"></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<div style="font-size: 10px; color: #88c0d0;">SECTEUR</div>
|
||||
<?php for($s=1; $s<=$grid_size; $s++): ?>
|
||||
<a href="?view=sector&galaxy_id=<?php echo $galaxy_id; ?>§or_id=<?php echo $s; ?>" class="sector-card">
|
||||
<div class="mini-map"><?php for($p=1; $p<=$grid_size; $p++): $dotColor = 'rgba(255,255,255,0.05)'; if (isset($sector_data[$s][$p])) $dotColor = getStatusColor($sector_data[$s][$p]['status'], $statuses_map); ?><div class="mini-dot" style="background-color: <?php echo $dotColor; ?>;"></div><?php endfor; ?></div>
|
||||
<div style="font-size: 20px; font-weight: bold;"><?php echo $s; ?></div>
|
||||
<?php if($isActive): ?><div style="font-size: 8px; color: #a3be8c; margin-top: 5px;"><i class="fa-solid fa-check"></i> Actif</div>
|
||||
<?php else: ?><div style="font-size: 8px; color: #4c566a; margin-top: 5px;">Inexploré</div><?php endif; ?>
|
||||
</a>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="legend">
|
||||
<?php foreach($statuses_db as $s): ?>
|
||||
<div class="legend-item"><span class="dot" style="background: <?php echo $s['color']; ?>;"></span> <?php echo $s['name']; ?></div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="legend"><?php foreach($statuses_db as $s): ?><div class="legend-item"><span class="dot" style="background: <?php echo $s['color']; ?>;"></span> <?php echo $s['name']; ?></div><?php endforeach; ?></div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- MODAL OVERLAY -->
|
||||
<div id="planetModal" class="modal-overlay" onclick="if(event.target === this) closePlanetModal()">
|
||||
<div class="modal-container">
|
||||
<div class="modal-header">
|
||||
<div style="display: flex; flex-direction: column; align-items: flex-start;"><h2 id="m-planet-name">Planet Name</h2><div id="m-planet-type" style="font-style: italic; font-size: 13px; color: #88c0d0; opacity: 0.8; margin-top: 2px;"></div></div>
|
||||
<h2 id="m-planet-name"></h2>
|
||||
<button class="modal-close" onclick="closePlanetModal()">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="planet-hero">
|
||||
<img id="m-planet-img" src="" class="planet-preview-img">
|
||||
<img id="m-planet-img" class="planet-preview-img">
|
||||
<div class="planet-meta">
|
||||
<div id="m-planet-status" class="planet-status-badge">Status</div>
|
||||
<div id="m-planet-faction" style="font-size: 13px; font-weight: bold; margin-bottom: 8px;">Faction: None</div>
|
||||
<div id="m-planet-mods" class="mod-list"></div>
|
||||
<div id="m-planet-type" style="font-size:12px; color:#88c0d0; font-weight:bold; margin-bottom:8px; text-transform:uppercase;"></div>
|
||||
<div id="m-planet-status" class="planet-status-badge"></div>
|
||||
<div id="m-planet-faction" style="font-size:13px; color:#eceff4;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="m-modifiers-section" class="control-section" style="display:none;">
|
||||
<h4>Bonus & Malus</h4>
|
||||
<div id="m-modifiers-list" style="display:flex; flex-wrap:wrap; gap:10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="m-orbital-section" class="control-section">
|
||||
<div class="control-title"><i class="fa-solid fa-satellite-dish"></i> Contrôle Orbital</div>
|
||||
<div id="m-orbital-bar" class="multi-control-bar"></div>
|
||||
<div id="m-orbital-legend" class="control-legend"></div>
|
||||
<h4>Zone Orbitale</h4>
|
||||
<div class="multi-control-bar" id="m-orbital-bar"></div>
|
||||
<div class="control-legend" id="m-orbital-legend"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="m-terrestrial-section" class="control-section">
|
||||
<div class="control-title"><i class="fa-solid fa-person-military-pointing"></i> Contrôle Terrestre</div>
|
||||
<div id="m-terrestrial-bar" class="multi-control-bar"></div>
|
||||
<div id="m-terrestrial-legend" class="control-legend"></div>
|
||||
</div>
|
||||
|
||||
<div id="m-cities-section">
|
||||
<div class="control-title"><i class="fa-solid fa-city"></i> Établissements & Villes</div>
|
||||
<div id="m-cities-container"></div>
|
||||
<h4>Zone Terrestre / Au Sol</h4>
|
||||
<div class="multi-control-bar" id="m-terrestrial-bar"></div>
|
||||
<div class="control-legend" id="m-terrestrial-legend"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($user_role === 'admin' || $user_role === 'gm'): ?>
|
||||
<div class="admin-footer">
|
||||
<a href="gm_console.php" class="btn-mj"><i class="fa-solid fa-headset"></i> CONSOLE MG</a>
|
||||
<?php if ($user_role === 'admin'): ?>
|
||||
<a href="admin.php" class="btn-adm"><i class="fa-solid fa-shield-halved"></i> CONSOLE ADMIN</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($user_role === 'admin' || $user_role === 'gm'): ?><div class="admin-footer"><a href="gm_console.php" style="background:#ebcb8b; color:#000;">MJ</a><?php if ($user_role === 'admin'): ?><a href="admin.php" style="background:#bf616a;">ADMIN</a><?php endif; ?></div><?php endif; ?>
|
||||
|
||||
<script>
|
||||
const factionsMap = <?php echo json_encode($factions_map); ?>;
|
||||
const typesMap = <?php echo json_encode($object_types_map); ?>;
|
||||
const statusesMap = <?php echo json_encode($statuses_map); ?>;
|
||||
|
||||
const factionsMap = <?php echo json_encode($factions_map); ?>; const typesMap = <?php echo json_encode($object_types_map); ?>; const statusesMap = <?php echo json_encode($statuses_map); ?>;
|
||||
function openPlanetModal(data) {
|
||||
if (!data) return;
|
||||
|
||||
const typeInfo = typesMap[data.type] || {};
|
||||
const statusInfo = statusesMap[data.status] || {};
|
||||
if (!data) return;
|
||||
const typeInfo = typesMap[data.type] || {};
|
||||
const statusInfo = statusesMap[data.status] || {};
|
||||
const factionInfo = factionsMap[data.faction_id] || { name: 'Aucune', color: '#8c92a3' };
|
||||
|
||||
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 = '';
|
||||
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 || '#333';
|
||||
document.getElementById('m-planet-faction').innerHTML = '<i class="fa-solid fa-flag" style="color:' + factionInfo.color + '"></i> Faction: ' + factionInfo.name;
|
||||
|
||||
// Modifiers
|
||||
const modSection = document.getElementById('m-modifiers-section');
|
||||
const modList = document.getElementById('m-modifiers-list');
|
||||
modList.innerHTML = '';
|
||||
if (typeInfo.modifiers && typeInfo.modifiers.length > 0) {
|
||||
modSection.style.display = 'block';
|
||||
typeInfo.modifiers.forEach(m => {
|
||||
const modDiv = document.createElement('div');
|
||||
modDiv.className = 'mod-item ' + (m.type === 'bonus' ? 'mod-bonus' : 'mod-malus');
|
||||
modDiv.innerHTML = `
|
||||
<i class="fa-solid ${m.type === 'bonus' ? 'fa-circle-up' : 'fa-circle-down'}"></i>
|
||||
<strong>${m.name}:</strong> ${m.description}
|
||||
`;
|
||||
modContainer.appendChild(modDiv);
|
||||
const div = document.createElement('div');
|
||||
div.className = 'modifier-badge ' + (m.type || 'bonus');
|
||||
div.innerHTML = `<i class="fa-solid ${m.icon || 'fa-circle-info'}"></i> <strong>${m.name}</strong>`;
|
||||
div.title = m.description || '';
|
||||
modList.appendChild(div);
|
||||
});
|
||||
} else {
|
||||
modContainer.innerHTML = '<div style="font-size: 11px; color: #64748b; font-style: italic;">Aucun modificateur particulier.</div>';
|
||||
modSection.style.display = 'none';
|
||||
}
|
||||
|
||||
// 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 = `<span class="settlement-name">${city.name}</span><span class="settlement-type">${city.type_name}</span>`;
|
||||
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';
|
||||
}
|
||||
const render = (c, b, l) => {
|
||||
b.innerHTML = ''; l.innerHTML = '';
|
||||
if (!c || Object.keys(c).length === 0) {
|
||||
const s = document.createElement('div'); s.className = 'control-segment'; s.style.width = '100%'; s.style.backgroundColor = '#1e293b'; b.appendChild(s);
|
||||
const t = document.createElement('div'); t.className = 'legend-tag'; t.innerText = 'Aucun contrôle'; l.appendChild(t);
|
||||
return;
|
||||
}
|
||||
Object.entries(c).forEach(([fid, lvl]) => {
|
||||
if (lvl <= 0) return;
|
||||
const f = factionsMap[fid] || { name: '?', color: '#88c0d0' };
|
||||
const s = document.createElement('div');
|
||||
s.className = 'control-segment';
|
||||
s.style.width = lvl + '%';
|
||||
s.style.backgroundColor = f.color;
|
||||
b.appendChild(s);
|
||||
const t = document.createElement('div');
|
||||
t.className = 'legend-tag';
|
||||
t.innerHTML = `<span class="legend-color" style="background:${f.color}"></span> ${f.name}: ${lvl}%`;
|
||||
l.appendChild(t);
|
||||
});
|
||||
};
|
||||
|
||||
document.getElementById('m-orbital-section').style.display = (typeInfo.orbital_control_enabled == 1) ? 'block' : 'none';
|
||||
document.getElementById('m-terrestrial-section').style.display = (typeInfo.terrestrial_control_enabled == 1) ? 'block' : 'none';
|
||||
|
||||
render(data.orbital_controls || {}, document.getElementById('m-orbital-bar'), document.getElementById('m-orbital-legend'));
|
||||
render(data.terrestrial_controls || {}, document.getElementById('m-terrestrial-bar'), document.getElementById('m-terrestrial-legend'));
|
||||
|
||||
document.getElementById('planetModal').style.display = 'flex';
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// Segment
|
||||
const segment = document.createElement('div');
|
||||
segment.className = 'control-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 = `<span class="legend-color" style="background:${fac.color}"></span> ${fac.name}: ${level}%`;
|
||||
legendElement.appendChild(tag);
|
||||
});
|
||||
}
|
||||
|
||||
function closePlanetModal() {
|
||||
document.getElementById('planetModal').style.display = 'none';
|
||||
}
|
||||
function closePlanetModal() { document.getElementById('planetModal').style.display = 'none'; }
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</body></html>
|
||||
Loading…
x
Reference in New Issue
Block a user