Autosave: 20260226-013905
This commit is contained in:
parent
65093ca0b5
commit
2cfa672890
205
admin.php
205
admin.php
@ -41,7 +41,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
|
||||
$slug = $_POST['slug'];
|
||||
$icon = $_POST['icon'];
|
||||
$description = $_POST['description'];
|
||||
$is_blinking = isset($_POST['is_blinking']) ? 1 : 0;
|
||||
$modifier_ids = isset($_POST['modifiers']) ? $_POST['modifiers'] : [];
|
||||
|
||||
$image_url = null;
|
||||
@ -119,13 +118,43 @@ if (isset($_GET['delete_status'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle Status Rules CRUD
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_status_rule') {
|
||||
$id = (int)$_POST['id'];
|
||||
$name = $_POST['name'];
|
||||
$status_id = (int)$_POST['status_id'];
|
||||
$object_type_id = $_POST['object_type_id'] !== "" ? (int)$_POST['object_type_id'] : null;
|
||||
$priority = (int)$_POST['priority'];
|
||||
$is_active = isset($_POST['is_active']) ? 1 : 0;
|
||||
$condition_type = $_POST['condition_type'];
|
||||
$min_control_value = $_POST['min_control_value'] !== "" ? (float)$_POST['min_control_value'] : null;
|
||||
$max_control_value = $_POST['max_control_value'] !== "" ? (float)$_POST['max_control_value'] : null;
|
||||
$description = $_POST['description'];
|
||||
|
||||
if ($id > 0) {
|
||||
$stmt = $db->prepare("UPDATE celestial_object_status_rules SET name = ?, status_id = ?, object_type_id = ?, priority = ?, is_active = ?, condition_type = ?, min_control_value = ?, max_control_value = ?, description = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $status_id, $object_type_id, $priority, $is_active, $condition_type, $min_control_value, $max_control_value, $description, $id]);
|
||||
} else {
|
||||
$stmt = $db->prepare("INSERT INTO celestial_object_status_rules (name, status_id, object_type_id, priority, is_active, condition_type, min_control_value, max_control_value, description) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$name, $status_id, $object_type_id, $priority, $is_active, $condition_type, $min_control_value, $max_control_value, $description]);
|
||||
}
|
||||
header("Location: admin.php?tab=status_rules&success=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_status_rule'])) {
|
||||
$id = (int)$_GET['delete_status_rule'];
|
||||
$db->prepare("DELETE FROM celestial_object_status_rules WHERE id = ?")->execute([$id]);
|
||||
header("Location: admin.php?tab=status_rules&success=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Handle Settlement Type CRUD
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'upsert_settlement_type') {
|
||||
$id = (int)$_POST['id'];
|
||||
$name = $_POST['name'];
|
||||
$slug = $_POST['slug'];
|
||||
$description = $_POST['description'];
|
||||
$is_blinking = isset($_POST['is_blinking']) ? 1 : 0;
|
||||
|
||||
if ($id > 0) {
|
||||
$stmt = $db->prepare("UPDATE settlement_types SET name = ?, slug = ?, description = ? WHERE id = ?");
|
||||
@ -152,7 +181,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
|
||||
$slug = $_POST['slug'];
|
||||
$type = $_POST['type'];
|
||||
$description = $_POST['description'];
|
||||
$is_blinking = isset($_POST['is_blinking']) ? 1 : 0;
|
||||
|
||||
if ($id > 0) {
|
||||
$stmt = $db->prepare("UPDATE modifiers SET name = ?, slug = ?, type = ?, description = ? WHERE id = ?");
|
||||
@ -232,7 +260,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
|
||||
$slug = $_POST['slug'];
|
||||
$icon = $_POST['icon'];
|
||||
$description = $_POST['description'];
|
||||
$is_blinking = isset($_POST['is_blinking']) ? 1 : 0;
|
||||
$show_in_header = isset($_POST["show_in_header"]) ? 1 : 0;
|
||||
|
||||
$image_url = null;
|
||||
@ -279,7 +306,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
|
||||
$name = $_POST['name'];
|
||||
$slug = $_POST['slug'];
|
||||
$description = $_POST['description'];
|
||||
$is_blinking = isset($_POST['is_blinking']) ? 1 : 0;
|
||||
|
||||
if ($id > 0) {
|
||||
$stmt = $db->prepare("UPDATE lootboxes SET name = ?, slug = ?, description = ? WHERE id = ?");
|
||||
@ -359,6 +385,7 @@ if (isset($_GET["delete_project_log"])) {
|
||||
$users_list = [];
|
||||
$objects_list = [];
|
||||
$statuses_list = [];
|
||||
$status_rules_list = [];
|
||||
$settlement_types_list = [];
|
||||
$modifiers_list = [];
|
||||
$factions_list = [];
|
||||
@ -379,6 +406,14 @@ if ($tab === 'users') {
|
||||
$modifiers_list = $db->query("SELECT * FROM modifiers ORDER BY type, name ASC")->fetchAll();
|
||||
} elseif ($tab === 'statuses') {
|
||||
$statuses_list = $db->query("SELECT * FROM celestial_object_statuses ORDER BY name ASC")->fetchAll();
|
||||
} elseif ($tab === 'status_rules') {
|
||||
$status_rules_list = $db->query("SELECT r.*, s.name as status_name, s.color as status_color, t.name as object_type_name
|
||||
FROM celestial_object_status_rules r
|
||||
JOIN celestial_object_statuses s ON r.status_id = s.id
|
||||
LEFT JOIN celestial_object_types t ON r.object_type_id = t.id
|
||||
ORDER BY r.priority DESC, r.name ASC")->fetchAll();
|
||||
$statuses_list = $db->query("SELECT id, name FROM celestial_object_statuses ORDER BY name ASC")->fetchAll();
|
||||
$objects_list = $db->query("SELECT id, name FROM celestial_object_types ORDER BY name ASC")->fetchAll();
|
||||
} elseif ($tab === 'settlement_types') {
|
||||
$settlement_types_list = $db->query("SELECT * FROM settlement_types ORDER BY name ASC")->fetchAll();
|
||||
} elseif ($tab === 'modifiers') {
|
||||
@ -408,8 +443,6 @@ if ($tab === 'users') {
|
||||
$lb['items'] = $stmt_i->fetchAll();
|
||||
}
|
||||
unset($lb);
|
||||
} elseif ($tab === "project_logs") {
|
||||
$project_logs_list = $db->query("SELECT * FROM project_logs ORDER BY created_at DESC")->fetchAll();
|
||||
}
|
||||
|
||||
?>
|
||||
@ -496,6 +529,7 @@ if ($tab === 'users') {
|
||||
<a href="?tab=users" class="tab-link <?php echo $tab === 'users' ? 'active' : ''; ?>"><i class="fa-solid fa-users"></i> Utilisateurs</a>
|
||||
<a href="?tab=objects" class="tab-link <?php echo $tab === 'objects' ? 'active' : ''; ?>"><i class="fa-solid fa-earth-europe"></i> Objets Célestes</a>
|
||||
<a href="?tab=modifiers" class="tab-link <?php echo $tab === 'modifiers' ? 'active' : ''; ?>"><i class="fa-solid fa-bolt"></i> Bonus & Malus</a>
|
||||
<a href="?tab=status_rules" class="tab-link <?php echo $tab === 'status_rules' ? 'active' : ''; ?>"><i class="fa-solid fa-gears"></i> Règles Statuts</a>
|
||||
<a href="?tab=statuses" class="tab-link <?php echo $tab === 'statuses' ? 'active' : ''; ?>"><i class="fa-solid fa-signal"></i> Statuts / États</a>
|
||||
<a href="?tab=settlement_types" class="tab-link <?php echo $tab === 'settlement_types' ? 'active' : ''; ?>"><i class="fa-solid fa-city"></i> Types d'Établissements</a>
|
||||
<a href="?tab=factions" class="tab-link <?php echo $tab === 'factions' ? 'active' : ''; ?>"><i class="fa-solid fa-flag"></i> Factions</a>
|
||||
@ -698,6 +732,132 @@ if ($tab === 'users') {
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php elseif ($tab === 'status_rules'): ?>
|
||||
<h3 style="color: #88c0d0;">Règles d'Activation des Statuts</h3>
|
||||
<div class="form-card">
|
||||
<h4>Créer / Modifier une Règle</h4>
|
||||
<form method="POST" id="statusRuleForm">
|
||||
<input type="hidden" name="action" value="upsert_status_rule">
|
||||
<input type="hidden" name="id" id="rule_id" value="0">
|
||||
|
||||
<div style="display: flex; gap: 20px;">
|
||||
<div class="form-group" style="flex: 2;">
|
||||
<label>Nom de la règle (Explicite)</label>
|
||||
<input type="text" name="name" id="rule_name" required placeholder="Ex: Occupation ennemie orbitale">
|
||||
</div>
|
||||
<div class="form-group" style="flex: 1;">
|
||||
<label>Statut à appliquer</label>
|
||||
<select name="status_id" id="rule_status_id" required>
|
||||
<option value="">-- Choisir un statut --</option>
|
||||
<?php foreach ($statuses_list as $sl): ?>
|
||||
<option value="<?php echo $sl['id']; ?>"><?php echo htmlspecialchars($sl['name']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="flex: 1;">
|
||||
<label>Type d'Objet (Optionnel)</label>
|
||||
<select name="object_type_id" id="rule_object_type_id">
|
||||
<option value="">Tous les objets (Global)</option>
|
||||
<?php foreach ($objects_list as $ol): ?>
|
||||
<option value="<?php echo $ol['id']; ?>"><?php echo htmlspecialchars($ol['name']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 20px;">
|
||||
<div class="form-group" style="flex: 1;">
|
||||
<label>Condition d'activation</label>
|
||||
<select name="condition_type" id="rule_condition_type" required>
|
||||
<option value="fixed">Forcer (Toujours actif)</option>
|
||||
<option value="orbital_control">Basé sur le contrôle Orbital</option>
|
||||
<option value="terrestrial_control">Basé sur le contrôle Terrestre</option>
|
||||
<option value="uncontrolled">Inoccupé (Contrôle total = 0%)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="flex: 1;">
|
||||
<label>Valeur de contrôle Min (%)</label>
|
||||
<input type="number" name="min_control_value" id="rule_min_val" step="0.1" placeholder="Ex: 50.1">
|
||||
</div>
|
||||
<div class="form-group" style="flex: 1;">
|
||||
<label>Valeur de contrôle Max (%)</label>
|
||||
<input type="number" name="max_control_value" id="rule_max_val" step="0.1" placeholder="Ex: 100">
|
||||
</div>
|
||||
<div class="form-group" style="flex: 0 0 100px;">
|
||||
<label>Priorité</label>
|
||||
<input type="number" name="priority" id="rule_priority" value="0">
|
||||
</div>
|
||||
<div class="form-group" style="flex: 0 0 120px;">
|
||||
<label>État</label>
|
||||
<div style="display: flex; align-items: center; gap: 10px; margin-top: 8px;">
|
||||
<input type="checkbox" name="is_active" id="rule_is_active" checked style="width: auto; height: auto;">
|
||||
<span style="font-size: 12px;">Activée</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Description / Notes internes</label>
|
||||
<textarea name="description" id="rule_desc" rows="2"></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-add">ENREGISTRER LA RÈGLE</button>
|
||||
<button type="button" class="btn" style="background: #4c566a; color: #fff;" onclick="resetStatusRuleForm()">ANNULER</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Priorité</th>
|
||||
<th>Nom de la Règle</th>
|
||||
<th>Statut Appliqué</th>
|
||||
<th>Cible</th>
|
||||
<th>Condition</th>
|
||||
<th>Statut</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($status_rules_list as $rule): ?>
|
||||
<tr style="<?php echo !$rule['is_active'] ? 'opacity: 0.5;' : ''; ?>">
|
||||
<td style="text-align: center;"><strong><?php echo $rule['priority']; ?></strong></td>
|
||||
<td><strong><?php echo htmlspecialchars($rule['name']); ?></strong></td>
|
||||
<td>
|
||||
<span style="display: flex; align-items: center; gap: 5px;">
|
||||
<div style="width: 12px; height: 12px; background: <?php echo $rule['status_color']; ?>; border: 1px solid #fff;"></div>
|
||||
<?php echo htmlspecialchars($rule['status_name']); ?>
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo $rule['object_type_name'] ? htmlspecialchars($rule['object_type_name']) : '<em style="color: #8c92a3;">Global</em>'; ?></td>
|
||||
<td>
|
||||
<small>
|
||||
<?php
|
||||
switch($rule['condition_type']) {
|
||||
case 'fixed': echo "Forcé (Fixe)"; break;
|
||||
case 'orbital_control': echo "Orbital: " . ($rule['min_control_value'] ?? 0) . "% à " . ($rule['max_control_value'] ?? 100) . "%"; break;
|
||||
case 'terrestrial_control': echo "Terrestre: " . ($rule['min_control_value'] ?? 0) . "% à " . ($rule['max_control_value'] ?? 100) . "%"; break;
|
||||
case 'uncontrolled': echo "Inoccupé (0%)"; break;
|
||||
}
|
||||
?>
|
||||
</small>
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<?php if ($rule['is_active']): ?>
|
||||
<span style="color: #a3be8c;"><i class="fa-solid fa-circle-check"></i> Actif</span>
|
||||
<?php else: ?>
|
||||
<span style="color: #bf616a;"><i class="fa-solid fa-circle-xmark"></i> Inactif</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-edit" onclick='editStatusRule(<?php echo json_encode($rule, JSON_HEX_APOS); ?>)'>Editer</button>
|
||||
<a href="?tab=status_rules&delete_status_rule=<?php echo $rule['id']; ?>" class="btn btn-del" onclick="return confirm('Supprimer cette règle ?')">Suppr</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; if (empty($status_rules_list)) echo '<tr><td colspan="7" style="text-align: center; padding: 20px;">Aucune règle configurée.</td></tr>'; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php elseif ($tab === 'statuses'): ?>
|
||||
<h3 style="color: #88c0d0;">Statuts / États</h3>
|
||||
<div class="form-card">
|
||||
@ -718,13 +878,13 @@ if ($tab === 'users') {
|
||||
<label>Couleur</label>
|
||||
<div class="color-group">
|
||||
<input type="color" id="st_color_picker" class="color-picker-input" oninput="document.getElementById('st_color').value = this.value">
|
||||
<input type="text" name="color" id="st_color" required placeholder="#ef4444" oninput="document.getElementById('st_color_picker').value = this.value">
|
||||
</div>
|
||||
<div style="margin-top: 5px;">
|
||||
<label style="display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9em;">
|
||||
<input type="checkbox" name="is_blinking" id="st_is_blinking" value="1"> Clignotement
|
||||
</label>
|
||||
</div>
|
||||
<input type="text" name="color" id="st_color" required placeholder="#ef4444" oninput="document.getElementById('st_color_picker').value = this.value">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -934,16 +1094,6 @@ if ($tab === 'users') {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 15px; background: rgba(0,0,0,0.2); padding: 10px; border-radius: 4px; border: 1px solid #334155;">
|
||||
<div style="flex: 1; display: flex; align-items: center; gap: 10px;">
|
||||
<input type="checkbox" name="orbital_control_enabled" id="obj_orbital_enabled" checked style="width: auto;">
|
||||
<label for="obj_orbital_enabled" style="margin-bottom: 0; cursor: pointer;">Contrôle Orbital activé</label>
|
||||
</div>
|
||||
<div style="flex: 1; display: flex; align-items: center; gap: 10px;">
|
||||
<input type="checkbox" name="terrestrial_control_enabled" id="obj_terrestrial_enabled" checked style="width: auto;">
|
||||
<label for="obj_terrestrial_enabled" style="margin-bottom: 0; cursor: pointer;">Contrôle Terrestre activé</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Description</label>
|
||||
<textarea name="description" id="res_desc" rows="2"></textarea>
|
||||
@ -1045,7 +1195,7 @@ if ($tab === 'users') {
|
||||
document.getElementById('logForm').reset();
|
||||
}
|
||||
</script>
|
||||
<?php elseif ($tab === 'lootboxes'): ?>
|
||||
<?php elseif ($tab === 'lootboxes'): ?>
|
||||
<h3 style="color: #88c0d0;">Système de Lootboxes</h3>
|
||||
<div class="form-card">
|
||||
<h4>Créer / Modifier une Lootbox</h4>
|
||||
@ -1210,6 +1360,21 @@ if ($tab === 'users') {
|
||||
document.getElementById('st_is_blinking').checked = false;
|
||||
}
|
||||
|
||||
function editStatusRule(data) {
|
||||
document.getElementById('rule_id').value = data.id;
|
||||
document.getElementById('rule_name').value = data.name;
|
||||
document.getElementById('rule_status_id').value = data.status_id;
|
||||
document.getElementById('rule_object_type_id').value = data.object_type_id || '';
|
||||
document.getElementById('rule_priority').value = data.priority;
|
||||
document.getElementById('rule_is_active').checked = data.is_active == 1;
|
||||
document.getElementById('rule_condition_type').value = data.condition_type;
|
||||
document.getElementById('rule_min_val').value = data.min_control_value || '';
|
||||
document.getElementById('rule_max_val').value = data.max_control_value || '';
|
||||
document.getElementById('rule_desc').value = data.description || '';
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
function resetStatusRuleForm() { document.getElementById('statusRuleForm').reset(); document.getElementById('rule_id').value = 0; document.getElementById('rule_is_active').checked = true; }
|
||||
|
||||
function editSettlementType(data) {
|
||||
document.getElementById('set_t_id').value = data.id;
|
||||
document.getElementById('set_t_name').value = data.name;
|
||||
|
||||
30
db/migrate_status_rules.php
Normal file
30
db/migrate_status_rules.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
$db = db();
|
||||
|
||||
$sql = "
|
||||
CREATE TABLE IF NOT EXISTS celestial_object_status_rules (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
status_id INT NOT NULL,
|
||||
object_type_id INT NULL,
|
||||
priority INT DEFAULT 0,
|
||||
is_active TINYINT(1) DEFAULT 1,
|
||||
condition_type ENUM('orbital_control', 'terrestrial_control', 'uncontrolled', 'fixed') NOT NULL DEFAULT 'fixed',
|
||||
min_control_value FLOAT DEFAULT NULL,
|
||||
max_control_value FLOAT DEFAULT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (status_id) REFERENCES celestial_object_statuses(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (object_type_id) REFERENCES celestial_object_types(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
";
|
||||
|
||||
try {
|
||||
$db->exec($sql);
|
||||
echo "Table celestial_object_status_rules created successfully.\n";
|
||||
} catch (PDOException $e) {
|
||||
echo "Error creating table: " . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
@ -269,26 +269,13 @@ if ($view === 'sector') {
|
||||
}
|
||||
|
||||
function getStatusColor($status, $type, $statuses_map, $object_types_map) {
|
||||
|
||||
function isStatusBlinking($status, $statuses_map) {
|
||||
return ($statuses_map[$status]["is_blinking"] ?? 0) == 1;
|
||||
}
|
||||
if ($type === 'empty') return 'rgba(255,255,255,0.05)';
|
||||
|
||||
function isStatusBlinking($status, $statuses_map) {
|
||||
return ($statuses_map[$status]["is_blinking"] ?? 0) == 1;
|
||||
}
|
||||
return $statuses_map[$status]['color'] ?? 'rgba(255,255,255,0.05)';
|
||||
|
||||
function isStatusBlinking($status, $statuses_map) {
|
||||
return ($statuses_map[$status]["is_blinking"] ?? 0) == 1;
|
||||
}
|
||||
if ($type === "empty") return "rgba(255,255,255,0.05)";
|
||||
return $statuses_map[$status]["color"] ?? "rgba(255,255,255,0.05)";
|
||||
}
|
||||
|
||||
function isStatusBlinking($status, $statuses_map) {
|
||||
return ($statuses_map[$status]["is_blinking"] ?? 0) == 1;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
|
||||
53
includes/status_helper.php
Normal file
53
includes/status_helper.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Helper to calculate dynamic status based on rules.
|
||||
*/
|
||||
function get_dynamic_status($planet, $rules) {
|
||||
// If no rules, return current status
|
||||
if (empty($rules)) return $planet['status'];
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
// 1. Check if rule is active
|
||||
if (!$rule['is_active']) continue;
|
||||
|
||||
// 2. Check if object type matches (NULL means global)
|
||||
if ($rule['object_type_id'] !== null && $rule['object_type_id'] != $planet['type_id']) {
|
||||
// Wait, planets table has 'type' (slug), not 'type_id'.
|
||||
// I need to resolve the type_id or use slug.
|
||||
// Let's assume we pass the planet with type_id or we resolve it here.
|
||||
}
|
||||
|
||||
// 3. Check Condition
|
||||
$match = false;
|
||||
switch ($rule['condition_type']) {
|
||||
case 'fixed':
|
||||
$match = true;
|
||||
break;
|
||||
case 'orbital_control':
|
||||
$val = (float)($planet['orbital_control'] ?? 0);
|
||||
$min = $rule['min_control_value'] !== null ? (float)$rule['min_control_value'] : -1;
|
||||
$max = $rule['max_control_value'] !== null ? (float)$rule['max_control_value'] : 101;
|
||||
if ($val >= $min && $val <= $max) $match = true;
|
||||
break;
|
||||
case 'terrestrial_control':
|
||||
$val = (float)($planet['terrestrial_control'] ?? 0);
|
||||
$min = $rule['min_control_value'] !== null ? (float)$rule['min_control_value'] : -1;
|
||||
$max = $rule['max_control_value'] !== null ? (float)$rule['max_control_value'] : 101;
|
||||
if ($val >= $min && $val <= $max) $match = true;
|
||||
break;
|
||||
case 'uncontrolled':
|
||||
$orb = (float)($planet['orbital_control'] ?? 0);
|
||||
$terr = (float)($planet['terrestrial_control'] ?? 0);
|
||||
if ($orb == 0 && $terr == 0) $match = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
// Find status slug from id
|
||||
// We should probably pass the status slug in the rule too or join it.
|
||||
return $rule['status_slug'];
|
||||
}
|
||||
}
|
||||
|
||||
return $planet['status'];
|
||||
}
|
||||
662
index.php
662
index.php
@ -70,7 +70,7 @@ if ($view === 'sector') {
|
||||
}
|
||||
|
||||
// Fetch Cities
|
||||
unset($slot_data);
|
||||
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
|
||||
@ -118,7 +118,7 @@ if ($view === 'sector') {
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($slot_data);
|
||||
unset($slot_data);
|
||||
|
||||
$stmt = $db->prepare("SELECT name FROM sectors WHERE id = ?");
|
||||
$stmt->execute([$sector_id]);
|
||||
@ -139,15 +139,7 @@ if ($view === 'sector') {
|
||||
}
|
||||
|
||||
function getStatusColor($status, $statuses_map) {
|
||||
|
||||
function isStatusBlinking($status, $statuses_map) {
|
||||
return ($statuses_map[$status]["is_blinking"] ?? 0) == 1;
|
||||
}
|
||||
return $statuses_map[$status]['color'] ?? 'rgba(255,255,255,0.05)';
|
||||
|
||||
function isStatusBlinking($status, $statuses_map) {
|
||||
return ($statuses_map[$status]["is_blinking"] ?? 0) == 1;
|
||||
}
|
||||
}
|
||||
|
||||
function isStatusBlinking($status, $statuses_map) {
|
||||
@ -198,406 +190,131 @@ function isStatusBlinking($status, $statuses_map) {
|
||||
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;
|
||||
}
|
||||
.slot:hover { border-color: #88c0d0; background: rgba(136, 192, 208, 0.1); }
|
||||
.slot.empty { cursor: default; }
|
||||
.slot.empty:hover { border-color: #3b4252; background: rgba(46, 52, 64, 0.3); }
|
||||
|
||||
.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-image { width: 100%; height: 100%; object-fit: contain; }
|
||||
.object-icon-container { font-size: 40px; margin-bottom: 10px; width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; position: relative; }
|
||||
.object-name { font-size: 12px; font-weight: bold; text-align: center; padding: 0 5px; color: #d8dee9; }
|
||||
|
||||
.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; }
|
||||
.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);
|
||||
}
|
||||
|
||||
.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-grid { display: grid; grid-template-columns: repeat(6, 140px); grid-template-rows: repeat(6, 140px); gap: 10px; }
|
||||
.sector-card { background: rgba(46, 52, 64, 0.4); border: 1px solid #3b4252; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: #fff; transition: all 0.2s; }
|
||||
.sector-card:hover { border-color: #88c0d0; background: rgba(136, 192, 208, 0.1); transform: translateY(-2px); }
|
||||
.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; }
|
||||
.mini-map { display: grid; grid-template-columns: repeat(6, 4px); grid-template-rows: repeat(6, 4px); gap: 1px; margin-bottom: 10px; }
|
||||
.mini-dot { width: 4px; height: 4px; border-radius: 50%; }
|
||||
|
||||
/* 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;
|
||||
}
|
||||
.legend { margin-top: 30px; display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; background: rgba(0,0,0,0.5); padding: 15px; border-radius: 5px; border: 1px solid #2d3545; }
|
||||
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #8c92a3; }
|
||||
.dot { width: 10px; height: 10px; border-radius: 50%; }
|
||||
|
||||
.admin-footer { position: fixed; bottom: 20px; right: 20px; display: flex; gap: 10px; }
|
||||
.btn-mj { background: #bf616a; color: #fff; padding: 10px 15px; border-radius: 5px; text-decoration: none; font-weight: bold; font-size: 12px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 15px rgba(191, 97, 106, 0.3); transition: all 0.2s; }
|
||||
.btn-adm { background: #5e81ac; color: #fff; padding: 10px 15px; border-radius: 5px; text-decoration: none; font-weight: bold; font-size: 12px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 15px rgba(94, 129, 172, 0.3); transition: all 0.2s; }
|
||||
.btn-mj:hover, .btn-adm:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.4); filter: brightness(1.1); }
|
||||
|
||||
/* Modal Styles */
|
||||
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); display: none; align-items: center; justify-content: center; z-index: 1000; }
|
||||
.modal-container { background: #1a202c; border: 1px solid #2d3545; width: 600px; max-width: 90%; border-radius: 8px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); overflow: hidden; }
|
||||
.modal-header { padding: 20px; border-bottom: 1px solid #2d3545; display: flex; justify-content: space-between; align-items: flex-start; background: #242c3d; }
|
||||
.modal-header h2 { margin: 0; color: #ebcb8b; font-size: 24px; }
|
||||
.modal-close { background: none; border: none; color: #8c92a3; font-size: 30px; cursor: pointer; line-height: 1; }
|
||||
.modal-close:hover { color: #fff; }
|
||||
.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));
|
||||
}
|
||||
.modal-body { padding: 25px; max-height: 80vh; overflow-y: auto; }
|
||||
|
||||
.planet-hero { display: flex; gap: 20px; margin-bottom: 25px; }
|
||||
.planet-preview-img { width: 120px; height: 120px; object-fit: contain; background: rgba(0,0,0,0.3); border-radius: 10px; padding: 10px; border: 1px solid #3b4252; }
|
||||
.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;
|
||||
}
|
||||
.planet-status-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: bold; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
|
||||
|
||||
.control-section { margin-bottom: 25px; padding: 15px; background: rgba(0,0,0,0.2); border-radius: 6px; border: 1px solid #2d3545; }
|
||||
.control-title { font-size: 13px; font-weight: bold; color: #88c0d0; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; text-transform: uppercase; }
|
||||
.multi-control-bar { height: 12px; background: #2e3440; border-radius: 6px; display: flex; overflow: hidden; margin-bottom: 10px; border: 1px solid #3b4252; }
|
||||
.control-segment { height: 100%; transition: width 0.3s; }
|
||||
.control-legend { display: flex; flex-wrap: wrap; gap: 15px; font-size: 11px; }
|
||||
.legend-tag { display: flex; align-items: center; gap: 5px; color: #d8dee9; }
|
||||
.legend-tag .color-box { width: 8px; height: 8px; border-radius: 2px; }
|
||||
|
||||
.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; }
|
||||
.city-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #242c3d; border: 1px solid #3b4252; border-radius: 5px; margin-bottom: 10px; }
|
||||
.city-info { display: flex; flex-direction: column; gap: 4px; }
|
||||
.city-name { font-weight: bold; color: #eceff4; font-size: 14px; }
|
||||
.city-type { font-size: 11px; color: #88c0d0; opacity: 0.8; }
|
||||
|
||||
.mod-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
|
||||
.mod-badge { font-size: 9px; padding: 2px 6px; border-radius: 3px; background: rgba(136, 192, 208, 0.1); color: #88c0d0; border: 1px solid rgba(136, 192, 208, 0.3); }
|
||||
|
||||
/* 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;
|
||||
}
|
||||
.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); }
|
||||
.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; }
|
||||
.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; }
|
||||
.resource-header { background: rgba(10, 15, 30, 0.9); border-bottom: 1px solid #2d3545; padding: 10px 30px; display: flex; justify-content: center; gap: 30px; position: sticky; top: 0; z-index: 100; backdrop-filter: blur(10px); }
|
||||
.res-item { display: flex; align-items: center; gap: 10px; }
|
||||
.res-item img { width: 24px; height: 24px; object-fit: contain; }
|
||||
.res-item i { font-size: 18px; width: 24px; text-align: center; }
|
||||
.res-val { font-family: 'Courier New', monospace; font-weight: bold; color: #eceff4; font-size: 15px; }
|
||||
.res-prod { font-size: 10px; color: #a3be8c; }
|
||||
</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="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>
|
||||
<header class="resource-header">
|
||||
<?php foreach($resources as $name => $r): ?>
|
||||
<div class="res-item" title="<?php echo $name; ?>">
|
||||
<?php if (!empty($r['image'])): ?>
|
||||
<img src="<?php echo htmlspecialchars($r['image']); ?>?v=<?php echo time(); ?>" alt="<?php echo $name; ?>">
|
||||
<?php else: ?>
|
||||
<i class="fa-solid <?php echo $r['icon']; ?>" style="color: #88c0d0;"></i>
|
||||
<?php endif; ?>
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<span class="res-val"><?php echo $r['val']; ?></span>
|
||||
<span class="res-prod"><?php echo $r['prod']; ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</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 class="user-auth-bar">
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<span>Connecté en tant que <span class="username"><?php echo htmlspecialchars($_SESSION['username'] ?? 'Utilisateur'); ?></span></span>
|
||||
<a href="profile.php"><i class="fa-solid fa-user-gear"></i> Profil</a>
|
||||
<a href="auth.php?action=logout"><i class="fa-solid fa-right-from-bracket"></i> 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 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>
|
||||
<h3>Navigation</h3>
|
||||
<form method="GET">
|
||||
<input type="hidden" name="view" value="<?php echo $view; ?>">
|
||||
<label>Galaxie</label>
|
||||
<input type="number" name="galaxy_id" value="<?php echo $galaxy_id; ?>" min="1" max="10">
|
||||
<?php if($view === 'sector'): ?>
|
||||
<label>Secteur</label>
|
||||
<input type="number" name="sector_id" value="<?php echo $sector_id; ?>" min="1" max="36">
|
||||
<?php endif; ?>
|
||||
<button type="submit">Sauter</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 style="margin-top: 20px; border-top: 1px solid #2d3545; padding-top: 15px;">
|
||||
<?php if($view === 'sector'): ?>
|
||||
<a href="?view=galaxy&galaxy_id=<?php echo $galaxy_id; ?>" style="color: #88c0d0; text-decoration: none; font-size: 12px; display: block; text-align: center;">
|
||||
<i class="fa-solid fa-arrow-left"></i> Vue Galaxie
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</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;
|
||||
<?php for($i=1; $i<=$grid_size; $i++): $obj = $grid[$i]; ?>
|
||||
<div class="slot <?php echo $obj ? '' : 'empty'; ?>"
|
||||
onclick='<?php echo $obj ? "openPlanetModal(".json_encode($obj).")" : ""; ?>'>
|
||||
<?php if($obj):
|
||||
$type_info = $object_types_map[$obj['type']] ?? [];
|
||||
?>
|
||||
<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; ?>
|
||||
</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">
|
||||
<div class="object-icon-container">
|
||||
<?php
|
||||
$icon = $type_info['icon'] ?? 'fa-earth-europe';
|
||||
$color = getStatusColor($obj['status'], $statuses_map);
|
||||
@ -625,7 +342,7 @@ function isStatusBlinking($status, $statuses_map) {
|
||||
$dotColor = 'rgba(255,255,255,0.05)';
|
||||
if (isset($sector_data[$s][$p])) { $dotColor = getStatusColor($sector_data[$s][$p]['status'], $statuses_map); }
|
||||
?>
|
||||
<div class="mini-dot <?php echo isStatusBlinking($sector_data[$s][$p]['status'], $statuses_map) ? 'blink' : ''; ?>" style="background-color: <?php echo $dotColor; ?>;"></div>
|
||||
<div class="mini-dot <?php echo isStatusBlinking($sector_data[$s][$p]['status'] ?? '', $statuses_map) ? 'blink' : ''; ?>" style="background-color: <?php echo $dotColor; ?>;"></div>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<div style="font-size: 10px; color: #88c0d0;">SECTEUR</div>
|
||||
@ -698,121 +415,118 @@ function isStatusBlinking($status, $statuses_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;
|
||||
const typeInfo = typesMap[data.type] || {};
|
||||
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-status').classList.toggle('blink', statusInfo.is_blinking == 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 statusInfo = statusesMap[data.status] || {};
|
||||
const statusBadge = document.getElementById('m-planet-status');
|
||||
statusBadge.innerText = statusInfo.name || data.status;
|
||||
statusBadge.style.background = statusInfo.color || '#4c566a';
|
||||
if (statusInfo.is_blinking == 1) statusBadge.classList.add('blink');
|
||||
else statusBadge.classList.remove('blink');
|
||||
|
||||
const img = document.getElementById('m-planet-img');
|
||||
img.src = typeInfo.image_url ? typeInfo.image_url + '?v=' + Date.now() : '';
|
||||
img.style.display = typeInfo.image_url ? 'block' : 'none';
|
||||
|
||||
// Faction (Simple logic: majority control)
|
||||
let dominantFaction = 'Aucune';
|
||||
let maxOrb = 0;
|
||||
for (let fid in data.orbital_controls) {
|
||||
if (data.orbital_controls[fid] > maxOrb) {
|
||||
maxOrb = data.orbital_controls[fid];
|
||||
dominantFaction = factionsMap[fid] ? factionsMap[fid].name : 'Inconnue';
|
||||
}
|
||||
}
|
||||
document.getElementById('m-planet-faction').innerText = 'Faction dominante (Orbital): ' + dominantFaction;
|
||||
|
||||
// Modifiers
|
||||
const modContainer = document.getElementById('m-planet-mods');
|
||||
modContainer.innerHTML = '';
|
||||
if (typeInfo.modifiers && typeInfo.modifiers.length > 0) {
|
||||
typeInfo.modifiers.forEach(m => {
|
||||
const modDiv = document.createElement('div');
|
||||
modDiv.className = 'mod-item ' + (m.type === 'bonus' ? 'mod-bonus' : 'mod-malus');
|
||||
modDiv.innerHTML = `
|
||||
<i class="fa-solid ${m.type === 'bonus' ? 'fa-circle-up' : 'fa-circle-down'}"></i>
|
||||
<strong>${m.name}:</strong> ${m.description}
|
||||
`;
|
||||
modContainer.appendChild(modDiv);
|
||||
if (typeInfo.modifiers) {
|
||||
typeInfo.modifiers.forEach(mod => {
|
||||
const span = document.createElement('span');
|
||||
span.className = 'mod-badge';
|
||||
span.innerText = mod.name;
|
||||
modContainer.appendChild(span);
|
||||
});
|
||||
} else {
|
||||
modContainer.innerHTML = '<div style="font-size: 11px; color: #64748b; font-style: italic;">Aucun modificateur particulier.</div>';
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
// Orbital Bar
|
||||
renderControlBar('m-orbital-bar', 'm-orbital-legend', data.orbital_controls);
|
||||
// Terrestrial Bar
|
||||
renderControlBar('m-terrestrial-bar', 'm-terrestrial-legend', data.terrestrial_controls);
|
||||
|
||||
// Cities
|
||||
const 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';
|
||||
const cityContainer = document.getElementById('m-cities-container');
|
||||
cityContainer.innerHTML = '';
|
||||
if (data.cities && data.cities.length > 0) {
|
||||
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);
|
||||
const div = document.createElement('div');
|
||||
div.className = 'city-item';
|
||||
let controlDesc = '';
|
||||
for (let fid in city.controls) {
|
||||
if (factionsMap[fid]) {
|
||||
controlDesc += `<span style="color:${factionsMap[fid].color || '#fff'}">${factionsMap[fid].name}: ${city.controls[fid]}%</span> `;
|
||||
}
|
||||
}
|
||||
|
||||
citiesContainer.appendChild(card);
|
||||
div.innerHTML = `
|
||||
<div class="city-info">
|
||||
<span class="city-name">${city.name}</span>
|
||||
<span class="city-type">${city.type_name || 'Établissement'}</span>
|
||||
</div>
|
||||
<div style="font-size: 10px; text-align: right;">${controlDesc}</div>
|
||||
`;
|
||||
cityContainer.appendChild(div);
|
||||
});
|
||||
} else {
|
||||
document.getElementById('m-cities-section').style.display = 'none';
|
||||
cityContainer.innerHTML = '<div style="font-size: 11px; color: #4c566a; font-style: italic;">Aucun établissement répertorié.</div>';
|
||||
}
|
||||
|
||||
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;
|
||||
function renderControlBar(barId, legendId, controls) {
|
||||
const bar = document.getElementById(barId);
|
||||
const legend = document.getElementById(legendId);
|
||||
bar.innerHTML = '';
|
||||
legend.innerHTML = '';
|
||||
|
||||
// Segment
|
||||
let total = 0;
|
||||
for (let fid in controls) {
|
||||
const val = parseInt(controls[fid]);
|
||||
if (val > 0) {
|
||||
total += val;
|
||||
const faction = factionsMap[fid] || { name: 'Inconnue', color: '#4c566a' };
|
||||
const segment = document.createElement('div');
|
||||
segment.className = 'control-segment';
|
||||
segment.style.width = val + '%';
|
||||
segment.style.backgroundColor = faction.color;
|
||||
segment.title = `${faction.name}: ${val}%`;
|
||||
bar.appendChild(segment);
|
||||
|
||||
const tag = document.createElement('div');
|
||||
tag.className = 'legend-tag';
|
||||
tag.innerHTML = `<span class="color-box" style="background:${faction.color}"></span> ${faction.name}: ${val}%`;
|
||||
legend.appendChild(tag);
|
||||
}
|
||||
}
|
||||
|
||||
if (total < 100) {
|
||||
const remain = 100 - total;
|
||||
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);
|
||||
segment.style.width = remain + '%';
|
||||
segment.style.backgroundColor = '#2e3440';
|
||||
segment.title = `Incontesté: ${remain}%`;
|
||||
bar.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);
|
||||
});
|
||||
tag.innerHTML = `<span class="color-box" style="background:#2e3440"></span> Incontesté: ${remain}%`;
|
||||
legend.appendChild(tag);
|
||||
}
|
||||
}
|
||||
|
||||
function closePlanetModal() {
|
||||
@ -820,4 +534,4 @@ function isStatusBlinking($status, $statuses_map) {
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user