Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,22 @@ export function totalFamiliarWeight(
);
}

/**
* JSON-ify an object with mafia constants rendered legibly
* @param obj The object to convert to a JSON string
* @returns A JSON string
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function toMafiaJson(obj: any): string {
return JSON.stringify(obj, (_, value) => {
const mafiaClass = MafiaClasses.find(
(mafiaClass) => value instanceof mafiaClass,
);
if (mafiaClass) return `[${mafiaClass.name}]${value}`;
return value;
});
}

export const familiarTags = Object.freeze([
"animal",
"insect",
Expand Down