forked from public/swade-fr-content
Auto-patch skill and swid
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { SWDELUXStatBlockParser } from "./sw-statblock-parser.js";
|
||||
|
||||
const __compFolderTranslation = [
|
||||
{
|
||||
@@ -68,6 +69,7 @@ class swadeFrTranslator {
|
||||
/************************************************************************************/
|
||||
Hooks.once('init', () => {
|
||||
|
||||
console.log("INIT !!!!!!")
|
||||
if (typeof Babele !== 'undefined') {
|
||||
|
||||
console.log("BABELE LOADED !!!");
|
||||
@@ -80,12 +82,18 @@ Hooks.once('init', () => {
|
||||
Babele.get().registerConverters({
|
||||
"gear_skill": (skill) => {
|
||||
let transl = skill
|
||||
//console.log("Testing", skill)
|
||||
if (skill) {
|
||||
let translated = game.babele.translate("swade-core-rules.swade-skills", { name: skill.trim() }, true)
|
||||
transl = translated.name || skill.trim()
|
||||
}
|
||||
return transl
|
||||
},
|
||||
"skill_swid": (swid) => {
|
||||
if (swid == "fighting") return "combat";
|
||||
if (swid == "shooting") return "tir";
|
||||
return swid
|
||||
},
|
||||
"category_converter": (category) => {
|
||||
return game.i18n.localize(category)
|
||||
},
|
||||
@@ -183,14 +191,17 @@ Hooks.once('init', () => {
|
||||
export class SwadeFRContentCommands {
|
||||
|
||||
static init() {
|
||||
|
||||
if (!game.swadeFRContent) {
|
||||
const swadeFRCommands = new SwadeFRContentCommands()
|
||||
swadeFRCommands.registerCommand({ path: ["/montremonsecret"], func: (content, msg, params) => SwadeFRContentCommands.enableSecret(), descr: "Affiche les compendiums secrets" });
|
||||
swadeFRCommands.registerCommand({ path: ["/cachemonsecret"], func: (content, msg, params) => SwadeFRContentCommands.disableSecret(), descr: "Cache les compendiums secrets" });
|
||||
swadeFRCommands.registerCommand({ path: ["/statparser"], func: (content, msg, params) => SwadeFRContentCommands.statParser(), descr: "Parse SW Delux stat block" });
|
||||
game.swadeFRContent = { commands: swadeFRCommands }
|
||||
}
|
||||
|
||||
Hooks.on("chatMessage", (html, content, msg) => {
|
||||
console.log("CHAT PARSER!!!")
|
||||
if (content[0] == '/') {
|
||||
let regExp = /(\S+)/g;
|
||||
let commands = content.match(regExp);
|
||||
@@ -268,13 +279,32 @@ export class SwadeFRContentCommands {
|
||||
static disableSecret() {
|
||||
game.settings.set("world", "swade-fr-content-hidden-compendiums", false)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static statParser() {
|
||||
let dialogue = new Dialog({
|
||||
title: `Import`,
|
||||
content: `<p>Stab block: <textarea id="swdelux-stat-parser" rows="20" cols="40"></textarea></p>`,
|
||||
buttons: {
|
||||
one: {
|
||||
icon: '',
|
||||
label: 'Parser !',
|
||||
callback: (html) => {
|
||||
let text = html.find('#swdelux-stat-parser').val();
|
||||
let parser = new SWDELUXStatBlockParser(text);
|
||||
parser.parse(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
dialogue.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_processCommand(commandsTable, name, params, content = '', msg = {}, path = "") {
|
||||
console.log("===> Processing command")
|
||||
let command = commandsTable[name];
|
||||
path = path + name + " ";
|
||||
if (command && command.subTable) {
|
||||
if (command?.subTable) {
|
||||
if (params[0]) {
|
||||
return this._processCommand(command.subTable, params[0], params.slice(1), content, msg, path)
|
||||
}
|
||||
@@ -283,7 +313,7 @@ export class SwadeFRContentCommands {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (command && command.func) {
|
||||
if (command?.func) {
|
||||
const result = command.func(content, msg, params);
|
||||
if (result == false) {
|
||||
BoLCommands._chatAnswer(msg, command.descr);
|
||||
@@ -366,6 +396,7 @@ async function loadSecretCompendiums() {
|
||||
|
||||
/************************************************************************************/
|
||||
Hooks.once('ready', () => {
|
||||
console.log(">>>>>>>>>>")
|
||||
|
||||
// add hidden register
|
||||
game.settings.register("world", "swade-fr-content-hidden-compendiums", {
|
||||
@@ -376,7 +407,7 @@ Hooks.once('ready', () => {
|
||||
type: Boolean,
|
||||
onChange: lang => window.location.reload()
|
||||
})
|
||||
|
||||
|
||||
SwadeFRContentCommands.init()
|
||||
|
||||
//FolderTranslate.translateFolders()
|
||||
@@ -386,5 +417,8 @@ Hooks.once('ready', () => {
|
||||
|
||||
/************************************************************************************/
|
||||
Hooks.once('babele.ready', () => {
|
||||
console.log(">>>>>>>>>> BABELE READY")
|
||||
loadSecretCompendiums()
|
||||
});
|
||||
|
||||
console.log(">>>>>>>>>>>> LOADED")
|
||||
|
Reference in New Issue
Block a user