This commit is contained in:
WBHarry 2026-07-21 23:49:28 +02:00 committed by GitHub
commit cae4af881a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 52 additions and 24 deletions

View file

@ -3284,7 +3284,9 @@
"lackingItemTransferPermission": "User {user} lacks owner permission needed to transfer items to {target}",
"noTokenTargeted": "No token is targeted",
"behaviorRegionRequiresGM": "Creating a Region with an attached Behavior requires an online GM",
"reloadRequired": "The {weapon} must be reloaded to be used!"
"reloadRequired": "The {weapon} must be reloaded to be used!",
"reloadRequiredRollResponse": "Reload Check: 1d6 -> {roll}. Reload required.",
"noReloadRequiredRollResponse": "Reload Check: 1d6 -> {roll}. No reload required."
},
"Progress": {
"migrationLabel": "Performing system migration. Please wait and do not close Foundry."
@ -3339,7 +3341,8 @@
"immune": "Immune",
"middleClick": "[Middle Click] Keep tooltip view",
"tokenSize": "The token size used on the canvas",
"previewTokenHelp": "Left-click to place, right-click to cancel"
"previewTokenHelp": "Left-click to place, right-click to cancel",
"noReloadRequired": "No Reload Required!"
}
}
}

View file

@ -287,7 +287,12 @@ 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 });
const { needsReload, rollValue } = await message.system.action.handleReload?.({ awaitRoll: true });
await message.update({ 'system.reloadCheckValue': rollValue });
if (needsReload)
ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.reloadRequiredRollResponse', { roll: rollValue }));
else
ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.noReloadRequiredRollResponse', { roll: rollValue }));
}
}

View file

@ -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 };
}
/**

View file

@ -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 needsReload() {
return this.reloadCheckValue === 1;
}
get action() {
const { actionActor, actionItem: itemAction } = this;
if (!this.source.action) return null;

View file

@ -139,7 +139,14 @@ 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?.() : {};
if (useReload) {
if (reloadResult.needsReload)
ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.reloadRequiredRollResponse', { roll: reloadResult.rollValue }));
else
ui.notifications.info(_loc('DAGGERHEART.UI.Notifications.noReloadRequiredRollResponse', { roll: reloadResult.rollValue }));
}
const cls = getDocumentClass('ChatMessage'),
msgData = {
@ -148,7 +155,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]
};

View file

@ -1,6 +1,8 @@
<div class="roll-buttons">
{{#if (eq automationSettings.reload 'button')}}
<button class="roll-reload-check" {{#if needsReload}}disabled{{/if}}>{{localize "DAGGERHEART.ACTIONS.Reload.checkReload"}}</button>
{{#if (and parent.system.hasReload (eq automationSettings.reload 'button'))}}
<button class="roll-reload-check" {{#if reloadCheckValue}}{{#unless parent.system.needsReload}}title="{{localize "DAGGERHEART.UI.Tooltip.noReloadRequired"}}"{{/unless}} disabled{{/if}}>
{{localize "DAGGERHEART.ACTIONS.Reload.checkReload"}}
</button>
{{/if}}
{{#if areas.length}}<button class="action-areas end-button"><i class="fa-solid fa-crosshairs"></i></button>{{/if}}
{{#if hasDamage}}

View file

@ -1,14 +1,10 @@
<div class="chat-roll">
<div class="roll-part-title"><span>{{title}}</span></div>
{{#if (eq action.type 'attack')}}
{{#if needsReload}}
<div class="roll-reload-container">
{{#if needsReload}}
<p class='reload-warning'>{{localize "DAGGERHEART.ACTIONS.Reload.reloadRequired"}}</p>
{{/if}}
</div>
{{/if}}
{{#if (and (eq action.type 'attack') parent.system.needsReload)}}
<div class="roll-reload-container">
<p class='reload-warning'>{{localize "DAGGERHEART.ACTIONS.Reload.reloadRequired"}}</p>
</div>
{{/if}}
{{#if actionDescription}}{{> 'systems/daggerheart/templates/ui/chat/parts/description-part.hbs'}}{{/if}}