- {{/desc}} {{#DV}}
+ {{/desc}}
+ {{#DV}}
- {{/rollWasFumble() test}} {{/test}} {{#attaque}} {{#rollWasCrit() attaque}}
-
- {{/degats2}} {{/degats}} {{/attaque}} {{#special}}
+ {{#rollWasCrit() test}}
+
+ {{/rollWasFumble() test}}
+ {{/test}}
+ {{#attaque}}
+ {{#rollWasCrit() attaque}}
+
+ {{/rollWasCrit() attaque}}
+ {{#rollWasFumble() attaque}}
+
+ {{/degats2}}
+ {{/degats}}
+ {{/attaque}}
+ {{^attaque}}
+ {{#degats}}
+
+ {{/degats2}}
+ {{/degats}}
+ {{/attaque}}
+ {{#special}}
|
{{text}}
@@ -1815,22 +1915,55 @@
console.log('** CO sheetworker' + m + ' >>>');
}
+ function addTrait(npcObj, traitObj) {
+ if (traitObj['nom'] !== '' && traitObj['desc'] !== '') {
+ if (!npcObj['Capas']) npcObj['Capas'] = [];
+ npcObj['Capas'].push(`${traitObj['nom']}~${traitObj['desc']}`);
+ traitObj['nom'] = '';
+ traitObj['desc'] = '';
+ }
+ }
+
function importStatblock(text) {
text = text.replace(/\r/g, '');
text = text.replace(/ \(DM/g, ' DM');
text = text.replace(/ \(RD/g, ' RD');
text = text.replace(/\, /g, ' ');
+ text = text.replace(/\n[ ]*\+/g,'+');
var npc = {};
var rows = text.split(/\n/);
+ var capacites = false;
+ var capacite = { 'nom': '', 'desc': '' };
console.log('** CO sheetworker : parsing text <<<');
for (var row = 0; row < rows.length; row++) {
console.log(rows[row]);
- if (rows[row].toUpperCase().indexOf('DM') !== -1) { // this is an attack line
+ if (row === 0 && rows[row].toUpperCase().indexOf('NC') === -1) {
+ npc['character_name'] = rows[row].trim(); // assume first line is name
+ continue;
+ }
+ if (!capacites && rows[row].toUpperCase().indexOf('DM') !== -1) { // this is an attack line
rows[row] = rows[row].replace(/\)$/g, ''); // handle CG statblocks
if (!npc['Atks']) npc['Atks'] = [];
npc['Atks'].push(rows[row]);
continue;
}
+ if (capacites) { // start parsing traits
+ let s = rows[row].indexOf(':');
+ if (s !== -1) {
+ addTrait(npc, capacite);
+ capacite['nom'] = rows[row].substring(0, s - 1).trim();
+ if (capacite['nom'].indexOf(' RD') !== -1) capacite['nom'] = capacite['nom'].replace(' RD', ' (RD');
+ capacite['desc'] = rows[row].substring(s + 1).trim();
+ } else {
+ capacite['desc'] += ' ' + rows[row].trim();
+ }
+ continue;
+ }
+ if (rows[row].trim().startsWith('---')) {
+ addTrait(npc, capacite);
+ capacites = !capacites;
+ continue;
+ }
rows[row] = rows[row].replace(/ \(/g, '('); // strip space before '(
rows[row] = rows[row].replace(/très /g, 'très~'); // handle 'très petite' size
rows[row] = rows[row].replace(/créature /g, 'PROFIL créature~'); // handle 'créature' mention
@@ -1838,12 +1971,18 @@
for (var item = 0; item < items.length; item++) {
if (item % 2 === 0) {
var k = items[item].toUpperCase().replace(/\./g, '');
- var v = items[item + 1].replace(/~/g, ' ');
- if (v.charAt(v.length - 1) === ')' && v.charAt(0) !== '(') v = v.substring(0, v.length - 1);
+ var v = items[item + 1];
+ if (v) {
+ v.replace(/~/g, ' ');
+ if (v.charAt(v.length - 1) === ')' && v.charAt(0) !== '(') v = v.substring(0, v.length - 1);
+ } else {
+ v = '';
+ }
npc[k] = v;
}
}
}
+ if (capacites) addTrait(npc, capacite);
console.log('** CO sheetworker : parsing text >>>');
return npc;
}
@@ -1877,6 +2016,8 @@
var jnor = '1d20';
var jsup = '2d20kh1';
var pnjAttrs = {};
+ if (pnjObj.hasOwnProperty('character_name')) pnjAttrs['character_name'] = pnjObj.character_name;
+ delete pnjObj['character_name'];
pnjAttrs['NIVEAU'] = parseInt(pnjObj.NC) || 0;
delete pnjObj['NC'];
pnjAttrs['TAILLE'] = pnjObj.TAILLE || '';
@@ -1984,12 +2125,42 @@
consoleLog(atkRow, 'adding attack');
setAttrs(atkRow);
} else {
- result = 'Err: impossible d\'analyser le contenu de "' + pnjObj.Atks[atk] + '"';
+ result += (result.length > 0 ? '\n' : '') + 'Err: impossible d\'analyser le contenu de "' + pnjObj.Atks[atk] + '"';
}
}
return result;
}
+
+ function processTraits(universe, pnjObj) {
+ let result = '';
+
+ for (let capa of pnjObj['Capas']) {
+ let capacite = capa.split('~')
+ if (capacite.length == 2) {
+ let name = capacite[0] || '';
+ let desc = capacite[1] || '';
+ if (name !== '' && desc !== '') {
+ newRowID = generateRowID();
+ let capaRow = {};
+ capaRow[`repeating_pnjcapas_${newRowID}_capanom`] = name;
+ desc = desc.replace(/\d+d\d+[+-]*\d*/g, '{{$&}}'); // search for d+/-
+ desc = desc.replace(/\[\d+d\d+[+-]*\d*\]/g, '{$&}'); // search for [d+/-]
+ desc = desc.replace(/\[{{/g, '[[');
+ desc = desc.replace(/}}\]/g, ']]');
+ desc = desc.replace(/{{/g, '[[');
+ desc = desc.replace(/}}/g, ']]');
+ capaRow[`repeating_pnjcapas_${newRowID}_capadesc`] = desc;
+ consoleLog(capaRow, 'adding trait');
+ setAttrs(capaRow);
+ }
+ } else {
+ result += (result.length > 0 ? '\n' : '') + 'Err: impossible d\'analyser le contenu de "' + capacite + '"';
+ }
+ }
+
+ return result;
+ }
function buildCaracs() {
getAttrs([
@@ -2170,27 +2341,34 @@
}
}
});
- // MAJ Version
- getAttrs(['VERFDP'], function(values) {
+ // MAJ Version, LAST_PV, messsage
+ getAttrs(['VERFDP', 'PV'], function(values) {
setAttrs({
- VERSION: values.VERFDP
+ VERSION: values.VERFDP,
+ LAST_PV: values.PV,
+ INFOMSG: ' '
});
});
- // PC
- getAttrs(['PC_DESC'], function(values) {
- var pc_desc = (values.PC_DESC) ? '' : 'Points de Chance';
+ // PC (one time only)
+ getAttrs(['PC_DESC'], function(value) {
+ var pc_desc = (value.PC_DESC) ? '' : 'Points de Chance';
if (pc_desc != '') {
setAttrs({
PC_DESC: pc_desc
});
}
});
- // LAST_PV
- getAttrs(['PV'], function(values) {
- setAttrs({
- LAST_PV: values.PV
- });
+ // seuil_enc (if needed)
+ getAttrs(['seuil_enc', 'FORCE'], function(values) {
+ let seuil_enc = parseInt(values.seuil_enc) || 0;
+ if (seuil_enc === 0) {
+ setAttrs({
+ seuil_enc: parseInt(values.FORCE) || 0
+ });
+ }
});
+ // encombrement (refresh)
+ encumbrance();
// CARACS
buildCaracs();
});
@@ -2251,9 +2429,12 @@
buffv.pop();
buffName = buffv.join(' ').trim();
} else {
- buffName = buffv[0];
+ buffName = buffv[0].trim();
buffVal = buffValue(buffv[1], caracs);
}
+ consoleLog(buff);
+ consoleLog(buffName);
+ consoleLog(buffVal);
if (!buffName.startsWith('-')) buffSum += buffVal;
}
}
@@ -2268,7 +2449,7 @@
const caracs = ['FOR', 'DEX', 'CON', 'INT', 'PER', 'CHA'];
let mod = e.sourceAttribute.substring(0, 3).toUpperCase();
if (!caracs.includes(mod)) return;
- const attrs = [...caracs, 'ATKCAC', 'ATKTIR', 'PSYINTUI', 'PSYINFLU', 'INIT', 'DEF', 'DEP'];
+ const attrs = [...caracs, 'ATKCAC', 'ATKTIR', 'ATKMAG', 'ATKMEN', 'INIT', 'DEF'];
for (let a = 0; a < attrs.length; a++) {
attrs[a] = `${attrs[a]}_BUFF_LIST`;
}
@@ -2345,104 +2526,7 @@
on('change:def_buff_list', function() {
parseBuff('DEF');
});
-
- on('change:condition', function() {
- getAttrs(['PCONDITION', 'CONDITION', 'ATKCAC_BUFF', 'ATKTIR_BUFF', 'INIT_BUFF', 'DEF_BUFF', 'ETATDE'], function(values) {
- // setup helper objects
- const conditions = {
- 'aucune': '',
- 'aveugle': 'A',
- 'etourdi': 'E',
- 'effraye': 'F',
- 'immobilise': 'I',
- 'panique': 'P',
- 'renverse': 'R',
- 'surpris': 'S'
- }
- const buffs = {
- '': {
- 'atc': 0,
- 'atd': 0,
- 'def': 0,
- 'init': 0
- },
- 'A': {
- 'atc': 5,
- 'atd': 10,
- 'def': 5,
- 'init': 5
- },
- 'E': {
- 'atc': 0,
- 'atd': 0,
- 'def': 5,
- 'init': 0
- },
- 'F': {
- 'atc': 5,
- 'atd': 5,
- 'def': 0,
- 'init': 0
- },
- 'I': {
- 'atc': 0,
- 'atd': 0,
- 'def': 0,
- 'init': 0
- },
- 'P': {
- 'atc': 0,
- 'atd': 0,
- 'def': 2,
- 'init': 0
- },
- 'R': {
- 'atc': 5,
- 'atd': 5,
- 'def': 5,
- 'init': 0
- },
- 'S': {
- 'atc': 0,
- 'atd': 0,
- 'def': 5,
- 'init': 0
- }
- }
- // check prior condition for die roll
- let etatde = values.ETATDE;
- switch (values.PCONDITION) {
- case conditions.immobilise:
- etatde = '20';
- break;
- case conditions.panique:
- etatde = '20';
- break;
- }
- // check condition for die roll
- switch (values.CONDITION) {
- case conditions.immobilise:
- etatde = '12';
- break;
- case conditions.panique:
- etatde = '12';
- break;
- case conditions.aucune:
- etatde = '20';
- break;
- }
- // Now update all buffs and prior condition
- setAttrs({
- ATKCAC_BUFF: values.ATKCAC_BUFF + buffs[values.PCONDITION].atc - buffs[values.CONDITION].atc,
- ATKTIR_BUFF: values.ATKTIR_BUFF + buffs[values.PCONDITION].atd - buffs[values.CONDITION].atd,
- INIT_BUFF: values.INIT_BUFF + buffs[values.PCONDITION].init - buffs[values.CONDITION].init,
- DEF_BUFF: values.DEF_BUFF + buffs[values.PCONDITION].def - buffs[values.CONDITION].def,
- ETATDE: etatde,
- PCONDITION: values.CONDITION
- });
- });
- });
-
+
on('change:blessure', function() {
getAttrs(['BLESSURE'], function(values) {
var etatde = (values.BLESSURE === '1') ? '12' : '20';
@@ -2462,7 +2546,11 @@
JETNORMAL: jetn,
JETSUP: jets,
JETSUPHERO: jetsh,
- JETRISQUE: jetr
+ JETRISQUE: jetr,
+ JDEX: jetn,
+ JDEXSUP: jets,
+ JDEXSUPHERO: jetsh,
+ JDEXRISQUE: jetr
});
});
});
@@ -2498,6 +2586,12 @@
messages += result;
delete pnjObj['Atks'];
}
+ if (pnjObj.hasOwnProperty('Capas')) {
+ result = processTraits(values.UNIVERS, pnjObj);
+ if (result != '' && messages != '') result = '\n' + result;
+ messages += result;
+ delete pnjObj['Capas'];
+ }
// Other attributes go to DIVERS field
var divers = '';
var otherAttrs = Object.keys(pnjObj);
@@ -2516,7 +2610,98 @@
});
});
- on('change:type_personnage', function() {
+ const npcAtkAttribs = [
+ 'atkatt',
+ 'atknom',
+ 'atkjet',
+ 'atkbonus',
+ 'atkcrit',
+ 'atkdmg',
+ 'atkdmnbde',
+ 'atkdmde',
+ 'atkdmbonus',
+ 'atkportee',
+ 'atkspec'
+ ]
+
+ function convertToPC() {
+ getAttrs([
+ 'pnj_for', 'pnj_dex', 'pnj_con', 'pnj_int', 'pnj_per', 'pnj_cha',
+ 'pnj_jetfor', 'pnj_jetdex', 'pnj_jetcon', 'pnj_jetint', 'pnj_jetper', 'pnj_jetcha',
+ 'pnj_init', 'pnj_def', 'pnj_pv', 'pnj_pv_max'
+ ], function(values) {
+ let attrs = {};
+ for (let attr of ['FORCE', 'DEXTERITE', 'CONSTITUTION', 'INTELLIGENCE', 'PERCEPTION', 'CHARISME']) {
+ let attrv = parseInt(values[`pnj_${attr.substring(0,3).toLowerCase()}`]) || 0;
+ attrs[attr] = 10 + (2 * attrv);
+ if (attr === 'DEXTERITE') {
+ let init = parseInt(values.pnj_init) || 0;
+ if (init === attrv + 1) {
+ attrs[attr]++;
+ } else {
+ attrs['INIT_BUFF'] = init - attrs[attr];
+ }
+ let defb = 10 + attrv;
+ let def = parseInt(values.pnj_def) || 0;
+ if (def !== defb) attrs['DEF_BUFF'] = def - defb;
+ attrs['DEX_SUP'] = (values['pnj_jetdex'] === '2d20kh1') ? '@{JDEXSUP}' : '@{JDEX}';
+ } else {
+ attrs[`${attr.substring(0,3)}_SUP`] = (values[`pnj_jet${attr.substring(0,3).toLowerCase()}`] === '2d20kh1') ? '@{JETSUP}' : '@{JETNORMAL}';
+ }
+ }
+ attrs['PV'] = parseInt(values.pnj_pv) || 0;
+ attrs['PV_max'] = parseInt(values.pnj_pv_max) || 0;
+ getSectionIDs('repeating_armes', function(ids) {
+ for (let id of ids) {
+ removeRepeatingRow(`repeating_armes_${id}`);
+ }
+ });
+ getSectionIDs('repeating_pnjatk', function(ids) {
+ for (let id of ids) {
+ getAttrs([...npcAtkAttribs.map(attr => `repeating_pnjatk_${id}_${attr}`), 'pnj_for', 'pnj_dex', 'pnj_cha'], function(values) {
+ consoleLog(values);
+ let v = {};
+ for (let attr of npcAtkAttribs) {
+ v[attr] = values[`repeating_pnjatk_${id}_${attr}`] || '';
+ }
+ newRowID = generateRowID();
+ let atkRow = {};
+ atkRow[`repeating_armes_${newRowID}_armeatt`] = v['atkatt'];
+ atkRow[`repeating_armes_${newRowID}_armenom`] = v['atknom'];
+ let magic = v['atknom'].toLowerCase().includes('attaque magique');
+ let tohit = parseInt(v['atkbonus']) || 0;
+ let atk = 0;
+ let bdm = 0;
+ if (v['atkportee'] && v['atkportee'] !== '') {
+ atk = magic ? values.pnj_cha || 0 : values.pnj_dex || 0;
+ atkRow[`repeating_armes_${newRowID}_armeatk`] = magic ? '@{ATKMAG}' : '@{ATKTIR}';
+ } else {
+ atk = magic ? values.pnj_cha || 0 : values.pnj_for || 0;
+ bdm = magic ? 0 : atk;
+ atkRow[`repeating_armes_${newRowID}_armeatk`] = magic ? '@{ATKMAG}' : '@{ATKCAC}';
+ atkRow[`repeating_armes_${newRowID}_armedmcar`] = magic ? '' : '@{FOR}';
+ }
+ if (tohit !== atk) atkRow[`repeating_armes_${newRowID}_armeatkdiv`] = tohit - atk;
+ atkRow[`repeating_armes_${newRowID}_armejetd`] = v['atkjet'];
+ atkRow[`repeating_armes_${newRowID}_armecrit`] = v['atkcrit'];
+ atkRow[`repeating_armes_${newRowID}_armedmg`] = v['atkdmg'];
+ atkRow[`repeating_armes_${newRowID}_armedmnbde`] = v['atkdmnbde'];
+ atkRow[`repeating_armes_${newRowID}_armedmde`] = v['atkdmde'];
+ let dmdiv = parseInt(v['atkdmbonus']) || 0;
+ if (dmdiv !== bdm) atkRow[`repeating_armes_${newRowID}_armedmdiv`] = dmdiv - bdm;
+ atkRow[`repeating_armes_${newRowID}_armeportee`] = v['atkportee'];
+ atkRow[`repeating_armes_${newRowID}_armespec`] = v['atkspec'];
+ setAttrs(atkRow);
+ });
+ }
+ });
+ setAttrs(attrs);
+ });
+ }
+
+ on('change:type_personnage', function(eventInfo) {
+ if (eventInfo.previousValue === 'pnj' && eventInfo.newValue === 'pj') convertToPC();
+ // if (eventInfo.previousValue === 'pj' && eventInfo.newValue === 'pnj') convertToNPC();
getAttrs(['type_personnage'], function(values) {
setAttrs({
type_fiche: values.type_personnage
@@ -2525,7 +2710,7 @@
});
function changeRanks(voie) {
- return `change:voie${voie}-1 change:voie${voie}-2 change:voie${voie}-3 change:voie${voie}-4 change:voie${voie}-5`;
+ return `change:voie${voie}nom change:voie${voie}-1 change:voie${voie}-2 change:voie${voie}-3 change:voie${voie}-4 change:voie${voie}-5`;
}
function attrRanks(voie) {
@@ -2612,7 +2797,7 @@
let portees = parseInt(portee) || 0;
if (portees !== 0) {
setAttrs({
- repeating_armes_armeportees: `${portees}${um} / ${portees*2}${um} / ${portees*3}${um}`
+ repeating_armes_armeportees: `${portees}m | ${portees*2}m (-5) | ${portees*3}m (-10)`
});
}
});
@@ -2652,7 +2837,6 @@
var pilote = value.PILOTE.trim() || '';
if (pilote === '') return;
getSectionIDs('repeating_jetv', function(ids) {
- let items = {};
for (let id = 0; id < ids.length; id++) {
getAttrs([`repeating_jetv_${ids[id]}_jetvcaracpil`, `repeating_jetv_${ids[id]}_jetvcaracp`], function(values) {
let attr = values[Object.keys(values)[0]];
@@ -2676,6 +2860,347 @@
});
});
});
+
+ function encumbrance() {
+ getSectionIDs('repeating_equipement', function(ids) {
+ const encombrement = {
+ total: 0,
+ zeros: 0
+ }
+ for (let id = 0; id < ids.length; id++) {
+ getAttrs([`repeating_equipement_${ids[id]}_equip-qte`, `repeating_equipement_${ids[id]}_equip-enc`], function(values) {
+ let qte = parseInt(values[Object.keys(values)[0]]) || 0;
+ let enc = parseInt(values[Object.keys(values)[1]]) || 0;
+ if (enc === 0) {
+ encombrement.zeros += qte;
+ if (encombrement.zeros >= 3) {
+ encombrement.total += Math.floor(encombrement.zeros / 3);
+ encombrement.zeros %= 3;
+ }
+ } else {
+ encombrement.total += qte*enc;
+ }
+ setAttrs({
+ total_enc: encombrement.total
+ });
+ });
+ }
+ });
+ }
+ on('change:repeating_equipement:equip-qte change:repeating_equipement:equip-enc', function() {
+ encumbrance();
+ });
+
+ on('change:total_enc', function() {
+ getAttrs(['use_encombrement', 'total_enc', 'seuil_enc'], function(values) {
+ let use_encombrement = values.use_encombrement === 1 ? true : false;
+ if (!use_encombrement) return;
+ let seuil_enc = parseInt(values.seuil_enc) || 0;
+ let encombrement = parseInt(values.total_enc) || 0;
+ if (seuil_enc > 0 && encombrement > 0) {
+ let cond = {};
+ if (encombrement > seuil_enc * 3) {
+ cond.CONDITION = 'I'; // Immobilisé
+ } else if (encombrement > seuil_enc * 2) {
+ cond.CONDITION = 'L'; // Ralenti
+ cond.ETATDE = '12'; // +Affaibli
+ } else if (encombrement > seuil_enc) {
+ cond.CONDITION = '';
+ cond.JDEX = '1d12';
+ cond.JDEXSUP = '2d12kh1';
+ cond.JDEXSUPHERO = '{2d12kh1, 0d12+10}kh1';
+ cond.JDEXRISQUE = '2d12kl1';
+ cond.ETATDE = '20';
+ } else {
+ cond.CONDITION = '';
+ cond.JDEX = '1d@{ETATDE}';
+ cond.JDEXSUP = '2d@{ETATDE}kh1';
+ cond.JDEXSUPHERO = '{2d@{ETATDE}kh1, 0d20+10}kh1';
+ cond.JDEXRISQUE = '1d12';
+ cond.ETATDE = '20';
+ }
+ if (cond !== null) setAttrs(cond);
+ }
+ });
+ });
+
+ on('clicked:reset', function() {
+ for (let v=1; v <= 9; v++) {
+ setRank(v.toString());
+ }
+ buildCaracs();
+ encumbrance();
+ });
+
+ on('change:mods_atk', function() {
+ let infomsg = 'Syntaxe non reconnue, corrigez SVP...';
+ setAttrs({ INFOMSG: infomsg });
+ getAttrs(['mods_atk', 'CARACS'], function(values) {
+ const aliases = {
+ 'attaque': 'att',
+ 'attaques': 'att',
+ 'cac': 'atc',
+ 'contact': 'atc',
+ 'cad': 'atd',
+ 'distance': 'atd',
+ 'magie': 'mag',
+ 'mental': 'men',
+ 'mentale': 'men',
+ 'tir': 'atd'
+ };
+ const modifiers = {
+ atc: '',
+ atcdm: '',
+ atd: '',
+ atddm: '',
+ mag: '',
+ magdm: '',
+ men: '',
+ mendm: ''
+ };
+ let result = ' ';
+ if (values.mods_atk !== '') {
+ let caracs = JSON.parse(values.CARACS);
+ let mods = values.mods_atk.replace('\n', ';').split(';');
+ for (let mod of mods) {
+ if (mod.trim() === '') continue;
+ let modv = mod.trim().split(' ');
+ let mod_attr = modv.shift().toLowerCase();
+ let to_dm = false;
+ if (mod_attr === 'dm') {
+ to_dm = true;
+ mod_attr = modv.shift().toLowerCase();
+ if (Object.keys(aliases).includes(mod_attr)) {
+ if (aliases[mod_attr] === 'att') mod_attr = 'dm';
+ if (aliases[mod_attr] === 'atc') mod_attr = 'atcdm';
+ if (aliases[mod_attr] === 'atd') mod_attr = 'atddm';
+ if (aliases[mod_attr] === 'mag') mod_attr = 'magdm';
+ if (aliases[mod_attr] === 'men') mod_attr = 'mendm';
+ } else {
+ if (mod_attr === 'att') mod_attr = 'dm';
+ if (mod_attr === 'atc') mod_attr = 'atcdm';
+ if (mod_attr === 'atd') mod_attr = 'atddm';
+ if (mod_attr === 'mag') mod_attr = 'magdm';
+ if (mod_attr === 'men') mod_attr = 'mendm';
+ }
+ }
+ let mod_sgn = '+';
+ let mod_val = modv.shift();
+ if (mod_val.startsWith('+') || mod_val.startsWith('-')) {
+ mod_sgn = mod_val.substring(0,1);
+ mod_val = mod_val.substring(1);
+ }
+ if (to_dm && mod_val.search(/\d+[dD]\d+/) !== -1) {
+ mod_val = `[[${mod_val}]]`;
+ } else {
+ mod_val = buffValue(mod_val, caracs);
+ if (mod_val === 0) continue;
+ }
+ let mod_desc = ` ${mod_sgn}${mod_val}[${modv.join(' ').trim()}]`;
+ switch (mod_attr) {
+ case 'atc':
+ case 'atcdm':
+ case 'atd':
+ case 'atddm':
+ case 'mag':
+ case 'magdm':
+ case 'men':
+ case 'mendm':
+ modifiers[mod_attr] += mod_desc;
+ break;
+ case 'att':
+ for (let attr of ['atc', 'atd', 'mag', 'men']) {
+ modifiers[attr] += mod_desc;
+ }
+ break;
+ case 'dm':
+ for (let attr of ['atcdm', 'atddm', 'magdm', 'mendm']) {
+ modifiers[attr] += mod_desc;
+ }
+ break;
+ default:
+ if (Object.keys(aliases).includes(mod_attr)) {
+ modifiers[aliases[mod_attr]] += mod_desc;
+ result = ' ';
+ } else {
+ result = infomsg;
+ }
+ break;
+ }
+ }
+ }
+ getSectionIDs('repeating_armes', function(ids) {
+ for (const id of ids) {
+ getAttrs([`repeating_armes_${id}_armeatk`, `repeating_armes_${id}_armeportee`], function(values) {
+ let type = values[Object.keys(values)[0]] || '';
+ let portee = values[Object.keys(values)[1]] || '';
+ let attr = {};
+ if (type === '@{ATKCAC}' || (type === '@{ATKTIR}' && portee === '')) {
+ attr[`repeating_armes_${id}_armebuff`] = modifiers.atc.trim();
+ attr[`repeating_armes_${id}_armebuffdm`] = modifiers.atcdm.trim();
+ } else if (type === '@{ATKTIR}') {
+ attr[`repeating_armes_${id}_armebuff`] = modifiers.atd.trim();
+ attr[`repeating_armes_${id}_armebuffdm`] = modifiers.atddm.trim();
+ } else if (type === '@{ATKMAG}') {
+ attr[`repeating_armes_${id}_armebuff`] = modifiers.mag.trim();
+ attr[`repeating_armes_${id}_armebuffdm`] = modifiers.magdm.trim();
+ } else if (type === '@{ATKMEN}') {
+ attr[`repeating_armes_${id}_armebuff`] = modifiers.men.trim();
+ attr[`repeating_armes_${id}_armebuffdm`] = modifiers.mendm.trim();
+ }
+ if (attr !== null) setAttrs(attr);
+ });
+ }
+ });
+ consoleLog(`[${result}]`);
+ setAttrs({ INFOMSG: result });
+ });
+ });
+
+ const conditions = {
+ 'aveugle': 'A',
+ 'effraye': 'F',
+ 'etourdi': 'E',
+ 'immobilise': 'I',
+ 'panique': 'P',
+ 'ralenti': 'L',
+ 'renverse': 'R',
+ 'surpris': 'S'
+ }
+
+ const conditions_data = {
+ '': {
+ 'atc': 0,
+ 'atd': 0,
+ 'def': 0,
+ 'init': 0,
+ 'title': ''
+ },
+ 'A': {
+ 'atc': 5,
+ 'atd': 10,
+ 'def': 5,
+ 'init': 5,
+ 'title': 'Aveuglé'
+ },
+ 'E': {
+ 'atc': 0,
+ 'atd': 0,
+ 'def': 5,
+ 'init': 0,
+ 'title': 'Etourdi'
+ },
+ 'F': {
+ 'atc': 5,
+ 'atd': 5,
+ 'def': 0,
+ 'init': 0,
+ 'title': 'Effrayé'
+ },
+ 'I': {
+ 'atc': 0,
+ 'atd': 0,
+ 'def': 0,
+ 'init': 0,
+ 'title': 'Immobilisé'
+ },
+ 'P': {
+ 'atc': 0,
+ 'atd': 0,
+ 'def': 2,
+ 'init': 0,
+ 'title': 'Paniqué'
+ },
+ 'L': {
+ 'atc': 0,
+ 'atd': 0,
+ 'def': 0,
+ 'init': 0,
+ 'title': 'Ralenti'
+ },
+ 'R': {
+ 'atc': 5,
+ 'atd': 5,
+ 'def': 5,
+ 'init': 0,
+ 'title': 'Renversé'
+ },
+ 'S': {
+ 'atc': 0,
+ 'atd': 0,
+ 'def': 5,
+ 'init': 0,
+ 'title': 'Surpris'
+ }
+ }
+
+ function applyConditions(buffs, conditionAttr, s) {
+ if (conditionAttr === '') return;
+ for (let cond of conditionAttr) {
+ buffs.atc += s * conditions_data[cond].atc;
+ buffs.atd += s * conditions_data[cond].atd;
+ buffs.def += s * conditions_data[cond].def;
+ buffs.init += s * conditions_data[cond].init;
+ }
+ }
+
+ function clickedConditions() {
+ let clickedConditions = '';
+ for (let condition of Object.keys(conditions)) {
+ clickedConditions += `clicked:cond_${condition} `;
+ }
+ return clickedConditions;
+ }
+
+ on(clickedConditions(), function(eventInfo) {
+ var clickedCondition = conditions[eventInfo.triggerName.replace('clicked:cond_','')];
+ getAttrs(['PCONDITION', 'CONDITION', 'ATKCAC_BUFF', 'ATKTIR_BUFF', 'INIT_BUFF', 'DEF_BUFF', 'ETATDE'], function(values) {
+ let buffs = {
+ 'atc': parseInt(values.ATKCAC_BUFF) || 0,
+ 'atd': parseInt(values.ATKTIR_BUFF) || 0,
+ 'def': parseInt(values.DEF_BUFF) || 0,
+ 'init': parseInt(values.INIT_BUFF) || 0
+ };
+ // debuffs prior condition
+ let pcondition = values.PCONDITION || '';
+ applyConditions(buffs, pcondition, +1);
+ // change condition
+ let condition = values.CONDITION || '';
+ if (condition.includes(clickedCondition)) {
+ condition = condition.replace(clickedCondition,'');
+ } else {
+ condition += clickedCondition;
+ }
+ // buff new condition
+ applyConditions(buffs, condition, -1);
+ // check prior condition for die roll
+ let etatde = values.ETATDE;
+ if (pcondition !== '' && (pcondition.includes(conditions.immobilise) || pcondition.includes(conditions.panique))) etatde = '20';
+ // check condition for die roll
+ if (condition !== '' && (condition.includes(conditions.immobilise) || condition.includes(conditions.panique))) etatde = '12';
+ //
+ let displayConditions = '';
+ if (condition !== '') {
+ for (cond of Object.keys(conditions)) {
+ if (condition.includes(conditions[cond])) {
+ displayConditions += (displayConditions === '' ? '' : ', ') + conditions_data[conditions[cond]].title;
+ }
+ }
+ }
+ if (displayConditions === '') displayConditions = ' ';
+ setAttrs({
+ ATKCAC_BUFF: buffs.atc,
+ ATKTIR_BUFF: buffs.atd,
+ DEF_BUFF: buffs.def,
+ INIT_BUFF: buffs.init,
+ ETATDE: etatde,
+ CONDITION: condition,
+ PCONDITION: condition,
+ conditions: displayConditions
+ });
+ });
+ });
+
diff --git a/ChroniquesOublieesContemporain/cond_aveugle.png b/ChroniquesOublieesContemporain/cond_aveugle.png
new file mode 100644
index 0000000000..5095be9864
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_aveugle.png differ
diff --git a/ChroniquesOublieesContemporain/cond_effraye.png b/ChroniquesOublieesContemporain/cond_effraye.png
new file mode 100644
index 0000000000..fbfce3fdf9
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_effraye.png differ
diff --git a/ChroniquesOublieesContemporain/cond_etourdi.png b/ChroniquesOublieesContemporain/cond_etourdi.png
new file mode 100644
index 0000000000..75c2f19f7a
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_etourdi.png differ
diff --git a/ChroniquesOublieesContemporain/cond_immobilise.png b/ChroniquesOublieesContemporain/cond_immobilise.png
new file mode 100644
index 0000000000..1a3a390a0b
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_immobilise.png differ
diff --git a/ChroniquesOublieesContemporain/cond_panique.png b/ChroniquesOublieesContemporain/cond_panique.png
new file mode 100644
index 0000000000..e73bfc19d5
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_panique.png differ
diff --git a/ChroniquesOublieesContemporain/cond_ralenti.png b/ChroniquesOublieesContemporain/cond_ralenti.png
new file mode 100644
index 0000000000..df5d327027
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_ralenti.png differ
diff --git a/ChroniquesOublieesContemporain/cond_renverse.png b/ChroniquesOublieesContemporain/cond_renverse.png
new file mode 100644
index 0000000000..21296fa459
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_renverse.png differ
diff --git a/ChroniquesOublieesContemporain/cond_surpris.png b/ChroniquesOublieesContemporain/cond_surpris.png
new file mode 100644
index 0000000000..d6eb9d4304
Binary files /dev/null and b/ChroniquesOublieesContemporain/cond_surpris.png differ
|