Merge branch 'v1.4-fix-combat' into 'v1.4'

Fix: regression combat

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!261
This commit is contained in:
Leratier Bretonnien 2021-06-01 04:34:33 +00:00
commit f04ef45fe1
7 changed files with 48 additions and 24 deletions

View File

@ -2274,6 +2274,9 @@ export class RdDActor extends Actor {
rollData.show = {} rollData.show = {}
rollData.depenseReve = Number(selectedSort.data.ptreve_reel); rollData.depenseReve = Number(selectedSort.data.ptreve_reel);
if (rollData.competence.name.includes('Thanatos')) { // Si Thanatos
await this.update({ "data.reve.reve.thanatosused": true });
}
let reveActuel = Misc.templateData(this).reve.reve.value; let reveActuel = Misc.templateData(this).reve.reve.value;
if (rolled.isSuccess) { // Réussite du sort ! if (rolled.isSuccess) { // Réussite du sort !
if (rolled.isPart) { if (rolled.isPart) {
@ -2282,9 +2285,6 @@ export class RdDActor extends Actor {
if (rollData.isSortReserve) { if (rollData.isSortReserve) {
rollData.depenseReve++; rollData.depenseReve++;
} }
if (rollData.competence.name.includes('Thanatos')) { // Si Thanatos
await this.update({ "data.reve.reve.thanatosused": true });
}
if (reveActuel > rollData.depenseReve) { if (reveActuel > rollData.depenseReve) {
// Incrémenter/gére le bonus de case // Incrémenter/gére le bonus de case
RdDItemSort.incrementBonusCase(this, selectedSort, rollData.tmr.coord); RdDItemSort.incrementBonusCase(this, selectedSort, rollData.tmr.coord);

View File

@ -40,7 +40,9 @@ export class ChatUtility {
} }
static removeChatMessageId(messageId) { static removeChatMessageId(messageId) {
ChatUtility.removeMessages({ messageId: messageId }); if (messageId){
ChatUtility.removeMessages({ messageId: messageId });
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -76,10 +76,10 @@ export class DialogItemAchat extends Dialog {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
html.find(".nombreLots").change(event => this.setnombreLots(Number(event.currentTarget.value))); html.find(".nombreLots").change(event => this.setNombreLots(Number(event.currentTarget.value)));
} }
setnombreLots(nombreLots) { setNombreLots(nombreLots) {
this.venteData.nombreLots = nombreLots; this.venteData.nombreLots = nombreLots;
this.venteData.prixTotal = (nombreLots * this.venteData.prixLot).toFixed(2); this.venteData.prixTotal = (nombreLots * this.venteData.prixLot).toFixed(2);
$(".prixTotal").text(this.venteData.prixTotal); $(".prixTotal").text(this.venteData.prixTotal);

View File

@ -357,6 +357,8 @@ export class RdDCombat {
return RdDCombat.onMsgEncaisser(sockmsg.data); return RdDCombat.onMsgEncaisser(sockmsg.data);
case "msg_defense": case "msg_defense":
return RdDCombat.onMsgDefense(sockmsg.data); return RdDCombat.onMsgDefense(sockmsg.data);
case "msg_combat_passearme":
return RdDCombat.onMsgPasseArme(sockmsg.data);
} }
} }
@ -391,9 +393,11 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static combatNouveauTour(combat) { static combatNouveauTour(combat) {
if (Misc.isElectedUser()) { if (Misc.isElectedUser()) {
let turn = combat.turns.find(t => t.tokenId == combat.current.tokenId); let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId);
this.displayActorCombatStatus(combat, turn.actor); if (turn?.actor) {
// TODO Playaudio for player?? RdDCombat.displayActorCombatStatus(combat, turn.actor);
// TODO Playaudio for player??
}
} }
} }
@ -427,9 +431,31 @@ export class RdDCombat {
return undefined; return undefined;
} }
static messagePasseArme(data) {
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_combat_passearme", data: data });
RdDCombat.onMsgPasseArme(data);
}
static onMsgPasseArme(data) {
switch (data.actionPasseArme) {
case "store-attaque":
game.system.rdd.combatStore.attaques[data.id] = data.rollData;
break;
case "store-defense":
game.system.rdd.combatStore.defenses[data.id] = data.rollData;
break;
case "delete-attaque":
delete game.system.rdd.combatStore.attaques[data.id];
break;
case "delete-defense":
delete game.system.rdd.combatStore.defenses[data.id];
break;
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static _storeAttaque(attackerId, attackerRoll) { static _storeAttaque(attackerId, attackerRoll) {
game.system.rdd.combatStore.attaques[attackerId] = duplicate(attackerRoll); RdDCombat.messagePasseArme({ actionPasseArme: "store-attaque", id: attackerId, rollData: attackerRoll });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -439,12 +465,12 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _deleteAttaque(attackerId) { static _deleteAttaque(attackerId) {
delete game.system.rdd.combatStore.attaques[attackerId]; RdDCombat.messagePasseArme({ actionPasseArme: "delete-attaque", id: attackerId });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _storeDefense(defenderRoll) { static _storeDefense(passeArme, defenderRoll) {
game.system.rdd.combatStore.defenses[defenderRoll.passeArme] = duplicate(defenderRoll); RdDCombat.messagePasseArme({ actionPasseArme: "store-defense", id: passeArme, rollData: defenderRoll });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -454,7 +480,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _deleteDefense(passeArme) { static _deleteDefense(passeArme) {
delete game.system.rdd.combatStore.defenses[passeArme]; RdDCombat.messagePasseArme({ actionPasseArme: "delete-defense", id: passeArme });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -496,7 +522,7 @@ export class RdDCombat {
if (rddCombat) { if (rddCombat) {
const defenderRoll = msg.defenderRoll; const defenderRoll = msg.defenderRoll;
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll); RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
RdDCombat._storeDefense(defenderRoll); RdDCombat._storeDefense(defenderRoll.passeArme, defenderRoll);
rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme); rddCombat.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
rddCombat._chatMessageDefense(msg.paramChatDefense); rddCombat._chatMessageDefense(msg.paramChatDefense);
} }
@ -761,7 +787,7 @@ export class RdDCombat {
let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} } let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} }
// Save rollData for defender // Save rollData for defender
RdDCombat._storeAttaque(this.attackerId, attackerRoll); RdDCombat._storeAttaque(this.attackerId, attackerRoll);
RdDCombat._storeDefense(defenderRoll) RdDCombat._storeDefense(defenderRoll.passeArme, defenderRoll);
attackerRoll.show = { attackerRoll.show = {
cible: this.target ? this.defender.data.name : 'la cible', cible: this.target ? this.defender.data.name : 'la cible',
@ -996,7 +1022,7 @@ export class RdDCombat {
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true }); this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true });
RdDCombat._storeDefense(defenderRoll); RdDCombat._storeDefense(defenderRoll.passeArme, defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1068,7 +1094,7 @@ export class RdDCombat {
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true }) this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true })
RdDCombat._storeDefense(defenderRoll); RdDCombat._storeDefense(defenderRoll.passeArme, defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -2,7 +2,6 @@
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
import { RdDUtility } from "./rdd-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDTokenHud { export class RdDTokenHud {

View File

@ -614,10 +614,7 @@ export class RdDUtility {
let actor = RdDUtility.getSelectedActor("Pour effectuer le paiement:"); let actor = RdDUtility.getSelectedActor("Pour effectuer le paiement:");
if (actor) { if (actor) {
actor.depenserDeniers(sumdenier, objData, quantite, fromActorId); actor.depenserDeniers(sumdenier, objData, quantite, fromActorId);
let chatMessageId = RdDUtility.findChatMessageId(event.currentTarget); ChatUtility.removeChatMessageId(RdDUtility.findChatMessageId(event.currentTarget));
if (chatMessageId) {
ChatUtility.removeChatMessageId(chatMessageId);
}
} }
}); });
} }

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.4.13", "version": "1.4.14",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.8.0", "minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "0.8.5", "compatibleCoreVersion": "0.8.5",