Merge branch 'ajout-morsure' into 'v1.2'

Ajout arme morsure au chafouin

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!108
This commit is contained in:
Leratier Bretonnien 2021-01-09 08:52:01 +00:00
commit f9b799db2f
25 changed files with 543 additions and 595 deletions

View File

@ -7,6 +7,7 @@ import { RdDUtility } from "./rdd-utility.js";
import { HtmlUtility } from "./html-utility.js";
import { RdDItem } from "./item.js";
import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */
export class RdDActorSheet extends ActorSheet {
@ -22,7 +23,7 @@ export class RdDActorSheet extends ActorSheet {
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
editCaracComp: false,
montrerCompetencesNiveauBase: false,
showCompNiveauBase: false,
montrerArchetype: false
});
}
@ -33,44 +34,32 @@ export class RdDActorSheet extends ActorSheet {
if ( data.actor.type == 'creature' || data.actor.type == 'humanoide') return data; // Shortcut
data.data.editCaracComp = this.options.editCaracComp;
data.data.montrerCompetencesNiveauBase = this.options.montrerCompetencesNiveauBase;
data.data.showCompNiveauBase = this.options.showCompNiveauBase;
data.data.montrerArchetype = this.options.montrerArchetype;
let compCategorieNiveau = RdDUtility.getLevelCategory(); // recup catégorie
data.itemsByType = RdDItem.buildItemsClassification(data.items);
// Competence per category
data.competenceByCategory = {};
let competenceXPTotal = 0;
if (data.itemsByType.competence) {
for (const item of data.itemsByType.competence) {
data.competenceByCategory = RdDItem.classify(
data.itemsByType.competence,
item => item.data.categorie,
item => {
this.actor.checkCompetenceXP(item.name); // Petite vérification experience
//console.log("Push...", item, item.data.categorie);
let list = data.competenceByCategory[item.data.categorie];
if (!list) {
list = [];
data.competenceByCategory[item.data.categorie] = list;
}
if (!RdDUtility.isTronc( item.name ) ) // Ignorer les compétences 'troncs' à ce stade
competenceXPTotal += RdDUtility.computeCompetenceXPCost(item);
item.data.afficherCompetence = true;
if ( data.data.montrerCompetencesNiveauBase && (Number(item.data.niveau) == Number(compCategorieNiveau[item.data.categorie]) ) ) {
item.data.afficherCompetence = false;
}
list.push(item);
}
}
this.competenceByCategory = duplicate(data.competenceByCategory); // Sauvegarde locale
competenceXPTotal += RdDUtility.computeCompetenceTroncXP(data.itemsByType.competence);
item.data.showCompetence = !data.data.showCompNiveauBase || (Number(item.data.niveau) != Number(RdDUtility.getLevelCategory(item.data.categorie)));
// Ignorer les compétences 'troncs' à ce stade
competenceXPTotal += RdDItemCompetence.isTronc(item.name) ? 0 : RdDItemCompetence.computeCompetenceXPCost(item);
return item;
});
competenceXPTotal += RdDItemCompetence.computeCompetenceTroncXP(data.itemsByType.competence);
data.data.competenceXPTotal = competenceXPTotal;
//console.log("XP competence : ", competenceXPTotal);
// Compute current carac sum
let sum = 0;
for (let caracName in data.data.carac) {
let carac = data.data.carac[caracName];
if (!carac.derivee) {
sum += parseInt(carac.value);
let currentCarac = data.data.carac[caracName];
if (!currentCarac.derivee) {
sum += parseInt(currentCarac.value);
}
}
data.data.caracSum = sum;
@ -138,7 +127,6 @@ export class RdDActorSheet extends ActorSheet {
return data;
}
/* -------------------------------------------- */
async _onDrop(event) {
await RdDUtility.processItemDropEvent(this, event);
@ -431,7 +419,7 @@ export class RdDActorSheet extends ActorSheet {
this.render(true);
});
html.find('#show-hide-competences').click((event) => {
this.options.montrerCompetencesNiveauBase = !this.options.montrerCompetencesNiveauBase;
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
this.render(true);
});
html.find('#show-hide-archetype').click((event) => {

View File

@ -46,13 +46,13 @@ export class RdDActor extends Actor {
}
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
if (data.items) {
let actor = super.create(data, options);
if (data.type == "personnage") {
await RdDActor.checkMonnaiePresence( data.items );
await actor.checkMonnaiePresence( data.items );
}
return super.create(data, options);
return actor;
}
data.items = [];
let compendiumName = "";
if (data.type == "personnage") {
compendiumName = "foundryvtt-reve-de-dragon.competences";
@ -61,16 +61,7 @@ export class RdDActor extends Actor {
} else if (data.type == "entite") {
compendiumName = "foundryvtt-reve-de-dragon.competences-entites";
}
let competences = [];
const pack = game.packs.get(compendiumName);
await pack.getIndex().then(index => competences = index);
for (let comp of competences)
{
let compItem = undefined;
await pack.getEntity(comp._id).then(skill => compItem = skill);
data.items.push(compItem);
}
data.items = RdDUtility.loadCompendium(compendiumName);
// Ajout monnaie
if (data.type == "personnage" ) {
await RdDActor.ajouterMonnaie( data.items );
@ -207,12 +198,12 @@ export class RdDActor extends Actor {
return this.data.data.compteurs?.surenc?.value ?? 0;
}
/* -------------------------------------------- */
getCompetenceList() {
loadCompendiumNames() {
return this.data.items.filter( (item) => item.type == 'competence');
}
/* -------------------------------------------- */
getCompetence(compName) {
return RdDUtility.findCompetence(this.data.items, compName);
return RdDItemCompetence.findCompetence(this.data.items, compName);
}
/* -------------------------------------------- */
getTache( id ) {
@ -1413,9 +1404,9 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async checkCompetenceXP( compName ) {
let competence = RdDUtility.findCompetence( this.data.items, compName);
let competence = RdDItemCompetence.findCompetence( this.data.items, compName);
if ( competence && competence.data.xp > 0) {
let xpNeeded = RdDUtility.getCompetenceNextXp( competence.data.niveau );
let xpNeeded = RdDItemCompetence.getCompetenceNextXp( competence.data.niveau );
if ( competence.data.xp >= xpNeeded ) {
competence.data.xp -= xpNeeded;
competence.data.niveau += 1;
@ -1937,7 +1928,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async ajouteNombreAstral( data ) {
// Gestion expérience (si existante)
data.competence = RdDUtility.findCompetence( this.data.items, "astrologie");
data.competence = RdDItemCompetence.findCompetence( this.data.items, "astrologie");
data.selectedCarac = this.data.data.carac["vue"];
this._appliquerAjoutExperience( data );

View File

@ -1,17 +1,37 @@
const competenceTroncs = [["Esquive", "Dague", "Corps à corps"],
["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"]];
const competence_xp_par_niveau = [5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 30, 30, 40, 40, 60, 60, 100, 100, 100, 100, 100, 100, 100, 100, 100];
export class RdDItemCompetence extends Item {
/* -------------------------------------------- */
static isCompetenceMelee(name) {
return name.toLowerCase().match(/(epée|épée|hache|fleau|fléau|masse|lance|hast|dague|bouclier)/);
static isCompetenceArme(competence) {
switch (competence.data.categorie) {
case 'melee':
return competence.name.toLowerCase() != 'esquive';
case 'tir':
case 'lancer':
return true;
}
return false;
}
/* -------------------------------------------- */
static isArmeUneMain(competence) {
return competence && competence.name.toLowerCase().includes("1 main");
return competence?.name.toLowerCase().includes("1 main");
}
static isArme2Main(competence) {
return competence?.name.toLowerCase().includes("2 main");
}
/* -------------------------------------------- */
static isMalusEncombrementTotal(competence) {
return competence && competence.name.toLowerCase().match(/(natation|acrobatie)/);
return competence?.name.toLowerCase().match(/(natation|acrobatie)/);
}
/* -------------------------------------------- */
static setRollDataCreature(rollData) {
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
rollData.competence = duplicate(rollData.competence);
@ -19,4 +39,65 @@ export class RdDItemCompetence extends Item {
rollData.competence.data.categorie = "creature";
rollData.selectedCarac = rollData.carac.carac_creature
}
/* -------------------------------------------- */
static isTronc(compName) {
for (let troncList of competenceTroncs) {
for (let troncName of troncList) {
if (troncName == compName)
return troncList;
}
}
return false;
}
/* -------------------------------------------- */
static computeCompetenceXPCost(competence) {
let minLevel = competence.data.base;
if (minLevel == competence.data.niveau) return 0;
if (competence.data.niveau < -10) return 0;
let xp = 0;
for (let i = minLevel + 1; i <= competence.data.niveau; i++) {
xp += competence_xp_par_niveau[i + 10];
//console.log(i, i+10, competence_xp_par_niveau[i+10]);
}
if (competence.data.categorie == 'draconic') {
xp += competence.data.xp_sort;
}
return xp;
}
/* -------------------------------------------- */
static computeCompetenceTroncXP(competences) {
let xp = 0;
for (let troncList of competenceTroncs) {
let minNiveau = 0;
for (let troncName of troncList) {
let comp = RdDItemCompetence.findCompetence(competences, troncName);
if (comp) {
minNiveau = Math.min(comp.data.niveau, minNiveau);
}
}
minNiveau = Math.max(minNiveau, 0); // Clamp à 0, pour le tronc commun
let minNiveauXP = competence_xp_par_niveau[minNiveau + 10];
xp += minNiveauXP;
for (let troncName of troncList) {
let comp = RdDItemCompetence.findCompetence(competences, troncName);
if (comp) {
xp += competence_xp_par_niveau[comp.data.niveau + 10] - minNiveauXP;
}
}
}
return xp;
}
/* -------------------------------------------- */
static findCompetence(list, name) {
name = name.toLowerCase();
return list.find(item => item.name.toLowerCase() == name && (item.type == "competence" || item.type == "competencecreature"))
}
/* -------------------------------------------- */
static getCompetenceNextXp(niveau) {
return competence_xp_par_niveau[niveau + 10];
}
}

View File

@ -2,6 +2,7 @@ import { RdDItemSort } from "./item-sort.js";
import { RdDUtility } from "./rdd-utility.js";
import { RdDItem } from "./item-rdd.js";
import { RdDAlchimie } from "./rdd-alchimie.js";
import { RdDItemCompetence } from "./item-competence.js";
/**
* Extend the basic ItemSheet with some very simple modifications
@ -47,10 +48,13 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */
async getData() {
let data = super.getData();
data.categorieCompetences = RdDUtility.getCategorieCompetences();
if ( data.item.type == 'tache' || data.item.type == 'livre' || data.item.type == 'meditation') {
data.caracList = duplicate(game.system.model.Actor.personnage.carac);
data.competenceList = await RdDUtility.getCompetenceList( 'foundryvtt-reve-de-dragon.competences' );
data.competences = await RdDUtility.loadCompendiumNames( 'foundryvtt-reve-de-dragon.competences' );
}
if (data.item.type == 'arme') {
data.competences = await RdDUtility.loadCompendium( 'foundryvtt-reve-de-dragon.competences', it => RdDItemCompetence.isCompetenceArme(it));
}
if ( data.item.type == 'recettealchimique' ) {
RdDAlchimie.processManipulation(data.item, this.actor && this.actor._id );
@ -101,8 +105,7 @@ export class RdDItemSheet extends ItemSheet {
async _onClickSelectCategorie(event) {
event.preventDefault();
const category = event.currentTarget.value;
let level = CONFIG.RDD.level_category[category];
let level = RdDUtility.getLevelCategory(event.currentTarget.value);
this.object.data.data.base = level;
$("#base").val( level );
}

View File

@ -4,15 +4,25 @@ export class RdDItem {
/* -------------------------------------------- */
static buildItemsClassification(items) {
let itemsByType = {};
return RdDItem.classify(items, it => it.type)
}
static classify(items, classifier = it => it.type, transform = it => it) {
let itemsBy = {};
RdDItem.classifyInto(itemsBy, items, classifier, transform);
return itemsBy;
}
static classifyInto(itemsBy, items, classifier = it => it.type, transform = it => it) {
for (const item of items) {
let list = itemsByType[item.type];
const classification = classifier(item);
let list = itemsBy[classification];
if (!list) {
list = [];
itemsByType[item.type] = list;
itemsBy[classification] = list;
}
list.push(item);
}
return itemsByType;
list.push(transform(item));
}
}
}

View File

@ -1,3 +1,4 @@
import { RdDItemCompetence } from "./item-competence.js";
import { Misc } from "./misc.js";
import { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDUtility } from "./rdd-utility.js";
@ -15,7 +16,7 @@ export class RdDAstrologieJoueur extends Dialog {
dates: game.system.rdd.calendrier.getJoursSuivants( 10 ),
etat: actor.getEtatGeneral(),
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
astrologie: RdDUtility.findCompetence( actor.data.items, 'Astrologie')
astrologie: RdDItemCompetence.findCompetence( actor.data.items, 'Astrologie')
}
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data);
let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 };

View File

@ -22,6 +22,7 @@ import { RdDTokenHud } from "./rdd-token-hud.js";
import { RdDCommands } from "./rdd-commands.js";
import { RdDCombat } from "./rdd-combat.js";
import { ChatUtility } from "./chat-utility.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@ -65,7 +66,7 @@ const _patch_initiative = () => {
}
}
let compName = ( armeCombat == undefined ) ? "Corps à corps" : armeCombat.data.competence;
competence = RdDUtility.findCompetence( c.actor.data.items, compName );
competence = RdDItemCompetence.findCompetence( c.actor.data.items, compName );
rollFormula = RdDUtility.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value);
}
}
@ -190,7 +191,6 @@ Hooks.once("init", async function() {
CONFIG.Actor.entityClass = RdDActor;
CONFIG.RDD = {
resolutionTable : RdDResolutionTable.resolutionTable,
level_category : RdDUtility.getLevelCategory(),
carac_array : RdDUtility.getCaracArray(),
ajustementsConditions : RdDUtility.getAjustementsConditions(),
difficultesLibres : RdDUtility.getDifficultesLibres()

View File

@ -6,42 +6,22 @@ import { RdDCombat } from "./rdd-combat.js";
import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */
const level_category = {
"generale": "-4",
"particuliere": "-8",
"specialisee": "-11",
"connaissance": "-11",
"draconic": "-11",
"melee": "-6",
"tir": "-8",
"lancer": "-8"
}
/* -------------------------------------------- */
const label_category = {
"generale": "Générales",
"particuliere": "Particulières",
"specialisee": "Spécialisées",
"connaissance": "Connaissances",
"draconic": "Draconics",
"melee": "Mêlée",
"tir": "Tir",
"lancer": "Lancer"
}
/* -------------------------------------------- */
const competenceTroncs = [ ["Esquive", "Dague", "Corps à corps"],
["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"] ];
const competence_xp = {
"-11" : [ 5, 10, 15, 25, 35, 45, 55, 70, 85, 100, 115, 135, 155, 175 ],
"-8" : [ 10, 20, 30, 40, 55, 70, 85, 100, 120, 140,160],
"-6" : [ 10, 20, 35, 50, 65, 80, 100, 120, 140],
"-4" : [ 15, 30, 45, 60, 80, 100, 120]
const categorieCompetences = {
"generale": { level: "-4", label: "Générales" },
"particuliere": { level: "-8", label: "Particulières" },
"specialisee": { level: "-11", label: "Spécialisées" },
"connaissance": { level: "-11", label: "Connaissances" },
"draconic": { level: "-11", label: "Draconics" },
"melee": { level: "-6", label: "Mêlée" },
"tir": { level: "-8", label: "Tir" },
"lancer": { level: "-8", label: "Lancer" }
}
/* -------------------------------------------- */
// This table starts at 0 -> niveau -10
const competence_xp_par_niveau = [ 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 30, 30, 40, 40, 60, 60, 100, 100, 100, 100, 100, 100, 100, 100, 100];
const carac_array = ["taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"];
const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10];
const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10];
@ -68,8 +48,7 @@ function _buildAllSegmentsFatigue(max) {
/* -------------------------------------------- */
function _cumulSegmentsFatigue(matrix) {
let cumulMatrix = [];
for (let line of matrix)
{
for (let line of matrix) {
let cumul = duplicate(line);
for (let i = 1; i < 12; i++) {
@ -87,20 +66,24 @@ const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix);
const fatigueMalus = [0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7]; // Provides the malus for each segment of fatigue
const fatigueLineSize = [3, 6, 7, 8, 9, 10, 11, 12];
const fatigueLineMalus = [0, -1, -2, -3, -4, -5, -6, -7];
const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 },
const fatigueMarche = {
"aise": { "4": 1, "6": 2, "8": 3, "10": 4, "12": 6 },
"malaise": { "4": 2, "6": 3, "8": 4, "10": 6 },
"difficile": { "4": 3, "6": 4, "8": 6 },
"tresdifficile": { "4":4, "6":6 } }
"tresdifficile": { "4": 4, "6": 6 }
}
/* -------------------------------------------- */
/* Static tables for commands /table */
const table2func = { "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open },
const table2func = {
"rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open },
"queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue },
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre },
"tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR },
"tete": { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete },
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle },
"tarot" : { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot} };
"tarot": { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot }
};
/* -------------------------------------------- */
const definitionsBlessures = [
@ -168,14 +151,14 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/item-ombre-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-monnaie-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-meditation-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie_parade.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-rarete.html',
'systems/foundryvtt-reve-de-dragon/templates/arme-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/sort-draconic.html',
'systems/foundryvtt-reve-de-dragon/templates/sort-tmr.html',
'systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html',
@ -345,141 +328,46 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static buildResolutionTable( ) {
let tableRes = []
for (var j=0; j<=21; j++) {
let subtab = [];
for (var i=-10; i<=22; i++) {
var m = (i + 10) * 0.5;
var v;
if (i == -9) {
v = Math.floor(j / 2);
} else if (i == -10) {
v = Math.floor(j / 4);
} else {
if (j % 2 == 0) {
var v = Math.ceil(j * m);
} else {
var v = Math.floor(j * m);
static getCategorieCompetences() {
return categorieCompetences;
}
static getLevelCategory(category) {
return categorieCompetences[category].level;
}
if (v < 1) v = 1;
let specResults
if ( v > 100 )
specResults = { part: Math.ceil(v / 5), epart: 1000, etotal: 1000 };
else
specResults = specialResults[Math.ceil(v / 5 )];
let tabIndex = i+10;
subtab[tabIndex] = { niveau: i, score: v, part: specResults.part, epart: specResults.epart, etotal: specResults.etotal }
static getLabelCategory(category) {
return categorieCompetences[category].label;
}
tableRes[j] = subtab;
}
return tableRes;
}
/* -------------------------------------------- */
static getLevelCategory( )
{
return level_category;
}
static getLabelCategory( )
{
return label_category;
}
static getCaracArray()
{
static getCaracArray() {
return carac_array;
}
static getDifficultesLibres()
{
static getDifficultesLibres() {
return difficultesLibres;
}
static getAjustementsConditions()
{
static getAjustementsConditions() {
return ajustementsConditions;
}
static getAjustementsEncaissement()
{
static getAjustementsEncaissement() {
return ajustementsEncaissement;
}
static getDefinitionsBlessures() {
return definitionsBlessures;
}
/* -------------------------------------------- */
static isTronc( compName )
{
for (let troncList of competenceTroncs) {
for (let troncName of troncList) {
if ( troncName == compName)
return troncList;
}
}
return false;
}
/* -------------------------------------------- */
static getCaracNextXp(value) {
return carac_xp_par_valeur[value - XP_CARAC_OFFSET];
}
/* -------------------------------------------- */
static getCompetenceNextXp( niveau ) {
return competence_xp_par_niveau[niveau+10];
}
/* -------------------------------------------- */
static computeCompetenceXPCost( competence )
{
let minLevel = competence.data.base;
if ( minLevel == competence.data.niveau) return 0;
if ( competence.data.niveau < -10) return 0;
let xp = 0;
for (let i=minLevel+1; i<=competence.data.niveau; i++) {
xp += competence_xp_par_niveau[i+10];
//console.log(i, i+10, competence_xp_par_niveau[i+10]);
}
if (competence.data.categorie == 'draconic') {
xp+= competence.data.xp_sort;
}
return xp;
}
/* -------------------------------------------- */
static computeCompetenceTroncXP( competenceList )
{
let xp = 0;
for (let troncList of competenceTroncs) {
let minNiveau = 0;
for (let troncName of troncList) {
let comp = RdDUtility.findCompetence( competenceList, troncName);
if (comp) {
minNiveau = Math.min(comp.data.niveau, minNiveau);
}
}
minNiveau = Math.max(minNiveau, 0); // Clamp à 0, pour le tronc commun
let minNiveauXP = competence_xp_par_niveau[minNiveau+10];
xp += minNiveauXP;
for (let troncName of troncList) {
let comp = RdDUtility.findCompetence( competenceList, troncName);
if (comp){
xp += competence_xp_par_niveau[comp.data.niveau+10] - minNiveauXP;
}
}
}
return xp;
}
/* -------------------------------------------- */
/** Retourne une liste triée d'armes avec le split arme1 main / arme 2 main */
static _finalizeArmeList( armes, competenceList, carac ) {
static _finalizeArmeList(armes, competences, carac) {
// Gestion des armes 1/2 mains
let armesEquipe = [];
for (const arme of armes) {
if (arme.data.equipe) {
armesEquipe.push(arme);
let comp = competenceList.find(c => c.name == arme.data.competence);
let comp = competences.find(c => c.name == arme.data.competence);
arme.data.initiative = RdDUtility.calculInitiative(arme.data.niveau, carac[comp.data.defaut_carac].value);
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
if (arme.data.unemain && !arme.data.deuxmains) {
@ -492,7 +380,7 @@ export class RdDUtility {
arme2main.data.mainInfo = "(2m)";
arme2main.data.dommages = arme2main.data.dommages.split("/")[1]; // Existence temporaire uniquement dans la liste des armes, donc OK
arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace !
let comp = competenceList.find(c => c.name == arme2main.data.competence);
let comp = competences.find(c => c.name == arme2main.data.competence);
arme2main.data.niveau = comp.data.niveau;
arme2main.data.initiative = RdDUtility.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value);
armesEquipe.push(arme2main);
@ -515,8 +403,7 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static computeCarac( data)
{
static computeCarac(data) {
data.carac.force.value = Math.min(data.carac.force.value, parseInt(data.carac.taille.value) + 4);
data.carac.derobee.value = Math.floor(parseInt(((21 - data.carac.taille.value)) + parseInt(data.carac.agilite.value)) / 2);
@ -573,8 +460,7 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static calculMalusFatigue(fatigue, maxEnd)
{
static calculMalusFatigue(fatigue, maxEnd) {
maxEnd = Math.max(maxEnd, 1);
maxEnd = Math.min(maxEnd, cumulFatigueMatrix.length);
let segments = cumulFatigueMatrix[maxEnd];
@ -628,8 +514,7 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static getLocalisation( )
{
static getLocalisation() {
// TODO: bouger dans une RollTable du compendium et chercher dans les RoolTable puis compendium pour permettre le changement?
let result = new Roll("1d20").roll().total;
let txt = ""
@ -667,8 +552,7 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static currentFatigueMalus( value, max)
{
static currentFatigueMalus(value, max) {
max = Math.max(1, Math.min(max, 60));
value = Math.min(max * 2, Math.max(0, value));
@ -684,20 +568,29 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static findCompetence(compList, compName)
{
compName = compName.toLowerCase();
return compList.find(item => item.name.toLowerCase() == compName && (item.type =="competence" || item.type == "competencecreature"))
}
/* -------------------------------------------- */
static async getCompetenceList( compendium ) {
static async loadCompendiumNames(compendium) {
const pack = game.packs.get(compendium);
let competences;
await pack.getIndex().then(index => competences = index);
return competences;
}
static async loadCompendium(compendium, filter = item => true) {
let compendiumItems = await RdDUtility.loadCompendiumNames(compendium);
const pack = game.packs.get(compendium);
let list = [];
for (let compendiumItem of compendiumItems) {
await pack.getEntity(compendiumItem._id).then(it => {
const item = it.data;
if (filter(item)) {
list.push(item);
}
});
};
return list;
}
/* -------------------------------------------- */
static async responseNombreAstral(data) {
let actor = game.actors.get(data.id);
@ -705,8 +598,7 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static performSocketMesssage( sockmsg )
{
static performSocketMesssage(sockmsg) {
console.log(">>>>> MSG RECV", sockmsg);
switch (sockmsg.msg) {
case "msg_encaisser":
@ -755,7 +647,7 @@ export class RdDUtility {
} else {
let initOffset = 0;
let caracForInit = 0;
let competence = RdDUtility.findCompetence( combatant.actor.data.items, arme.data.competence);
let competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, arme.data.competence);
if (actor.data.type == 'creature' || actor.data.type == 'entite') {
caracForInit = competence.data.carac_value;
@ -814,7 +706,8 @@ export class RdDUtility {
menuItems.push({
name: arme.data.competence,
icon: "<i class='fas fa-dice-d6'></i>",
callback: target => { RdDUtility.rollInitiativeCompetence( combatantId, arme ) } } );
callback: target => { RdDUtility.rollInitiativeCompetence(combatantId, arme) }
});
}
new ContextMenu(html, ".directory-list", menuItems).render();
}
@ -846,8 +739,7 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static async chatListeners( html )
{
static async chatListeners(html) {
RdDCombat.registerChatCallbacks(html);
// Gestion spécifique message passeurs
@ -884,7 +776,8 @@ export class RdDUtility {
/* -------------------------------------------- */
static createMonnaie(name, valeur_deniers, img = "", enc = 0.01) {
let piece = { name: name, type: 'monnaie', img: img, _id: randomID(16),
let piece = {
name: name, type: 'monnaie', img: img, _id: randomID(16),
data: {
quantite: 0,
valeur_deniers: valeur_deniers,

File diff suppressed because one or more lines are too long

View File

@ -191,8 +191,8 @@
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer"
>{{#if data.editCaracComp}}Vérouiller{{else}}Dévérouiller{{/if}}</a></span>
<span><a id="show-hide-competences"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.montrerCompetencesNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout"
>{{#if data.montrerCompetencesNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span>
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout"
>{{#if data.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span>
<span><a id="show-hide-archetype"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.montrerArchetype}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer l'archétype"
>{{#if data.montrerArchetype}}Masquer l'archétype{{else}}Voir l'archétype{{/if}}</a></span>
@ -204,7 +204,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.generale as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -227,7 +227,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.particuliere as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -249,7 +249,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.specialisee as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -270,11 +270,11 @@
<div class="flex-group-left flexcol competence-column">
<header class="competence-header flexrow">
<span class="competence-title">Compétences De Mêlée</span>
<span class="competence-title">Compétences de Mêlée</span>
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.melee as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -293,11 +293,11 @@
</ul>
<header class="competence-header flexrow">
<span class="competence-title">Compétences De Tir</span>
<span class="competence-title">Compétences de Tir</span>
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.tir as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -316,11 +316,11 @@
</ul>
<header class="competence-header flexrow">
<span class="competence-title">Compétences De Lancer</span>
<span class="competence-title">Compétences de Lancer</span>
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.lancer as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -343,7 +343,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.connaissance as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -366,7 +366,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.draconic as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>

View File

@ -1,17 +0,0 @@
<option value="Dague">Dague</option>
<option value="Epée à 1 main">Epée à 1 main</option>
<option value="Epée à 2 mains">Epée à 2 mains</option>
<option value="Hache à 1 main">Hache à 1 main</option>
<option value="Hache à 2 mains">Hache à 2 mains</option>
<option value="Masse à 1 main">Masse à 1 main</option>
<option value="Masse à 2 mains">Masse à 2 mains</option>
<option value="Fléau">Fléau</option>
<option value="Lance">Lance</option>
<option value="Arme d'hast">Arme d'hast</option>
<option value="Bouclier">Bouclier</option>
<option value="Arbalète">Arbalète</option>
<option value="Arc">Arc</option>
<option value="Fronde">Fronde</option>
<option value="Dague de jet">Dague de jet</option>
<option value="Javelot">Javelot</option>
<option value="Fouet">Fouet</option>

View File

@ -1,8 +0,0 @@
<option value="generale">Générale</option>
<option value="particuliere">Particulières</option>
<option value="specialisee">Spécialisées</option>
<option value="connaissance">Connaissances</option>
<option value="tir">Tir</option>
<option value="lancer">Lancer</option>
<option value="melee">Mêlée</option>
<option value="draconic">Draconic</option>

View File

@ -0,0 +1,3 @@
{{#each @root.categorieCompetences as |categorie key|}}
<option value="{{@key}}">{{categorie.label}}</option>
{{/each}}

View File

@ -0,0 +1,3 @@
{{#each @root.competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option>
{{/each}}

View File

@ -12,7 +12,7 @@
<label for="categorie">Compétence associée</label>
<select name="data.competence" id="competence" data-dtype="String">
{{#select item.data.competence}}
{{>"systems/foundryvtt-reve-de-dragon/templates/arme-competence.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.html"}}
{{/select}}
</select>
</div>
@ -28,7 +28,7 @@
<label>Catégorie parade </label>
<select name="data.categorie_parade" id="categorie_parade" data-dtype="String">
{{#select data.categorie_parade}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie_parade.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html"}}
{{/select}}
</select>
</div>

View File

@ -18,7 +18,7 @@
<label for="categorie">Catégorie </label>
<select name="data.categorie" id="categorie" data-dtype="String">
{{#select item.data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.html"}}
{{/select}}
</select>
</div>

View File

@ -32,7 +32,7 @@
<label>Catégorie parade </label>
<select name="data.categorie_parade" id="categorie_parade" data-dtype="String">
{{#select data.categorie_parade}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie_parade.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html"}}
{{/select}}
</select>
</div>

View File

@ -37,7 +37,7 @@
<label>Catégorie</label>
<select name="data.categorie" id="categorie" data-dtype="String">
{{#select data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}}
{{/select}}
</select>
</div>

View File

@ -42,7 +42,7 @@
<label>Catégorie</label>
<select name="data.categorie" id="categorie" data-dtype="String">
{{#select data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}}
{{/select}}
</select>
</div>

View File

@ -16,7 +16,7 @@
<label for="xp">Compétence</label>
<select name="data.competence" id="competenceselect" data-dtype="String">
{{#select item.data.competence}}
{{#each competenceList as |competence key|}}
{{#each competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option>
{{/each}}
{{/select}}

View File

@ -12,7 +12,7 @@
<label for="xp">Compétence</label>
<select name="data.competence" id="competenceselect" data-dtype="String">
{{#select item.data.competence}}
{{#each competenceList as |competence key|}}
{{#each competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option>
{{/each}}
{{/select}}

View File

@ -32,7 +32,7 @@
<label>Catégorie</label>
<select name="data.categorie" id="categorie" data-dtype="String">
{{#select data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}}
{{/select}}
</select>
</div>

View File

@ -22,7 +22,7 @@
<label for="xp">Compétence</label>
<select name="data.competence" id="competenceselect" data-dtype="String">
{{#select item.data.competence}}
{{#each competenceList as |competence key|}}
{{#each competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option>
{{/each}}
{{/select}}