Remember player name for new crews
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -5,11 +5,11 @@
|
|||||||
- [ ] Use the same vertical UI for the player list in all phases
|
- [ ] Use the same vertical UI for the player list in all phases
|
||||||
- [x] In the admin panel, if a pi-rat doesn't have a name yet, it should show something like 'not chosen yet' rather than the player name
|
- [x] In the admin panel, if a pi-rat doesn't have a name yet, it should show something like 'not chosen yet' rather than the player name
|
||||||
- [x] In the admin panel, the "Open" and "Copy" buttons should be the same size
|
- [x] In the admin panel, the "Open" and "Copy" buttons should be the same size
|
||||||
- [ ] Store the player name in local storage and pre-populate it when joining a new game (but don't force it, let the player edit it if they'd prefer a different name)
|
- [x] Store the player name in local storage and pre-populate it when joining a new game (but don't force it, let the player edit it if they'd prefer a different name)
|
||||||
- [ ] If a player tries to rejoin a game that has ended or that they've been kicked from, they should get an error message and it should be removed from the list of re-joinable games
|
- [ ] If a player tries to rejoin a game that has ended or that they've been kicked from, they should get an error message and it should be removed from the list of re-joinable games
|
||||||
- [ ] Games should have join codes in addition to join links. Join codes should be a sequence of 5 alphanumeric characters (upper case letters only, no ambiguous letters like 0/O/1/I). Add a panel to the home page for joining a game via code, and display the join code on the admin page
|
- [ ] Games should have join codes in addition to join links. Join codes should be a sequence of 5 alphanumeric characters (upper case letters only, no ambiguous letters like 0/O/1/I). Add a panel to the home page for joining a game via code, and display the join code on the admin page
|
||||||
|
|
||||||
## Words Words Words (Waiting for Fable to come back)
|
## Words Words Words
|
||||||
|
|
||||||
- [ ] **TLDR rules**. A one page summary sheet of the rulebook, for the impatient
|
- [ ] **TLDR rules**. A one page summary sheet of the rulebook, for the impatient
|
||||||
- [ ] **Suggestions.** Take a pass through all of the suggestions in suggestions.js, rewrite ones that are stiff, awkward, or don't fit the theme/setting as described in the rulebook. Move the suggestion pool from suggestions.js into a backend API endpoint.
|
- [ ] **Suggestions.** Take a pass through all of the suggestions in suggestions.js, rewrite ones that are stiff, awkward, or don't fit the theme/setting as described in the rulebook. Move the suggestion pool from suggestions.js into a backend API endpoint.
|
||||||
|
|||||||
@@ -6,10 +6,17 @@
|
|||||||
// - Add a CHANGELOG entry only when a commit changes something players can
|
// - Add a CHANGELOG entry only when a commit changes something players can
|
||||||
// see. Skip refactors, tests, and tooling. Keep wording player-facing.
|
// 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, ...] }.
|
// Newest first. Each entry: { version, date: 'YYYY-MM-DD', changes: [string, ...] }.
|
||||||
export const CHANGELOG = [
|
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,
|
version: 16,
|
||||||
date: '2026-07-10',
|
date: '2026-07-10',
|
||||||
|
|||||||
@@ -6,12 +6,18 @@
|
|||||||
import { saveSession } from '../lib/sessions';
|
import { saveSession } from '../lib/sessions';
|
||||||
export let params = {};
|
export let params = {};
|
||||||
|
|
||||||
onMount(() => setPageTitle('Join the Crew'));
|
const PLAYER_NAME_KEY = 'pirats-player-name';
|
||||||
|
|
||||||
let gameId = params.id;
|
let gameId = params.id;
|
||||||
let playerName = '';
|
let playerName = '';
|
||||||
let error = '';
|
let error = '';
|
||||||
let joining = false;
|
let joining = false;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
setPageTitle('Join the Crew');
|
||||||
|
playerName = localStorage.getItem(PLAYER_NAME_KEY) || '';
|
||||||
|
});
|
||||||
|
|
||||||
// We can extract ?creator=true from $querystring if needed,
|
// We can extract ?creator=true from $querystring if needed,
|
||||||
// though the backend determines creator based on if they are the first player.
|
// 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.
|
// For UI purposes, we could show "You are the creator" if we want.
|
||||||
@@ -22,6 +28,7 @@
|
|||||||
error = '';
|
error = '';
|
||||||
try {
|
try {
|
||||||
const data = await apiRequest(`/game/${gameId}/join`, 'POST', { name: playerName });
|
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;
|
// Remember this session so the home page can offer a rejoin link;
|
||||||
// the dashboard enriches it with crew/rat names once state loads.
|
// the dashboard enriches it with crew/rat names once state loads.
|
||||||
saveSession({ gameId, playerId: data.id, playerName });
|
saveSession({ gameId, playerId: data.id, playerName });
|
||||||
|
|||||||
Reference in New Issue
Block a user