332 lines
25 KiB
PHP
332 lines
25 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
session_start();
|
|
$db = db();
|
|
|
|
$user_role = 'user';
|
|
if (isset($_SESSION['user_id'])) {
|
|
$stmt = $db->prepare("SELECT role FROM users WHERE id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$u_data = $stmt->fetch();
|
|
$user_role = $u_data['role'] ?? 'user';
|
|
}
|
|
|
|
$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, 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) {
|
|
$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 = 36;
|
|
$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"]]; }
|
|
|
|
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) {
|
|
$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), '?'));
|
|
$stmt = $db->prepare("SELECT * FROM planet_faction_control WHERE planet_id IN ($placeholders)");
|
|
$stmt->execute($planet_ids);
|
|
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);
|
|
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; }
|
|
}
|
|
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); } }
|
|
}
|
|
}
|
|
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";
|
|
$page_title = "$sector_display_name [G$galaxy_id]";
|
|
} else {
|
|
$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']];
|
|
}
|
|
$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); }
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<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', 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; padding: 10px 20px; }
|
|
.user-auth-bar a { color: #88c0d0; text-decoration: none; font-weight: bold; }
|
|
#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; }
|
|
.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; }
|
|
|
|
.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; }
|
|
.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; }
|
|
.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; }
|
|
.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; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="main-wrapper">
|
|
<header id="top-bar">
|
|
<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-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; 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++): $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>
|
|
<?php endif; ?>
|
|
|
|
<?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++): ?>
|
|
<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>
|
|
</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>
|
|
</main>
|
|
</div>
|
|
|
|
<div id="planetModal" class="modal-overlay" onclick="if(event.target === this) closePlanetModal()">
|
|
<div class="modal-container">
|
|
<div class="modal-header">
|
|
<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" class="planet-preview-img">
|
|
<div class="planet-meta">
|
|
<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">
|
|
<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">
|
|
<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" 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); ?>;
|
|
function openPlanetModal(data) {
|
|
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 || '#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 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 {
|
|
modSection.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 closePlanetModal() { document.getElementById('planetModal').style.display = 'none'; }
|
|
</script>
|
|
</body></html>
|