86d6d157f0
Очередь NPC/игроков с DnD, курсором на сцене, состояниями и запасом; сброс при смене сцены. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import type { InitiativeConditionId, InitiativeState } from '../../../shared/types/initiative';
|
|
import {
|
|
initiativeNpcEntryId,
|
|
initiativePlayerEntryId,
|
|
} from '../../../shared/types/initiative';
|
|
|
|
export function initiativeHighlightForNpc(
|
|
state: InitiativeState | null | undefined,
|
|
placementId: string,
|
|
): boolean {
|
|
if (!state?.enabled || !state.activeId) return false;
|
|
return state.activeId === initiativeNpcEntryId(placementId);
|
|
}
|
|
|
|
export function initiativeHighlightForPlayer(
|
|
state: InitiativeState | null | undefined,
|
|
playerId: string,
|
|
): boolean {
|
|
if (!state?.enabled || !state.activeId) return false;
|
|
return state.activeId === initiativePlayerEntryId(playerId);
|
|
}
|
|
|
|
export function initiativeConditionsForNpc(
|
|
state: InitiativeState | null | undefined,
|
|
placementId: string,
|
|
): InitiativeConditionId[] {
|
|
if (!state) return [];
|
|
return state.conditions[initiativeNpcEntryId(placementId)] ?? [];
|
|
}
|
|
|
|
export function initiativeConditionsForPlayer(
|
|
state: InitiativeState | null | undefined,
|
|
playerId: string,
|
|
): InitiativeConditionId[] {
|
|
if (!state) return [];
|
|
return state.conditions[initiativePlayerEntryId(playerId)] ?? [];
|
|
}
|