forked from public/foundryvtt-reve-de-dragon
Support de races
L'item "race" permet de paramétrer des ajustements de caracs, des min/max de taille, et une limite de force. Ajouter une race à un acteur enlève la/les races précédentes et ajoute les modificateurs de caracs de la nouvelle race. Enlever une race enlève les modificateurs de caracs de la race aux caractéristiques
This commit is contained in:
@ -17,7 +17,7 @@ import { RdDItemSigneDraconique } from "./item/signedraconique.js";
|
||||
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
|
||||
import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
|
||||
import { Draconique } from "./tmr/draconique.js";
|
||||
import { RdDCarac } from "./rdd-carac.js";
|
||||
import { LIST_CARAC, RdDCarac } from "./rdd-carac.js";
|
||||
import { DialogConsommer } from "./dialog-item-consommer.js";
|
||||
import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js";
|
||||
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||
@ -41,6 +41,7 @@ import { RdDCombatManager } from "./rdd-combat.js";
|
||||
import { RdDItemTete } from "./item/tete.js";
|
||||
import { DialogSelect } from "./dialog-select.js";
|
||||
import { PAS_DE_DRACONIC, POSSESSION_SANS_DRACONIC } from "./item/base-items.js";
|
||||
import { RdDItemRace } from "./item/race.js";
|
||||
|
||||
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
|
||||
|
||||
@ -58,7 +59,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
*/
|
||||
prepareActorData() {
|
||||
|
||||
this.system.carac.force.value = Math.min(this.system.carac.force.value, parseInt(this.system.carac.taille.value) + 4);
|
||||
RdDItemRace.applyRacialLimits(this)
|
||||
|
||||
this.system.carac.melee.value = Math.floor((this.getForce() + parseInt(this.system.carac.agilite.value)) / 2);
|
||||
this.system.carac.tir.value = Math.floor((parseInt(this.system.carac.vue.value) + parseInt(this.system.carac.dexterite.value)) / 2);
|
||||
@ -660,18 +661,16 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCarac(caracName, to) {
|
||||
if (caracName == "force") {
|
||||
if (Number(to) > this.getTaille() + 4) {
|
||||
ui.notifications.warn("Votre FORCE doit être au maximum de TAILLE+4");
|
||||
return;
|
||||
}
|
||||
to = Number(to)
|
||||
if (!RdDItemRace.checkRacialMax(this, caracName, to)){
|
||||
return
|
||||
}
|
||||
if (caracName == "reve") {
|
||||
if (caracName == LIST_CARAC.reve.code) {
|
||||
if (to > Misc.toInt(this.system.reve.seuil.value)) {
|
||||
this.setPointsDeSeuil(to);
|
||||
}
|
||||
}
|
||||
if (caracName == "chance") {
|
||||
if (caracName == LIST_CARAC.chance.code) {
|
||||
if (to > Misc.toInt(this.system.compteurs.chance.value)) {
|
||||
this.setPointsDeChance(to);
|
||||
}
|
||||
@ -1531,13 +1530,12 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isCaracMax(code) {
|
||||
if (code == 'force' && parseInt(this.system.carac.force.value) >= parseInt(this.system.carac.taille.value) + 4) {
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
return RdDItemRace.isRacialMax(this, code)
|
||||
}
|
||||
|
||||
async checkCaracXP(caracName, display = true) {
|
||||
let carac = this.findCaracByName(caracName);
|
||||
if (carac && carac.xp > 0) {
|
||||
@ -1664,10 +1662,12 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollUnSort(coord) {
|
||||
RdDEmpoignade.checkEmpoignadeEnCours(this)
|
||||
if (RdDEmpoignade.checkEmpoignadeEnCours(this)) {
|
||||
return
|
||||
}
|
||||
if (EffetsDraconiques.isSortImpossible(this)) {
|
||||
ui.notifications.error("Une queue ou un souffle vous empèche de lancer de sort!");
|
||||
return;
|
||||
ui.notifications.error("Une queue ou un souffle vous empèche de lancer de sort!")
|
||||
return
|
||||
}
|
||||
// Duplication car les pts de reve sont modifiés dans le sort
|
||||
let sorts = foundry.utils.duplicate(this.$filterSortList(this.itemTypes['sort'], coord));
|
||||
@ -3033,12 +3033,14 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
/* -------------------------------------------- */
|
||||
async onCreateItem(item, options, id) {
|
||||
switch (item.type) {
|
||||
case 'tete':
|
||||
case 'queue':
|
||||
case 'ombre':
|
||||
case 'souffle':
|
||||
await this.onCreateOwnedDraconique(item, options, id);
|
||||
break;
|
||||
case ITEM_TYPES.tete:
|
||||
case ITEM_TYPES.queue:
|
||||
case ITEM_TYPES.ombre:
|
||||
case ITEM_TYPES.souffle:
|
||||
await this.onCreateOwnedDraconique(item, options, id)
|
||||
break
|
||||
case ITEM_TYPES.race:
|
||||
await this.onCreateOwnedRace(item, options, id)
|
||||
}
|
||||
await item.onCreateItemTemporel(this);
|
||||
await item.onCreateDecoupeComestible(this);
|
||||
@ -3046,16 +3048,19 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
async onDeleteItem(item, options, id) {
|
||||
switch (item.type) {
|
||||
case 'tete':
|
||||
case 'queue':
|
||||
case 'ombre':
|
||||
case 'souffle':
|
||||
case ITEM_TYPES.tete:
|
||||
case ITEM_TYPES.queue:
|
||||
case ITEM_TYPES.ombre:
|
||||
case ITEM_TYPES.souffle:
|
||||
await this.onDeleteOwnedDraconique(item, options, id)
|
||||
break
|
||||
case 'casetmr':
|
||||
case ITEM_TYPES.race:
|
||||
await this.onDeleteOwnedRace(item, options, id)
|
||||
break
|
||||
case ITEM_TYPES.casetmr:
|
||||
await this.onDeleteOwnedCaseTmr(item, options, id)
|
||||
break
|
||||
case 'empoignade':
|
||||
case ITEM_TYPES.empoignade:
|
||||
await RdDEmpoignade.deleteLinkedEmpoignade(this.id, item)
|
||||
break
|
||||
}
|
||||
@ -3084,6 +3089,35 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
}
|
||||
|
||||
async onCreateOwnedRace(item, options, id) {
|
||||
if (Misc.isFirstConnectedGM()) {
|
||||
const raceIds = this.itemTypes[ITEM_TYPES.race].map(it => it.id).filter(id => id != item.id)
|
||||
if (raceIds.length > 0) {
|
||||
await this.deleteEmbeddedDocuments('Item', raceIds)
|
||||
}
|
||||
await this._applyRaceCaracUpdates(item, 1)
|
||||
}
|
||||
}
|
||||
|
||||
async onDeleteOwnedRace(item, options, id) {
|
||||
if (Misc.isFirstConnectedGM()) {
|
||||
await this._applyRaceCaracUpdates(item, -1)
|
||||
}
|
||||
}
|
||||
|
||||
async _applyRaceCaracUpdates(item, sign) {
|
||||
const updates = {};
|
||||
RdDCarac.caracs(it => true).forEach(c => {
|
||||
const toAdd = Number(foundry.utils.getProperty(item, c.path)) * sign
|
||||
if (toAdd != 0) {
|
||||
updates[c.path] = Number(foundry.utils.getProperty(this, c.path)) + toAdd
|
||||
}
|
||||
})
|
||||
if (Object.keys(updates).length > 0) {
|
||||
await this.update(updates)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async onDeleteOwnedCaseTmr(item, options, id) {
|
||||
if (Misc.isFirstConnectedGM()) {
|
||||
|
Reference in New Issue
Block a user