Fix: reset des utilisations d'items
This commit is contained in:
parent
894d4f3941
commit
09365eb744
@ -10,6 +10,7 @@
|
|||||||
- Fix
|
- Fix
|
||||||
- les achats des commerces sont de nouveau possibles
|
- les achats des commerces sont de nouveau possibles
|
||||||
- la commande /astro fonctionne de nouveau
|
- la commande /astro fonctionne de nouveau
|
||||||
|
- le nombre d'utilisations d'items est réinitialisé à chaque round et fin de combat
|
||||||
|
|
||||||
## 12.0.16 - Le secret d'Astrobazzarh
|
## 12.0.16 - Le secret d'Astrobazzarh
|
||||||
- Fix: les jets envoyés messages uniquement au MJ ne sont plus envoyés à tous les autres joueurs (et dupliqués)
|
- Fix: les jets envoyés messages uniquement au MJ ne sont plus envoyés à tous les autres joueurs (et dupliqués)
|
||||||
|
@ -2615,7 +2615,7 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async resetItemUse() {
|
async resetItemUse() {
|
||||||
await this.setFlag(SYSTEM_RDD, 'itemUse', {});
|
await this.unsetFlag(SYSTEM_RDD, 'itemUse');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -78,8 +78,10 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
async jetEndurance(resteEndurance = undefined) { return { jetEndurance: 0, sonne: false } }
|
async jetEndurance(resteEndurance = undefined) { return { jetEndurance: 0, sonne: false } }
|
||||||
isDead() { return false }
|
isDead() { return false }
|
||||||
|
isSonne() { return false }
|
||||||
blessuresASoigner() { return [] }
|
blessuresASoigner() { return [] }
|
||||||
getEtatGeneral(options = { ethylisme: false }) { return 0 }
|
getEtatGeneral(options = { ethylisme: false }) { return 0 }
|
||||||
|
isActorCombat() { return true }
|
||||||
|
|
||||||
async computeArmure(attackerRoll) { return this.getProtectionNaturelle() }
|
async computeArmure(attackerRoll) { return this.getProtectionNaturelle() }
|
||||||
async remiseANeuf() { }
|
async remiseANeuf() { }
|
||||||
@ -405,12 +407,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
return RdDItemArme.getCompetenceArme(arme, competenceName)
|
return RdDItemArme.getCompetenceArme(arme, competenceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
verifierForceMin(item) {
|
verifierForceMin(item) { }
|
||||||
}
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async resetItemUse() { }
|
|
||||||
async incDecItemUse(itemId, inc = 1) { }
|
|
||||||
getItemUse(itemId) { return 0; }
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async encaisser() { await RdDEncaisser.encaisser(this) }
|
async encaisser() { await RdDEncaisser.encaisser(this) }
|
||||||
|
@ -276,11 +276,11 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
|||||||
ui.notifications.info(`${this.name} est hors combat, il ne reste donc pas sonné`);
|
ui.notifications.info(`${this.name} est hors combat, il ne reste donc pas sonné`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.setEffect(STATUSES.StatusStunned, sonne);
|
await this.setEffect(STATUSES.StatusStunned, sonne)
|
||||||
}
|
}
|
||||||
|
|
||||||
getSonne() {
|
isSonne() {
|
||||||
return this.getEffect(STATUSES.StatusStunned);
|
return this.getEffect(STATUSES.StatusStunned)
|
||||||
}
|
}
|
||||||
|
|
||||||
isEffectAllowed(effectId) { return true }
|
isEffectAllowed(effectId) { return true }
|
||||||
|
@ -205,11 +205,8 @@ export class RdDBaseActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async onPreUpdateItem(item, change, options, id) { }
|
async onPreUpdateItem(item, change, options, id) { }
|
||||||
|
|
||||||
async onCreateItem(item, options, id) { }
|
async onCreateItem(item, options, id) { }
|
||||||
|
|
||||||
async onDeleteItem(item, options, id) { }
|
async onDeleteItem(item, options, id) { }
|
||||||
|
|
||||||
async onUpdateActor(update, options, actorId) { }
|
async onUpdateActor(update, options, actorId) { }
|
||||||
|
|
||||||
async onTimeChanging(oldTimestamp, newTimestamp) {
|
async onTimeChanging(oldTimestamp, newTimestamp) {
|
||||||
@ -708,5 +705,9 @@ export class RdDBaseActor extends Actor {
|
|||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
async resetItemUse() { }
|
||||||
|
async incDecItemUse(itemId, inc = 1) { }
|
||||||
|
getItemUse(itemId) { return 0; }
|
||||||
|
async finDeRound(options = { terminer: false }) { }
|
||||||
|
isActorCombat() { return false }
|
||||||
}
|
}
|
@ -42,7 +42,8 @@ export class RdDCombatManager extends Combat {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => { RdDCombatManager.pushInitiativeOptions(html, options); });
|
Hooks.on("getCombatTrackerEntryContext", (html, options) => { RdDCombatManager.pushInitiativeOptions(html, options); });
|
||||||
Hooks.on("updateCombat", (combat, change, options, userId) => { RdDCombat.onUpdateCombat(combat, change, options, userId) });
|
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() })
|
||||||
|
Hooks.on("deleteCombat", (combat, html, id) => { combat.onDeleteCombat() })
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -61,20 +62,31 @@ export class RdDCombatManager extends Combat {
|
|||||||
RdDEmpoignade.deleteAllEmpoignades()
|
RdDEmpoignade.deleteAllEmpoignades()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async onDeleteCombat() {
|
||||||
/* -------------------------------------------- */
|
if (Misc.isFirstConnectedGM()) {
|
||||||
async finDeRound(options = { terminer: false }) {
|
if (game.combats.size <= 1) {
|
||||||
this.turns.forEach(turn => turn.actor.resetItemUse());
|
game.actors.forEach(actor => actor.resetItemUse())
|
||||||
|
|
||||||
for (let combatant of this.combatants) {
|
|
||||||
if (combatant.actor) {
|
|
||||||
await combatant.actor.finDeRound(options);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async finDeRound(options = { terminer: false }) {
|
||||||
|
|
||||||
|
for (let combatant of this.combatants) {
|
||||||
|
if (!combatant.actor) {
|
||||||
|
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`)
|
||||||
|
}
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static calculAjustementInit(actor, arme) {
|
static calculAjustementInit(actor, arme) {
|
||||||
const efficacite = (arme?.system.magique) ? arme.system.ecaille_efficacite : 0
|
const efficacite = (arme?.system.magique) ? arme.system.ecaille_efficacite : 0
|
||||||
const etatGeneral = actor.getEtatGeneral() ?? 0
|
const etatGeneral = actor.getEtatGeneral() ?? 0
|
||||||
@ -125,7 +137,6 @@ export class RdDCombatManager extends Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log("Combatat", c);
|
|
||||||
const roll = combatant.getInitiativeRoll(rollFormula);
|
const roll = combatant.getInitiativeRoll(rollFormula);
|
||||||
if (!roll.total) {
|
if (!roll.total) {
|
||||||
await roll.evaluate();
|
await roll.evaluate();
|
||||||
@ -236,29 +247,12 @@ export class RdDCombatManager extends Combat {
|
|||||||
return attaque;
|
return attaque;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 listActionsCombat(combatant) {
|
static listActionsCombat(combatant) {
|
||||||
const actor = combatant.actor;
|
const actor = combatant.actor;
|
||||||
|
if (!actor.isActorCombat()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let actions = RdDCombatManager.listActionsPossessions(actor);
|
let actions = RdDCombatManager.listActionsPossessions(actor);
|
||||||
if (actions.length > 0) {
|
if (actions.length > 0) {
|
||||||
return actions;
|
return actions;
|
||||||
@ -281,6 +275,26 @@ export class RdDCombatManager extends Combat {
|
|||||||
return RdDCombatManager._indexActions(actions);
|
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) {
|
static _indexActions(actions) {
|
||||||
for (let index = 0; index < actions.length; index++) {
|
for (let index = 0; index < actions.length; index++) {
|
||||||
actions[index].index = index;
|
actions[index].index = index;
|
||||||
@ -457,8 +471,8 @@ export class RdDCombat {
|
|||||||
if (Misc.isFirstConnectedGM()) {
|
if (Misc.isFirstConnectedGM()) {
|
||||||
let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId);
|
let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId);
|
||||||
if (turn?.actor) {
|
if (turn?.actor) {
|
||||||
RdDCombat.displayActorCombatStatus(combat, turn.actor, turn.token);
|
|
||||||
// TODO Playaudio for player??
|
// TODO Playaudio for player??
|
||||||
|
RdDCombat.displayActorCombatStatus(combat, turn.actor, turn.token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -978,7 +992,7 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_filterArmesParade(defender, competence) {
|
_filterArmesParade(defender, competence, arme) {
|
||||||
let items = defender.items.filter(it => RdDItemArme.isArmeUtilisable(it) || RdDItemCompetenceCreature.isCompetenceParade(it))
|
let items = defender.items.filter(it => RdDItemArme.isArmeUtilisable(it) || RdDItemCompetenceCreature.isCompetenceParade(it))
|
||||||
items.forEach(item => item.system.nbUsage = defender.getItemUse(item.id)); // Ajout du # d'utilisation ce round
|
items.forEach(item => item.system.nbUsage = defender.getItemUse(item.id)); // Ajout du # d'utilisation ce round
|
||||||
|
|
||||||
@ -1335,11 +1349,14 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async displayActorCombatStatus(combat, actor, token) {
|
static async displayActorCombatStatus(combat, actor, token) {
|
||||||
|
if (!actor?.isActorCombat()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
let formData = {
|
let formData = {
|
||||||
combatId: combat._id,
|
combatId: combat._id,
|
||||||
alias: token.name ?? actor.name,
|
alias: token.name ?? actor.name,
|
||||||
etatGeneral: actor.getEtatGeneral(),
|
etatGeneral: actor.getEtatGeneral(),
|
||||||
isSonne: actor.getSonne(),
|
isSonne: actor.isSonne(),
|
||||||
blessuresStatus: actor.computeResumeBlessure(),
|
blessuresStatus: actor.computeResumeBlessure(),
|
||||||
SConst: actor.getSConst(),
|
SConst: actor.getSConst(),
|
||||||
actorId: actor.id,
|
actorId: actor.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user