import AwERoll from "./roll.mjs"

export default class AwEChatMessage extends ChatMessage {
  /** @override */
  async _renderRollContent(messageData) {
    if (this.rolls[0] instanceof AwERoll) {
      const isPrivate = !this.isContentVisible
      const roll      = this.rolls[0]

      const html = await foundry.applications.handlebars.renderTemplate(
        AwERoll.CHAT_TEMPLATE,
        {
          flavor:    this.flavor,
          total:     roll.total,
          outcome:   isPrivate ? null : roll.outcome,
          dc:        roll.dc,
          isPrivate
        }
      )
      messageData.message.content = html
      return
    }
    return super._renderRollContent(messageData)
  }
}
