Catégories des compétences de créatures

Les créatures peuvent avoir des compétences d'armes (lancer,
mêlée, tir, armes naturelles), de parade, de possession, et générales.

Les initiatives sont cohérentes. Les possessions sont en phase 10
d'initiative.
This commit is contained in:
Vincent Vandemeulebrouck 2023-06-13 01:55:38 +02:00
parent 9e050d3e12
commit e46f35ef92
19 changed files with 232 additions and 129 deletions

View File

@ -271,10 +271,11 @@ export class RdDActor extends RdDBaseActor {
} }
getDraconicOuPossession() { getDraconicOuPossession() {
const possessions = this.items.filter(it => it.type == 'competencecreature' && it.system.ispossession) const possession = this.items.filter(it => it.type == TYPES.competencecreature && it.system.categorie == 'possession')
.sort(Misc.descending(it => it.system.niveau)); .sort(Misc.descending(it => it.system.niveau))
if (possessions.length > 0) { .find(it=>true);
return duplicate(possessions[0]); if (possession) {
return duplicate(possession);
} }
const draconics = [...this.getDraconicList().filter(it => it.system.niveau >= 0), const draconics = [...this.getDraconicList().filter(it => it.system.niveau >= 0),
POSSESSION_SANS_DRACONIC] POSSESSION_SANS_DRACONIC]
@ -960,9 +961,9 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async updateCompetence(idOrName, compValue) { async updateCompetence(idOrName, compValue) {
let competence = this.getCompetence(idOrName); const competence = this.getCompetence(idOrName);
if (competence) { if (competence) {
let toNiveau = compValue ?? RdDItemCompetence.getNiveauBase(competence.system.categorie); const toNiveau = compValue ?? RdDItemCompetence.getNiveauBase(competence.system.categorie, competence.getCategories());
this.notifyCompetencesTronc(competence, toNiveau); this.notifyCompetencesTronc(competence, toNiveau);
const fromNiveau = competence.system.niveau; const fromNiveau = competence.system.niveau;
await this.updateEmbeddedDocuments('Item', [{ _id: competence.id, 'system.niveau': toNiveau }]); await this.updateEmbeddedDocuments('Item', [{ _id: competence.id, 'system.niveau': toNiveau }]);
@ -2307,7 +2308,7 @@ export class RdDActor extends RdDBaseActor {
RdDPossession.onAttaquePossession(target, this, rollData.competence) RdDPossession.onAttaquePossession(target, this, rollData.competence)
} }
else { else {
const arme = RdDItemCompetenceCreature.armeNaturelle(rollData.competence) const arme = RdDItemCompetenceCreature.armeCreature(rollData.competence)
RdDCombat.rddCombatTarget(target, this).attaque(competence, arme) RdDCombat.rddCombatTarget(target, this).attaque(competence, arme)
} }
}); });
@ -3054,7 +3055,7 @@ export class RdDActor extends RdDBaseActor {
const competence = this.getCompetence(arme.system.competence) const competence = this.getCompetence(arme.system.competence)
if (competence.system.ispossession) { if (competence.isCompetencePossession()) {
return RdDPossession.onAttaquePossession(target, this, competence); return RdDPossession.onAttaquePossession(target, this, competence);
} }
RdDCombat.rddCombatTarget(target, this).attaque(competence, arme); RdDCombat.rddCombatTarget(target, this).attaque(competence, arme);

View File

@ -3,7 +3,8 @@ import { Misc } from "../misc.js";
import { DialogSplitItem } from "../dialog-split-item.js"; import { DialogSplitItem } from "../dialog-split-item.js";
import { RdDSheetUtility } from "../rdd-sheet-utility.js"; import { RdDSheetUtility } from "../rdd-sheet-utility.js";
import { Monnaie } from "../item-monnaie.js"; import { Monnaie } from "../item-monnaie.js";
import { RdDItem } from "../item.js"; import { RdDItem, TYPES } from "../item.js";
import { RdDItemCompetenceCreature } from "../item-competencecreature.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /**
@ -53,6 +54,8 @@ export class RdDBaseActorSheet extends ActorSheet {
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.inventaires); this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.inventaires);
this._appliquerRechercheObjets(formData.conteneurs, formData.inventaires); this._appliquerRechercheObjets(formData.conteneurs, formData.inventaires);
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs); formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
formData.competences.filter(it => it.type == TYPES.competencecreature)
.forEach(it => it.isdommages = RdDItemCompetenceCreature.isDommages(it))
return formData; return formData;
} }
@ -125,27 +128,27 @@ export class RdDBaseActorSheet extends ActorSheet {
.map(t => Misc.arrayOrEmpty(itemTypes[t])) .map(t => Misc.arrayOrEmpty(itemTypes[t]))
.reduce((a, b) => a.concat(b), []) .reduce((a, b) => a.concat(b), [])
.sort(Misc.ascending(it => it.name)); .sort(Misc.ascending(it => it.name));
} }
/* -------------------------------------------- */ /** @override */ /* -------------------------------------------- */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html; this.html = html;
this.html.find('.conteneur-name a').click(async event => { this.html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(this.getItemId(event)); RdDUtility.toggleAfficheContenu(this.getItemId(event));
this.render(true); this.render(true);
}); });
this.html.find('.item-edit').click(async event => this.getItem(event)?.sheet.render(true)) this.html.find('.item-edit').click(async event => this.getItem(event)?.sheet.render(true))
this.html.find('.item-montrer').click(async event => this.getItem(event)?.postItemToChat()); this.html.find('.item-montrer').click(async event => this.getItem(event)?.postItemToChat());
this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat()); this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat());
this.html.find('.recherche') this.html.find('.recherche')
.each((index, field) => { .each((index, field) => {
this._rechercheSelectArea(field); this._rechercheSelectArea(field);
}) })
.keyup(async event => this._rechercherKeyup(event)) .keyup(async event => this._rechercherKeyup(event))
.change(async event => this._rechercherKeyup(event)); .change(async event => this._rechercherKeyup(event));
this.html.find('.recherche').prop( "disabled", false ); this.html.find('.recherche').prop("disabled", false);
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;

View File

@ -1,4 +1,5 @@
import { RdDItemCompetenceCreature } from "./item-competencecreature.js" import { RdDItemCompetenceCreature } from "./item-competencecreature.js"
import { TYPES } from "./item.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
const nomCategorieParade = { const nomCategorieParade = {
@ -19,7 +20,7 @@ const nomCategorieParade = {
export class RdDItemArme extends Item { export class RdDItemArme extends Item {
static isArme(item) { static isArme(item) {
return (item.type == 'competencecreature' && item.system.iscombat) || item.type == 'arme'; return RdDItemCompetenceCreature.getCategorieAttaque(item) || item.type == 'arme';
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -27,7 +28,7 @@ export class RdDItemArme extends Item {
switch (arme ? arme.type : '') { switch (arme ? arme.type : '') {
case 'arme': return arme; case 'arme': return arme;
case 'competencecreature': case 'competencecreature':
return RdDItemCompetenceCreature.armeNaturelle(arme); return RdDItemCompetenceCreature.armeCreature(arme);
} }
return RdDItemArme.mainsNues(); return RdDItemArme.mainsNues();
} }

View File

@ -23,7 +23,7 @@ const limitesArchetypes = [
]; ];
/* -------------------------------------------- */ /* -------------------------------------------- */
const categorieCompetences = { const categoriesCompetences = {
"generale": { base: -4, label: "Générales" }, "generale": { base: -4, label: "Générales" },
"particuliere": { base: -8, label: "Particulières" }, "particuliere": { base: -8, label: "Particulières" },
"specialisee": { base: -11, label: "Spécialisées" }, "specialisee": { base: -11, label: "Spécialisées" },
@ -49,16 +49,16 @@ const competence_xp_cumul = _buildCumulXP();
export class RdDItemCompetence extends Item { export class RdDItemCompetence extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
static getCategorieCompetences() { static getCategories() {
return categorieCompetences; return categoriesCompetences;
}
/* -------------------------------------------- */
static getNiveauBase(category) {
return categorieCompetences[category].base;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getLabelCategorie(category) { static getLabelCategorie(category) {
return categorieCompetences[category].label; return categoriesCompetences[category].label;
}
/* -------------------------------------------- */
static getNiveauBase(category, categories = categoriesCompetences) {
return categories[category]?.base ?? 0;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -192,7 +192,7 @@ export class RdDItemCompetence extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isNiveauBase(item) { static isNiveauBase(item) {
return Number(item.system.niveau) == RdDItemCompetence.getNiveauBase(item.system.categorie); return Number(item.system.niveau) == RdDItemCompetence.getNiveauBase(item.system.categorie, item.getCategories());
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -1,51 +1,97 @@
import { RdDItem, TYPES } from "./item.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
const categories = {
"generale": { base: 0, label: "Générale" },
"naturelle": { base: 0, label: "Arme naturelle" },
"melee": { base: 0, label: "Mêlée" },
"parade": { base: 0, label: "Parade" },
"tir": { base: 0, label: "Tir" },
"lancer": { base: 0, label: "Lancer" },
"possession": { base: 0, label: "Possession" },
}
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDItemCompetenceCreature extends Item { export class RdDItemCompetenceCreature extends Item {
/* -------------------------------------------- */ static getCategories() {
static setRollDataCreature(rollData) { return categories;
rollData.competence = rollData.competence
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.system.carac_value } }
rollData.competence.system.defaut_carac = "carac_creature"
rollData.competence.system.categorie = "creature"
rollData.selectedCarac = rollData.carac.carac_creature
if (rollData.competence.system.iscombat) {
rollData.arme = RdDItemCompetenceCreature.armeNaturelle(rollData.competence);
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static armeNaturelle(competencecreature) { static setRollDataCreature(rollData) {
if (RdDItemCompetenceCreature.isCompetenceAttaque(competencecreature)) { rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.system.carac_value } }
// si c'est un Item compétence: cloner pour ne pas modifier lma compétence rollData.competence.system.defaut_carac = "carac_creature"
let arme = (competencecreature instanceof Item) ? competencecreature.clone(): competencecreature; rollData.selectedCarac = rollData.carac.carac_creature
mergeObject(arme.system, rollData.arme = RdDItemCompetenceCreature.armeCreature(rollData.competence);
}
/* -------------------------------------------- */
static armeCreature(item) {
const categorieAttaque = RdDItemCompetenceCreature.getCategorieAttaque(item)
if (categorieAttaque != undefined) {
// si c'est un Item compétence: cloner pour ne pas modifier la compétence
let arme = item.clone();
mergeObject(arme,
{ {
competence: arme.name, action: item.isCompetencePossession() ? 'possession' : 'attaque',
initiative: RdDCombatManager.calculInitiative(competencecreature.system.niveau, competencecreature.system.carac_value), system: {
niveau: competencecreature.system.niveau, competence: arme.name,
equipe: true, cac: categorieAttaque == "naturelle" ? "naturelle" : "",
resistance: 100, niveau: item.system.niveau,
dommagesReels: arme.system.dommages, initiative: RdDCombatManager.calculInitiative(item.system.niveau, item.system.carac_value),
penetration: 0, equipe: true,
force: 0, resistance: 100,
rapide: true, dommagesReels: arme.system.dommages,
cac: competencecreature.system.isnaturelle ? "naturelle" : "", penetration: 0,
action: 'attaque' force: 0,
rapide: true,
}
}); });
return arme; return arme;
} }
console.error("RdDItemCompetenceCreature.toActionArme(", competencecreature, ") : impossible de transformer l'Item en arme");
return undefined; return undefined;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isCompetenceAttaque(item) { static getCategorieAttaque(item) {
return item.type == 'competencecreature' && item.system.iscombat; if (item.type == TYPES.competencecreature) {
switch (item.system.categorie) {
case "melee":
case "tir":
case "lancer":
case "naturelle":
case "possession":
return item.system.categorie
}
}
return undefined
} }
static isDommages(item) {
if (item.type == TYPES.competencecreature) {
switch (item.system.categorie) {
case "melee":
case "tir":
case "lancer":
case "naturelle":
return true
}
}
return false
}
static isParade(item) {
if (item.type == TYPES.competencecreature) {
switch (item.system.categorie) {
case "melee":
case "naturelle":
case "parade":
return true
}
}
return false
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static isCompetenceParade(item) { static isCompetenceParade(item) {
return item.type == 'competencecreature' && item.system.categorie_parade !== ""; return item.type == 'competencecreature' && item.system.categorie_parade !== "";

View File

@ -11,6 +11,8 @@ import { RdDSheetUtility } from "./rdd-sheet-utility.js";
import { SystemCompendiums } from "./settings/system-compendiums.js"; import { SystemCompendiums } from "./settings/system-compendiums.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDTimestamp } from "./time/rdd-timestamp.js"; import { RdDTimestamp } from "./time/rdd-timestamp.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
import { TYPES } from "./item.js";
/** /**
* Extend the basic ItemSheet for RdD specific items * Extend the basic ItemSheet for RdD specific items
@ -98,9 +100,13 @@ export class RdDItemSheet extends ItemSheet {
isComestible: this.item.getUtilisationCuisine(), isComestible: this.item.getUtilisationCuisine(),
options: RdDSheetUtility.mergeDocumentRights(this.options, this.item, this.isEditable) options: RdDSheetUtility.mergeDocumentRights(this.options, this.item, this.isEditable)
} }
if (this.item.type == TYPES.competencecreature) {
formData.isparade = RdDItemCompetenceCreature.isParade(this.item)
formData.isdommages = RdDItemCompetenceCreature.isDommages(this.item)
}
const competences = await SystemCompendiums.getCompetences('personnage'); const competences = await SystemCompendiums.getCompetences('personnage');
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences() formData.categories = this.item.getCategories()
if (this.item.type == 'tache' || this.item.type == 'livre' || this.item.type == 'meditation' || this.item.type == 'oeuvre') { if (this.item.type == 'tache' || this.item.type == 'livre' || this.item.type == 'meditation' || this.item.type == 'oeuvre') {
formData.caracList = duplicate(game.system.model.Actor.personnage.carac) formData.caracList = duplicate(game.system.model.Actor.personnage.carac)
formData.caracList["reve-actuel"] = duplicate(game.system.model.Actor.personnage.reve.reve) formData.caracList["reve-actuel"] = duplicate(game.system.model.Actor.personnage.reve.reve)
@ -249,7 +255,8 @@ export class RdDItemSheet extends ItemSheet {
event.preventDefault(); event.preventDefault();
if (this.item.isCompetence()) { if (this.item.isCompetence()) {
let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value); const categorie = event.currentTarget.value;
const level = RdDItemCompetence.getNiveauBase(categorie, this.item.getCategories());
this.item.system.base = level; this.item.system.base = level;
this.html.find('[name="system.base"]').val(level); this.html.find('[name="system.base"]').val(level);
} }

View File

@ -6,6 +6,8 @@ import { RdDTimestamp } from "./time/rdd-timestamp.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
import { SystemCompendiums } from "./settings/system-compendiums.js"; import { SystemCompendiums } from "./settings/system-compendiums.js";
import { RdDRaretes } from "./item/raretes.js"; import { RdDRaretes } from "./item/raretes.js";
import { RdDItemCompetence } from "./item-competence.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
export const TYPES = { export const TYPES = {
competence: 'competence', competence: 'competence',
@ -218,6 +220,7 @@ export class RdDItem extends Item {
isService() { return this.type == TYPES.service; } isService() { return this.type == TYPES.service; }
isCompetence() { return typesObjetsCompetence.includes(this.type) } isCompetence() { return typesObjetsCompetence.includes(this.type) }
isCompetencePossession() { return TYPES.competencecreature == this.type && this.system.categorie == "possession" }
isTemporel() { return typesObjetsTemporels.includes(this.type) } isTemporel() { return typesObjetsTemporels.includes(this.type) }
isOeuvre() { return typesObjetsOeuvres.includes(this.type) } isOeuvre() { return typesObjetsOeuvres.includes(this.type) }
isDraconique() { return RdDItem.getItemTypesDraconiques().includes(this.type) } isDraconique() { return RdDItem.getItemTypesDraconiques().includes(this.type) }
@ -234,6 +237,13 @@ export class RdDItem extends Item {
isPresentDansMilieux(milieux) { isPresentDansMilieux(milieux) {
return this.getEnvironnements(milieux).length > 0 return this.getEnvironnements(milieux).length > 0
} }
getCategories() {
switch (this.type) {
case TYPES.competence: return RdDItemCompetence.getCategories()
case TYPES.competencecreature: return RdDItemCompetenceCreature.getCategories()
}
return {}
}
getEnvironnements(milieux = undefined) { getEnvironnements(milieux = undefined) {
const environnements = this.isInventaire() ? this.system.environnement : undefined; const environnements = this.isInventaire() ? this.system.environnement : undefined;

View File

@ -2,7 +2,7 @@ import { RdDBaseActor } from "./actor/base-actor.js";
import { LOG_HEAD, SYSTEM_RDD } from "./constants.js"; import { LOG_HEAD, SYSTEM_RDD } from "./constants.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { Monnaie } from "./item-monnaie.js"; import { Monnaie } from "./item-monnaie.js";
import { RdDItem } from "./item.js"; import { RdDItem, TYPES } from "./item.js";
import { RdDTimestamp } from "./time/rdd-timestamp.js"; import { RdDTimestamp } from "./time/rdd-timestamp.js";
import { RdDRaretes } from "./item/raretes.js"; import { RdDRaretes } from "./item/raretes.js";
@ -13,7 +13,7 @@ class Migration {
async applyItemsUpdates(computeUpdates) { async applyItemsUpdates(computeUpdates) {
await game.actors.forEach(async (actor) => { await game.actors.forEach(async (actor) => {
const actorItemUpdates = computeUpdates(actor.items); const actorItemUpdates = computeUpdates(actor.items).filter(it => it != undefined);
if (actorItemUpdates.length > 0) { if (actorItemUpdates.length > 0) {
console.log( console.log(
this.code, this.code,
@ -24,7 +24,7 @@ class Migration {
} }
}); });
const itemUpdates = computeUpdates(game.items); const itemUpdates = computeUpdates(game.items).filter(it => it != undefined);
if (itemUpdates.length > 0) { if (itemUpdates.length > 0) {
console.log(this.code, "Applying updates on items", itemUpdates); console.log(this.code, "Applying updates on items", itemUpdates);
await Item.updateDocuments(itemUpdates); await Item.updateDocuments(itemUpdates);
@ -65,7 +65,6 @@ class _1_5_34_migrationPngWebp {
} }
} }
class _10_0_16_MigrationSortsReserve extends Migration { class _10_0_16_MigrationSortsReserve extends Migration {
get code() { return "creation-item-sort-reserve"; } get code() { return "creation-item-sort-reserve"; }
get version() { return "10.0.16"; } get version() { return "10.0.16"; }
@ -370,6 +369,7 @@ class _10_4_6_ServicesEnCommerces extends Migration {
return itemToCreate; return itemToCreate;
} }
} }
class _10_5_0_UpdatePeriodicite extends Migration { class _10_5_0_UpdatePeriodicite extends Migration {
get code() { return "migration-periodicite-poisons-maladies"; } get code() { return "migration-periodicite-poisons-maladies"; }
get version() { return "10.5.0"; } get version() { return "10.5.0"; }
@ -458,6 +458,43 @@ class _10_7_0_MigrationBlessures extends Migration {
} }
} }
class _10_7_19_CategorieCompetenceCreature extends Migration {
get code() { return "categorie-competence-creature"; }
get version() { return "10.7.19"; }
async migrate() {
await this.applyItemsUpdates(items => items
.filter(it => TYPES.competencecreature == it.type)
.map(it => this.migrateCompetenceCreature(it))
);
}
migrateCompetenceCreature(it) {
const categorie = this.getCategorie(it)
if (categorie == it.system.categorie) {
return undefined
}
return { _id: it.id, 'system.categorie': categorie }
}
getCategorie(it) {
if (it.system.ispossession) {
return 'possession'
}
switch (it.system.categorie) {
case "melee":
if (it.system.isnaturelle) {
return 'naturelle'
}
return 'melee'
case "particuliere": case "specialisee": case "connaissance":
return "generale"
default:
return it.system.categorie
}
}
}
export class Migrations { export class Migrations {
static getMigrations() { static getMigrations() {
return [ return [
@ -474,6 +511,7 @@ export class Migrations {
new _10_4_6_ServicesEnCommerces(), new _10_4_6_ServicesEnCommerces(),
new _10_5_0_UpdatePeriodicite(), new _10_5_0_UpdatePeriodicite(),
new _10_7_0_MigrationBlessures(), new _10_7_0_MigrationBlessures(),
new _10_7_19_CategorieCompetenceCreature(),
]; ];
} }
@ -490,7 +528,7 @@ export class Migrations {
migrate() { migrate() {
const currentVersion = game.settings.get(SYSTEM_RDD, "systemMigrationVersion"); const currentVersion = game.settings.get(SYSTEM_RDD, "systemMigrationVersion");
if (isNewerVersion(game.system.version, currentVersion)) { if (isNewerVersion(game.system.version, currentVersion)) {
//if (true) { /* comment previous and uncomment here to test before upgrade */ // if (true) { /* comment previous and uncomment here to test before upgrade */
const migrations = Migrations.getMigrations().filter(m => isNewerVersion(m.version, currentVersion)); const migrations = Migrations.getMigrations().filter(m => isNewerVersion(m.version, currentVersion));
if (migrations.length > 0) { if (migrations.length > 0) {
migrations.sort((a, b) => this.compareVersions(a, b)); migrations.sort((a, b) => this.compareVersions(a, b));

View File

@ -87,7 +87,7 @@ export class RdDCombatManager extends Combat {
let rollFormula = formula ?? RdDCombatManager.formuleInitiative(2, 10, 0, 0); let rollFormula = formula ?? RdDCombatManager.formuleInitiative(2, 10, 0, 0);
if (!formula) { if (!formula) {
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') { if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
const competence = combatant.actor.items.find(it => it.system.iscombat) const competence = combatant.actor.items.find(it => RdDItemCompetenceCreature.getCategorieAttaque(it))
if (competence) { if (competence) {
rollFormula = RdDCombatManager.formuleInitiative(2, competence.system.carac_value, competence.system.niveau, 0); rollFormula = RdDCombatManager.formuleInitiative(2, competence.system.carac_value, competence.system.niveau, 0);
} }
@ -230,15 +230,15 @@ export class RdDCombatManager extends Combat {
} }
static listActionsCreature(competences) { static listActionsCreature(competences) {
return competences.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it)) return competences.map(it => RdDItemCompetenceCreature.armeCreature(it))
.map(it => RdDItemCompetenceCreature.armeNaturelle(it)); .filter(it => it != undefined);
} }
static listActionsPossessions(actor) { static listActionsPossessions(actor) {
return RdDCombatManager._indexActions(actor.getPossessions().map(p => { return RdDCombatManager._indexActions(actor.getPossessions().map(p => {
return { return {
name: p.name, name: p.name,
action: 'conjurer', action: 'possession',
system: { system: {
competence: p.name, competence: p.name,
possessionid: p.system.possessionid, possessionid: p.system.possessionid,
@ -255,7 +255,7 @@ export class RdDCombatManager extends Combat {
return actions; return actions;
} }
if (actor.isCreatureEntite()) { if (actor.isCreatureEntite()) {
actions = actions.concat(RdDCombatManager.listActionsCreature(actor.itemTypes['competencecreature'])); actions = RdDCombatManager.listActionsCreature(actor.itemTypes['competencecreature']);
} else if (actor.isPersonnage()) { } else if (actor.isPersonnage()) {
// Recupération des items 'arme' // Recupération des items 'arme'
const armes = actor.itemTypes['arme'].filter(it => RdDItemArme.isArmeUtilisable(it)) const armes = actor.itemTypes['arme'].filter(it => RdDItemArme.isArmeUtilisable(it))
@ -263,7 +263,7 @@ export class RdDCombatManager extends Combat {
.concat(RdDItemArme.mainsNues()); .concat(RdDItemArme.mainsNues());
const competences = actor.itemTypes['competence']; const competences = actor.itemTypes['competence'];
actions = actions.concat(RdDCombatManager.listActionsArmes(armes, competences, actor.system.carac)); actions = RdDCombatManager.listActionsArmes(armes, competences, actor.system.carac);
if (actor.system.attributs.hautrevant.value) { if (actor.system.attributs.hautrevant.value) {
actions.push({ name: "Draconic", action: 'haut-reve', system: { initOnly: true, competence: "Draconic" } }); actions.push({ name: "Draconic", action: 'haut-reve', system: { initOnly: true, competence: "Draconic" } });
@ -351,7 +351,7 @@ export class RdDCombatManager extends Combat {
} else if (combatant.actor.getSurprise() == "demi") { } else if (combatant.actor.getSurprise() == "demi") {
initOffset = 0; initOffset = 0;
initInfo = "Demi Surprise" initInfo = "Demi Surprise"
} else if (action.action == 'conjurer') { } else if (action.action == 'possession') {
initOffset = 10; initOffset = 10;
caracForInit = combatant.actor.getReveActuel(); caracForInit = combatant.actor.getReveActuel();
initInfo = "Possession" initInfo = "Possession"
@ -790,7 +790,7 @@ export class RdDCombat {
passeArme: randomID(16), passeArme: randomID(16),
mortalite: arme?.system.mortalite, mortalite: arme?.system.mortalite,
coupsNonMortels: false, coupsNonMortels: false,
competence: competence, competence: competence.clone(),
surprise: this.attacker.getSurprise(true), surprise: this.attacker.getSurprise(true),
surpriseDefenseur: this.defender.getSurprise(true), surpriseDefenseur: this.defender.getSurprise(true),
targetToken: Targets.extractTokenData(this.target), targetToken: Targets.extractTokenData(this.target),
@ -1045,7 +1045,7 @@ export class RdDCombat {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre, diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll, attackerRoll: attackerRoll,
competence: this.defender.getCompetence(competenceParade), competence: this.defender.getCompetence(competenceParade).clone(),
arme: armeParade, arme: armeParade,
surprise: this.defender.getSurprise(true), surprise: this.defender.getSurprise(true),
needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(attackerRoll.arme, armeParade), needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(attackerRoll.arme, armeParade),
@ -1126,7 +1126,7 @@ export class RdDCombat {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre, diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll, attackerRoll: attackerRoll,
competence: competence, competence: competence.clone(),
surprise: this.defender.getSurprise(true), surprise: this.defender.getSurprise(true),
surpriseDefenseur: this.defender.getSurprise(true), surpriseDefenseur: this.defender.getSurprise(true),
carac: this.defender.system.carac, carac: this.defender.system.carac,

View File

@ -70,7 +70,7 @@ export class RdDEmpoignade {
let rollData = { let rollData = {
mode: mode, mode: mode,
isEmpoignade: true, isEmpoignade: true,
competence: attacker.getCompetence("Corps à corps"), competence: attacker.getCompetence("Corps à corps").clone(),
selectedCarac: attacker.system.carac.melee, selectedCarac: attacker.system.carac.melee,
empoignade: empoignade, empoignade: empoignade,
attackerId: attacker.id, attackerId: attacker.id,

View File

@ -39,7 +39,7 @@ export class RdDPossession {
let rollData = { let rollData = {
mode: "possession", mode: "possession",
isECNIDefender: false, isECNIDefender: false,
competence: competence, competence: competence.clone(),
possession: possession, possession: possession,
attacker: attacker, attacker: attacker,
defender: defender, defender: defender,
@ -127,7 +127,7 @@ export class RdDPossession {
const dialog = await RdDRoll.create(defender, rollData, const dialog = await RdDRoll.create(defender, rollData,
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-defense-possession.html' }, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-defense-possession.html' },
{ {
name: 'conjurer', name: 'possession',
label: 'Conjurer une Possession', label: 'Conjurer une Possession',
callbacks: [ callbacks: [
{ action: async (r) => await RdDPossession.$onRollConjuration(r) } { action: async (r) => await RdDPossession.$onRollConjuration(r) }

View File

@ -75,7 +75,7 @@ export class RdDTokenHud {
(event) => { (event) => {
const actionIndex = event.currentTarget.attributes['data-action-index']?.value; const actionIndex = event.currentTarget.attributes['data-action-index']?.value;
const action = hudData.actions[actionIndex]; const action = hudData.actions[actionIndex];
if (action.action == 'conjurer') { if (action.action == 'possession') {
const possession = combatant.actor.getPossession(action.system.possessionid); const possession = combatant.actor.getPossession(action.system.possessionid);
combatant.actor.conjurerPossession(possession); combatant.actor.conjurerPossession(possession);
} }

View File

@ -182,7 +182,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/enum-caracteristiques.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-caracteristiques.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-base-competence.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-base-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-categories.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.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-categorie-parade.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-potion.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-potion.html',

View File

@ -586,11 +586,11 @@
}, },
"competencecreature": { "competencecreature": {
"templates": ["description"], "templates": ["description"],
"categorie_parade": "", "carac_value": 0,
"niveau": 0, "niveau": 0,
"default_diffLibre": 0, "default_diffLibre": 0,
"categorie": "", "categorie": "",
"carac_value": 0, "categorie_parade": "",
"iscombat": false, "iscombat": false,
"isnaturelle": true, "isnaturelle": true,
"ispossession": false, "ispossession": false,

View File

@ -9,18 +9,24 @@
<input class="competence-carac creature-carac" type="text" compname="{{comp.name}}" name="{{comp._id}}.carac" <input class="competence-carac creature-carac" type="text" compname="{{comp.name}}" name="{{comp._id}}.carac"
value="{{comp.system.carac_value}}" data-dtype="number" value="{{comp.system.carac_value}}" data-dtype="number"
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/> {{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
<input class="competence-value creature-niveau" type="text" compname="{{comp.name}}" name="{{comp._id}}.niveau" <input class="competence-value creature-niveau" type="text" data-dtype="number"
value="{{numberFormat comp.system.niveau decimals=0 sign=true}}" data-dtype="number" compname="{{comp.name}}" name="{{comp._id}}.niveau"
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/> value="{{numberFormat comp.system.niveau decimals=0 sign=true}}"
<input class="competence-damage creature-dommages" type="text" compname="{{comp.name}}" name="{{comp._id}}.dommages" {{#unless @root.options.vueDetaillee}}disabled{{/unless}}
value="{{numberFormat comp.system.dommages decimals=0 sign=true}}" data-dtype="number" />
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/> <input class="competence-damage creature-dommages" type="text" data-dtype="number"
{{#if @root.options.vueDetaillee}} {{#if comp.isdommages}}
<div class="item-controls"> compname="{{comp.name}}" name="{{comp._id}}.dommages"
<a class="item-edit" title="Edit Item"><i class="fas fa-edit"></i></a> value="{{numberFormat comp.system.dommages decimals=0 sign=true}}"
<a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a> {{#unless @root.options.vueDetaillee}}disabled{{/unless}}
</div> {{else}}disabled{{/if}}
{{/if}} />
{{#if @root.options.vueDetaillee}}
<div class="item-controls">
<a class="item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
{{/if}}
</li> </li>
{{/each}} {{/each}}
</ol> </ol>

View File

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

View File

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

View File

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

View File

@ -6,50 +6,38 @@
<label for="system.categorie">Catégorie</label> <label for="system.categorie">Catégorie</label>
<select name="system.categorie" class="categorie" data-dtype="String"> <select name="system.categorie" class="categorie" data-dtype="String">
{{#select system.categorie}} {{#select system.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categories.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="niveau">Valeur de Caractéristique </label> <label for="niveau">Valeur de Caractéristique</label>
<input class="attribute-value" type="text" name="system.carac_value" value="{{system.carac_value}}" data-dtype="Number"/> <input class="attribute-value" type="text" name="system.carac_value" value="{{system.carac_value}}" data-dtype="Number"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="niveau">Niveau </label> <label for="niveau">Niveau</label>
<input class="attribute-value" type="text" name="system.niveau" value="{{system.niveau}}" data-dtype="Number"/> <input class="attribute-value" type="text" name="system.niveau" value="{{system.niveau}}" data-dtype="Number"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="default_diffLibre">Difficulté libre par défaut</label> <label for="default_diffLibre">Difficulté libre par défaut</label>
<input class="attribute-value" type="text" name="system.default_diffLibre" value="{{system.default_diffLibre}}" data-dtype="Number"/> <input class="attribute-value" type="text" name="system.default_diffLibre" value="{{system.default_diffLibre}}" data-dtype="Number"/>
</div> </div>
<div class="form-group"> {{#if isdommages}}
<label for="system.ispossession">Attaque de possession</label>
<input class="attribute-value" type="checkbox" name="system.ispossession" {{#if system.ispossession}}checked{{/if}}/>
</div>
{{#unless system.ispossession}}
<div class="form-group">
<label for="system.iscombat">Compétence d'attaque</label>
<input class="attribute-value" type="checkbox" name="system.iscombat" {{#if system.iscombat}}checked{{/if}}/>
</div>
{{#if system.iscombat}}
<div class="form-group">
<label for="system.isnaturelle">Arme naturelle</label>
<input class="attribute-value" type="checkbox" name="system.isnaturelle" {{#if system.isnaturelle}}checked{{/if}}/>
</div>
<div class="form-group"> <div class="form-group">
<label for="niveau">Dommages (+dom)</label> <label for="niveau">Dommages (+dom)</label>
<input class="attribute-value" type="text" name="system.dommages" value="{{system.dommages}}" data-dtype="Number"/> <input class="attribute-value" type="text" name="system.dommages" value="{{system.dommages}}" data-dtype="Number"/>
</div> </div>
{{/if}} {{/if}}
{{#if isparade}}
<div class="form-group"> <div class="form-group">
<label>Catégorie parade </label> <label>Catégorie parade</label>
<select name="system.categorie_parade" id="categorie_parade" data-dtype="String"> <select name="system.categorie_parade" id="categorie_parade" data-dtype="String">
{{#select system.categorie_parade}} {{#select system.categorie_parade}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>
{{/unless}} {{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section> </section>