mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-23 02:49:55 +02:00
[Fix] Reload Fixes (#2099)
This commit is contained in:
parent
d50545af4e
commit
7f61715adf
10 changed files with 150 additions and 77 deletions
|
|
@ -287,7 +287,19 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
|
||||
async onRollReloadCheck(_event, messageData) {
|
||||
const message = game.messages.get(messageData._id);
|
||||
const needsReload = await message.system.action.handleReload?.({ awaitRoll: true });
|
||||
await message.update({ 'system.needsReload': needsReload });
|
||||
|
||||
if (message.system.reloadCheckValue) {
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: _loc('DAGGERHEART.ACTIONS.Reload.rerollConfirmationTitle')
|
||||
},
|
||||
content: _loc('DAGGERHEART.ACTIONS.Reload.rerollConfirmationText')
|
||||
});
|
||||
|
||||
if (!confirmed) return;
|
||||
}
|
||||
|
||||
const { rollValue } = await message.system.action.handleReload?.({ awaitRoll: true });
|
||||
await message.update({ 'system.reloadCheckValue': rollValue });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ export const reloadChoices = {
|
|||
id: 'off',
|
||||
label: 'DAGGERHEART.CONFIG.ReloadChoices.off.label'
|
||||
},
|
||||
button: {
|
||||
id: 'button',
|
||||
label: 'DAGGERHEART.CONFIG.ReloadChoices.button.label'
|
||||
manual: {
|
||||
id: 'manual',
|
||||
label: 'DAGGERHEART.CONFIG.ReloadChoices.manual.label'
|
||||
},
|
||||
auto: {
|
||||
id: 'auto',
|
||||
|
|
|
|||
|
|
@ -74,13 +74,13 @@ export default class DHAttackAction extends DHDamageAction {
|
|||
else
|
||||
game.dice3d.showForRoll(roll, game.user, true);
|
||||
}
|
||||
|
||||
const needsToReload = roll.total === 1;
|
||||
if (needsToReload) {
|
||||
|
||||
const needsReload = roll.total === 1;
|
||||
if (needsReload) {
|
||||
this.item.update({ 'system.resource.value': 0 });
|
||||
}
|
||||
|
||||
return needsToReload;
|
||||
return { needsReload, rollValue: roll.total };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
hasEffect: new fields.BooleanField({ initial: false }),
|
||||
hasSave: new fields.BooleanField({ initial: false }),
|
||||
hasTarget: new fields.BooleanField({ initial: false }),
|
||||
needsReload: new fields.BooleanField({ initial: false }),
|
||||
reloadCheckValue: new fields.NumberField({ integer: true, nullable: true, initial: null }),
|
||||
isDirect: new fields.BooleanField({ initial: false }),
|
||||
onSave: new fields.StringField(),
|
||||
source: new fields.SchemaField({
|
||||
|
|
@ -76,10 +76,14 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
return fromUuidSync(this.source.actor);
|
||||
}
|
||||
|
||||
get actionItem() {
|
||||
get item() {
|
||||
const actionActor = this.actionActor;
|
||||
if (!actionActor || !this.source.item) return null;
|
||||
|
||||
return actionActor.items.get(this.source.item);
|
||||
}
|
||||
|
||||
get actionItem() {
|
||||
switch (this.source.originItem.type) {
|
||||
case CONFIG.DH.ITEM.originItemType.restMove:
|
||||
const restMoves = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves;
|
||||
|
|
@ -87,11 +91,18 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
|||
this.source.originItem.actionIndex
|
||||
];
|
||||
default:
|
||||
const item = actionActor.items.get(this.source.item);
|
||||
return item ? item.system.actionsList?.find(a => a.id === this.source.action) : null;
|
||||
return this.item?.system.actionsList?.find(a => a.id === this.source.action);
|
||||
}
|
||||
}
|
||||
|
||||
get hasReload() {
|
||||
return this.item?.system.hasReload;
|
||||
}
|
||||
|
||||
get reloadCheckFailed() {
|
||||
return this.reloadCheckValue === 1;
|
||||
}
|
||||
|
||||
get action() {
|
||||
const { actionActor, actionItem: itemAction } = this;
|
||||
if (!this.source.action) return null;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
reload: new fields.StringField({
|
||||
required: true,
|
||||
choices: CONFIG.DH.SETTINGS.reloadChoices,
|
||||
initial: CONFIG.DH.SETTINGS.reloadChoices.button.id,
|
||||
initial: CONFIG.DH.SETTINGS.reloadChoices.manual.id,
|
||||
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.label',
|
||||
hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.hint'
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export default class DHRoll extends BaseRoll {
|
|||
item?.system.hasReload &&
|
||||
action?.type === 'attack' &&
|
||||
reloadSetting === CONFIG.DH.SETTINGS.reloadChoices.auto.id;
|
||||
const needsReload = useReload ? await action?.handleReload?.() : false;
|
||||
const reloadResult = useReload ? await action?.handleReload?.() : {};
|
||||
|
||||
const cls = getDocumentClass('ChatMessage'),
|
||||
msgData = {
|
||||
|
|
@ -148,7 +148,11 @@ export default class DHRoll extends BaseRoll {
|
|||
title: roll.title,
|
||||
speaker: cls.getSpeaker({ actor: roll.data?.parent }),
|
||||
sound: config.mute ? null : CONFIG.sounds.dice,
|
||||
system: { ...config, actionDescription, needsReload },
|
||||
system: {
|
||||
...config,
|
||||
actionDescription,
|
||||
reloadCheckValue: reloadResult.rollValue
|
||||
},
|
||||
rolls: [roll]
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue