Add Roll Modification (#61)
Changes: + add roll Mod (only for attributes) + check for roll mods when rolling on attributes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Evaluated } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/dice/roll";
|
||||
import { M5Character } from "../actors/M5Character";
|
||||
import { M5EwResult, M5RollData, M5RollResult, M5SkillUnlearned, M5Stats } from "../M5Base";
|
||||
import { M5EwResult, M5ModOperation, M5ModType, M5RollData, M5RollResult, M5SkillUnlearned, M5Stats } from "../M5Base";
|
||||
import { stat } from "fs";
|
||||
|
||||
export class M5Roll {
|
||||
@@ -115,31 +115,20 @@ export class M5Roll {
|
||||
return ChatMessage.create(chatData);
|
||||
}
|
||||
|
||||
static fromAttribute(actor: any, attributeKey: string) {
|
||||
const character = actor as M5Character;
|
||||
const attribute = character.attribute(attributeKey);
|
||||
|
||||
const rollData = actor.getRollData() as M5RollData;
|
||||
rollData.i = attribute.value + attribute.bonus;
|
||||
rollData.rolls["0"] = {
|
||||
formula: "@i - 1d100",
|
||||
enabled: true,
|
||||
label: (game as Game).i18n.localize("midgard5.pw"),
|
||||
result: "",
|
||||
total: 0,
|
||||
totalStr: "",
|
||||
dice: {},
|
||||
css: "",
|
||||
} as M5RollResult;
|
||||
|
||||
return new M5Roll(rollData, actor, (game as Game).i18n.localize(`midgard5.actor-${attributeKey}-long`));
|
||||
}
|
||||
|
||||
static fromAttributeValue(actor: any, attributeKey: string, attributeValue: number) {
|
||||
const rollData = actor.getRollData() as M5RollData;
|
||||
const itemData = actor.items.filter((x) => x.type === "effect").map((y) => y.system.mods);
|
||||
rollData.c = 0;
|
||||
for (let effectKey in itemData) {
|
||||
for (let modkey in itemData[effectKey])
|
||||
if (itemData[effectKey][modkey].type === M5ModType.ATTRIBUTE && itemData[effectKey][modkey].operation === M5ModOperation.ROLL) {
|
||||
rollData.c += itemData[effectKey][modkey].value;
|
||||
}
|
||||
}
|
||||
|
||||
rollData.i = attributeValue;
|
||||
rollData.rolls["0"] = {
|
||||
formula: "@i - 1d100",
|
||||
formula: "@i - 1d100 - @c",
|
||||
enabled: true,
|
||||
label: (game as Game).i18n.localize("midgard5.pw"),
|
||||
result: "",
|
||||
@@ -208,7 +197,7 @@ export class M5Roll {
|
||||
|
||||
static perception(actor: any) {
|
||||
const rollData = actor.getRollData() as M5RollData;
|
||||
|
||||
|
||||
rollData.rolls["0"] = {
|
||||
formula: "1d20 + @c.calc.stats.perception.value + @c.calc.stats.perceptionFW",
|
||||
enabled: true,
|
||||
@@ -219,13 +208,13 @@ export class M5Roll {
|
||||
dice: {},
|
||||
css: "",
|
||||
} as M5RollResult;
|
||||
|
||||
|
||||
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.perception"));
|
||||
}
|
||||
|
||||
|
||||
static drinking(actor: any) {
|
||||
const rollData = actor.getRollData() as M5RollData;
|
||||
|
||||
|
||||
rollData.rolls["0"] = {
|
||||
formula: "1d20 + @c.calc.stats.drinking.value + @c.calc.stats.drinkingFW",
|
||||
enabled: true,
|
||||
@@ -236,7 +225,7 @@ export class M5Roll {
|
||||
dice: {},
|
||||
css: "",
|
||||
} as M5RollResult;
|
||||
|
||||
|
||||
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.drinking"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user