Add Roll Modification (#61)
Changes: + add roll Mod (only for attributes) + check for roll mods when rolling on attributes
This commit is contained in:
parent
31cfd52131
commit
c313d3448c
|
|
@ -291,6 +291,7 @@
|
||||||
"midgard5.kido-variante-kontrollieren": "Kontrollieren",
|
"midgard5.kido-variante-kontrollieren": "Kontrollieren",
|
||||||
|
|
||||||
"midgard5.mod-operation-add100": "Addieren (max 100)",
|
"midgard5.mod-operation-add100": "Addieren (max 100)",
|
||||||
|
"midgard5.mod-operation-roll": "Wurf Modifikation",
|
||||||
"midgard5.mod-operation-add": "Addieren",
|
"midgard5.mod-operation-add": "Addieren",
|
||||||
"midgard5.mod-operation-set": "Basiswert",
|
"midgard5.mod-operation-set": "Basiswert",
|
||||||
"midgard5.mod-operation-fixed": "Fester Wert",
|
"midgard5.mod-operation-fixed": "Fester Wert",
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ export enum M5Stats {
|
||||||
PROTECTION_LP = "lpProtection",
|
PROTECTION_LP = "lpProtection",
|
||||||
PROTECTION_AP = "apProtection",
|
PROTECTION_AP = "apProtection",
|
||||||
PERCEPTION = "perception",
|
PERCEPTION = "perception",
|
||||||
DRINKING = "drinking"
|
DRINKING = "drinking",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum M5ModType {
|
export enum M5ModType {
|
||||||
|
|
@ -96,6 +96,7 @@ export enum M5ModType {
|
||||||
|
|
||||||
export enum M5ModOperation {
|
export enum M5ModOperation {
|
||||||
ADD_100 = "add100",
|
ADD_100 = "add100",
|
||||||
|
ROLL = "roll",
|
||||||
ADD = "add",
|
ADD = "add",
|
||||||
SET = "set",
|
SET = "set",
|
||||||
FIXED = "fixed",
|
FIXED = "fixed",
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,6 @@ export class M5Item extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
const roll = new M5Roll(rollData, this.actor, item.name);
|
const roll = new M5Roll(rollData, this.actor, item.name);
|
||||||
console.log(roll);
|
|
||||||
return roll.toMessage();
|
return roll.toMessage();
|
||||||
} else {
|
} else {
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Evaluated } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/dice/roll";
|
import { Evaluated } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/dice/roll";
|
||||||
import { M5Character } from "../actors/M5Character";
|
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";
|
import { stat } from "fs";
|
||||||
|
|
||||||
export class M5Roll {
|
export class M5Roll {
|
||||||
|
|
@ -115,31 +115,20 @@ export class M5Roll {
|
||||||
return ChatMessage.create(chatData);
|
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) {
|
static fromAttributeValue(actor: any, attributeKey: string, attributeValue: number) {
|
||||||
const rollData = actor.getRollData() as M5RollData;
|
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.i = attributeValue;
|
||||||
rollData.rolls["0"] = {
|
rollData.rolls["0"] = {
|
||||||
formula: "@i - 1d100",
|
formula: "@i - 1d100 - @c",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
label: (game as Game).i18n.localize("midgard5.pw"),
|
label: (game as Game).i18n.localize("midgard5.pw"),
|
||||||
result: "",
|
result: "",
|
||||||
|
|
@ -208,7 +197,7 @@ export class M5Roll {
|
||||||
|
|
||||||
static perception(actor: any) {
|
static perception(actor: any) {
|
||||||
const rollData = actor.getRollData() as M5RollData;
|
const rollData = actor.getRollData() as M5RollData;
|
||||||
|
|
||||||
rollData.rolls["0"] = {
|
rollData.rolls["0"] = {
|
||||||
formula: "1d20 + @c.calc.stats.perception.value + @c.calc.stats.perceptionFW",
|
formula: "1d20 + @c.calc.stats.perception.value + @c.calc.stats.perceptionFW",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
@ -219,13 +208,13 @@ export class M5Roll {
|
||||||
dice: {},
|
dice: {},
|
||||||
css: "",
|
css: "",
|
||||||
} as M5RollResult;
|
} as M5RollResult;
|
||||||
|
|
||||||
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.perception"));
|
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.perception"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static drinking(actor: any) {
|
static drinking(actor: any) {
|
||||||
const rollData = actor.getRollData() as M5RollData;
|
const rollData = actor.getRollData() as M5RollData;
|
||||||
|
|
||||||
rollData.rolls["0"] = {
|
rollData.rolls["0"] = {
|
||||||
formula: "1d20 + @c.calc.stats.drinking.value + @c.calc.stats.drinkingFW",
|
formula: "1d20 + @c.calc.stats.drinking.value + @c.calc.stats.drinkingFW",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
@ -236,7 +225,7 @@ export class M5Roll {
|
||||||
dice: {},
|
dice: {},
|
||||||
css: "",
|
css: "",
|
||||||
} as M5RollResult;
|
} as M5RollResult;
|
||||||
|
|
||||||
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.drinking"));
|
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.drinking"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
{{#select mod.operation}}
|
{{#select mod.operation}}
|
||||||
{{#if (eq mod.type "attribute")}}
|
{{#if (eq mod.type "attribute")}}
|
||||||
<option value="add100">{{localize "midgard5.mod-operation-add100"}}</option>
|
<option value="add100">{{localize "midgard5.mod-operation-add100"}}</option>
|
||||||
|
<option value="roll">{{localize "midgard5.mod-operation-roll"}}</option>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<option value="add">{{localize "midgard5.mod-operation-add"}}</option>
|
<option value="add">{{localize "midgard5.mod-operation-add"}}</option>
|
||||||
<option value="set">{{localize "midgard5.mod-operation-set"}}</option>
|
<option value="set">{{localize "midgard5.mod-operation-set"}}</option>
|
||||||
|
|
@ -48,7 +49,7 @@
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<input name="data.mods.{{modId}}.value" type="text" value="{{mod.value}}" data-dtype="Number" />
|
<input name="data.mods.{{modId}}.value" type="number" value="{{mod.value}}" data-dtype="Number" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue