@@ -2,16 +2,16 @@ import type { ApplicationV1HeaderButton } from "@client/appv1/api/application-v1
22import type { ActorSheetOptions } from "@client/appv1/sheets/actor-sheet.d.mts" ;
33import type { EffectTrait } from "@item/abstract-effect/types.ts" ;
44import { ErrorPF2e , htmlClosest , htmlQuery } from "@util" ;
5- import type { CharacterStrike } from "../data.ts" ;
5+ import type { CharacterAttack } from "../data.ts" ;
66import type { CharacterPF2e } from "../document.ts" ;
77import type { ElementalBlastConfig } from "../elemental-blast.ts" ;
88import { CharacterSheetPF2e , type CharacterSheetData } from "../sheet.ts" ;
99
1010class AttackPopout < TActor extends CharacterPF2e > extends CharacterSheetPF2e < TActor > {
11- type : "strike" | "blast" = "strike" ;
12- #strikeItemId = "" ;
13- #strikeSlug = "" ;
14- #strike ?: CharacterStrike ;
11+ type : AttackPopoutOptions [ "type" ] = "strike" ;
12+ #itemId = "" ;
13+ #slug = "" ;
14+ #attack ?: CharacterAttack ;
1515 #elementTrait?: EffectTrait ;
1616 #blasts: ElementalBlastConfig [ ] = [ ] ;
1717
@@ -21,9 +21,9 @@ class AttackPopout<TActor extends CharacterPF2e> extends CharacterSheetPF2e<TAct
2121
2222 override get id ( ) : string {
2323 const id = super . id ;
24- return this . type === "strike "
25- ? `${ id } -strike -${ this . #strikeItemId } - ${ this . #strikeSlug } `
26- : `${ id } -blast -${ this . #elementTrait } ` ;
24+ return this . type === "blast "
25+ ? `${ id } -blast -${ this . #elementTrait } `
26+ : `${ id } -${ this . type } -${ this . #itemId } - ${ this . #slug } ` ;
2727 }
2828
2929 static override get defaultOptions ( ) : ActorSheetOptions {
@@ -43,7 +43,7 @@ class AttackPopout<TActor extends CharacterPF2e> extends CharacterSheetPF2e<TAct
4343 if ( this . type === "blast" ) {
4444 return this . #blasts. at ( 0 ) ?. label ?? null ;
4545 }
46- return this . #strike ?. label ?? null ;
46+ return this . #attack ?. label ?? null ;
4747 }
4848
4949 constructor ( object : TActor , options : AttackPopoutOptions ) {
@@ -59,14 +59,14 @@ class AttackPopout<TActor extends CharacterPF2e> extends CharacterSheetPF2e<TAct
5959 }
6060 this . #elementTrait = options . elementTrait ;
6161 } else {
62- if ( ! options . strikeSlug ) {
63- throw ErrorPF2e ( 'AttackPopout of type "strike" is missing mandatory "strikeSlug " option.' ) ;
62+ if ( ! options . slug ) {
63+ throw ErrorPF2e ( 'AttackPopout of type "strike" is missing mandatory "slug " option.' ) ;
6464 }
65- if ( ! options . strikeItemId ) {
66- throw ErrorPF2e ( 'AttackPopout of type "strike" is missing mandatory "strikeItemId " option.' ) ;
65+ if ( ! options . itemId ) {
66+ throw ErrorPF2e ( 'AttackPopout of type "strike" is missing mandatory "itemId " option.' ) ;
6767 }
68- this . #strikeSlug = options . strikeSlug ;
69- this . #strikeItemId = options . strikeItemId ;
68+ this . #slug = options . slug ;
69+ this . #itemId = options . itemId ;
7070 }
7171 this . type = options . type ;
7272 }
@@ -80,17 +80,15 @@ class AttackPopout<TActor extends CharacterPF2e> extends CharacterSheetPF2e<TAct
8080 base . toggles . actions = base . toggles . actions ?. filter ( ( t ) => t . domain === "elemental-blast" ) ?? [ ] ;
8181 } else {
8282 base . elementalBlasts = [ ] ;
83- if ( this . #strikeSlug && this . #strikeItemId) {
84- this . #strike = base . data . actions . find (
85- ( a ) => a . item . id === this . #strikeItemId && a . slug === this . #strikeSlug,
86- ) ;
83+ if ( this . #slug && this . #itemId) {
84+ this . #attack = base . data . actions . find ( ( a ) => a . item . id === this . #itemId && a . slug === this . #slug) ;
8785 }
8886 }
8987
9088 return {
9189 ...base ,
92- strike : this . #strike ,
93- strikeIndex : base . data . actions . findIndex ( ( a ) => a === this . #strike ) ,
90+ attack : this . #attack ,
91+ index : base . data . actions . findIndex ( ( a ) => a === this . #attack ) ,
9492 popoutType : this . type ,
9593 } ;
9694 }
@@ -120,9 +118,9 @@ interface BaseAttackPopoutOptions extends Partial<ActorSheetOptions> {
120118}
121119
122120interface StrikePopoutOptions extends BaseAttackPopoutOptions {
123- type : "strike" ;
124- strikeSlug ?: string ;
125- strikeItemId ?: string ;
121+ type : "strike" | "area-fire" | "auto-fire" ;
122+ slug ?: string ;
123+ itemId ?: string ;
126124}
127125
128126interface BlastPopoutOptions extends BaseAttackPopoutOptions {
@@ -133,8 +131,8 @@ interface BlastPopoutOptions extends BaseAttackPopoutOptions {
133131type AttackPopoutOptions = StrikePopoutOptions | BlastPopoutOptions ;
134132
135133interface AttackPopoutData < TActor extends CharacterPF2e > extends CharacterSheetData < TActor > {
136- strike ?: CharacterStrike ;
137- strikeIndex ?: number ;
134+ attack ?: CharacterAttack ;
135+ index ?: number ;
138136 popoutType : AttackPopoutOptions [ "type" ] ;
139137}
140138
0 commit comments