Files
Octoturge a4f8941fca chore: initialize homebrew-magic-rpg monorepo
Consolidates the HbM: RPG project (formerly the loose hbm-books
working folder) into a single repo. ObsidianNotes, foundry-lore, and
foundry-system are wired in as submodules pointing at their existing
Gitea repos. Loose tooling scripts are organized under tools/,
obsolete/one-off scripts (fix_vault.py, generate_mocs.py, debug-*.ts,
write_file_helper.py) and _books/ (superseded by ObsidianNotes) are
excluded via .gitignore rather than deleted. foundryvtt-admin is
excluded pending its own separate repo.
2026-08-17 21:28:50 +02:00

69 lines
1.9 KiB
JavaScript

/**
* HbM: RPG v3 - Spell Template
*/
export const spellTemplate = {
name: '',
nameEN: '', // English translation
school: '', // Szkoła magii
circle: 1, // Krąg (1-9)
castingTime: '',
range: '',
duration: '',
components: {
verbal: false,
somatic: false,
material: '',
},
description: '',
higherCircles: '', // Opis dla wyższych kręgów
notes: '',
};
export function formatSpellForBook(spell) {
const components = [];
if (spell.components.verbal) components.push('W');
if (spell.components.somatic) components.push('S');
if (spell.components.material) components.push(`M (${spell.components.material})`);
return `### ${spell.name}
*${spell.school}, ${spell.circle}. krąg*
**Czas rzucania:** ${spell.castingTime}
**Zasięg:** ${spell.range}
**Komponenty:** ${components.join(', ')}
**Czas trwania:** ${spell.duration}
${spell.description}
${spell.higherCircles ? `**Na wyższych kręgach:** ${spell.higherCircles}` : ''}
`.trim();
}
export function parseSpellFromText(text) {
// Basic parser for spell text - customize based on your format
const spell = { ...spellTemplate };
const nameMatch = text.match(/^###?\s*(.+)/m);
if (nameMatch) spell.name = nameMatch[1].trim();
const schoolMatch = text.match(/\*([^,]+),\s*(\d+)\.\s*krąg\*/);
if (schoolMatch) {
spell.school = schoolMatch[1].trim();
spell.circle = parseInt(schoolMatch[2]);
}
const castingMatch = text.match(/Czas rzucania:\*?\*?\s*(.+)/i);
if (castingMatch) spell.castingTime = castingMatch[1].trim();
const rangeMatch = text.match(/Zasięg:\*?\*?\s*(.+)/i);
if (rangeMatch) spell.range = rangeMatch[1].trim();
const durationMatch = text.match(/Czas trwania:\*?\*?\s*(.+)/i);
if (durationMatch) spell.duration = durationMatch[1].trim();
return spell;
}
export default { spellTemplate, formatSpellForBook, parseSpellFromText };