11import { ProgressDataModel } from '../common/progress-data-model.mjs' ;
22import { MiscAbilityMigrations } from './misc-ability-migrations.mjs' ;
3- import { CheckHooks } from '../../../checks/check-hooks.mjs' ;
4- import { deprecationNotice } from '../../../helpers/deprecation-helper.mjs' ;
5- import { Checks } from '../../../checks/checks.mjs' ;
6- import { CheckConfiguration } from '../../../checks/check-configuration.mjs' ;
7- import { ChooseWeaponDialog } from '../skill/choose-weapon-dialog.mjs' ;
8- import { CHECK_DETAILS } from '../../../checks/default-section-order.mjs' ;
9- import { CommonSections } from '../../../checks/common-sections.mjs' ;
103import { ItemPartialTemplates } from '../item-partial-templates.mjs' ;
11- import { TraitUtils } from '../../../pipelines/traits.mjs' ;
124import { BaseSkillDataModel } from '../skill/base-skill-data-model.mjs' ;
13- import { CommonEvents } from '../../../checks/common-events.mjs' ;
14-
15- const skillForAttributeCheck = 'skillForAttributeCheck' ;
16-
17- /**
18- * @type RenderCheckHook
19- */
20- let onRenderAccuracyCheck = async ( data , check , actor , item , flags ) => {
21- if ( check . type === 'accuracy' && item ?. system instanceof MiscAbilityDataModel ) {
22- const inspector = CheckConfiguration . inspect ( check ) ;
23- const weapon = await fromUuid ( inspector . getWeaponReference ( ) ) ;
24- if ( check . critical ) {
25- CommonSections . opportunity ( data . sections , item . system . opportunity , CHECK_DETAILS ) ;
26- }
27- CommonSections . description ( data . sections , item . system . description , item . system . summary . value , CHECK_DETAILS ) ;
28- if ( item . system . hasClock . value ) {
29- CommonSections . clock ( data . sections , item . system . progress , CHECK_DETAILS ) ;
30- }
31-
32- // Tag info
33- let tags = [ ] ;
34- tags . push ( ...TraitUtils . toTags ( item . system . traits ) ) ;
35- if ( weapon ) {
36- if ( weapon . system . getTags instanceof Function ) {
37- tags . push ( ...weapon . system . getTags ( item . system . useWeapon . traits ) ) ;
38- }
39- }
40- CommonSections . tags ( data . sections , tags , CHECK_DETAILS ) ;
41- }
42- } ;
43- Hooks . on ( CheckHooks . renderCheck , onRenderAccuracyCheck ) ;
44-
45- /**
46- * @type RenderCheckHook
47- */
48- let onRenderAttributeCheck = async ( data , check , actor , item , flags ) => {
49- if ( check . type === 'attribute' && item ?. system instanceof MiscAbilityDataModel && check . additionalData [ skillForAttributeCheck ] ) {
50- const inspector = CheckConfiguration . inspect ( check ) ;
51- const ability = await fromUuid ( inspector . getWeaponReference ( ) ) ;
52- CommonSections . itemFlavor ( data . sections , ability ) ;
53- if ( check . critical ) {
54- CommonSections . opportunity ( data . sections , ability . system . opportunity , CHECK_DETAILS ) ;
55- }
56- CommonSections . description ( data . sections , ability . system . description , ability . system . summary . value , CHECK_DETAILS , true ) ;
57- if ( ability . system . hasClock . value ) {
58- CommonSections . clock ( data . sections , item . system . progress , CHECK_DETAILS ) ;
59- }
60- }
61- } ;
62-
63- Hooks . on ( CheckHooks . renderCheck , onRenderAttributeCheck ) ;
64-
65- /**
66- * @type RenderCheckHook
67- */
68- const onRenderDisplay = ( data , check , actor , item , flags ) => {
69- if ( check . type === 'display' && item ?. system instanceof MiscAbilityDataModel ) {
70- const skill = item . system ;
71- CommonSections . tags ( data . sections , skill . getCommonTags ( ) , CHECK_DETAILS ) ;
72- if ( item . system . hasResource . value ) {
73- CommonSections . resource ( data . sections , item . system . rp , CHECK_DETAILS ) ;
74- }
75- CommonSections . description ( data . sections , item . system . description , item . system . summary . value , CHECK_DETAILS ) ;
76- const inspector = CheckConfiguration . inspect ( check ) ;
77- const targets = inspector . getTargetsOrDefault ( ) ;
78- CommonSections . actions ( data , actor , item , targets , flags , inspector ) ;
79- CommonEvents . skill ( actor , item ) ;
80- }
81- } ;
82-
83- Hooks . on ( CheckHooks . renderCheck , onRenderDisplay ) ;
845
856/**
867 * @property {string } subtype.value
@@ -107,22 +28,6 @@ Hooks.on(CheckHooks.renderCheck, onRenderDisplay);
10728 * @property {Set<String> } traits
10829 */
10930export class MiscAbilityDataModel extends BaseSkillDataModel {
110- static {
111- deprecationNotice ( this , 'rollInfo.useWeapon.accuracy.value' , 'useWeapon.accuracy' ) ;
112- deprecationNotice ( this , 'rollInfo.useWeapon.damage.value' , 'useWeapon.damage' ) ;
113- deprecationNotice ( this , 'rollInfo.useWeapon.hrZero.value' , 'damage.hrZero' ) ;
114- deprecationNotice ( this , 'rollInfo.attributes.primary.value' , 'attributes.primary' ) ;
115- deprecationNotice ( this , 'rollInfo.attributes.secondary.value' , 'attributes.secondary' ) ;
116- deprecationNotice ( this , 'rollInfo.accuracy.value' , 'accuracy' ) ;
117- deprecationNotice ( this , 'rollInfo.damage.hasDamage.value' , 'damage.hasDamage' ) ;
118- deprecationNotice ( this , 'rollInfo.damage.value' , 'damage.value' ) ;
119- deprecationNotice ( this , 'rollInfo.damage.type.value' , 'damage.type' ) ;
120- deprecationNotice ( this , 'impdamage.hasImpDamage.value' ) ;
121- deprecationNotice ( this , 'impdamage.value' ) ;
122- deprecationNotice ( this , 'impdamage.impType.value' ) ;
123- deprecationNotice ( this , 'impdamage.type.value' ) ;
124- }
125-
12631 static defineSchema ( ) {
12732 const { SchemaField, StringField, BooleanField, NumberField, EmbeddedDataField } = foundry . data . fields ;
12833 return Object . assign ( super . defineSchema ( ) , {
@@ -140,75 +45,8 @@ export class MiscAbilityDataModel extends BaseSkillDataModel {
14045 return source ;
14146 }
14247
143- /**
144- * @param {KeyboardModifiers } modifiers
145- * @return {Promise<void> }
146- */
147- async roll ( modifiers ) {
148- if ( this . hasRoll . value ) {
149- if ( this . useWeapon . accuracy ) {
150- return Checks . accuracyCheck ( this . parent . actor , this . parent , this . #initializeAccuracyCheck( modifiers ) ) ;
151- } else {
152- return Checks . attributeCheck (
153- this . parent . actor ,
154- {
155- primary : this . attributes . primary ,
156- secondary : this . attributes . secondary ,
157- } ,
158- this . parent ,
159- this . #initializeAttributeCheck( modifiers ) ,
160- ) ;
161- }
162- }
163- return Checks . display ( this . parent . actor , this . parent , this . #initializeSkillDisplay( modifiers ) ) ;
164- }
165-
166- /**
167- * @param {KeyboardModifiers } modifiers
168- * @return {CheckCallback }
169- * @remarks Expects a weapon
170- */
171- #initializeSkillDisplay( modifiers ) {
172- return async ( check , actor , item ) => {
173- const config = CheckConfiguration . configure ( check ) ;
174- await this . configureDisplayCheck ( config , actor , item ) ;
175- } ;
176- }
177-
178- /**
179- * @return {CheckCallback }
180- */
181- #initializeAttributeCheck( modifiers ) {
182- return async ( check , actor , item ) => {
183- await this . configureAttributeCheck ( modifiers , check , actor , item ) ;
184- } ;
185- }
186-
187- /**
188- * @param modifiers
189- * @return {CheckCallback }
190- */
191- #initializeAccuracyCheck( modifiers ) {
192- return async ( check , actor , item ) => {
193- const weapon = await ChooseWeaponDialog . prompt ( actor , true ) ;
194- if ( weapon === false ) {
195- let message = game . i18n . localize ( 'FU.AbilityNoWeaponEquipped' ) ;
196- ui . notifications . error ( message ) ;
197- throw new Error ( message ) ;
198- }
199- if ( weapon == null ) {
200- throw new Error ( 'no selection' ) ;
201- }
202- const { check : weaponCheck , error } = await Checks . prepareCheckDryRun ( 'accuracy' , actor , weapon ) ;
203- if ( error ) {
204- throw error ;
205- }
206-
207- check . primary = weaponCheck . primary ;
208- check . secondary = weaponCheck . secondary ;
209-
210- return this . configureAccuracyCheck ( modifiers , check , actor , item , weapon ) ;
211- } ;
48+ getTags ( ) {
49+ return super . getTags ( ) ;
21250 }
21351
21452 get attributePartials ( ) {
0 commit comments