2025-05-28 15:36:51 -07:00

27 lines
712 B
TypeScript

import { createSelector } from "reselect";
import {
DecorationUtils,
rulesEngineSelectors,
} from "@dndbeyond/character-rules-engine/es";
import { IRollContext } from "@dndbeyond/dice";
import { appEnvSelectors } from "./index";
export const getCharacterRollContext = createSelector(
[
appEnvSelectors.getCharacterId,
rulesEngineSelectors.getName,
rulesEngineSelectors.getDecorationInfo,
],
(characterId, name, decorationInfo): IRollContext => {
return {
entityId: characterId ? characterId.toString() : "",
entityType: "character",
name: name?.toString(),
avatarUrl:
DecorationUtils.getAvatarInfo(decorationInfo).avatarUrl?.toString(),
};
}
);