Armes/Protections/Equipement

This commit is contained in:
sladecraven 2022-10-24 18:36:24 +02:00
parent 312a4d8699
commit 435988bea5
2 changed files with 8265 additions and 0 deletions

View File

@ -0,0 +1,40 @@
/* -------------------------------------------- */
import { HawkmoonUtility } from "./hawkmoon-utility.js";
import "./xregexp-all.js";
const __level1Expr = '(?<effectType>[a-z]+):(?<objectType>[a-zA-Z]+)\\((?<objectName>[a-zA-Z0-9\\.]+)\\)\\s+(?<modifierValue>[\\d]+)\\s*{*(?<modifierLabel>[a-zA-Zàéè\\s]*)}*'
const __effectTypes = {modifier: 1, cost: 1, provide: 1}
/* -------------------------------------------- */
export class HawkmoonEffectParser {
/* -------------------------------------------- */
static init() {
this.__objectTypes = { }
Object.entries(game.data.model.Actor).forEach(kv => {
this.__objectTypes[kv[0]] = duplicate(kv[1])
})
Object.entries(game.data.model.Item).forEach(kv => {
this.__objectTypes[kv[0]] = duplicate(kv[1])
})
}
/* -------------------------------------------- */
static parseEffectString(effectString) {
let parse1 = XRegExp.exec(effectString, XRegExp(__level1Expr, 'gi'))
if (parse1.effectType && __effectTypes[parse1.effectType.toLowerCase()]) {
parse1.effectType = parse1.effectType.toLowerCase()
if ( parse1.objectType && this.__objectTypes[parse1.objectType.toLowerCase()] ) {
parse1.objectType = parse1.objectType.toLowerCase()
console.log("Level 1 parsing : ", parse1, Object.keys(__effectTypes) )
} else {
ui.notifications.warn("EffectParser : Le type d'objet est inconnu. Les valeurs valides sont : " + Object.keys(this.__objectTypes).toString() )
}
} else {
ui.notifications.warn("EffectParser : Le type d'effet est inconnu. Les valeurs valides sont : " + Object.keys(__effectTypes).toString() )
}
}
}

8225
modules/xregexp-all.js Normal file

File diff suppressed because it is too large Load Diff