Skip to content

Commit

Permalink
Merge pull request #1252 from Miskatonic-Investigative-Society/develop
Browse files Browse the repository at this point in the history
0.9.0
  • Loading branch information
HavlockV authored Sep 23, 2022
2 parents ac52739 + 1cb947d commit 863ffe5
Show file tree
Hide file tree
Showing 170 changed files with 11,752 additions and 8,865 deletions.
288 changes: 221 additions & 67 deletions .github/ABANDONED.md

Large diffs are not rendered by default.

145 changes: 80 additions & 65 deletions .github/CHANGELOG.md

Large diffs are not rendered by default.

531 changes: 93 additions & 438 deletions .github/TRANSLATIONS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/en/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# System documentation for version 0.8.0
# System documentation for version 0.9.0

This document is a work in progress overview of the CoC7 system it is not a tutorial for how to use FoundryVTT.

Expand Down
18 changes: 9 additions & 9 deletions docs/en/effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ This last tab will includes all changes made to the character sheet.

## Changes

An effect includes a list of changes. Each change needs to be addressed with the corresponding data path.
An effect includes a list of changes. Each change needs to be addressed with the corresponding system path.
The available changes are :

- Characteristics: data.characteristics.\[characteristic\].value
- Characteristics: system.characteristics.\[characteristic\].value
- available \[characteristic\] are: str, con, siz, dex, app, int, pow, edu
- attributes:
- mov: data.attribs.mov.value
- build: data.attribs.build.value
- bonus damage: data.attribs.db.value
- armor: data.attribs.armor.value
- mov: system.attribs.mov.value
- build: system.attribs.build.value
- bonus damage: system.attribs.db.value
- armor: system.attribs.armor.value
- derived attributes. Only the maximum value of those attributes should be modified. Those changes are applied after all other changes have been made. If that attibute is in auto mode, it will be recalculated with the previous characteristics changes before having it's value affected.
- max hit points: data.attribs.hp.max
- max sanity: data.attribs.san.max
- max hit points: system.attribs.hp.max
- max sanity: system.attribs.san.max
- skills. Skills are identified by their name without specialization. Skill names are case sensitive !
- data.skills.Handgun.value
- system.skills.Handgun.value
277 changes: 146 additions & 131 deletions generate-manuals.js
Original file line number Diff line number Diff line change
@@ -1,152 +1,167 @@
import * as crypto from 'crypto'
import { Remarkable } from 'remarkable'
import * as fs from 'fs'
import write from './node_modules/write/index.js'

const collisions = {}

const sources = {
rmtiwtbixojhyf5v: {
name: 'Active effects',
lang: 'en',
file: 'effects.md'
},
xV4Hxxmu6zjIMw9h: {
name: 'Actor Importer',
lang: 'en',
file: 'actor_importer.md'
},
wZtTHpGV3atKV2oD: {
en: {
name: 'Call of Cthulhu 7th Edition (Unofficial)',
lang: 'en',
file: 'README.md'
},
uug1mm5nokly4o2v: {
name: 'Character Creation',
lang: 'en',
file: 'character_creation.md'
},
VdOeGcxsu3jsVm3F: {
name: 'Chases',
lang: 'en',
file: 'chases.md'
},
nk68b2ew15iw0bb8: {
name: 'Combat',
lang: 'en',
file: 'combat.md'
},
wilj4rvkreemh70n: {
name: 'Commands Cheat Sheet',
lang: 'en',
file: 'commands_cheat_sheet.md'
},
nVYLlqVzmUV5dXAW: {
name: 'Creating your first investigator',
lang: 'en',
file: 'first_investigator.md'
},
di6mcnaxfyi0y2l4: {
name: 'Items',
lang: 'en',
file: 'items.md'
},
kv2tbz6x29cq6ewq: {
name: 'Item Type: Archetype',
lang: 'en',
file: 'item_archetype.md'
},
oruecvy7jne4u4gt: {
name: 'Item Type: Book',
lang: 'en',
file: 'item_book.md'
},
qa934whpkpauiyc9: {
name: 'Item Type: Occupation',
lang: 'en',
file: 'item_occupation.md'
},
JU1GCWwc8at7gzJ4: {
name: 'Item Type: Setup',
lang: 'en',
file: 'item_setup.md'
},
mz0ulbkecfvv8nw7: {
name: 'Item Type: Skill',
lang: 'en',
file: 'item_skill.md'
},
fk040vqb4per5ju1: {
name: 'Links',
lang: 'en',
file: 'links.md'
},
emuu3wo0uul91029: {
name: 'Link creation tool',
lang: 'en',
file: 'link_creation_window.md'
},
ce7s8psgyctzx5r1: {
name: 'Sanity',
lang: 'en',
file: 'sanity.md'
pages: [
{
name: 'System documentation for version 9.0',
file: 'README.md'
},
{
name: 'Active effects',
file: 'effects.md'
},
{
name: 'Actor Importer',
file: 'actor_importer.md'
},
{
name: 'Character Creation',
file: 'character_creation.md'
},
{
name: 'Chases',
file: 'chases.md'
},
{
name: 'Combat',
file: 'combat.md'
},
{
name: 'Commands Cheat Sheet',
file: 'commands_cheat_sheet.md'
},
{
name: 'Creating your first investigator',
file: 'first_investigator.md'
},
{
name: 'Items',
file: 'items.md'
},
{
name: 'Item Type: Archetype',
file: 'item_archetype.md'
},
{
name: 'Item Type: Book',
file: 'item_book.md'
},
{
name: 'Item Type: Occupation',
file: 'item_occupation.md'
},
{
name: 'Item Type: Setup',
file: 'item_setup.md'
},
{
name: 'Item Type: Skill',
file: 'item_skill.md'
},
{
name: 'Links',
file: 'links.md'
},
{
name: 'Link creation tool',
file: 'link_creation_window.md'
},
{
name: 'Sanity',
file: 'sanity.md'
}
]
}
}

const dbFile = []

for (const id in sources) {
try {
const md = new Remarkable()
const input = fs.readFileSync(
'./module/manual/' + sources[id].lang + '/' + sources[id].file,
'utf8'
)

const source = md.render(input)

const html = source
.replace(/<p>\.<\/p>/g, '<p>&nbsp;</p>')
.replace(
/\[(fas fa-[^\]]+|game-icon game-icon-[^\]]+)\]/g,
'<em class="$1">&nbsp;</em>'
)
.replace(/src="..\/..\/assets\//g, 'src="systems/CoC7/assets/')
.replace(/\n\s*/g, '\n')
.replace(/@@coc7./g, '<span>@</span>coc7.')

try {
for (const lang in sources) {
const id = generateBuildConsistentID('manual' + lang)
const dbEntry = {
_id: id,
name: sources[id].name + ' [' + sources[id].lang + ']',
content: '<div class="coc7overview">\n' + html + '\n</div>'
name: sources[lang].name + ' [' + lang + ']',
pages: [],
_id: id
}
const links = {}
for (const source of sources[lang].pages) {
const id = generateBuildConsistentID('manual' + lang + source.file)
collisions[id] = true
links[source.file] = id
}
for (const page in sources[lang].pages) {
const md = new Remarkable()
let input = fs.readFileSync(
'./module/manual/' + lang + '/' + sources[lang].pages[page].file,
'utf8'
)

dbFile.push(JSON.stringify(dbEntry))
const mdFile = input
.replace(/\[(fas fa-[^\]]+|game-icon game-icon-[^\]]+)\]/g, '')
.replace(/@@coc7./g, '@coc7.')
.replace(/@Compendium\[[^\]]+\.[^\\.]+\]{([^}]+)}/g, '[_$1_]')

let mdFile = input
.replace(/\n.\n/g, '\n')
.replace(/\[(fas fa-[^\]]+|game-icon game-icon-[^\]]+)\]/g, '')
.replace(/@@coc7./g, '@coc7.')
write('./docs/' + lang + '/' + sources[lang].pages[page].file, mdFile)

const compendiumLinks = mdFile.matchAll(
/@Compendium\[(?<pack>[^\]]+)\.(?<id>[^\\.]+)\]{(?<name>[^}]+)}/g
)
for (const link of compendiumLinks) {
if (link.groups.pack !== 'CoC7.system-doc') {
mdFile = mdFile.replace(link[0], '[_' + link.groups.name + '_]')
} else {
mdFile = mdFile.replace(
link[0],
'[' +
link.groups.name +
'](' +
sources[link.groups.id].file +
')'
)
const matches = input.matchAll(/\[(.+?)\]\(((?![a-z]{1,10}:)(.+?))\)/g)
for (const match of matches) {
if (typeof links[match[2]] !== 'undefined') {
input = input.replace(match[0], '@UUID[.' + links[match[2]] + ']{' + match[1] + '}')
}
}
}

write('./docs/' + sources[id].lang + '/' + sources[id].file, mdFile)
} catch (e) {
console.log('EXCEPTION:', e)
const html = md.render(input)
.replace(
/\[(fas fa-[^\]]+|game-icon game-icon-[^\]]+)\]/g,
'<em class="$1">&nbsp;</em>'
)
.replace(/src="..\/..\/assets\//g, 'src="systems/CoC7/assets/')
.replace(/\n\s*/g, '\n')
.replace(/@@coc7./g, '<span>@</span>coc7.')

dbEntry.pages.push({
name: sources[lang].pages[page].name,
type: 'text',
_id: links[sources[lang].pages[page].file],
title: {
show: false,
level: 1
},
text: {
format: 1,
content: '<div class="coc7overview">\n' + html + '\n</div>',
markdown: ''
},
sort: Number(page)
})
}
dbFile.push(JSON.stringify(dbEntry))
}
} catch (e) {
console.log('EXCEPTION:', e)
}

write('./packs/system-doc.db', dbFile.join('\n'))

/**
* generateBuildConsistentID uses idSource to generate an id that will be consistent across builds.
*
* Note: This is called outside of foundry to build manual .db files and substitutes foundry.utils.randomID in a build consistent way.
* It creates a hash from the key so it is consistent between builds and the converts to base 64 so it uses the same range of characters as FoundryVTTs generator.
* @param {string} idSource
* @returns id, an string of 16 characters with the id consistently generated from idSource
*/
function generateBuildConsistentID (idSource) {
let id = crypto.createHash('md5').update(idSource).digest('base64').replace(/[\\+=\\/]/g, '').substring(0, 16)
while (typeof collisions[id] !== 'undefined') {
id = crypto.createHash('md5').update(idSource + Math.random().toString()).digest('base64').replace(/[\\+=\\/]/g, '').substring(0, 16)
}
return id
}
Loading

0 comments on commit 863ffe5

Please sign in to comment.