Merge pull request 'Version 10.6.19 - La cerise de Pralinor' (#630) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10

Reviewed-on: #630
This commit is contained in:
uberwald 2023-02-24 09:56:29 +01:00
commit a810e20eca
5 changed files with 41 additions and 73 deletions

View File

@ -123,21 +123,27 @@ export class RdDBaseActorSheet extends ActorSheet {
.map(t => Misc.arrayOrEmpty(itemTypes[t])) .map(t => Misc.arrayOrEmpty(itemTypes[t]))
.reduce((a, b) => a.concat(b), []) .reduce((a, b) => a.concat(b), [])
.sort(Misc.ascending(it => it.name)); .sort(Misc.ascending(it => it.name));
} }
/* -------------------------------------------- */ /** @override */ /* -------------------------------------------- */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html; this.html = html;
this.html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(this.getItemId(event));
this.render(true);
});
this.html.find('.item-edit').click(async event => this.getItem(event)?.sheet.render(true))
this.html.find('.item-montrer').click(async event => this.getItem(event)?.postItemToChat());
this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat());
this.html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(this.getItemId(event));
this.render(true);
});
this.html.find('.item-edit').click(async event => this.getItem(event)?.sheet.render(true))
this.html.find('.item-montrer').click(async event => this.getItem(event)?.postItemToChat());
this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat());
this.html.find('.recherche')
.each((index, field) => {
this._rechercheSelectArea(field);
})
.keyup(async event => this._rechercherKeyup(event))
.change(async event => this._rechercherKeyup(event));
this.html.find('.recherche').prop( "disabled", false );
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
@ -160,12 +166,6 @@ export class RdDBaseActorSheet extends ActorSheet {
this.html.find('.monnaie-moins').click(async event => { this.html.find('.monnaie-moins').click(async event => {
this.actor.monnaieIncDec(this.getItemId(event), -1); this.actor.monnaieIncDec(this.getItemId(event), -1);
}); });
this.html.find('.recherche')
.each((index, field) => {
this._rechercheSelectArea(field);
})
.keyup(async event => this._rechercherKeyup(event))
.change(async event => this._rechercherKeyup(event));
} }
_rechercherKeyup(event) { _rechercherKeyup(event) {

View File

@ -39,35 +39,31 @@ export class RdDCombatManager extends Combat {
static init() { static init() {
/* -------------------------------------------- */ /* -------------------------------------------- */
Hooks.on("getCombatTrackerEntryContext", (html, options) => { Hooks.on("getCombatTrackerEntryContext", (html, options) => { RdDCombatManager.pushInitiativeOptions(html, options); });
RdDCombatManager.pushInitiativeOptions(html, options); Hooks.on("updateCombat", (combat, change, options, userId) => { RdDCombat.onUpdateCombat(combat, change, options, userId) });
}); Hooks.on("preDeleteCombat", (combat, html, id) => { combat.onPreDeleteCombat() });
Hooks.on("preDeleteCombat", (combat, html, id) => {
combat.onPreDeleteCombat()
});
}
/* -------------------------------------------- */
cleanItemUse() {
for (let turn of this.turns) {
turn.actor.resetItemUse()
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async nextRound() { async nextRound() {
this.cleanItemUse();
await this.finDeRound(); await this.finDeRound();
return await super.nextRound(); return await super.nextRound();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async onPreDeleteCombat() { async onPreDeleteCombat() {
await this.finDeRound({ terminer: true }); if (Misc.isUniqueConnectedGM()) {
await this.finDeRound({ terminer: true });
ChatUtility.removeChatMessageContaining(`<div data-combatid="${this.id}" data-combatmessage="actor-turn-summary">`)
game.messages.filter(m => ChatUtility.getMessageData(m, 'attacker-roll') != undefined && ChatUtility.getMessageData(m, 'defender-roll') != undefined)
.forEach(it => it.delete());
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async finDeRound(options = { terminer: false }) { async finDeRound(options = { terminer: false }) {
this.turns.forEach(turn => turn.actor.resetItemUse());
for (let combatant of this.combatants) { for (let combatant of this.combatants) {
if (combatant.actor) { if (combatant.actor) {
await combatant.actor.finDeRound(options); await combatant.actor.finDeRound(options);
@ -144,9 +140,8 @@ export class RdDCombatManager extends Combat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static calculInitiative(niveau, caracValue, bonusEcaille = 0) { static calculInitiative(niveau, caracValue, bonus = 0) {
let base = niveau + Math.floor(caracValue / 2); let base = niveau + Math.floor(caracValue / 2) + bonus;
base += bonusEcaille;
return "1d6" + (base >= 0 ? "+" : "") + base; return "1d6" + (base >= 0 ? "+" : "") + base;
} }
@ -420,18 +415,11 @@ export class RdDCombatManager extends Combat {
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDCombat { export class RdDCombat {
static init() {
Hooks.on("updateCombat", (combat, change, options, userId) => { RdDCombat.onUpdateCombat(combat, change, options, userId) });
Hooks.on("preDeleteCombat", (combat, options, userId) => { RdDCombat.onPreDeleteCombat(combat, options, userId); });
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static onSocketMessage(sockmsg) { static onSocketMessage(sockmsg) {
switch (sockmsg.msg) { switch (sockmsg.msg) {
case "msg_encaisser": case "msg_encaisser": return RdDCombat.onMsgEncaisser(sockmsg.data);
return RdDCombat.onMsgEncaisser(sockmsg.data); case "msg_defense": return RdDCombat.onMsgDefense(sockmsg.data);
case "msg_defense":
return RdDCombat.onMsgDefense(sockmsg.data);
} }
} }
@ -442,16 +430,6 @@ export class RdDCombat {
} }
} }
/* -------------------------------------------- */
static onPreDeleteCombat(combat, options, userId) {
if (Misc.isUniqueConnectedGM()) {
combat.cleanItemUse();
ChatUtility.removeChatMessageContaining(`<div data-combatid="${combat.id}" data-combatmessage="actor-turn-summary">`)
game.messages.filter(m => ChatUtility.getMessageData(m, 'attacker-roll') != undefined && ChatUtility.getMessageData(m, 'defender-roll') != undefined)
.forEach(it => it.delete());
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static combatNouveauTour(combat) { static combatNouveauTour(combat) {
if (Misc.isUniqueConnectedGM()) { if (Misc.isUniqueConnectedGM()) {
@ -756,15 +734,6 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async attaque(competence, arme) { async attaque(competence, arme) {
// const nonIncarnee = this.defender.isEntite([ENTITE_NONINCARNE])
// const blurette = this.defender.isEntite([ENTITE_BLURETTE])
// if (nonIncarnee || blurette) {
// ChatMessage.create( {
// content: `<strong>La cible est ${nonIncarnee ? 'non incarnée' : 'une blurette'}.
// Il est impossible de l'atteindre.`,
// whisper: ChatMessage.getWhisperRecipients("GM")})
// }
if (!await this.attacker.accorder(this.defender, 'avant-attaque')) { if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
return; return;
} }
@ -970,9 +939,8 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
_filterArmesParade(defender, competence) { _filterArmesParade(defender, competence) {
let items = defender.items.filter(it => RdDItemArme.isArmeUtilisable(it) || RdDItemCompetenceCreature.isCompetenceParade(it)) let items = defender.items.filter(it => RdDItemArme.isArmeUtilisable(it) || RdDItemCompetenceCreature.isCompetenceParade(it))
for (let item of items) { items.forEach(item => item.system.nbUsage = defender.getItemUse(item.id)); // Ajout du # d'utilisation ce round
item.system.nbUsage = defender.getItemUse(item.id); // Ajout du # d'utilisation ce round
}
switch (competence.system.categorie) { switch (competence.system.categorie) {
case 'tir': case 'tir':
case 'lancer': case 'lancer':

View File

@ -180,7 +180,6 @@ export class SystemReveDeDragon {
RdDUtility.init(); RdDUtility.init();
RdDDice.init(); RdDDice.init();
RdDCommands.init(); RdDCommands.init();
RdDCombat.init();
RdDCombatManager.init(); RdDCombatManager.init();
RdDTokenHud.init(); RdDTokenHud.init();
RdDBaseActor.init(); RdDBaseActor.init();

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
{ {
"id": "foundryvtt-reve-de-dragon", "id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"version": "10.6.18", "version": "10.6.19",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.18.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.19.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",