Attaques V2 depuis onglet combat
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# 13.0
|
# 13.0
|
||||||
|
|
||||||
|
## 13.0.29 - Le tricorne d'Illysis
|
||||||
|
|
||||||
|
- gestion des attaques avec jets V2 depuis l'onglet de combat'
|
||||||
|
|
||||||
## 13.0.28 - La quadrature d'Illysis
|
## 13.0.28 - La quadrature d'Illysis
|
||||||
|
|
||||||
- Les ajustements de portée sont calculés pour les attaques à distance
|
- Les ajustements de portée sont calculés pour les attaques à distance
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
|
|
||||||
getTaille() { return Misc.toInt(this.system.carac.taille?.value) }
|
getTaille() { return Misc.toInt(this.system.carac.taille?.value) }
|
||||||
getConstitution() { return this.getReve() }
|
getConstitution() { return this.getReve() }
|
||||||
getVie() { return this.getReve() }
|
|
||||||
getCaracVie() { return { [CARACS.VIE]: { label: "Vie", value: this.getVieMax(), type: "number" } } }
|
|
||||||
|
|
||||||
getForce() { return this.getReve() }
|
getForce() { return this.getReve() }
|
||||||
getAgilite() { return this.getForce() }
|
getAgilite() { return this.getForce() }
|
||||||
@@ -484,17 +482,15 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
|
|
||||||
async rollCompetence(idOrName, options = { tryTarget: true, arme: undefined }) {
|
async rollCompetence(idOrName, options = { tryTarget: true, arme: undefined }) {
|
||||||
RdDEmpoignade.checkEmpoignadeEnCours(this)
|
RdDEmpoignade.checkEmpoignadeEnCours(this)
|
||||||
|
|
||||||
const competence = this.getCompetence(idOrName);
|
const competence = this.getCompetence(idOrName);
|
||||||
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
|
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
|
||||||
const rollData = {
|
const rollData = {
|
||||||
ids: { actorId: this.id },
|
ids: { actorId: this.id },
|
||||||
type: { allowed: options.arme ? ATTAQUE_ROLL_TYPES : DEFAULT_ROLL_TYPES },
|
type: { allowed: DEFAULT_ROLL_TYPES },
|
||||||
selected: {
|
selected: {
|
||||||
carac: competence.type == ITEM_TYPES.competencecreature ? { key: competence.name } : undefined,
|
carac: competence.type == ITEM_TYPES.competencecreature ? { key: competence.name } : undefined,
|
||||||
comp: { key: competence.name },
|
comp: { key: competence.name },
|
||||||
diff: { type: options.arme ? DIFF.ATTAQUE : DIFF.LIBRE, value: competence.system.default_diffLibre ?? 0 },
|
diff: { type: DIFF.LIBRE, value: competence.system.default_diffLibre ?? 0 },
|
||||||
attaque: options.arme ? { arme: { key: options.arme.id } } : undefined
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return await RollDialog.create(rollData)
|
return await RollDialog.create(rollData)
|
||||||
@@ -566,7 +562,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
type: {
|
type: {
|
||||||
allowed: [ROLL_TYPE_ATTAQUE], current: ROLL_TYPE_ATTAQUE
|
allowed: [ROLL_TYPE_ATTAQUE], current: ROLL_TYPE_ATTAQUE
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
return await RollDialog.create(rollData, { onRollDone: RollDialog.onRollDoneClose })
|
return await RollDialog.create(rollData, { onRollDone: RollDialog.onRollDoneClose })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -575,16 +571,18 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
|
|
||||||
/** --------------------------------------------
|
/** --------------------------------------------
|
||||||
* @param {*} arme item d'arme/compétence de créature
|
* @param {*} arme item d'arme/compétence de créature
|
||||||
* @param {*} categorieArme catégorie d'attaque à utiliser: competence (== melee), lancer, tir; naturelle, possession
|
* @param {*} maniement catégorie d'attaque à utiliser: competence (== melee), lancer, tir; naturelle, possession
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
rollArme(arme, categorieArme = 'competence', token = undefined) {
|
async rollArme(arme, maniement = 'competence', token = undefined) {
|
||||||
token = token ?? RdDUtility.getSelectedToken(this)
|
token = token ?? RdDUtility.getSelectedToken(this)
|
||||||
const compToUse = RdDItemArme.getCompetenceArme(arme, categorieArme)
|
const compToUse = RdDItemArme.getCompetenceArme(arme, maniement)
|
||||||
|
|
||||||
if (!RdDItemArme.isUtilisable(arme)) {
|
if (!RdDItemArme.isUtilisable(arme)) {
|
||||||
ui.notifications.warn(`Arme inutilisable: ${arme.name} non équipée ou avec une résistance de 0 ou moins`)
|
ui.notifications.warn(`Arme inutilisable: ${arme.name} non équipée ou avec une résistance de 0 ou moins`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Targets.hasTargets()) {
|
if (!Targets.hasTargets()) {
|
||||||
RdDConfirm.confirmer({
|
RdDConfirm.confirmer({
|
||||||
settingConfirmer: "confirmer-combat-sans-cible",
|
settingConfirmer: "confirmer-combat-sans-cible",
|
||||||
@@ -596,7 +594,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
onAction: async () => {
|
onAction: async () => {
|
||||||
this.rollCompetence(compToUse, { tryTarget: false, arme: arme })
|
this.rollCompetence(compToUse, { tryTarget: false, arme: arme })
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,11 +604,12 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const competence = this.getCompetence(compToUse)
|
const comp = this.getCompetence(compToUse)
|
||||||
if (competence.isCompetencePossession()) {
|
if (comp.isCompetencePossession()) {
|
||||||
return RdDPossession.onAttaquePossession(target, this, competence);
|
// TODO: vérifier si c'est possible, sinon simplifier
|
||||||
|
return RdDPossession.onAttaquePossession(target, this, comp);
|
||||||
}
|
}
|
||||||
RdDCombat.rddCombatTarget(target, this, token).attaque(competence, arme);
|
RdDCombat.rddCombatTarget(target, this, token).attaque(comp, arme, maniement)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-8
@@ -518,8 +518,8 @@ export class RdDCombat {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
attaqueChanceuse(attackerRoll) {
|
attaqueChanceuse(attackerRoll) {
|
||||||
ui.notifications.info("L'attaque est rejouée grâce à la chance")
|
ui.notifications.info("L'attaque est rejouée grâce à la chance")
|
||||||
attackerRoll.essais.attaqueChance = true;
|
attackerRoll.essais.attaqueChance = true
|
||||||
this.attaque(attackerRoll, attackerRoll.arme);
|
this.attaque(attackerRoll, attackerRoll.arme)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@@ -646,11 +646,11 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async attaqueV2() {
|
async attaqueV2(options = undefined) {
|
||||||
if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
|
if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await this.doRollAttaque({
|
const rollData = {
|
||||||
ids: {
|
ids: {
|
||||||
actorId: this.attackerId,
|
actorId: this.attackerId,
|
||||||
actorTokenId: this.attackerTokenId,
|
actorTokenId: this.attackerTokenId,
|
||||||
@@ -658,8 +658,19 @@ export class RdDCombat {
|
|||||||
opponentTokenId: this.defenderTokenId,
|
opponentTokenId: this.defenderTokenId,
|
||||||
},
|
},
|
||||||
type: { allowed: ['attaque'], current: 'attaque' },
|
type: { allowed: ['attaque'], current: 'attaque' },
|
||||||
|
selected: {},
|
||||||
passeArme: foundry.utils.randomID(16),
|
passeArme: foundry.utils.randomID(16),
|
||||||
})
|
}
|
||||||
|
if (options) {
|
||||||
|
rollData.selected = {
|
||||||
|
attaque: {
|
||||||
|
comp: { id: options.comp.id },
|
||||||
|
arme: { id: options.arme.id },
|
||||||
|
main: options.main
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await this.doRollAttaque(rollData)
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRollAttaque(rollData, callbacks = []) {
|
async doRollAttaque(rollData, callbacks = []) {
|
||||||
@@ -740,12 +751,14 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async attaque(competence, arme) {
|
async attaque(competence, arme, main) {
|
||||||
if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
|
if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
|
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
|
||||||
return this.attacker.rollCompetence(competence.name, { arme: arme })
|
return this.attaqueV2(
|
||||||
|
{ comp: competence, arme: arme, main: main }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (arme.system.cac == EMPOIGNADE) {
|
if (arme.system.cac == EMPOIGNADE) {
|
||||||
RdDEmpoignade.onAttaqueEmpoignade(this.attacker, this.defender)
|
RdDEmpoignade.onAttaqueEmpoignade(this.attacker, this.defender)
|
||||||
@@ -754,7 +767,7 @@ export class RdDCombat {
|
|||||||
RdDEmpoignade.checkEmpoignadeEnCours(this.attacker)
|
RdDEmpoignade.checkEmpoignadeEnCours(this.attacker)
|
||||||
|
|
||||||
let rollData = this._prepareAttaque(competence, arme)
|
let rollData = this._prepareAttaque(competence, arme)
|
||||||
console.log("RdDCombat.attaque >>>", rollData);
|
console.log("RdDCombat.attaque >>>", rollData)
|
||||||
if (arme) {
|
if (arme) {
|
||||||
this.attacker.verifierForceMin(arme);
|
this.attacker.verifierForceMin(arme);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export class RdDHotbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Roll macro */
|
/** Roll macro */
|
||||||
static rollMacro(itemName, itemType, categorieArme = 'competence') {
|
static rollMacro(itemName, itemType, maniement = 'competence') {
|
||||||
const speaker = ChatMessage.getSpeaker();
|
const speaker = ChatMessage.getSpeaker();
|
||||||
let actor;
|
let actor;
|
||||||
if (speaker.token) actor = game.actors.tokens[speaker.token];
|
if (speaker.token) actor = game.actors.tokens[speaker.token];
|
||||||
@@ -117,10 +117,10 @@ export class RdDHotbar {
|
|||||||
// Trigger the item roll
|
// Trigger the item roll
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case ITEM_TYPES.arme:
|
case ITEM_TYPES.arme:
|
||||||
return actor.rollArme(item, categorieArme);
|
return actor.rollArme(item, maniement);
|
||||||
case ITEM_TYPES.competence:
|
case ITEM_TYPES.competence:
|
||||||
if (item.isCorpsACorps()) {
|
if (item.isCorpsACorps()) {
|
||||||
switch (categorieArme) {
|
switch (maniement) {
|
||||||
case PUGILAT:
|
case PUGILAT:
|
||||||
return actor.rollArme(RdDItemArme.pugilat(actor));
|
return actor.rollArme(RdDItemArme.pugilat(actor));
|
||||||
case EMPOIGNADE:
|
case EMPOIGNADE:
|
||||||
@@ -130,7 +130,7 @@ export class RdDHotbar {
|
|||||||
return actor.rollCompetence(item);
|
return actor.rollCompetence(item);
|
||||||
case ITEM_TYPES.competencecreature:
|
case ITEM_TYPES.competencecreature:
|
||||||
return item.system.iscombat
|
return item.system.iscombat
|
||||||
? actor.rollArme(item, categorieArme)
|
? actor.rollArme(item, maniement)
|
||||||
: actor.rollCompetence(item);
|
: actor.rollCompetence(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,11 +52,13 @@ export class RollPartAttaque extends RollPartSelect {
|
|||||||
|
|
||||||
restore(rollData) {
|
restore(rollData) {
|
||||||
const saved = this.getSaved(rollData) ?? {}
|
const saved = this.getSaved(rollData) ?? {}
|
||||||
this.setCurrent(rollData, {
|
if (saved.key) {
|
||||||
key: saved.key,
|
this.setCurrent(rollData, {
|
||||||
tactique: saved.tactique,
|
key: saved.key,
|
||||||
dmg: saved.dmg
|
tactique: saved.tactique,
|
||||||
})
|
dmg: saved.dmg
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store(rollData, targetData) {
|
store(rollData, targetData) {
|
||||||
@@ -70,8 +72,10 @@ export class RollPartAttaque extends RollPartSelect {
|
|||||||
|
|
||||||
|
|
||||||
findAttaque(attaques, saved) {
|
findAttaque(attaques, saved) {
|
||||||
return attaques.find(at => at.arme.id == saved?.arme?.id &&
|
return attaques.find(at => at.arme.id == (saved?.arme?.id ?? at.arme.id)
|
||||||
at.comp.id == saved?.comp?.id
|
&& at.comp.id == (saved?.comp?.id ?? at.comp.id)
|
||||||
|
&& at.main == (saved?.main ?? at.main)
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user