Remember player name for new crews
This commit is contained in:
@@ -6,10 +6,17 @@
|
||||
// - Add a CHANGELOG entry only when a commit changes something players can
|
||||
// see. Skip refactors, tests, and tooling. Keep wording player-facing.
|
||||
|
||||
export const VERSION = 16;
|
||||
export const VERSION = 17;
|
||||
|
||||
// Newest first. Each entry: { version, date: 'YYYY-MM-DD', changes: [string, ...] }.
|
||||
export const CHANGELOG = [
|
||||
{
|
||||
version: 17,
|
||||
date: '2026-07-10',
|
||||
changes: [
|
||||
'Join forms now remember your player name for the next crew while still letting you edit it.',
|
||||
],
|
||||
},
|
||||
{
|
||||
version: 16,
|
||||
date: '2026-07-10',
|
||||
|
||||
@@ -6,12 +6,18 @@
|
||||
import { saveSession } from '../lib/sessions';
|
||||
export let params = {};
|
||||
|
||||
onMount(() => setPageTitle('Join the Crew'));
|
||||
const PLAYER_NAME_KEY = 'pirats-player-name';
|
||||
|
||||
let gameId = params.id;
|
||||
let playerName = '';
|
||||
let error = '';
|
||||
let joining = false;
|
||||
|
||||
onMount(() => {
|
||||
setPageTitle('Join the Crew');
|
||||
playerName = localStorage.getItem(PLAYER_NAME_KEY) || '';
|
||||
});
|
||||
|
||||
// We can extract ?creator=true from $querystring if needed,
|
||||
// though the backend determines creator based on if they are the first player.
|
||||
// For UI purposes, we could show "You are the creator" if we want.
|
||||
@@ -22,6 +28,7 @@
|
||||
error = '';
|
||||
try {
|
||||
const data = await apiRequest(`/game/${gameId}/join`, 'POST', { name: playerName });
|
||||
localStorage.setItem(PLAYER_NAME_KEY, playerName.trim());
|
||||
// Remember this session so the home page can offer a rejoin link;
|
||||
// the dashboard enriches it with crew/rat names once state loads.
|
||||
saveSession({ gameId, playerId: data.id, playerName });
|
||||
|
||||
Reference in New Issue
Block a user