Compare commits
No commits in common. "b92003ac1f1935ddd626c0adc4aa48bc3bb45eba" and "d91bee0f4237575f93dc4d6804dabfb91a7157cd" have entirely different histories.
b92003ac1f
...
d91bee0f42
@ -1,10 +1,4 @@
|
||||
# 12.0
|
||||
## 12.0.19 - La témérité d'Astrobazzarh
|
||||
- Fix
|
||||
- les défenses des créatures sont correctement filtrées
|
||||
- le lancer d'initiative pour tous les personnages/PNJs fonctionne correctement
|
||||
- les lieux et commerces n'ont pas d'initiative
|
||||
|
||||
## 12.0.18 - A la barbe d'Astrobazzarh
|
||||
- Améliorations sur la feuille de PNJ simplifiée
|
||||
- Ajout du portrait
|
||||
|
@ -36,8 +36,6 @@ import { ITEM_TYPES } from "./item.js";
|
||||
import { RdDBaseActorSang } from "./actor/base-actor-sang.js";
|
||||
import { RdDCoeur } from "./coeur/rdd-coeur.js";
|
||||
import { DialogChoixXpCarac } from "./dialog-choix-xp-carac.js";
|
||||
import { RdDItemArme } from "./item-arme.js";
|
||||
import { RdDCombatManager } from "./rdd-combat.js";
|
||||
|
||||
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
|
||||
|
||||
@ -132,23 +130,6 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
.reduce(Misc.sum(), 0);
|
||||
}
|
||||
|
||||
listActionsCombat() {
|
||||
// Recupération des armes
|
||||
const actions = RdDCombatManager.listActionsArmes(
|
||||
this.itemTypes[ITEM_TYPES.arme]
|
||||
.filter(it => RdDItemArme.isAttaque(it))
|
||||
.concat(RdDItemArme.empoignade(this))
|
||||
.concat(RdDItemArme.mainsNues(this))
|
||||
,
|
||||
this.itemTypes[ITEM_TYPES.competence],
|
||||
this.system.carac)
|
||||
|
||||
if (this.system.attributs.hautrevant.value) {
|
||||
actions.push({ name: "Draconic", action: 'haut-reve', system: { initOnly: true, competence: "Draconic" } });
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getTache(id) { return this.findItemLike(id, 'tache') }
|
||||
getMeditation(id) { return this.findItemLike(id, 'meditation') }
|
||||
@ -1567,7 +1548,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async appliquerAjoutExperience(rollData, hideChatMessage = 'show') {
|
||||
if (!Misc.isFirstConnectedGM()) {
|
||||
if (!Misc.isFirstConnectedGM()){
|
||||
return
|
||||
}
|
||||
hideChatMessage = hideChatMessage == 'hide' || (Misc.isRollModeHiddenToPlayer() && !game.user.isGM)
|
||||
@ -3086,7 +3067,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
incarnation.name = 'Réincarnation de ' + incarnation.name
|
||||
incarnation.system = {
|
||||
carac: foundry.utils.duplicate(this.system.carac),
|
||||
heure: RdDTimestamp.defHeure(await RdDDice.rollHeure({ rollMode: "selfroll", showDice: SHOW_DICE })).key,
|
||||
heure: RdDTimestamp.defHeure(await RdDDice.rollHeure( { rollMode: "selfroll", showDice: SHOW_DICE })).key,
|
||||
age: 18,
|
||||
biographie: '',
|
||||
notes: '',
|
||||
|
@ -15,7 +15,7 @@ import { StatusEffects } from "../settings/status-effects.js";
|
||||
import { ITEM_TYPES } from "../item.js";
|
||||
import { Targets } from "../targets.js";
|
||||
import { RdDPossession } from "../rdd-possession.js";
|
||||
import { RdDCombat, RdDCombatManager } from "../rdd-combat.js";
|
||||
import { RdDCombat } from "../rdd-combat.js";
|
||||
import { RdDConfirm } from "../rdd-confirm.js";
|
||||
import { ENTITE_INCARNE, SHOW_DICE, SYSTEM_RDD } from "../constants.js";
|
||||
import { RdDItemArme } from "../item-arme.js";
|
||||
@ -83,23 +83,6 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
getEtatGeneral(options = { ethylisme: false }) { return 0 }
|
||||
isActorCombat() { return true }
|
||||
|
||||
getCaracInit(competence) {
|
||||
if (!competence){
|
||||
return 0
|
||||
}
|
||||
if (competence.type == ITEM_TYPES.competencecreature) {
|
||||
return competence.system.carac_value
|
||||
}
|
||||
return this.system.carac[competence.system.defaut_carac].value;
|
||||
}
|
||||
listActionsCombat() {
|
||||
return this.itemTypes[ITEM_TYPES.competencecreature]
|
||||
.filter(it => RdDItemCompetenceCreature.isAttaque(it))
|
||||
.map(it => RdDItemCompetenceCreature.armeCreature(it))
|
||||
.filter(it => it != undefined);
|
||||
}
|
||||
|
||||
|
||||
async computeArmure(attackerRoll) { return this.getProtectionNaturelle() }
|
||||
async remiseANeuf() { }
|
||||
async appliquerAjoutExperience(rollData, hideChatMessage = 'show') { }
|
||||
@ -172,6 +155,9 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
getPossession(possessionId) {
|
||||
return this.itemTypes[ITEM_TYPES.possession].find(it => it.system.possessionid == possessionId);
|
||||
}
|
||||
getPossessions() {
|
||||
return this.itemTypes[ITEM_TYPES.possession];
|
||||
}
|
||||
getEmpoignades() {
|
||||
return this.itemTypes[ITEM_TYPES.empoignade];
|
||||
}
|
||||
@ -384,7 +370,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
rollArme(arme, categorieArme, token) {
|
||||
token = token ?? RdDUtility.getSelectedToken(this)
|
||||
const compToUse = this.$getCompetenceArme(arme, categorieArme)
|
||||
if (!RdDItemArme.isUtilisable(arme)) {
|
||||
if (!RdDItemArme.isArmeUtilisable(arme)) {
|
||||
ui.notifications.warn(`Arme inutilisable: ${arme.name} a une résistance de 0 ou moins`)
|
||||
return
|
||||
}
|
||||
@ -466,7 +452,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
alias: defenderToken?.name ?? this.name,
|
||||
hasPlayerOwner: this.hasPlayerOwner,
|
||||
show: show ?? {}
|
||||
}, { overwrite: false });
|
||||
}, {overwrite: false});
|
||||
|
||||
await ChatUtility.createChatWithRollMode(
|
||||
{
|
||||
|
@ -710,19 +710,4 @@ export class RdDBaseActor extends Actor {
|
||||
getItemUse(itemId) { return 0; }
|
||||
async finDeRound(options = { terminer: false }) { }
|
||||
isActorCombat() { return false }
|
||||
getCaracInit(competence) { return 0 }
|
||||
listActionsCombat() { return [] }
|
||||
listActionsPossessions() {
|
||||
return this.itemTypes[ITEM_TYPES.possession]
|
||||
.map(p => {
|
||||
return {
|
||||
name: p.name,
|
||||
action: 'possession',
|
||||
system: {
|
||||
competence: p.name,
|
||||
possessionid: p.system.possessionid,
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -152,8 +152,8 @@ export class Mapping {
|
||||
}
|
||||
|
||||
static prepareArme(actor, arme, maniement) {
|
||||
const nameCompetenceArme = RdDItemArme.getCompetenceArme(arme, maniement)
|
||||
const competence = actor.getCompetence(nameCompetenceArme)
|
||||
const nameCompArme = RdDItemArme.getCompetenceArme(arme, maniement)
|
||||
const competence = actor.getCompetence(nameCompArme)
|
||||
if (RdDItemCompetence.isNiveauBase(competence)) {
|
||||
return undefined
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ export class RdDItemArme extends Item {
|
||||
return arme.system.competence.replace(" 1 main", " 2 mains");
|
||||
}
|
||||
|
||||
static isUtilisable(arme) {
|
||||
static isArmeUtilisable(arme) {
|
||||
switch (arme.type) {
|
||||
case ITEM_TYPES.arme: return arme.system.equipe && (arme.system.resistance > 0 || arme.system.portee_courte > 0)
|
||||
case ITEM_TYPES.competencecreature: return true
|
||||
@ -214,26 +214,6 @@ export class RdDItemArme extends Item {
|
||||
return false
|
||||
}
|
||||
|
||||
static isAttaque(arme) {
|
||||
switch (arme.type) {
|
||||
case ITEM_TYPES.arme:
|
||||
return arme.system.equipe && (arme.system.resistance > 0 || arme.system.portee_courte > 0)
|
||||
case ITEM_TYPES.competencecreature:
|
||||
return arme.system.iscombat && RdDItemCompetenceCreature.isAttaque(item)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
static isParade(arme) {
|
||||
switch (arme.type) {
|
||||
case ITEM_TYPES.arme:
|
||||
return arme.system.equipe && arme.system.resistance > 0 && true/* TODO: regarder la categorie d'arme?*/
|
||||
case ITEM_TYPES.competencecreature:
|
||||
return arme.system.iscombat && RdDItemCompetenceCreature.isParade(arme)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
static ajoutCorpsACorps(armes, actor) {
|
||||
armes.push(RdDItemArme.mainsNues(actor));
|
||||
armes.push(RdDItemArme.empoignade(actor));
|
||||
|
@ -27,28 +27,29 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
static armeCreature(item) {
|
||||
const categorieAttaque = RdDItemCompetenceCreature.getCategorieAttaque(item)
|
||||
if (categorieAttaque != undefined) {
|
||||
// cloner pour ne pas modifier la compétence
|
||||
return foundry.utils.mergeObject(item, {
|
||||
// si c'est un Item compétence: cloner pour ne pas modifier la compétence
|
||||
let arme = item.clone();
|
||||
return foundry.utils.mergeObject(arme, {
|
||||
action: item.isCompetencePossession() ? 'possession' : 'attaque',
|
||||
system: {
|
||||
competence: item.name,
|
||||
competence: arme.name,
|
||||
cac: categorieAttaque == "naturelle" ? "naturelle" : "",
|
||||
niveau: item.system.niveau,
|
||||
initiative: RdDCombatManager.calculInitiative(item.system.niveau, item.system.carac_value),
|
||||
equipe: true,
|
||||
resistance: 100,
|
||||
dommagesReels: item.system.dommages,
|
||||
dommagesReels: arme.system.dommages,
|
||||
penetration: 0,
|
||||
force: 0,
|
||||
rapide: true,
|
||||
}
|
||||
}, { inplace: false, });
|
||||
}, { inplace: false });
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isAttaque(item) {
|
||||
static isCompetenceAttaque(item) {
|
||||
if (item.type == ITEM_TYPES.competencecreature) {
|
||||
switch (item.system.categorie) {
|
||||
case "melee":
|
||||
@ -59,7 +60,7 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return undefined
|
||||
}
|
||||
|
||||
static getCategorieAttaque(item) {
|
||||
@ -76,7 +77,6 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
static isDommages(item) {
|
||||
if (item.type == ITEM_TYPES.competencecreature) {
|
||||
switch (item.system.categorie) {
|
||||
@ -89,7 +89,6 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
static isParade(item) {
|
||||
if (item.type == ITEM_TYPES.competencecreature) {
|
||||
switch (item.system.categorie) {
|
||||
@ -102,4 +101,8 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static isCompetenceParade(item) {
|
||||
return item.type == 'competencecreature' && item.system.categorie_parade !== "";
|
||||
}
|
||||
}
|
||||
|
@ -72,28 +72,19 @@ export class RdDCombatManager extends Combat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async finDeRound(options = { terminer: false }) {
|
||||
this.combatants.map(it => RdDCombatManager.getActorCombatant(it, { warning: false }))
|
||||
.filter(it => it != undefined)
|
||||
.forEach(async actor => {
|
||||
await actor.finDeRound(options)
|
||||
await actor.resetItemUse()
|
||||
})
|
||||
}
|
||||
|
||||
static getActorCombatant(combatant, options = { warning: true }) {
|
||||
if (!combatant.actor) {
|
||||
if (options.warning) {
|
||||
for (let combatant of this.combatants) {
|
||||
if (!combatant.actor) {
|
||||
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`)
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
else if (!combatant.actor.isActorCombat()) {
|
||||
if (options.warning) {
|
||||
ui.notifications.warn(`${combatant.name} ne peut pas combattre!`)
|
||||
else if (!combatant.actor.isActorCombat()) {
|
||||
ui.notifications.warn(`Le combatant ${combatant.name} ne peut pas combattre!`)
|
||||
}
|
||||
else {
|
||||
await combatant.actor.finDeRound(options)
|
||||
await combatant.actor.resetItemUse()
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
return combatant.actor
|
||||
}
|
||||
|
||||
static calculAjustementInit(actor, arme) {
|
||||
@ -104,27 +95,56 @@ export class RdDCombatManager extends Combat {
|
||||
}
|
||||
|
||||
/************************************************************************************/
|
||||
async rollInitiative(ids, messageOptions = {}) {
|
||||
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, messageOptions)
|
||||
ids = typeof ids === "string" ? [ids] : ids
|
||||
ids.forEach(async id =>
|
||||
await this.rollInitRdD(id, undefined, messageOptions)
|
||||
)
|
||||
return this
|
||||
}
|
||||
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
|
||||
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
|
||||
|
||||
async rollInitRdD(id, formula, messageOptions = {}) {
|
||||
const combatant = this.combatants.get(id);
|
||||
const actor = RdDCombatManager.getActorCombatant(combatant)
|
||||
if (actor) {
|
||||
const rollFormula = formula ?? RdDCombatManager.getFirstInitRollFormula(actor)
|
||||
ids = typeof ids === "string" ? [ids] : ids;
|
||||
// calculate initiative
|
||||
for (let cId = 0; cId < ids.length; cId++) {
|
||||
const combatant = this.combatants.get(ids[cId]);
|
||||
const ajustement = RdDCombatManager.calculAjustementInit(combatant.actor, undefined);
|
||||
let rollFormula = formula ?? RdDCombatManager.formuleInitiative(2, 10, 0, ajustement);
|
||||
|
||||
if (!formula) {
|
||||
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
||||
const competence = combatant.actor.items.find(it => RdDItemCompetenceCreature.isCompetenceAttaque(it))
|
||||
if (competence) {
|
||||
rollFormula = RdDCombatManager.formuleInitiative(2, competence.system.carac_value, competence.system.niveau, etatGeneral);
|
||||
}
|
||||
} else {
|
||||
const armeCombat = combatant.actor.itemTypes['arme'].find(it => it.system.equipe)
|
||||
let compName = "Corps à corps"
|
||||
if (armeCombat) {
|
||||
if (armeCombat.system.competence != "") {
|
||||
compName = armeCombat.system.competence
|
||||
}
|
||||
if (armeCombat.system.lancer != "") {
|
||||
compName = armeCombat.system.lancer
|
||||
}
|
||||
if (armeCombat.system.tir != "") {
|
||||
compName = armeCombat.system.tir
|
||||
}
|
||||
}
|
||||
const competence = RdDItemCompetence.findCompetence(combatant.actor.items, compName);
|
||||
if (competence && competence.system.defaut_carac) {
|
||||
const carac = combatant.actor.system.carac[competence.system.defaut_carac].value;
|
||||
const niveau = competence.system.niveau;
|
||||
|
||||
const ajustement = RdDCombatManager.calculAjustementInit(combatant.actor, armeCombat)
|
||||
rollFormula = RdDCombatManager.formuleInitiative(2, carac, niveau, ajustement);
|
||||
} else {
|
||||
ui.notifications.warn(`Votre arme ${armeCombat.name} n'a pas de compétence renseignée`);
|
||||
}
|
||||
}
|
||||
}
|
||||
const roll = combatant.getInitiativeRoll(rollFormula);
|
||||
if (!roll.total) {
|
||||
await roll.evaluate();
|
||||
}
|
||||
const total = Math.max(roll.total, 0.00);
|
||||
console.log("Compute init for", rollFormula, roll, total, combatant);
|
||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: combatant._id || combatant.id, initiative: total }]);
|
||||
let id = combatant._id || combatant.id;
|
||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: id, initiative: total }]);
|
||||
|
||||
// Send a chat message
|
||||
let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode");
|
||||
@ -136,7 +156,7 @@ export class RdDCombatManager extends Combat {
|
||||
alias: combatant.token.name,
|
||||
sound: CONFIG.sounds.dice,
|
||||
},
|
||||
flavor: `${combatant.token.name} a fait son jet d'Initiative (${messageOptions.info})<br>`
|
||||
flavor: `${combatant.token.name} a fait son jet d'Initiative (${messageOptions.initInfo})<br>`,
|
||||
},
|
||||
messageOptions);
|
||||
roll.toMessage(messageData, { rollMode, create: true });
|
||||
@ -144,20 +164,7 @@ export class RdDCombatManager extends Combat {
|
||||
RdDCombatManager.processPremierRoundInit();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
static getFirstInitRollFormula(actor) {
|
||||
const actions = actor.listActionsCombat()
|
||||
if (actions.length > 0) {
|
||||
const action = actions[0]
|
||||
const init = RdDCombatManager.getInitData(actor, action)
|
||||
const ajustement = RdDCombatManager.calculAjustementInit(actor, action)
|
||||
return RdDCombatManager.formuleInitiative(init.offset, init.carac, init.niveau, ajustement);
|
||||
}
|
||||
|
||||
let ajustement = RdDCombatManager.calculAjustementInit(actor, undefined);
|
||||
return RdDCombatManager.formuleInitiative(2, 10, 0, ajustement);
|
||||
}
|
||||
};
|
||||
|
||||
static formuleInitiative(rang, carac, niveau, bonusMalus) {
|
||||
return `${rang} +( (${RdDCombatManager.calculInitiative(niveau, carac, bonusMalus)} )/100)`;
|
||||
@ -240,6 +247,61 @@ export class RdDCombatManager extends Combat {
|
||||
return attaque;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static listActionsCombat(combatant) {
|
||||
const actor = combatant.actor;
|
||||
if (!actor.isActorCombat()) {
|
||||
return
|
||||
}
|
||||
let actions = RdDCombatManager.listActionsPossessions(actor);
|
||||
if (actions.length > 0) {
|
||||
return actions;
|
||||
}
|
||||
if (actor.isCreatureEntite()) {
|
||||
actions = RdDCombatManager.listActionsCreature(actor.itemTypes['competencecreature']);
|
||||
} else if (actor.isPersonnage()) {
|
||||
// Recupération des items 'arme'
|
||||
const competences = actor.itemTypes['competence'];
|
||||
const armes = actor.itemTypes['arme'].filter(it => RdDItemArme.isArmeUtilisable(it))
|
||||
.concat(RdDItemArme.empoignade(actor))
|
||||
.concat(RdDItemArme.mainsNues(actor));
|
||||
actions = RdDCombatManager.listActionsArmes(armes, competences, actor.system.carac);
|
||||
|
||||
if (actor.system.attributs.hautrevant.value) {
|
||||
actions.push({ name: "Draconic", action: 'haut-reve', system: { initOnly: true, competence: "Draconic" } });
|
||||
}
|
||||
}
|
||||
|
||||
return RdDCombatManager._indexActions(actions);
|
||||
}
|
||||
|
||||
static listActionsCreature(competences) {
|
||||
return competences
|
||||
.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it))
|
||||
.map(it => RdDItemCompetenceCreature.armeCreature(it))
|
||||
.filter(it => it != undefined);
|
||||
}
|
||||
|
||||
static listActionsPossessions(actor) {
|
||||
return RdDCombatManager._indexActions(actor.getPossessions().map(p => {
|
||||
return {
|
||||
name: p.name,
|
||||
action: 'possession',
|
||||
system: {
|
||||
competence: p.name,
|
||||
possessionid: p.system.possessionid,
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
static _indexActions(actions) {
|
||||
for (let index = 0; index < actions.length; index++) {
|
||||
actions[index].index = index;
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static processPremierRoundInit() {
|
||||
// Check if we have the whole init !
|
||||
@ -277,13 +339,13 @@ export class RdDCombatManager extends Combat {
|
||||
/* -------------------------------------------- */
|
||||
static pushInitiativeOptions(html, options) {
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
let option = options[i]
|
||||
let option = options[i];
|
||||
if (option.name == 'COMBAT.CombatantReroll') { // Replace !
|
||||
option.name = "Sélectionner l'initiative..."
|
||||
option.condition = true
|
||||
option.icon = '<i class="far fa-question-circle"></i>'
|
||||
option.name = "Sélectionner l'initiative...";
|
||||
option.condition = true;
|
||||
option.icon = '<i class="far fa-question-circle"></i>';
|
||||
option.callback = target => {
|
||||
RdDCombatManager.displayInitiativeMenu(html, target.data('combatant-id'))
|
||||
RdDCombatManager.displayInitiativeMenu(html, target.data('combatant-id'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,83 +356,96 @@ export class RdDCombatManager extends Combat {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static rollInitiativeAction(combatantId, action) {
|
||||
const combatant = game.combat.combatants.get(combatantId)
|
||||
const actor = RdDCombatManager.getActorCombatant(combatant)
|
||||
if (actor == undefined) { return [] }
|
||||
const combatant = game.combat.combatants.get(combatantId);
|
||||
if (combatant.actor == undefined) {
|
||||
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
||||
return [];
|
||||
}
|
||||
let initInfo = "";
|
||||
let initOffset = 0;
|
||||
let caracForInit = 0;
|
||||
let compNiveau = 0;
|
||||
let compData = { name: "Aucune" };
|
||||
if (combatant.actor.getSurprise() == "totale") {
|
||||
initOffset = -1; // To force 0
|
||||
initInfo = "Surprise Totale"
|
||||
} else if (combatant.actor.getSurprise() == "demi") {
|
||||
initOffset = 0;
|
||||
initInfo = "Demi Surprise"
|
||||
} else if (action.action == 'possession') {
|
||||
initOffset = 10;
|
||||
caracForInit = combatant.actor.getReveActuel();
|
||||
initInfo = "Possession"
|
||||
} else if (action.action == 'autre') {
|
||||
initOffset = 2;
|
||||
initInfo = "Autre Action"
|
||||
} else if (action.action == 'haut-reve') {
|
||||
initOffset = 9;
|
||||
initInfo = "Draconic"
|
||||
} else {
|
||||
compData = RdDItemCompetence.findCompetence(combatant.actor.items, action.system.competence);
|
||||
compNiveau = compData.system.niveau;
|
||||
initInfo = action.name + " / " + action.system.competence;
|
||||
|
||||
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
|
||||
caracForInit = compData.system.carac_value;
|
||||
} else {
|
||||
caracForInit = combatant.actor.system.carac[compData.system.defaut_carac].value;
|
||||
}
|
||||
initOffset = RdDCombatManager._baseInitOffset(compData.system.categorie, action);
|
||||
}
|
||||
|
||||
// Cas des créatures et entités vs personnages
|
||||
const ajustement = RdDCombatManager.calculAjustementInit(combatant.actor, action)
|
||||
let rollFormula = RdDCombatManager.formuleInitiative(initOffset, caracForInit, compNiveau, ajustement);
|
||||
// Garder la trace de l'arme/compétence utilisée pour l'iniative
|
||||
combatant.initiativeData = { arme: action } // pour reclasser l'init au round 0
|
||||
|
||||
const init = RdDCombatManager.getInitData(actor, action)
|
||||
const ajustement = RdDCombatManager.calculAjustementInit(actor, action)
|
||||
const rollFormula = RdDCombatManager.formuleInitiative(init.offset, init.carac, init.niveau, ajustement);
|
||||
|
||||
game.combat.rollInitRdD(combatantId, rollFormula, init);
|
||||
game.combat.rollInitiative(combatantId, rollFormula, { initInfo: initInfo });
|
||||
}
|
||||
|
||||
static getInitData(actor, action) {
|
||||
if (actor.getSurprise() == "totale") { return { offset: -1, info: "Surprise Totale", carac: 0, niveau: 0 } }
|
||||
if (actor.getSurprise() == "demi") { return { offset: 0, info: "Demi Surprise", carac: 0, niveau: 0 } }
|
||||
if (action.action == 'autre') { return { offset: 2, info: "Autre Action", carac: 0, niveau: 0 } }
|
||||
if (action.action == 'possession') { return { offset: 10, info: "Possession", carac: actor.getReveActuel(), niveau: 0 } }
|
||||
if (action.action == 'haut-reve') { return { offset: 9, info: "Draconic", carac: actor.getReveActuel(), niveau: 0 } }
|
||||
|
||||
const comp = RdDItemCompetence.findCompetence(actor.items, action.system.competence);
|
||||
return {
|
||||
offset: RdDCombatManager.initOffset(comp?.system.categorie, action),
|
||||
info: action.name + " / " + action.system.competence,
|
||||
carac: actor.getCaracInit(comp),
|
||||
niveau: comp?.system.niveau ?? -8
|
||||
/* -------------------------------------------- */
|
||||
static _baseInitOffset(categorie, arme) {
|
||||
if (categorie == "tir") { // Offset de principe pour les armes de jet
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
static initOffset(categorie, arme) {
|
||||
switch (categorie) {
|
||||
case "tir": return 8
|
||||
case "lancer": return 7
|
||||
default:
|
||||
switch (arme.system.cac) {
|
||||
case "empoignade": return 3
|
||||
case "pugilat": return 4
|
||||
case "naturelle": return 4
|
||||
default: return 5
|
||||
}
|
||||
if (categorie == "lancer") { // Offset de principe pour les armes de jet
|
||||
return 7;
|
||||
}
|
||||
switch (arme.system.cac) {
|
||||
case "empoignade":
|
||||
return 3;
|
||||
case "pugilat":
|
||||
case "naturelle":
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static displayInitiativeMenu(html, combatantId) {
|
||||
const combatant = game.combat.combatants.get(combatantId)
|
||||
const actor = RdDCombatManager.getActorCombatant(combatant, { warning: false })
|
||||
if (actor) {
|
||||
const actions = RdDCombatManager.listActionsActorCombatant(actor)
|
||||
// Build the relevant submenu
|
||||
const menuItems = actions.map(action => {
|
||||
return {
|
||||
console.log("Combatant ; ", combatantId);
|
||||
const combatant = game.combat.combatants.get(combatantId);
|
||||
if (!(combatant?.actor)) {
|
||||
ui.notifications.warn(`Le combatant ${combatant.name ?? combatantId} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
||||
return;
|
||||
}
|
||||
|
||||
let actions = RdDCombatManager.listActionsCombat(combatant);
|
||||
|
||||
// Build the relevant submenu
|
||||
if (actions) {
|
||||
let menuItems = [];
|
||||
for (let action of actions) {
|
||||
menuItems.push({
|
||||
name: action.system.competence,
|
||||
icon: "<i class='fas fa-dice-d6'></i>",
|
||||
callback: target => { RdDCombatManager.rollInitiativeAction(combatantId, action) }
|
||||
}
|
||||
})
|
||||
if (menuItems.length > 0) {
|
||||
new ContextMenu(html, ".directory-list", menuItems).render();
|
||||
});
|
||||
}
|
||||
new ContextMenu(html, ".directory-list", menuItems).render();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static listActionsActorCombatant( actor) {
|
||||
const possessions = actor.listActionsPossessions()
|
||||
const actions = possessions.length > 0
|
||||
? possessions
|
||||
: actor.listActionsCombat()
|
||||
|
||||
for (let index = 0; index < actions.length; index++) {
|
||||
actions[index].index = index
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -917,13 +992,13 @@ export class RdDCombat {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_filterArmesParade(defender, competence, armeAttaque) {
|
||||
let defenses = defender.items.filter(it => RdDItemArme.isParade(it))
|
||||
_filterArmesParade(defender, competence, arme) {
|
||||
let defenses = defender.items.filter(it => RdDItemArme.isArmeUtilisable(it) || RdDItemCompetenceCreature.isCompetenceParade(it))
|
||||
defenses = foundry.utils.duplicate(defenses)
|
||||
defenses.forEach(armeDefense => {
|
||||
// Ajout du # d'utilisation ce round
|
||||
armeDefense.nbUsage = defender.getItemUse(armeDefense.id)
|
||||
armeDefense.typeParade = RdDItemArme.defenseArmeParade(armeAttaque, armeDefense)
|
||||
armeDefense.typeParade = RdDItemArme.defenseArmeParade(arme, armeDefense)
|
||||
})
|
||||
|
||||
switch (competence.system.categorie) {
|
||||
@ -1278,7 +1353,7 @@ export class RdDCombat {
|
||||
if (!actor?.isActorCombat()) {
|
||||
return
|
||||
}
|
||||
const formData = {
|
||||
let formData = {
|
||||
combatId: combat._id,
|
||||
alias: token.name ?? actor.name,
|
||||
etatGeneral: actor.getEtatGeneral(),
|
||||
@ -1299,6 +1374,6 @@ export class RdDCombat {
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-sante.hbs`, formData),
|
||||
whisper: ChatUtility.getOwners(actor),
|
||||
alias: token.name ?? actor.name
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
@ -28,15 +28,16 @@ export class RdDTokenHud {
|
||||
await RdDTokenHud.addExtensionHudSoins(html, actor);
|
||||
|
||||
if (isCombat) {
|
||||
const combatant = game.combat.combatants.find(c => c.tokenId == tokenId)
|
||||
const actor = RdDCombatManager.getActorCombatant(combatant, { warning: false })
|
||||
if (actor) {
|
||||
let actions = RdDCombatManager.listActionsActorCombatant(actor)
|
||||
// initiative
|
||||
await RdDTokenHud.addExtensionHudInit(html, combatant, actions)
|
||||
// combat
|
||||
await RdDTokenHud.addExtensionHudCombat(html, combatant, token, actions)
|
||||
let combatant = game.combat.combatants.find(c => c.tokenId == tokenId);
|
||||
if (!(combatant?.actor)) {
|
||||
ui.notifications.warn(`Le combatant ${token.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
||||
return;
|
||||
}
|
||||
let actions = RdDCombatManager.listActionsCombat(combatant);
|
||||
// initiative
|
||||
await RdDTokenHud.addExtensionHudInit(html, combatant, actions);
|
||||
// combat
|
||||
await RdDTokenHud.addExtensionHudCombat(html, combatant, token, actions);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ export class AutoAdjustDarkness {
|
||||
}
|
||||
|
||||
static async adjust(darkness) {
|
||||
if (game.user.isGM && AutoAdjustDarkness.isAuto()) {
|
||||
if (AutoAdjustDarkness.isAuto()) {
|
||||
const scene = game.scenes.viewed;
|
||||
if (scene?.environment?.globalLight?.enabled && scene?.tokenVision) {
|
||||
await scene.update({ darkness });
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"id": "foundryvtt-reve-de-dragon",
|
||||
"title": "Rêve de Dragon",
|
||||
"version": "12.0.19",
|
||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-12.0.19.zip",
|
||||
"version": "12.0.18",
|
||||
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-12.0.18.zip",
|
||||
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v11/system.json",
|
||||
"changelog": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/branch/v11/changelog.md",
|
||||
"compatibility": {
|
||||
|
Loading…
Reference in New Issue
Block a user