2024-05-17 12:46:44 +02:00
|
|
|
let spells = await game.wfrp4e.utility.findAll("spell", "Chargement des sorts")
|
2024-05-16 17:57:51 +02:00
|
|
|
|
|
|
|
let lore = (await game.wfrp4e.tables.rollTable("random-caster", {hideDSN: true})).text
|
|
|
|
this.script.scriptNotification(lore)
|
2024-05-17 12:46:44 +02:00
|
|
|
if (lore == "Au choix") {
|
2024-05-16 17:57:51 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-17 12:46:44 +02:00
|
|
|
else if (lore == "Magie des Arcanes") {
|
2024-05-16 17:57:51 +02:00
|
|
|
lore = "Arcane"
|
|
|
|
}
|
|
|
|
|
2024-05-17 12:46:44 +02:00
|
|
|
else if (lore == "Magie Mineure ") {
|
2024-05-16 17:57:51 +02:00
|
|
|
lore = "petty"
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
lore = lore.toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
let spellsWithLore = []
|
|
|
|
if (lore == "Arcane") {
|
|
|
|
spellsWithLore = spells.filter(i => !i.system.lore.value)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
spellsWithLore = spells.filter(i => i.system.lore.value == lore)
|
|
|
|
}
|
|
|
|
|
|
|
|
let selectedSpell = spellsWithLore[Math.floor(CONFIG.Dice.randomUniform() * spellsWithLore.length)]
|
|
|
|
Item.implementation.create(selectedSpell.toObject(), { parent: this.actor}).then(item => {
|
|
|
|
this.actor.setupCast(item).then(test => test.roll());
|
|
|
|
})
|