1- import { GrimwildActor } from "./actor.mjs" ;
2-
31export class GrimwildChatMessage extends ChatMessage {
42 /** @inheritDoc */
53 async renderHTML ( ...args ) {
@@ -88,7 +86,7 @@ export class GrimwildChatMessage extends ChatMessage {
8886 return ;
8987 }
9088 }
91- else if ( [ ' applyMark' , ' applyHarm' ] . includes ( action ) ) {
89+ else if ( [ " applyMark" , " applyHarm" ] . includes ( action ) ) {
9290 if ( damageTaken ) {
9391 element . setAttribute ( "disabled" , true ) ;
9492 return ;
@@ -107,7 +105,7 @@ export class GrimwildChatMessage extends ChatMessage {
107105 return {
108106 updateSpark : this . _updateSpark ,
109107 applyMark : this . _applyHarm ,
110- applyHarm : this . _applyHarm ,
108+ applyHarm : this . _applyHarm
111109 } ;
112110 }
113111
@@ -199,25 +197,23 @@ export class GrimwildChatMessage extends ChatMessage {
199197 let harmUpdate = { } ;
200198 // Handle marks.
201199 if ( stat ) {
202- if ( [ ' bra' , ' agi' , ' wit' , ' pre' ] . includes ( stat ) ) {
200+ if ( [ " bra" , " agi" , " wit" , " pre" ] . includes ( stat ) ) {
203201 const isMarked = actor . system . stats [ stat ] . marked ;
204202 if ( ! isMarked ) {
205203 update [ `system.stats.${ stat } .marked` ] = true ;
206204 }
205+ else if ( [ "bra" , "agi" ] . includes ( stat ) ) {
206+ harmUpdate = this . calculateHarm ( actor , "bloodied" ) ;
207+ }
207208 else {
208- if ( [ 'bra' , 'agi' ] . includes ( stat ) ) {
209- harmUpdate = this . calculateHarm ( actor , 'bloodied' ) ;
210- }
211- else {
212- harmUpdate = this . calculateHarm ( actor , 'rattled' ) ;
213- }
209+ harmUpdate = this . calculateHarm ( actor , "rattled" ) ;
214210 }
215211 }
216212 }
217213
218214 // Handle harm.
219215 if ( harm ) {
220- if ( [ ' bloodied' , ' rattled' ] . includes ( harm ) ) {
216+ if ( [ " bloodied" , " rattled" ] . includes ( harm ) ) {
221217 harmUpdate = this . calculateHarm ( actor , harm ) ;
222218 }
223219 }
@@ -255,21 +251,19 @@ export class GrimwildChatMessage extends ChatMessage {
255251 */
256252 calculateHarm ( actor , harm ) {
257253 const harmPools = game . settings . get ( "grimwild" , "enableHarmPools" ) ;
258- const maxHarm = game . settings . get ( "grimwild" , `max${ harm === ' bloodied' ? ' Bloodied' : ' Rattled' } ` ) ?? 1 ;
254+ const maxHarm = game . settings . get ( "grimwild" , `max${ harm === " bloodied" ? " Bloodied" : " Rattled" } ` ) ?? 1 ;
259255 const update = { } ;
260- if ( ! actor . system [ harm == ' bloodied' ? ' isBloodied' : ' isRattled' ] ) {
256+ if ( ! actor . system [ harm === " bloodied" ? " isBloodied" : " isRattled" ] ) {
261257 update [ `system.${ harm } .marked` ] = true ;
262258 if ( harmPools ) {
263259 update [ `system.${ harm } .pool.diceNum` ] = 1 ;
264260 }
265261 }
262+ else if ( ! harmPools || actor . system [ harm ] . pool . diceNum >= maxHarm ) {
263+ update [ "system.dropped" ] = true ;
264+ }
266265 else {
267- if ( ! harmPools || actor . system [ harm ] . pool . diceNum >= maxHarm ) {
268- update [ `system.dropped` ] = true ;
269- }
270- else {
271- update [ `system.${ harm } .pool.diceNum` ] = actor . system [ harm ] . pool . diceNum + 1 ;
272- }
266+ update [ `system.${ harm } .pool.diceNum` ] = actor . system [ harm ] . pool . diceNum + 1 ;
273267 }
274268
275269 return update ;
0 commit comments