Add rollTables
This commit is contained in:
@@ -302,7 +302,7 @@ export class CrucibleActor extends Actor {
|
||||
// Compute whole enc
|
||||
let enc = 0
|
||||
for (let item of equipments) {
|
||||
item.data.idrDice = CrucibleUtility.getDiceFromLevel(Number(item.data.idr))
|
||||
//item.data.idrDice = CrucibleUtility.getDiceFromLevel(Number(item.data.idr))
|
||||
if (item.data.equipped) {
|
||||
if (item.data.iscontainer) {
|
||||
enc += item.data.contentsEnc
|
||||
@@ -323,23 +323,6 @@ export class CrucibleActor extends Actor {
|
||||
this.encCurrent = enc
|
||||
this.containersTree = equipments.filter(item => item.data.containerid == "") // Returns the root of equipements without container
|
||||
|
||||
// Manages slow effect
|
||||
let overCapacity = Math.floor(this.encCurrent / this.getEncumbranceCapacity())
|
||||
this.encHindrance = Math.floor(this.encCurrent / this.getEncumbranceCapacity())
|
||||
|
||||
//console.log("Capacity", overCapacity, this.encCurrent / this.getEncumbranceCapacity() )
|
||||
let effect = this.data.items.find(item => item.type == "effect" && item.data.data.slow)
|
||||
if (overCapacity >= 4) {
|
||||
if (!effect) {
|
||||
effect = await CrucibleUtility.getEffectFromCompendium("Slowed")
|
||||
effect.data.slow = true
|
||||
this.createEmbeddedDocuments('Item', [effect])
|
||||
}
|
||||
} else {
|
||||
if (effect) {
|
||||
this.deleteEmbeddedDocuments('Item', [effect.id])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -589,7 +572,8 @@ export class CrucibleActor extends Actor {
|
||||
let armor = this.getEquippedArmor()
|
||||
if (armor) {
|
||||
armor = duplicate(armor)
|
||||
let diceValue = armor.data.absorprionroll
|
||||
let diceColor = armor.data.absorprionroll
|
||||
let rollTable = CrucibleUtility.getRollTableFromDiceColor( diceColor)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import { CrucibleCommands } from "./crucible-commands.js";
|
||||
const __level2Dice = ["d0", "d4", "d6", "d8", "d10", "d12"];
|
||||
const __name2DiceValue = { "0": 0, "d0": 0, "d4": 4, "d6": 6, "d8": 8, "d10": 10, "d12": 12 }
|
||||
const __skillLevel2Dice = ["0d8", "1d8", "2d8","3d8", "4d8", '6d8', "8d8", "10d8"]
|
||||
const __color2RollTable = { blue: "Blue Armor Die", black: "Black Armor Die", green: "Green Armor Die", purple: "Purple Armor Die",
|
||||
white: "White Armor Die", red: "Red Armor Die", blackgreen: "Black & Green Armor Dice"}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class CrucibleUtility {
|
||||
@@ -66,18 +68,35 @@ export class CrucibleUtility {
|
||||
this.skills = skills.map(i => i.toObject())
|
||||
this.weaponSkills = duplicate( this.skills.filter( item => item.data.isweaponskill))
|
||||
this.shieldSkills = duplicate( this.skills.filter( item => item.data.isshieldskill))
|
||||
|
||||
const rollTables = await CrucibleUtility.loadCompendium("fvtt-crucible-rpg.rolltables")
|
||||
this.rollTables = rollTables.map(i => i.toObject())
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async loadCompendiumData(compendium) {
|
||||
const pack = game.packs.get(compendium);
|
||||
return await pack?.getDocuments() ?? [];
|
||||
const pack = game.packs.get(compendium)
|
||||
return await pack?.getDocuments() ?? []
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async loadCompendium(compendium, filter = item => true) {
|
||||
let compendiumData = await CrucibleUtility.loadCompendiumData(compendium);
|
||||
return compendiumData.filter(filter);
|
||||
let compendiumData = await CrucibleUtility.loadCompendiumData(compendium)
|
||||
return compendiumData.filter(filter)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getRollTableFromDiceColor( diceColor) {
|
||||
let rollTableName = __color2RollTable[diceColor]
|
||||
if (rollTableName) {
|
||||
const pack = game.packs.get("fvtt-crucible-rpg.rolltables")
|
||||
const index = await pack.getIndex()
|
||||
const entry = index.find(e => e.name === rollTableName)
|
||||
let table = await pack.getDocument(entry._id)
|
||||
const draw = await table.draw({ displayChat: true, rollMode: "gmroll"})
|
||||
return draw.results.length > 0 ? draw.results[0] : undefined
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user