Skip to content
Merged

Qol #23

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/lib/+map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
let fleetSelections = $state([]);
let rotation = $state(0);
let selectedFleetToMove = $state(null);
let isPlacementLocked = $state(false);
let warning = $state({ show: false, x: 0, y: 0, text: '', id: 0 });

// AI Memory for Hunt & Seek logic
Expand Down Expand Up @@ -216,6 +217,7 @@
$socket.on('game_start', ({ activePlayer }) => {
activePlayerId.set(activePlayer);
isConfirmed = true;
isPlacementLocked = true;
selectedGroup = [];
targetingMode = 'focus';
});
Expand Down Expand Up @@ -412,8 +414,12 @@
const isSpecial = specialTiles.some(t => t.col === hex.col && t.row === hex.row);
if (isSpecial) { showWarning(event.clientX, event.clientY, isConfirmed ? "Cannot select land" : "Cannot place fleet on land"); return; }

if (isPlacementLocked && !isConfirmed) {
return;
}

// --- PLACEMENT LOGIC ---
if (!isConfirmed) {
if (!isPlacementLocked) {
const tacticalNames = [$playerName + " I", $playerName + " II"]
const index = fleetSelections.findIndex(h => h.q === hex.q && h.r === hex.r);
if (index > -1) {
Expand Down Expand Up @@ -516,7 +522,7 @@
function confirmFleets() {
if (fleetSelections.length === 2) {
addLog("All fleets are positioned!", "system");

isPlacementLocked = true;
if ($isMultiplayer) {
const fleetPositions = { alpha: { q: fleetSelections[0].q, r: fleetSelections[0].r }, beta: { q: fleetSelections[1].q, r: fleetSelections[1].r } };
$socket.emit('place_fleets', { gameId: $gameId, fleetPositions });
Expand Down
11 changes: 9 additions & 2 deletions src/lib/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import { socket, gameId, activePlayerId } from '$lib/gameStore';
// Used for API calls to server
let isSubmitted = $state(false);

let isClicked = $state(false);

// Standard JS props (using defaults to prevent crashes)
let {
targetingMode = $bindable(),
Expand Down Expand Up @@ -47,8 +48,9 @@

<button
class="button"
class:confirmed={isClicked}
disabled={fleetSelections.length !== 2}
onclick={() => onConfirm()}
onclick={() => {onConfirm(); isClicked=true;}}
onmouseenter={() => $isHovering = true}
onmouseleave={() => $isHovering = false}
>
Expand Down Expand Up @@ -306,4 +308,9 @@
100% { transform: scale(1); opacity: 1; }
}

.confirmed {
border-color: #10b981 !important;
color: #10b981 !important;
background: rgba(16, 185, 129, 0.2) !important;
}
</style>
Loading