diff --git a/admin.php b/admin.php index 15d1eb0..b206ca4 100644 --- a/admin.php +++ b/admin.php @@ -642,9 +642,11 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["action"]) && $_POST[" $faction_id = !empty($_POST["faction_id"]) ? (int)$_POST["faction_id"] : null; $can_be_destroyed = isset($_POST["can_be_destroyed"]) ? 1 : 0; $can_be_captured = isset($_POST["can_be_captured"]) ? 1 : 0; - $points_per_hit = (int)$_POST["points_per_hit"]; - $bonus_destruction = (int)$_POST["bonus_destruction"]; - $bonus_capture = (int)$_POST["bonus_capture"]; + + // Fallback for legacy fields if not in form + $points_per_hit = isset($_POST["points_per_hit"]) ? (int)$_POST["points_per_hit"] : 0; + $bonus_destruction = isset($_POST["bonus_destruction"]) ? (int)$_POST["bonus_destruction"] : 0; + $bonus_capture = isset($_POST["bonus_capture"]) ? (int)$_POST["bonus_capture"] : 0; $grid_data = $_POST["grid_data"]; $cost_resource_id = !empty($_POST["cost_resource_id"]) ? (int)$_POST["cost_resource_id"] : null; @@ -683,16 +685,14 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["action"]) && $_POST[" // Handle Rewards $db->prepare("DELETE FROM unit_rewards WHERE unit_id = ?")->execute([$id]); if (isset($_POST["reward_action"]) && is_array($_POST["reward_action"])) { - $ins_rw = $db->prepare("INSERT INTO unit_rewards (unit_id, action_type, resource_id, amount) VALUES (?, ?, ?, ?)"); + $ins_rw = $db->prepare("INSERT INTO unit_rewards (unit_id, action_type, lootbox_id) VALUES (?, ?, ?)"); foreach ($_POST["reward_action"] as $idx => $action) { - $res_id = (int)$_POST["reward_resource_id"][$idx]; - $amount = (int)$_POST["reward_amount"][$idx]; - if ($amount > 0) { - $ins_rw->execute([$id, $action, $res_id, $amount]); + $lb_id = (int)$_POST["reward_lootbox_id"][$idx]; + if ($lb_id > 0) { + $ins_rw->execute([$id, $action, $lb_id]); } } } - header("Location: admin.php?tab=units&success=1"); exit; } @@ -757,6 +757,7 @@ if ($tab === 'users') { } elseif ($tab === 'levels') { $levels_list = $db->query("SELECT l.*, r.name as resource_name FROM levels l JOIN game_resources r ON l.resource_id = r.id ORDER BY l.required_quantity ASC")->fetchAll(); $resources_list = $db->query("SELECT id, name FROM game_resources ORDER BY name ASC")->fetchAll(); + $lootboxes_list = $db->query("SELECT id, name FROM lootboxes ORDER BY name ASC")->fetchAll(); } elseif ($tab === 'resources') { $resources_list = $db->query("SELECT * FROM game_resources ORDER BY name ASC")->fetchAll(); } elseif ($tab === 'project_logs') { @@ -787,13 +788,14 @@ if ($tab === 'users') { elseif ($tab === "units") { $units_list = $db->query("SELECT u.*, f.name as faction_name FROM units u LEFT JOIN factions f ON u.faction_id = f.id ORDER BY u.name ASC")->fetchAll(); foreach ($units_list as &$unit) { - $stmt_rw = $db->prepare("SELECT action_type, resource_id, amount FROM unit_rewards WHERE unit_id = ?"); + $stmt_rw = $db->prepare("SELECT action_type, lootbox_id, resource_id, amount FROM unit_rewards WHERE unit_id = ?"); $stmt_rw->execute([$unit["id"]]); $unit["rewards"] = $stmt_rw->fetchAll(); } unset($unit); $factions_list = $db->query("SELECT id, name FROM factions ORDER BY name ASC")->fetchAll(); $resources_list = $db->query("SELECT id, name FROM game_resources ORDER BY name ASC")->fetchAll(); + $lootboxes_list = $db->query("SELECT id, name FROM lootboxes ORDER BY name ASC")->fetchAll(); } ?> @@ -919,9 +921,9 @@ elseif ($tab === "units") { .ms-item { padding: 5px 8px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 11px; } .ms-item:hover { background: #2d3545; } .ms-item input { width: auto !important; } - .unit-grid-container { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; } - .unit-grid { display: grid; grid-template-columns: repeat(6, 64px); grid-template-rows: repeat(6, 64px); gap: 2px; background: #2d3545; padding: 2px; width: fit-content; } - .unit-cell { width: 64px; height: 64px; background: #0f172a; cursor: pointer; border: 1px solid #334155; } + .unit-grid-container { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; padding: 15px; background: #1a202c; border-radius: 8px; border: 1px solid #2d3545; width: fit-content; } + .unit-grid { display: grid; grid-template-columns: repeat(6, 40px); grid-template-rows: repeat(6, 40px); gap: 2px; background: #2d3545; padding: 2px; width: fit-content; } + .unit-cell { width: 40px; height: 40px; background: #0f172a; cursor: pointer; border: 1px solid #334155; } .unit-cell.active { background: #88c0d0; } .unit-cell:hover { border-color: #88c0d0; } @@ -1049,17 +1051,17 @@ elseif ($tab === "units") { -