foundryvtt-wh4-lang-fr-fr/modules/import-stat-2.js

35 lines
1.2 KiB
JavaScript

let str = `JABBERSLYTHE
M WS BS S T I Agi Dex
Int WP Fel W
7 45 40 55
50 20 35 - 10 20 - 20
Traits: Armour 3, Bestial, Bite+9, Bounce, Corrosive
Blood, Distracting, Infected, Maddening Aura (see
page 17), Night Vision, Size (Enormous), Tail +8,
Tongue Attack +5 (12), Venom, Weapon +9.
`;
import "./xregexp-all.js";
const us_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w';
const fr_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w';
const carac_val = '(?<M>[0-9-]+)\\s+(?<WS>[0-9-]+)\\s+(?<BS>[0-9-]+)\\s+(?<S>[0-9-]+)\\s+(?<T>[0-9-]+)\\s+(?<I>[0-9-]+)\\s+(?<Ag>[0-9-]+)\\s+(?<Dex>[0-9-]+)\\s+(?<Int>[0-9-]+)\\s+(?<WP>[0-9-]+)\\s+(?<Soc>[0-9-]+)\\s+(?<W>[0-9-]+)';
const traits = "Traits:"
Hooks.once('init', () => {
let t1 = "agi";
let reg0 = XRegExp('agi?', 'gi');
//console.log("PARSER pos 1: ", reg0.test( t1 ) );
let reg1 = XRegExp(us_carac, 'gi');
let res = reg1.test(str);
//console.log("PARSER pos 2: ", res);
if (res) { //stat block identified
let reg2 = XRegExp(carac_val, 'gi')
let res = XRegExp.exec(str, reg2);
//console.log("Movement is : ", res);
}
//Do we have Traits ?
})