import { ChatUtility } from "./chat-utility.js";
import { renderTemplate } from "./constants.js";

export class RdDRollResult {

  static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.hbs') {
    return await ChatMessage.create(ChatUtility.adaptVisibility(
      { content: await RdDRollResult.buildRollDataHtml(rollData, template) },
      { actor: actor, rollMode: rollData.current?.rollmode?.key ?? game.settings.get("core", "messageMode") }
    ))
  }

  static async buildRollDataHtml(rollData, template = 'chat-resultat-general.hbs') {
    rollData.show = rollData.show || {};
    return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData);
  }
}
