mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-24 11: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": {
|
"Reload": {
|
||||||
"checkReload": "Check 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": {
|
"RollField": {
|
||||||
"diceRolling": {
|
"diceRolling": {
|
||||||
|
|
@ -1328,7 +1333,7 @@
|
||||||
},
|
},
|
||||||
"ReloadChoices": {
|
"ReloadChoices": {
|
||||||
"off": { "label": "Don't Use" },
|
"off": { "label": "Don't Use" },
|
||||||
"button": { "label": "Use button" },
|
"manual": { "label": "Manual" },
|
||||||
"auto": { "label": "Automatic" }
|
"auto": { "label": "Automatic" }
|
||||||
},
|
},
|
||||||
"RollTypes": {
|
"RollTypes": {
|
||||||
|
|
@ -2820,7 +2825,7 @@
|
||||||
},
|
},
|
||||||
"reload": {
|
"reload": {
|
||||||
"label": "Reload Checking",
|
"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": {
|
"resourceScrollTexts": {
|
||||||
"label": "Show Resource Change Scrolltexts",
|
"label": "Show Resource Change Scrolltexts",
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,19 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
|
|
||||||
async onRollReloadCheck(_event, messageData) {
|
async onRollReloadCheck(_event, messageData) {
|
||||||
const message = game.messages.get(messageData._id);
|
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',
|
id: 'off',
|
||||||
label: 'DAGGERHEART.CONFIG.ReloadChoices.off.label'
|
label: 'DAGGERHEART.CONFIG.ReloadChoices.off.label'
|
||||||
},
|
},
|
||||||
button: {
|
manual: {
|
||||||
id: 'button',
|
id: 'manual',
|
||||||
label: 'DAGGERHEART.CONFIG.ReloadChoices.button.label'
|
label: 'DAGGERHEART.CONFIG.ReloadChoices.manual.label'
|
||||||
},
|
},
|
||||||
auto: {
|
auto: {
|
||||||
id: 'auto',
|
id: 'auto',
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ export default class DHAttackAction extends DHDamageAction {
|
||||||
game.dice3d.showForRoll(roll, game.user, true);
|
game.dice3d.showForRoll(roll, game.user, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const needsToReload = roll.total === 1;
|
const needsReload = roll.total === 1;
|
||||||
if (needsToReload) {
|
if (needsReload) {
|
||||||
this.item.update({ 'system.resource.value': 0 });
|
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 }),
|
hasEffect: new fields.BooleanField({ initial: false }),
|
||||||
hasSave: new fields.BooleanField({ initial: false }),
|
hasSave: new fields.BooleanField({ initial: false }),
|
||||||
hasTarget: 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 }),
|
isDirect: new fields.BooleanField({ initial: false }),
|
||||||
onSave: new fields.StringField(),
|
onSave: new fields.StringField(),
|
||||||
source: new fields.SchemaField({
|
source: new fields.SchemaField({
|
||||||
|
|
@ -76,10 +76,14 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
|
||||||
return fromUuidSync(this.source.actor);
|
return fromUuidSync(this.source.actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
get actionItem() {
|
get item() {
|
||||||
const actionActor = this.actionActor;
|
const actionActor = this.actionActor;
|
||||||
if (!actionActor || !this.source.item) return null;
|
if (!actionActor || !this.source.item) return null;
|
||||||
|
|
||||||
|
return actionActor.items.get(this.source.item);
|
||||||
|
}
|
||||||
|
|
||||||
|
get actionItem() {
|
||||||
switch (this.source.originItem.type) {
|
switch (this.source.originItem.type) {
|
||||||
case CONFIG.DH.ITEM.originItemType.restMove:
|
case CONFIG.DH.ITEM.originItemType.restMove:
|
||||||
const restMoves = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).restMoves;
|
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
|
this.source.originItem.actionIndex
|
||||||
];
|
];
|
||||||
default:
|
default:
|
||||||
const item = actionActor.items.get(this.source.item);
|
return this.item?.system.actionsList?.find(a => a.id === this.source.action);
|
||||||
return item ? item.system.actionsList?.find(a => a.id === this.source.action) : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get hasReload() {
|
||||||
|
return this.item?.system.hasReload;
|
||||||
|
}
|
||||||
|
|
||||||
|
get reloadCheckFailed() {
|
||||||
|
return this.reloadCheckValue === 1;
|
||||||
|
}
|
||||||
|
|
||||||
get action() {
|
get action() {
|
||||||
const { actionActor, actionItem: itemAction } = this;
|
const { actionActor, actionItem: itemAction } = this;
|
||||||
if (!this.source.action) return null;
|
if (!this.source.action) return null;
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
||||||
reload: new fields.StringField({
|
reload: new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
choices: CONFIG.DH.SETTINGS.reloadChoices,
|
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',
|
label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.label',
|
||||||
hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.hint'
|
hint: 'DAGGERHEART.SETTINGS.Automation.FIELDS.reload.hint'
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ export default class DHRoll extends BaseRoll {
|
||||||
item?.system.hasReload &&
|
item?.system.hasReload &&
|
||||||
action?.type === 'attack' &&
|
action?.type === 'attack' &&
|
||||||
reloadSetting === CONFIG.DH.SETTINGS.reloadChoices.auto.id;
|
reloadSetting === CONFIG.DH.SETTINGS.reloadChoices.auto.id;
|
||||||
const needsReload = useReload ? await action?.handleReload?.() : false;
|
const reloadResult = useReload ? await action?.handleReload?.() : {};
|
||||||
|
|
||||||
const cls = getDocumentClass('ChatMessage'),
|
const cls = getDocumentClass('ChatMessage'),
|
||||||
msgData = {
|
msgData = {
|
||||||
|
|
@ -148,7 +148,11 @@ export default class DHRoll extends BaseRoll {
|
||||||
title: roll.title,
|
title: roll.title,
|
||||||
speaker: cls.getSpeaker({ actor: roll.data?.parent }),
|
speaker: cls.getSpeaker({ actor: roll.data?.parent }),
|
||||||
sound: config.mute ? null : CONFIG.sounds.dice,
|
sound: config.mute ? null : CONFIG.sounds.dice,
|
||||||
system: { ...config, actionDescription, needsReload },
|
system: {
|
||||||
|
...config,
|
||||||
|
actionDescription,
|
||||||
|
reloadCheckValue: reloadResult.rollValue
|
||||||
|
},
|
||||||
rolls: [roll]
|
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 {
|
.roll-part-extra {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
@ -643,20 +621,74 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.roll-buttons {
|
.roll-buttons {
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 5px;
|
|
||||||
width: 100%;
|
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
height: 36px;
|
height: 32px;
|
||||||
flex: 1 1 calc(50% - 5px);
|
}
|
||||||
font-family: @font-body;
|
|
||||||
font-weight: 700;
|
|
||||||
|
|
||||||
&:nth-last-child(1):nth-child(odd) {
|
.main-buttons {
|
||||||
flex-basis: 100%;
|
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,7 +1,5 @@
|
||||||
<div class="roll-buttons">
|
<div class="roll-buttons">
|
||||||
{{#if (eq automationSettings.reload 'button')}}
|
<div class="main-buttons">
|
||||||
<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 areas.length}}<button class="action-areas end-button"><i class="fa-solid fa-crosshairs"></i></button>{{/if}}
|
||||||
{{#if hasDamage}}
|
{{#if hasDamage}}
|
||||||
{{#if damage.active}}
|
{{#if damage.active}}
|
||||||
|
|
@ -18,4 +16,25 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if (and hasEffect)}}<button class="duality-action-effect">{{localize "DAGGERHEART.UI.Chat.attackRoll.applyEffect"}}</button>{{/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}}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1,16 +1,6 @@
|
||||||
<div class="chat-roll">
|
<div class="chat-roll">
|
||||||
<div class="roll-part-title"><span>{{title}}</span></div>
|
<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 actionDescription}}{{> 'systems/daggerheart/templates/ui/chat/parts/description-part.hbs'}}{{/if}}
|
||||||
{{#if hasRoll}}
|
{{#if hasRoll}}
|
||||||
<div class="roll-part-header"><span>{{localize "Result"}}</span></div>
|
<div class="roll-part-header"><span>{{localize "Result"}}</span></div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue