Fix: reset des utilisations d'items
This commit is contained in:
parent
894d4f3941
commit
09365eb744
@ -10,6 +10,7 @@
|
||||
- Fix
|
||||
- les achats des commerces sont de nouveau possibles
|
||||
- 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
|
||||
- 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() {
|
||||
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 } }
|
||||
isDead() { return false }
|
||||
isSonne() { return false }
|
||||
blessuresASoigner() { return [] }
|
||||
getEtatGeneral(options = { ethylisme: false }) { return 0 }
|
||||
isActorCombat() { return true }
|
||||
|
||||
async computeArmure(attackerRoll) { return this.getProtectionNaturelle() }
|
||||
async remiseANeuf() { }
|
||||
@ -405,12 +407,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
return RdDItemArme.getCompetenceArme(arme, competenceName)
|
||||
}
|
||||
|
||||
verifierForceMin(item) {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async resetItemUse() { }
|
||||
async incDecItemUse(itemId, inc = 1) { }
|
||||
getItemUse(itemId) { return 0; }
|
||||
verifierForceMin(item) { }
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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é`);
|
||||
return;
|
||||
}
|
||||
await this.setEffect(STATUSES.StatusStunned, sonne);
|
||||
await this.setEffect(STATUSES.StatusStunned, sonne)
|
||||
}
|
||||
|
||||
getSonne() {
|
||||
return this.getEffect(STATUSES.StatusStunned);
|
||||
isSonne() {
|
||||
return this.getEffect(STATUSES.StatusStunned)
|
||||
}
|
||||
|
||||
isEffectAllowed(effectId) { return true }
|
||||
|
@ -205,11 +205,8 @@ export class RdDBaseActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async onPreUpdateItem(item, change, options, id) { }
|
||||
|
||||
async onCreateItem(item, options, id) { }
|
||||
|
||||
async onDeleteItem(item, options, id) { }
|
||||
|
||||
async onUpdateActor(update, options, actorId) { }
|
||||
|
||||
async onTimeChanging(oldTimestamp, newTimestamp) {
|
||||
@ -708,5 +705,9 @@ export class RdDBaseActor extends Actor {
|
||||
}
|
||||
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("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()
|
||||
}
|
||||
}
|
||||
async onDeleteCombat() {
|
||||
if (Misc.isFirstConnectedGM()) {
|
||||
if (game.combats.size <= 1) {
|
||||
game.actors.forEach(actor => actor.resetItemUse())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async finDeRound(options = { terminer: false }) {
|
||||
this.turns.forEach(turn => turn.actor.resetItemUse());
|
||||
|
||||
for (let combatant of this.combatants) {
|
||||
if (combatant.actor) {
|
||||
await combatant.actor.finDeRound(options);
|
||||
}
|
||||
else {
|
||||
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) {
|
||||
const efficacite = (arme?.system.magique) ? arme.system.ecaille_efficacite : 0
|
||||
const etatGeneral = actor.getEtatGeneral() ?? 0
|
||||
@ -125,7 +137,6 @@ export class RdDCombatManager extends Combat {
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log("Combatat", c);
|
||||
const roll = combatant.getInitiativeRoll(rollFormula);
|
||||
if (!roll.total) {
|
||||
await roll.evaluate();
|
||||
@ -236,29 +247,12 @@ export class RdDCombatManager extends Combat {
|
||||
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) {
|
||||
const actor = combatant.actor;
|
||||
if (!actor.isActorCombat()) {
|
||||
return
|
||||
}
|
||||
let actions = RdDCombatManager.listActionsPossessions(actor);
|
||||
if (actions.length > 0) {
|
||||
return actions;
|
||||
@ -281,6 +275,26 @@ export class RdDCombatManager extends Combat {
|
||||
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;
|
||||
@ -457,8 +471,8 @@ export class RdDCombat {
|
||||
if (Misc.isFirstConnectedGM()) {
|
||||
let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId);
|
||||
if (turn?.actor) {
|
||||
RdDCombat.displayActorCombatStatus(combat, turn.actor, turn.token);
|
||||
// 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))
|
||||
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) {
|
||||
if (!actor?.isActorCombat()) {
|
||||
return
|
||||
}
|
||||
let formData = {
|
||||
combatId: combat._id,
|
||||
alias: token.name ?? actor.name,
|
||||
etatGeneral: actor.getEtatGeneral(),
|
||||
isSonne: actor.getSonne(),
|
||||
isSonne: actor.isSonne(),
|
||||
blessuresStatus: actor.computeResumeBlessure(),
|
||||
SConst: actor.getSConst(),
|
||||
actorId: actor.id,
|
||||
|
Loading…
Reference in New Issue
Block a user