Potions et élémentaires
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* -------------------------------------------- */
|
||||
import { MournbladeUtility } from "./mournblade-utility.js";
|
||||
import { MournbladeRollDialog } from "./applications/mournblade-roll-dialog.mjs";
|
||||
import MournbladeInvocationDialog from "./applications/mournblade-invocation-dialog.mjs";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const __degatsBonus = [-2, -2, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9, 10, 10]
|
||||
@@ -215,6 +216,9 @@ export class MournbladeActor extends Actor {
|
||||
getArmors() {
|
||||
return this.getItemSorted(["protection"])
|
||||
}
|
||||
getCapacites() {
|
||||
return this.getItemSorted(["capacite"])
|
||||
}
|
||||
getRuneEffects() {
|
||||
return this.getItemSorted(["runeeffect"])
|
||||
}
|
||||
@@ -455,7 +459,7 @@ export class MournbladeActor extends Actor {
|
||||
} else {
|
||||
ame.currentmax -= value
|
||||
}
|
||||
this.update({ 'system.ame': ame })
|
||||
return this.update({ 'system.ame': ame })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -650,6 +654,91 @@ export class MournbladeActor extends Actor {
|
||||
await MournbladeRollDialog.create(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollSortilege() {
|
||||
const runes = this.getRunes()
|
||||
if (runes.length < 2) {
|
||||
ui.notifications.warn("Il faut au moins deux Runes pour lancer un Sortilège.")
|
||||
return
|
||||
}
|
||||
const comp = this.items.find(c => c.type == "competence" && c.name.toLowerCase() == "savoir : runes")
|
||||
if (!comp) {
|
||||
ui.notifications.warn("La compétence Savoir : Runes n'a pas été trouvée, abandon.")
|
||||
return
|
||||
}
|
||||
let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes")
|
||||
rollData.isSortilege = true
|
||||
rollData.difficulte = 0
|
||||
rollData.runemode = "prononcer"
|
||||
rollData.runeame = 0
|
||||
await MournbladeRollDialog.createSortilege(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async preparePotion() {
|
||||
const runes = this.getRunes()
|
||||
if (runes.length === 0) {
|
||||
ui.notifications.warn("Aucune Rune disponible pour préparer une potion.")
|
||||
return
|
||||
}
|
||||
const comp = this.items.find(c => c.type == "competence" && c.name.toLowerCase() == "savoir : runes")
|
||||
if (!comp) {
|
||||
ui.notifications.warn("La compétence Savoir : Runes n'a pas été trouvée, abandon.")
|
||||
return
|
||||
}
|
||||
let rollData = this.getCommonRollData("cla", comp._id)
|
||||
rollData.isPotion = true
|
||||
rollData.mainDice = "1d10"
|
||||
|
||||
// Optionally cap by Savoir:Haut-Parler and Savoir:Alchimie
|
||||
const hautParlerComp = this.items.find(c => c.type == "competence" && c.name.toLowerCase() == "savoir : haut-parler")
|
||||
const alchimieComp = this.items.find(c => c.type == "competence" && c.name.toLowerCase() == "savoir : alchimie")
|
||||
if (hautParlerComp) rollData.limitHautParlerValue = hautParlerComp.system.niveau
|
||||
if (alchimieComp) rollData.limitAlchimieValue = alchimieComp.system.niveau
|
||||
|
||||
await MournbladeRollDialog.createPotion(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async invoquerElementaire() {
|
||||
const persuasionComp = this.items.find(c => c.type == "competence" && c.name.toLowerCase() == "persuasion")
|
||||
if (!persuasionComp) {
|
||||
ui.notifications.warn("La compétence Persuasion est requise pour invoquer un Élémentaire.")
|
||||
return
|
||||
}
|
||||
let rollData = this.getCommonRollData("pre", persuasionComp._id)
|
||||
rollData.isInvocationElementaire = true
|
||||
rollData.mainDice = "1d10"
|
||||
|
||||
const hautParlerComp = this.items.find(c => c.type == "competence" && c.name.toLowerCase() == "savoir : haut-parler")
|
||||
const seigneursElemComp = this.items.find(c => c.type == "competence" && c.name.toLowerCase() == "savoir : seigneurs élémentaires")
|
||||
if (hautParlerComp) rollData.hautParlerNiveau = hautParlerComp.system.niveau
|
||||
if (seigneursElemComp) rollData.seigneursElemNiveau = seigneursElemComp.system.niveau
|
||||
|
||||
await MournbladeInvocationDialog.create(this, rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async bannirElementaire(invocIndex) {
|
||||
const invocations = foundry.utils.duplicate(this.system.invocationsElementaires || [])
|
||||
const invoc = invocations[invocIndex]
|
||||
if (!invoc) return
|
||||
|
||||
// Free the blocked soul
|
||||
await this.subPointsAme("prononcer", -invoc.soulCost)
|
||||
|
||||
// Delete the created actor if it still exists
|
||||
if (invoc.actorId) {
|
||||
const createdActor = game.actors.get(invoc.actorId)
|
||||
if (createdActor) await createdActor.delete()
|
||||
}
|
||||
|
||||
// Remove from the list
|
||||
invocations.splice(invocIndex, 1)
|
||||
await this.update({ "system.invocationsElementaires": invocations })
|
||||
ui.notifications.info(`L'Élémentaire ${invoc.actorName} a été banni. ${invoc.soulCost} points d'Âme libérés.`)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollArmeOffensif(armeId) {
|
||||
let arme = this.items.get(armeId)
|
||||
|
||||
Reference in New Issue
Block a user