feat(players): app Players library and circular NPC tokens on scenes
Add userData players/teams, scene npcTokens with hex-inscribed sizing, session scale synced to presentation, and Playwright e2e coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { ipcChannels } from '../../../shared/ipc/contracts';
|
||||
import type { AppPlayer, AppPlayerTeam } from '../../../shared/types';
|
||||
import { getDndApi } from '../dndApi';
|
||||
|
||||
export function useAppPlayers(): { players: AppPlayer[]; teams: AppPlayerTeam[] } {
|
||||
const api = getDndApi();
|
||||
const [players, setPlayers] = useState<AppPlayer[]>([]);
|
||||
const [teams, setTeams] = useState<AppPlayerTeam[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
void api.invoke(ipcChannels.players.list, {}).then((res) => {
|
||||
setPlayers(res.players);
|
||||
setTeams(res.teams);
|
||||
});
|
||||
return api.on(ipcChannels.players.stateChanged, ({ players: nextPlayers, teams: nextTeams }) => {
|
||||
setPlayers(nextPlayers);
|
||||
setTeams(nextTeams);
|
||||
});
|
||||
}, [api]);
|
||||
|
||||
return { players, teams };
|
||||
}
|
||||
Reference in New Issue
Block a user