Skip to content

Commit 3122673

Browse files
committed
Fix elemental weapon inline
1 parent 5d68222 commit 3122673

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

module/checks/common-sections.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,15 @@ const actions = (data, actor, item, targetData, flags, inspector = undefined) =>
420420
}
421421
}
422422

423+
// Remove malformed actions
424+
actions = actions.filter((a) => {
425+
if (!a) {
426+
ui.notifications.warn(`An action was malformed during the rendering of this chat message. Please report the issue!`);
427+
return false;
428+
}
429+
return true;
430+
});
431+
423432
// Set any flags
424433
Pipeline.toggleFlag(flags, Flags.ChatMessage.Targets);
425434
flags = Pipeline.setFlag(flags, Flags.ChatMessage.Source, sourceInfo);

module/documents/items/skill/base-skill-data-model.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,16 +399,16 @@ export class BaseSkillDataModel extends FUStandardItemDataModel {
399399
* @returns {Promise<WeaponResolution>}
400400
*/
401401
async getWeapon(actor) {
402-
const weapon = await WeaponResolver.prompt(actor, true);
403-
if (weapon === false) {
402+
const getWeapon = await WeaponResolver.prompt(actor, true);
403+
if (getWeapon === false) {
404404
let message = game.i18n.localize('FU.AbilityNoWeaponEquipped');
405405
ui.notifications.error(message);
406406
throw new Error(message);
407407
}
408-
if (weapon == null) {
408+
if (getWeapon == null) {
409409
throw new Error('no selection');
410410
}
411-
return weapon;
411+
return getWeapon;
412412
}
413413

414414
/**

module/enrichers/inline-weapon.mjs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FU, systemPath } from '../helpers/config.mjs';
1+
import { FU } from '../helpers/config.mjs';
22
import { InlineHelper, InlineSourceInfo } from '../helpers/inline-helper.mjs';
33
import { targetHandler } from '../helpers/target-handler.mjs';
44
import { CharacterDataModel } from '../documents/actors/character/character-data-model.mjs';
@@ -11,6 +11,7 @@ import { InlineEffects } from './inline-effects.mjs';
1111
import { StringUtils } from '../helpers/string-utils.mjs';
1212
import { systemAssetPath } from '../helpers/system-utils.mjs';
1313
import { CustomWeaponDataModel } from '../documents/items/customWeapon/custom-weapon-data-model.mjs';
14+
import FoundryUtils from '../helpers/foundry-utils.mjs';
1415

1516
const INLINE_WEAPON = 'InlineWeapon';
1617
const className = `inline-weapon`;
@@ -139,12 +140,14 @@ function createAlterDamageTypeEffect(weapon, type, label) {
139140
async function applyEffectToWeapon(actor, sourceInfo, choices, config) {
140141
if (actor.system instanceof CharacterDataModel) {
141142
const source = sourceInfo.resolve();
142-
const weapon = await WeaponResolver.prompt(actor, true);
143-
if (!weapon) {
143+
const promptWeapon = await WeaponResolver.prompt(actor, true);
144+
if (!promptWeapon) {
144145
ui.notifications.error('FU.AbilityNoWeaponEquipped', { localize: true });
145146
return;
146147
}
147148

149+
const weapon = promptWeapon.item;
150+
148151
const onApply = async (choice) => {
149152
choice = choice.trim();
150153
if (choice in FU.damageTypes) {
@@ -167,15 +170,13 @@ async function applyEffectToWeapon(actor, sourceInfo, choices, config) {
167170
if (isAny) {
168171
choices = Object.keys(FU.damageTypes);
169172
}
170-
const result = await foundry.applications.api.DialogV2.wait({
171-
window: { title: 'Select Damage Type' },
172-
content: await foundry.applications.handlebars.renderTemplate(systemPath('templates/dialog/dialog-inline-weapon-enchant.hbs')),
173-
rejectClose: false,
174-
buttons: choices.map((choice) => ({
175-
action: choice,
176-
label: game.i18n.localize(FU.damageTypes[choice]),
177-
})),
178-
});
173+
const options = choices.map((choice) => ({
174+
label: game.i18n.localize(FU.damageTypes[choice]),
175+
value: choice,
176+
icon: FU.affIcon[choice],
177+
}));
178+
const result = await FoundryUtils.selectIconOptionDialog('FU.SelectDamageType', options);
179+
179180
console.log(result);
180181
if (result) {
181182
onApply(result);

module/helpers/targeting.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async function filterTargetsByRule(actor, item, targets) {
7373
return targets;
7474
case 'weapon': {
7575
const weapon = await WeaponResolver.prompt(actor);
76-
return [weapon];
76+
return [weapon.item];
7777
}
7878
case 'special':
7979
return targets;

templates/dialog/dialog-select-option-icon.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<button type="button" class="fu-dialog__icon-option"
1010
data-tooltip="{{label}}"
1111
data-action="selectOption" data-value="{{value}}">
12-
<i class="{{icon}}"></i>
12+
<i class="fu-icon--m {{icon}}"></i>
1313
</button>
1414
{{/each}}
1515
</div>

0 commit comments

Comments
 (0)