@@ -130,42 +130,42 @@ export class DISActor extends Actor {
130130 } ) ;
131131 }
132132
133- async showAttackDialog ( itemId ) {
133+ async showAttackDialogWithItem ( itemId ) {
134134 const item = this . items . get ( itemId ) ;
135135 if ( ! item ) {
136136 return ;
137137 }
138+ let attackAbility ;
139+ if ( item . data . data . weaponType === "melee" ) {
140+ attackAbility = "body" ;
141+ } else {
142+ attackAbility = "tech" ;
143+ }
144+ await this . showAttackDialog (
145+ item . name , attackAbility , item . data . data . damage ) ;
146+ }
147+
148+ async showAttackDialog ( attackName , attackAbility , attackDamage ) {
138149 const attackDialog = new AttackDialog ( ) ;
139150 attackDialog . actor = this ;
140- attackDialog . itemId = itemId ;
151+ attackDialog . attackName = attackName ;
152+ attackDialog . attackAbility = attackAbility ;
153+ attackDialog . attackDamage = attackDamage ;
141154 attackDialog . render ( true ) ;
142155 }
143156
144- async attack ( itemId , defenderDR , rollType , risky ) {
145- const item = this . items . get ( itemId ) ;
146- if ( ! item ) {
147- return ;
148- }
149-
157+ async rollAttack ( attackName , attackAbility , attackDamage , defenderDR , rollType , risky ) {
150158 let d20Formula = "1d20" ;
151159 if ( rollType === "advantage" ) {
152160 d20Formula = "2d20kh" ;
153161 } else if ( rollType === "disadvantage" ) {
154162 d20Formula = "2d20kl" ;
155163 }
156- let ability ;
157- if ( item . data . data . weaponType === "melee" ) {
158- ability = "body" ;
159- } else {
160- ability = "tech" ;
161- }
162- const weaponTypeKey = `DIS.WeaponType${ item . data . data . weaponType [ 0 ] . toUpperCase ( ) + item . data . data . weaponType . substring ( 1 ) } ` ;
163- const attackTitle = `${ game . i18n . localize ( weaponTypeKey ) } ${ game . i18n . localize ( "DIS.Attack" ) } ` ;
164- // TODO: localize
165- const attackText = `To hit: ${ d20Formula } +${ ability . toUpperCase ( ) } vs. DR${ defenderDR } ` ;
164+ const attackTitle = `${ game . i18n . localize ( "DIS.AttackWith" ) } ${ attackName } ` ;
165+ const attackText = `${ game . i18n . localize ( "DIS.ToHit" ) } : ${ d20Formula } +${ attackAbility . toUpperCase ( ) } ${ game . i18n . localize ( "DIS.Vs" ) } ${ game . i18n . localize ( "DIS.DR" ) } ${ defenderDR } ` ;
166166 const rollData = this . getRollData ( ) ;
167167 const attackRoll = new Roll (
168- `${ d20Formula } + @abilities.${ ability } .value` ,
168+ `${ d20Formula } + @abilities.${ attackAbility } .value` ,
169169 rollData
170170 ) ;
171171 attackRoll . evaluate ( { async : false } ) ;
@@ -180,7 +180,7 @@ export class DISActor extends Actor {
180180 if ( isCrit || attackRoll . total >= defenderDR ) {
181181 // hit
182182 attackOutcome = game . i18n . localize ( isCrit ? "DIS.AttackCriticalHit" : "DIS.AttackHit" ) ;
183- const baseDamage = item . data . data . damage ;
183+ const baseDamage = attackDamage ;
184184 let damageFormula = baseDamage ;
185185 if ( isCrit ) {
186186 damageFormula += ` + ${ baseDamage } ` ;
@@ -202,6 +202,7 @@ export class DISActor extends Actor {
202202 }
203203
204204 const chatData = {
205+ attackName,
205206 attackOutcome,
206207 attackRoll,
207208 attackText,
0 commit comments