import {evaluateRoll} from "../globals/DSARoll.mjs";

export class Talent {


    /**
     * @typedef TalentEigenschaften
     * @property Number mu
     * @property Number kl
     * @property Number in
     * @property Number ch
     * @property Number ff
     * @property Number ge
     * @property Number ko
     * @property Number kk
     */

    /**
     * @typedef TalentData
     * @property {String} name
     * @property {Number} taw
     * @property {Number} mod
     * @property {Actor} owner
     * @property {TalentEigenschaften} eigenschaften
     * @property {"mu","kl","in","ch","ff","ge","ko","kk"} eigenschaft1
     * @property {"mu","kl","in","ch","ff","ge","ko","kk"} eigenschaft2
     * @property {"mu","kl","in","ch","ff","ge","ko","kk"} eigenschaft3
     */

    /**
     *
     * @param {TalentData} data
     **/
    constructor(data) {
        this.data = data
    }

    /**
     * @param {"publicroll", "gmroll", "privateroll"} rollMode
     * @returns {Promise<{tap: any, meisterlich: boolean, patzer: boolean, evaluatedRoll: Roll<EmptyObject> & {_evaluated: true, _total: number, readonly total: number}}>}
     */
    evaluate(rollMode) {
        return this.#talentRoll(this.data, rollMode)
    }


    /**
     *
     * @param {TalentData} data
     * @param {"publicroll", "gmroll", "privateroll"} rollMode
     * @returns {Promise<{tap: any, meisterlich: boolean, patzer: boolean, evaluatedRoll: Roll<EmptyObject> & {_evaluated: true, _total: number, readonly total: number}}>}
     */
    async #talentRoll(data, rollMode) {
        const dsaDieRollEvaluated = await evaluateRoll("3d20", {
            value: data.taw,
            mod: data.mod,
            owner: data.owner,
            werte: [data.eigenschaften[data.eigenschaft1], data.eigenschaften[data.eigenschaft2], data.eigenschaften[data.eigenschaft3]],
        })
        return dsaDieRollEvaluated
    }

}