ENH: Damage button
							parent
							
								
									b418a0c2c5
								
							
						
					
					
						commit
						e7b5919e40
					
				|  | @ -28,6 +28,19 @@ export const addChatMessageContextOptions = function(html, options) { | |||
| 
 | ||||
| /* -------------------------------------------- */ | ||||
| 
 | ||||
| export const addChatMessageButtons = function(msg, html, data) { | ||||
|   let roll = html.find('.damage-roll'); | ||||
|   if (roll.length > 0) { | ||||
|     let total = roll.find('.dice-total'); | ||||
|     let value = total.text(); | ||||
|     roll.append($(`<div class="dice-damage"><button type="button" data-action="apply-damage"><i class="fas fa-tint"></i></button></div>`)) | ||||
|     roll.find('button[data-action="apply-damage"]').click((ev) => { | ||||
|       ev.preventDefault(); | ||||
|       applyChatCardDamage(roll, 1); | ||||
|     }) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Apply rolled dice damage to the token or tokens which are currently controlled. | ||||
|  * This allows for damage to be scaled by a multiplier to account for healing, critical hits, or resistance | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ export class OseDice { | |||
|       isSuccess: false, | ||||
|       isFailure: false, | ||||
|       target: data.rollData.target, | ||||
|       total: roll.total | ||||
|     }; | ||||
| 
 | ||||
|     let die = roll.parts[0].total; | ||||
|  | @ -119,6 +120,7 @@ export class OseDice { | |||
|       isSuccess: false, | ||||
|       isFailure: false, | ||||
|       target: "", | ||||
|       total: roll.total | ||||
|     }; | ||||
|     result.target = data.rollData.thac0; | ||||
|     if (game.settings.get("ose", "ascendingAC")) { | ||||
|  | @ -194,6 +196,7 @@ export class OseDice { | |||
|                 ) | ||||
|                 .then(() => { | ||||
|                   if (templateData.result.isSuccess) { | ||||
|                     templateData.result.dmg = dmgRoll.total; | ||||
|                     game.dice3d | ||||
|                     .showForRoll( | ||||
|                       dmgRoll, | ||||
|  |  | |||
|  | @ -118,3 +118,4 @@ Hooks.on("preUpdateCombat", async (combat, data, diff, id) => { | |||
| 
 | ||||
| Hooks.on("renderChatLog", (app, html, data) => OseItem.chatListeners(html)); | ||||
| Hooks.on("getChatLogEntryContext", chat.addChatMessageContextOptions); | ||||
| Hooks.on("renderChatMessage", chat.addChatMessageButtons); | ||||
|  |  | |||
|  | @ -67,6 +67,32 @@ | |||
|       color: #aa0200; | ||||
|     } | ||||
|   } | ||||
|   .damage-roll { | ||||
|     position: relative; | ||||
|     .dice-damage { | ||||
|       display: none; | ||||
|       position: absolute; | ||||
|       line-height: 24px; | ||||
|       text-align: center; | ||||
|       background: rgba(0, 0, 0, 0.1); | ||||
|       border-radius: 3px; | ||||
|       box-shadow: 0 0 2px #fff inset; | ||||
|       bottom: 1px; | ||||
|       right: 10px; | ||||
|       button { | ||||
|         padding: 2px 5px; | ||||
|         width: 22px; | ||||
|         line-height: 14px; | ||||
|         height: 22px; | ||||
|         cursor: pointer; | ||||
|       } | ||||
|     } | ||||
|     &:hover { | ||||
|       .dice-damage { | ||||
|         display: block; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| .ose.chat-card { | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ | |||
|         <div class="chat-details"> | ||||
|             <div class="roll-result"><b>{{localize 'OSE.messages.InflictsDamage'}}</b></div> | ||||
|         </div> | ||||
|         <div>{{{rollDamage}}}</div> | ||||
|         <div class="damage-roll">{{{rollDamage}}}</div> | ||||
|         {{/if}} | ||||
|     </div> | ||||
| </section> | ||||
		Loading…
	
		Reference in New Issue