mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 10:29:54 +02:00
[Fix] Reload Fixes (#2099)
This commit is contained in:
parent
d50545af4e
commit
7f61715adf
10 changed files with 150 additions and 77 deletions
11
lang/en.json
11
lang/en.json
|
|
@ -128,7 +128,12 @@
|
|||
},
|
||||
"Reload": {
|
||||
"checkReload": "Check Reload",
|
||||
"reloadRequired": "Reload Required!"
|
||||
"reloadRequired": "Reload Required!",
|
||||
"notRolled": "Not Rolled",
|
||||
"checkFailed": "Check Failed",
|
||||
"checkPassed": "Check Passed",
|
||||
"rerollConfirmationTitle": "Reroll Reload Check",
|
||||
"rerollConfirmationText": "Are you sure you want to reload the reload check?"
|
||||
},
|
||||
"RollField": {
|
||||
"diceRolling": {
|
||||
|
|
@ -1328,7 +1333,7 @@
|
|||
},
|
||||
"ReloadChoices": {
|
||||
"off": { "label": "Don't Use" },
|
||||
"button": { "label": "Use button" },
|
||||
"manual": { "label": "Manual" },
|
||||
"auto": { "label": "Automatic" }
|
||||
},
|
||||
"RollTypes": {
|
||||
|
|
@ -2820,7 +2825,7 @@
|
|||
},
|
||||
"reload": {
|
||||
"label": "Reload Checking",
|
||||
"hint": "If the system should present a button for checking if the character will need to reload or do it automatically"
|
||||
"hint": "If the system should automatically roll reload checks or wait for the manual press of a button in chat"
|
||||
},
|
||||
"resourceScrollTexts": {
|
||||
"label": "Show Resource Change Scrolltexts",
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -271,28 +271,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.roll-reload-container {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
|
||||
.reload-warning {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 5px;
|
||||
width: fit-content;
|
||||
gap: 5px;
|
||||
cursor: pointer;
|
||||
padding: 5px;
|
||||
transition: all 0.3s ease;
|
||||
color: @beige;
|
||||
background: @red-40;
|
||||
outline: 1px solid @red;
|
||||
}
|
||||
}
|
||||
|
||||
.roll-part-extra {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
|
@ -643,20 +621,74 @@
|
|||
}
|
||||
|
||||
.roll-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
width: 100%;
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
|
||||
button {
|
||||
height: 36px;
|
||||
flex: 1 1 calc(50% - 5px);
|
||||
font-family: @font-body;
|
||||
font-weight: 700;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
&:nth-last-child(1):nth-child(odd) {
|
||||
flex-basis: 100%;
|
||||
.main-buttons {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
|
||||
&.end-button {
|
||||
flex: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.extra-button-row {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
|
||||
.image-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
img {
|
||||
height: 24px;
|
||||
filter: @dark-filter;
|
||||
}
|
||||
|
||||
.dice-result {
|
||||
position: absolute;
|
||||
font-size: 18px;
|
||||
color: @beige;
|
||||
filter: drop-shadow(0 0 1px @light-white);
|
||||
}
|
||||
}
|
||||
|
||||
.reload-data {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 5px;
|
||||
gap: 5px;
|
||||
cursor: pointer;
|
||||
padding: 5px;
|
||||
transition: all 0.3s ease;
|
||||
color: @golden;
|
||||
background: @golden-40;
|
||||
|
||||
&.failed-check {
|
||||
background: @red-40;
|
||||
color: @red;
|
||||
}
|
||||
|
||||
&.passed-check {
|
||||
background: @green-40;
|
||||
color: @green;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,40 @@
|
|||
<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}}
|
||||
{{#if areas.length}}<button class="action-areas end-button"><i class="fa-solid fa-crosshairs"></i></button>{{/if}}
|
||||
{{#if hasDamage}}
|
||||
{{#if damage.active}}
|
||||
<button class="duality-action damage-button">{{localize "DAGGERHEART.UI.Chat.damageRoll.dealDamage"}}</button>
|
||||
{{else}}
|
||||
<button class="duality-action duality-action-damage">{{localize "DAGGERHEART.UI.Chat.attackRoll.rollDamage"}}</button>
|
||||
<div class="main-buttons">
|
||||
{{#if areas.length}}<button class="action-areas end-button"><i class="fa-solid fa-crosshairs"></i></button>{{/if}}
|
||||
{{#if hasDamage}}
|
||||
{{#if damage.active}}
|
||||
<button class="duality-action damage-button">{{localize "DAGGERHEART.UI.Chat.damageRoll.dealDamage"}}</button>
|
||||
{{else}}
|
||||
<button class="duality-action duality-action-damage">{{localize "DAGGERHEART.UI.Chat.attackRoll.rollDamage"}}</button>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if hasHealing}}
|
||||
{{#if damage.active}}
|
||||
<button class="duality-action damage-button">{{localize "DAGGERHEART.UI.Chat.healingRoll.applyHealing"}}</button>
|
||||
{{else}}
|
||||
<button class="duality-action duality-action-damage">{{localize "DAGGERHEART.UI.Chat.attackRoll.rollHealing"}}</button>
|
||||
{{#if hasHealing}}
|
||||
{{#if damage.active}}
|
||||
<button class="duality-action damage-button">{{localize "DAGGERHEART.UI.Chat.healingRoll.applyHealing"}}</button>
|
||||
{{else}}
|
||||
<button class="duality-action duality-action-damage">{{localize "DAGGERHEART.UI.Chat.attackRoll.rollHealing"}}</button>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if (and hasEffect)}}<button class="duality-action-effect">{{localize "DAGGERHEART.UI.Chat.attackRoll.applyEffect"}}</button>{{/if}}
|
||||
</div>
|
||||
|
||||
{{#if parent.system.hasReload}}
|
||||
<div class="extra-button-row">
|
||||
<button class="roll-reload-check">
|
||||
<div class="image-container">
|
||||
<img class="dice-icon normal" src="{{concat 'systems/daggerheart/assets/icons/dice/default/d20.svg'}}" alt="">
|
||||
{{#if reloadCheckValue}}<div class="dice-result">{{reloadCheckValue}}</div>{{/if}}
|
||||
</div>
|
||||
|
||||
{{localize "DAGGERHEART.ACTIONS.Reload.checkReload"}}
|
||||
</button>
|
||||
<div class="reload-data {{#if reloadCheckValue}}{{ifThen parent.system.reloadCheckFailed 'failed-check' 'passed-check'}}{{/if}}">
|
||||
{{#unless reloadCheckValue}}
|
||||
{{localize "DAGGERHEART.ACTIONS.Reload.notRolled"}}
|
||||
{{else}}
|
||||
{{ifThen parent.system.reloadCheckFailed (localize "DAGGERHEART.ACTIONS.Reload.checkFailed") (localize "DAGGERHEART.ACTIONS.Reload.checkPassed")}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if (and hasEffect)}}<button class="duality-action-effect">{{localize "DAGGERHEART.UI.Chat.attackRoll.applyEffect"}}</button>{{/if}}
|
||||
</div>
|
||||
|
|
@ -1,15 +1,5 @@
|
|||
<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}}
|
||||
|
||||
{{#if actionDescription}}{{> 'systems/daggerheart/templates/ui/chat/parts/description-part.hbs'}}{{/if}}
|
||||
{{#if hasRoll}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue