Import des sorts en réserve
This commit is contained in:
parent
5dd5a03487
commit
1c68c34641
@ -33,16 +33,22 @@ const XREGEXP_WEAPON_MANIEMENT = "(?<maniement>(" + Misc.join(Object.keys(MANIEM
|
|||||||
|
|
||||||
const XREGEXP_SORT_VOIE = "(?<voies>[OHNT](\\/[OHNT])*)"
|
const XREGEXP_SORT_VOIE = "(?<voies>[OHNT](\\/[OHNT])*)"
|
||||||
const XREGEXP_SORT_NAME = "(?<name>[^\\(]+)"
|
const XREGEXP_SORT_NAME = "(?<name>[^\\(]+)"
|
||||||
const XREGEXP_SORT_CASE = "\\((?<case>([A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+|[A-M]\\d{1,2})+)\\)";
|
// const XREGEXP_SORT_CASE = "(?<coord>([A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+|[A-M]\\d{1,2})+)"
|
||||||
|
const XREGEXP_SORT_CASE = "(?<coord>([A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+|[A-M]\\d{1,2}))"
|
||||||
|
|
||||||
const XREGEXP_SORT = "(" + XREGEXP_SORT_VOIE
|
const XREGEXP_SORT = "(" + XREGEXP_SORT_VOIE
|
||||||
+ WHITESPACES + XREGEXP_SORT_NAME
|
+ WHITESPACES + XREGEXP_SORT_NAME
|
||||||
+ WHITESPACES + XREGEXP_SORT_CASE
|
+ WHITESPACES + "\\(" + XREGEXP_SORT_CASE + "\\)"
|
||||||
+ WHITESPACES + "R(?<diff>([\\-\\d]+|(\\w|\\s)+))"
|
+ WHITESPACES + "R(?<diff>([\\-\\d]+|(\\w|\\s)+))"
|
||||||
+ WHITESPACES + "r(?<reve>(\\d+(\\+)?|\\s\\w+))"
|
+ WHITESPACES + "r(?<reve>(\\d+(\\+)?|\\s\\w+))"
|
||||||
+ "(" + WHITESPACES + "\\+(?<bonus>\\d+)\\s?%" + WHITESPACES + "en" + WHITESPACES + "(?<bonuscase>[A-M]\\d{1,2})" + ")?"
|
+ "(" + WHITESPACES + "\\+(?<bonus>\\d+)\\s?%" + WHITESPACES + "en" + WHITESPACES + "(?<bonuscase>[A-M]\\d{1,2})" + ")?"
|
||||||
+ ")"
|
+ ")"
|
||||||
|
|
||||||
|
const XREGEXP_SORTRESERVE_CASE = "(?<coord>[A-M]\\d{1,2})";
|
||||||
|
|
||||||
|
const XREGEXP_SORT_RESERVE = XREGEXP_SORTRESERVE_CASE
|
||||||
|
+ WHITESPACES + XREGEXP_SORT_NAME
|
||||||
|
+ WHITESPACES + "(\\((?<description>[^\\)]+)\\))?"
|
||||||
|
|
||||||
// Main class for parsing a stat block
|
// Main class for parsing a stat block
|
||||||
export class RdDStatBlockParser {
|
export class RdDStatBlockParser {
|
||||||
@ -324,10 +330,10 @@ export class RdDStatBlockParser {
|
|||||||
|
|
||||||
XRegExp.forEach(statString, XRegExp(XREGEXP_SORT, 'gu' /* keep case sensitive to match the spell draconic skill */),
|
XRegExp.forEach(statString, XRegExp(XREGEXP_SORT, 'gu' /* keep case sensitive to match the spell draconic skill */),
|
||||||
function (matchSort, i) {
|
function (matchSort, i) {
|
||||||
|
actorData.flags.hautRevant = true
|
||||||
const sortName = Grammar.toLowerCaseNoAccent(matchSort.name).trim().replace("’", "'");
|
const sortName = Grammar.toLowerCaseNoAccent(matchSort.name).trim().replace("’", "'");
|
||||||
let sort = sorts.find(s => Grammar.toLowerCaseNoAccent(s.name) == sortName)
|
let sort = sorts.find(s => Grammar.toLowerCaseNoAccent(s.name) == sortName)
|
||||||
if (sort) {
|
if (sort) {
|
||||||
actorData.flags.hautRevant = true
|
|
||||||
sort = sort.toObject();
|
sort = sort.toObject();
|
||||||
if (matchSort.bonus && matchSort.bonuscase) {
|
if (matchSort.bonus && matchSort.bonuscase) {
|
||||||
sort.system.bonuscase = `${matchSort.bonuscase}:${matchSort.bonus}`;
|
sort.system.bonuscase = `${matchSort.bonuscase}:${matchSort.bonus}`;
|
||||||
@ -337,7 +343,38 @@ export class RdDStatBlockParser {
|
|||||||
else {
|
else {
|
||||||
ui.notifications.warn(`Impossible de trouver le sort ${matchSort.name} / ${sortName}`)
|
ui.notifications.warn(`Impossible de trouver le sort ${matchSort.name} / ${sortName}`)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
const sortsReserve = XRegExp.exec(statString, XRegExp('En réserve\\s+(?<reserve>.*)', 'gu' /* keep case sensitive to match the spell draconic skill */))
|
||||||
|
if (sortsReserve?.reserve) {
|
||||||
|
actorData.flags.hautRevant = true
|
||||||
|
XRegExp.forEach(sortsReserve.reserve, XRegExp(XREGEXP_SORT_RESERVE, 'giu'),
|
||||||
|
function (matchSortReserve, i) {
|
||||||
|
const name = Grammar.toLowerCaseNoAccent(matchSortReserve.name).trim().replace("’", "'");
|
||||||
|
const sort = sorts.find(s => Grammar.toLowerCaseNoAccent(s.name) == name)
|
||||||
|
if (sort) {
|
||||||
|
if (!items.find(it => it._id == sort.id)) {
|
||||||
|
const nouveauSort = sort.toObject()
|
||||||
|
nouveauSort.system.bonuscase = `${matchSortReserve.coord}:1`;
|
||||||
|
items.push(sort.toObject())
|
||||||
|
}
|
||||||
|
items.push({
|
||||||
|
name: sort.name,
|
||||||
|
type: 'sortreserve',
|
||||||
|
img: sort.img,
|
||||||
|
system: {
|
||||||
|
sortid: sort.id,
|
||||||
|
draconic: sort.system.draconic,
|
||||||
|
coord: matchSortReserve.coord,
|
||||||
|
ptreve: Number(sort.system.ptreve.match(/\d+/)),
|
||||||
|
},
|
||||||
|
description: matchSortReserve.description
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui.notifications.warn(`Impossible de mettre ${matchSortReserve.name} en réserve en ${matchSortReserve.coord}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (actorData.flags.hautRevant) {
|
if (actorData.flags.hautRevant) {
|
||||||
const donHR = await RdDItemTete.teteDonDeHautReve();
|
const donHR = await RdDItemTete.teteDonDeHautReve();
|
||||||
|
Loading…
Reference in New Issue
Block a user