Jet V2 pour les créatures
This commit is contained in:
		| @@ -186,12 +186,12 @@ export class RdDActor extends RdDBaseActorSang { | ||||
|     const uniques = [] | ||||
|  | ||||
|     const addAttaque = (arme, main = undefined, action = 'attaque') => { | ||||
|       const dommagesArme = RdDItemArme.valeurMain(arme.system.dommages, main) | ||||
|       const dommages = RdDItemArme.valeurMain(arme.system.dommages, main) | ||||
|       const forceRequise = RdDItemArme.valeurMain(arme.system.force ?? 0, main) | ||||
|       const ecaillesEfficacite = arme.system.magique ? arme.system.ecaille_efficacite : 0; | ||||
|  | ||||
|       const comp = this.getCompetence(RdDActor.$getCompetenceAction(arme, main)) | ||||
|       const unique = [comp.id, arme.name, dommagesArme, forceRequise, ecaillesEfficacite].join('|'); | ||||
|       const unique = [comp.id, arme.name, dommages, forceRequise, ecaillesEfficacite].join('|'); | ||||
|       if (uniques.includes(unique)) { | ||||
|         return | ||||
|       } | ||||
| @@ -212,7 +212,7 @@ export class RdDActor extends RdDBaseActorSang { | ||||
|         main: main, | ||||
|         carac: { key: caracCode, value: caracValue }, | ||||
|         equipe: arme.system.equipe, | ||||
|         dommagesArme: dommagesArme, | ||||
|         dommages: dommages, | ||||
|         forceRequise: forceRequise, | ||||
|         initiative: RdDInitiative.getRollInitiative(caracValue, niveau, ajustement) | ||||
|       }) | ||||
|   | ||||
| @@ -176,10 +176,11 @@ export class RdDBaseActorReve extends RdDBaseActor { | ||||
|   } | ||||
|  | ||||
|   getCompetences(name = undefined, options = { onMessage: message => { } }) { | ||||
|     const all = [...this.itemTypes[ITEM_TYPES.competence], ...this.itemTypes[ITEM_TYPES.competencecreature]] | ||||
|     if (name == undefined) { | ||||
|       return this.itemTypes[ITEM_TYPES.competence] | ||||
|       return all | ||||
|     } | ||||
|     return RdDItemCompetence.findCompetences(this.itemTypes[ITEM_TYPES.competence], name, options) | ||||
|     return RdDItemCompetence.findCompetences(all, name, options) | ||||
|   } | ||||
|  | ||||
|   getCompetenceCorpsACorps(options = { onMessage: message => { } }) { | ||||
| @@ -246,10 +247,10 @@ export class RdDBaseActorReve extends RdDBaseActor { | ||||
|     if (this.isEffectAllowed(statusId)) { | ||||
|       const effect = this.getEffectByStatus(statusId); | ||||
|       if (!status && effect) { | ||||
|         await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id], { render: true}) | ||||
|         await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id], { render: true }) | ||||
|       } | ||||
|       if (status && !effect) { | ||||
|         await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.prepareActiveEffect(statusId)], { render: true}) | ||||
|         await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.prepareActiveEffect(statusId)], { render: true }) | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| @@ -309,6 +310,22 @@ export class RdDBaseActorReve extends RdDBaseActor { | ||||
|  | ||||
|   async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) { | ||||
|     RdDEmpoignade.checkEmpoignadeEnCours(this) | ||||
|  | ||||
|     if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) { | ||||
|       const competence = this.getCompetence(compName); | ||||
|       const rollData = { | ||||
|         ids: { actorId: this.id }, | ||||
|         type: { allowed: DEFAULT_ROLL_TYPES, current: PART_COMP }, | ||||
|         selected: { | ||||
|           carac: { key: caracName }, | ||||
|           comp: { key: competence.name }, | ||||
|           diff: { value: diff } | ||||
|         } | ||||
|       } | ||||
|       RollDialog.create(rollData, options) | ||||
|       return | ||||
|     } | ||||
|  | ||||
|     const competence = this.getCompetence(compName); | ||||
|     await this.openRollDialog({ | ||||
|       name: 'jet-competence', | ||||
| @@ -423,32 +440,22 @@ export class RdDBaseActorReve extends RdDBaseActor { | ||||
|     await RdDRollResult.displayRollData(rollData, this, 'chat-resultat-general.hbs'); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async rollCompetenceV2(rollData) { | ||||
|     rollData.ids = rollData?.ids ?? {} | ||||
|     rollData.type = rollData.type ?? { allowed: DEFAULT_ROLL_TYPES } | ||||
|     rollData.ids.actorId = this.id | ||||
|     await RollDialog.create(rollData) | ||||
|   } | ||||
|  | ||||
|   async rollCompetence(idOrName, options = { tryTarget: true, arme: undefined }) { | ||||
|     RdDEmpoignade.checkEmpoignadeEnCours(this) | ||||
|  | ||||
|     const competence = this.getCompetence(idOrName); | ||||
|     if (competence.type != ITEM_TYPES.competencecreature && OptionsAvancees.isUsing(ROLL_DIALOG_V2)) { | ||||
|     if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) { | ||||
|       const rollData = { | ||||
|         ids: { actorId: this.id }, | ||||
|         type: { allowed: options.arme ? ATTAQUE_ROLL_TYPES : DEFAULT_ROLL_TYPES }, | ||||
|         selected: { | ||||
|           carac: competence.type == ITEM_TYPES.competencecreature ? { key: competence.name } : undefined, | ||||
|           comp: { key: competence.name }, | ||||
|           diff: { type: DIFF.LIBRE, value: competence.system.default_diffLibre ?? 0 } | ||||
|           diff: { type: options.arme ? DIFF.ATTAQUE : DIFF.LIBRE, value: competence.system.default_diffLibre ?? 0 }, | ||||
|           attaque: options.arme ? { arme: { key: options.arme.id } } : undefined | ||||
|         } | ||||
|       } | ||||
|       if (options.arme) { | ||||
|         rollData.selected.attaque = { arme: { id: options.arme.id }, comp: { id: competence.id } } | ||||
|         rollData.type = { allowed: ATTAQUE_ROLL_TYPES } | ||||
|       } | ||||
|  | ||||
|       await this.rollCompetenceV2(rollData) | ||||
|       return | ||||
|       return await RollDialog.create(rollData) | ||||
|     } | ||||
|  | ||||
|     let rollData = { | ||||
| @@ -512,19 +519,13 @@ export class RdDBaseActorReve extends RdDBaseActor { | ||||
|         title: 'Ne pas utiliser les automatisation de combat', | ||||
|         buttonLabel: "Pas d'automatisation", | ||||
|         onAction: async () => { | ||||
|           this.rollCompetenceV2({ | ||||
|             ids: { | ||||
|               actorId: this.id, | ||||
|               actorTokenId: token?.id, | ||||
|             }, | ||||
|             selected: { | ||||
|               conditions: { value: 0 } | ||||
|             }, | ||||
|           const rollData = { | ||||
|             ids: { actorId: this.id, actorTokenId: token?.id, }, | ||||
|             type: { | ||||
|               allowed: [ROLL_TYPE_COMP, ROLL_TYPE_ATTAQUE, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE, ROLL_TYPE_JEU], | ||||
|               current: ROLL_TYPE_COMP | ||||
|               allowed: [ROLL_TYPE_ATTAQUE], current: ROLL_TYPE_ATTAQUE | ||||
|             } | ||||
|           }) | ||||
|           }; | ||||
|           return await RollDialog.create(rollData) | ||||
|         } | ||||
|       }) | ||||
|     } | ||||
|   | ||||
| @@ -56,8 +56,7 @@ export class RdDBaseActorSheet extends foundry.appv1.sheets.ActorSheet { | ||||
|     this._appliquerRechercheObjets(formData.conteneurs, formData.inventaires); | ||||
|     formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs); | ||||
|     formData.competences.filter(it => it.type == ITEM_TYPES.competencecreature) | ||||
|       .forEach(it => it.isdommages = it.isDommages() | ||||
|       ) | ||||
|       .forEach(it => it.isdommages = it.isDommages()) | ||||
|  | ||||
|     return formData; | ||||
|   } | ||||
|   | ||||
| @@ -160,7 +160,7 @@ export class Mapping { | ||||
|       return undefined | ||||
|     } | ||||
|     const categorie = Mapping.complementCategorie(arme, maniement) | ||||
|     const dommages = Mapping.dommagesArme(actor, arme, maniement) | ||||
|     const dommages = Mapping.dommages(actor, arme, maniement) | ||||
|     return { | ||||
|       name: arme.name + categorie, | ||||
|       niveau: Misc.toSignedString(competence.system.niveau), | ||||
| @@ -170,7 +170,8 @@ export class Mapping { | ||||
|       arme: arme | ||||
|     } | ||||
|   } | ||||
|   static dommagesArme(actor, arme, maniement) { | ||||
|  | ||||
|   static dommages(actor, arme, maniement) { | ||||
|     const dmgArme = RdDItemArme.dommagesReels(arme, maniement) | ||||
|     const dommages = Misc.toSignedString(dmgArme + RdDBonus.bonusDmg(actor, maniement, dmgArme)) | ||||
|     switch (arme.system.mortalite) { | ||||
|   | ||||
| @@ -32,6 +32,7 @@ export class RdDItemCompetenceCreature extends RdDItem { | ||||
|             initiative: initative, | ||||
|             mortalite: this.system.mortalite, | ||||
|             dommages: this.system.dommages, | ||||
|             forceRequise: 0, | ||||
|             equipe: true, | ||||
|             resistance: 100, | ||||
|             penetration: 0, | ||||
| @@ -43,7 +44,8 @@ export class RdDItemCompetenceCreature extends RdDItem { | ||||
|         carac: { key: this.name, value: this.system.carac_value }, | ||||
|         equipe: true, | ||||
|         mortalite: this.system.mortalite, | ||||
|         dmg: this.system.dommages, | ||||
|         dommages: this.system.dommages, | ||||
|         //dmg: this.system.dommages, | ||||
|         initiative: initative | ||||
|       }; | ||||
|       return attaque | ||||
|   | ||||
| @@ -727,8 +727,6 @@ export class RdDCombat { | ||||
|     RollBasicParts.loadSurprises(attackerRoll) | ||||
|     attackerRoll.passeArme = attackerRoll.passeArme ?? foundry.utils.randomID(16) | ||||
|     attackerRoll.dmg = RdDBonus.dmgRollV2(attackerRoll, attackerRoll.current.attaque) | ||||
|     // attackerRoll.current.attaque.dmg = attackerRoll.dmg | ||||
|     // attaque.dmg = attackerRoll.current.attaque.dmg | ||||
|     const attaque = RollDialog.saveParts(attackerRoll) | ||||
|     const defense = { | ||||
|       attackerRoll: attaque, | ||||
|   | ||||
| @@ -12,7 +12,7 @@ export const ROLL_TYPE_TACHE = 'tache' | ||||
| export const ATTAQUE_ROLL_TYPES = [ROLL_TYPE_ATTAQUE] | ||||
| export const COMBAT_ROLL_TYPES = [ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE] | ||||
| export const DEMIREVE_ROLL_TYPES = [ROLL_TYPE_SORT] | ||||
| export const DEFAULT_ROLL_TYPES = [ROLL_TYPE_COMP, ROLL_TYPE_TACHE, ROLL_TYPE_MEDITATION, ROLL_TYPE_CUISINE, ROLL_TYPE_OEUVRE, ROLL_TYPE_JEU] | ||||
| export const DEFAULT_ROLL_TYPES = [ROLL_TYPE_COMP, ROLL_TYPE_ATTAQUE, ROLL_TYPE_TACHE, ROLL_TYPE_MEDITATION, ROLL_TYPE_CUISINE, ROLL_TYPE_OEUVRE, ROLL_TYPE_JEU] | ||||
|  | ||||
|  | ||||
| export const DIFF = { | ||||
|   | ||||
| @@ -36,7 +36,7 @@ export class RollPartAttaque extends RollPartSelect { | ||||
|   restore(rollData) { | ||||
|     const saved = this.getSaved(rollData) | ||||
|     super.restore(rollData) | ||||
|     if (saved.dmg) { | ||||
|     if (saved.dmg != undefined) { | ||||
|       this.getCurrent(rollData).dmg = this.getSaved(rollData).dmg | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -12,22 +12,30 @@ export class RollPartCarac extends RollPartSelect { | ||||
|  | ||||
|   loadRefs(rollData) { | ||||
|     const refs = this.getRefs(rollData) | ||||
|     refs.all = this.$getActorCaracs(rollData) | ||||
|     const actor = rollData.active.actor | ||||
|     refs.all = [...this.$getActorCaracs(actor), ...this.$getCaracCompetenceCreature(actor)] | ||||
|     refs.caracs = refs.all | ||||
|     this.$selectCarac(rollData) | ||||
|   } | ||||
|  | ||||
|   choices(refs) { return refs.caracs } | ||||
|  | ||||
|   $getActorCaracs(rollData) { | ||||
|     return Object.entries(rollData.active.actor.getCarac()) | ||||
|   $getActorCaracs(actor) { | ||||
|     return Object.entries(actor.getCarac()) | ||||
|       .filter(([key, c]) => key != 'taille') | ||||
|       /* TODO: filter by context */ | ||||
|       .map(([key, carac]) => { | ||||
|         return RollPartCarac.$extractCarac(key, carac) | ||||
|       }) | ||||
|   } | ||||
|  | ||||
|   $getCaracCompetenceCreature(actor) { | ||||
|     if (actor.isPersonnage()) { | ||||
|       return [] | ||||
|     } | ||||
|     return actor.getCompetences() | ||||
|       .map(it => { return { key: it.name, label: it.name, value: parseInt(it.system.carac_value) } }) | ||||
|   } | ||||
|  | ||||
|   static $extractCarac(key, carac) { | ||||
|     return { | ||||
|       key: key, | ||||
| @@ -40,7 +48,6 @@ export class RollPartCarac extends RollPartSelect { | ||||
|     allowed = allowed.filter(it => it != undefined) | ||||
|     const refs = this.getRefs(rollData) | ||||
|     refs.caracs = allowed.length > 0 | ||||
|       // ? refs.all.filter(it => allowed.includes(Grammar.toLowerCaseNoAccent(it.key))) | ||||
|       ? refs.all.filter(it => allowed.includes(it.key)) | ||||
|       : refs.all | ||||
|     this.$selectCarac(rollData) | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| import { ITEM_TYPES } from "../constants.js" | ||||
| import { Grammar } from "../grammar.js" | ||||
| import { CARACS, RdDCarac } from "../rdd-carac.js" | ||||
| import { CARACS } from "../rdd-carac.js" | ||||
| import { RdDTimestamp } from "../time/rdd-timestamp.js" | ||||
| import { TMRUtility } from "../tmr-utility.js" | ||||
| import { ROLL_TYPE_MEDITATION } from "./roll-constants.mjs" | ||||
| import { PART_CARAC } from "./roll-part-carac.mjs" | ||||
| import { PART_CARAC, RollPartCarac } from "./roll-part-carac.mjs" | ||||
| import { PART_COMP } from "./roll-part-comp.mjs" | ||||
| import { RollPartSelect } from "./roll-part-select.mjs" | ||||
| import { ROLLDIALOG_SECTION } from "./roll-part.mjs" | ||||
| @@ -34,8 +34,9 @@ export class RollPartMeditation extends RollPartSelect { | ||||
|  | ||||
|   loadRefs(rollData) { | ||||
|     const refs = this.getRefs(rollData) | ||||
|     refs.meditations = rollData.active.actor.itemTypes[ITEM_TYPES.meditation] | ||||
|       .map(it => RollPartMeditation.$extractMeditation(it, rollData.active.actor)) | ||||
|     const actor = rollData.active.actor | ||||
|     refs.meditations = actor.itemTypes[ITEM_TYPES.meditation] | ||||
|       .map(it => RollPartMeditation.$extractMeditation(it, actor)) | ||||
|  | ||||
|     if (refs.meditations.length > 0) { | ||||
|       this.$selectMeditation(rollData) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user