Include Weapons and effects
Changes: + include weapon pack and effect pack + handle effects as own entity + effects can influence your attributes and skills + add Aktive Effekte page for effects on your character
This commit is contained in:
+84
-83
@@ -1,52 +1,52 @@
|
||||
import { BooleanField } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/fields.mjs"
|
||||
import { BooleanField } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/fields.mjs";
|
||||
|
||||
export interface M5Skill {
|
||||
fw: number
|
||||
attribute: string
|
||||
pp: number
|
||||
fw: number;
|
||||
attribute: string;
|
||||
pp: number;
|
||||
}
|
||||
|
||||
export interface M5SkillUnlearned extends M5Skill {
|
||||
initial: number
|
||||
initial: number;
|
||||
}
|
||||
|
||||
export interface M5SkillLearned extends M5Skill {
|
||||
skill: string
|
||||
type: string
|
||||
skill: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface M5SkillCalculated extends M5Skill {
|
||||
label: string,
|
||||
calc: any
|
||||
label: string;
|
||||
calc: any;
|
||||
}
|
||||
|
||||
export interface M5Attribute {
|
||||
value: number
|
||||
bonus: number
|
||||
value: number;
|
||||
bonus: number;
|
||||
}
|
||||
|
||||
export interface M5RollData {
|
||||
c: any
|
||||
i: any
|
||||
iType: string
|
||||
rolls: {}
|
||||
c: any;
|
||||
i: any;
|
||||
iType: string;
|
||||
rolls: {};
|
||||
res: {
|
||||
label: string
|
||||
}
|
||||
label: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface M5RollTemplate {
|
||||
formula: string
|
||||
label: string
|
||||
enabled: boolean
|
||||
formula: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface M5RollResult extends M5RollTemplate {
|
||||
total: number
|
||||
totalStr: string
|
||||
result: string
|
||||
dice: {}
|
||||
css: string
|
||||
total: number;
|
||||
totalStr: string;
|
||||
result: string;
|
||||
dice: {};
|
||||
css: string;
|
||||
}
|
||||
|
||||
export enum M5EwResult {
|
||||
@@ -55,7 +55,7 @@ export enum M5EwResult {
|
||||
CRITICAL = "roll-ew-result-critical",
|
||||
HIGH = "roll-ew-result-high",
|
||||
FAIL = "roll-ew-result-fail",
|
||||
PASS = "roll-ew-result-pass"
|
||||
PASS = "roll-ew-result-pass",
|
||||
}
|
||||
|
||||
export enum M5Attributes {
|
||||
@@ -67,7 +67,7 @@ export enum M5Attributes {
|
||||
ZT = "zt",
|
||||
AU = "au",
|
||||
PA = "pa",
|
||||
WK = "wk"
|
||||
WK = "wk",
|
||||
}
|
||||
|
||||
export enum M5Stats {
|
||||
@@ -81,96 +81,97 @@ export enum M5Stats {
|
||||
BRAWL = "brawl",
|
||||
POISON_RESISTANCE = "poisonResistance",
|
||||
LP = "lp",
|
||||
AP = "ap"
|
||||
AP = "ap",
|
||||
}
|
||||
|
||||
export enum M5ModType {
|
||||
ATTRIBUTE = "attribute",
|
||||
STAT = "stat",
|
||||
SKILL = "skill"
|
||||
SKILL = "skill",
|
||||
}
|
||||
|
||||
export enum M5ModOperation {
|
||||
ADD_100 = "add100",
|
||||
ADD = "add",
|
||||
SET = "set",
|
||||
FIXED = "fixed"
|
||||
FIXED = "fixed",
|
||||
}
|
||||
|
||||
export interface M5ItemMod {
|
||||
type: M5ModType
|
||||
id: string
|
||||
operation: M5ModOperation
|
||||
value: number
|
||||
type: M5ModType;
|
||||
id: string;
|
||||
operation: M5ModOperation;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface M5ModPair {
|
||||
mod: M5ItemMod
|
||||
source: string
|
||||
mod: M5ItemMod;
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface M5ModSource {
|
||||
item: string
|
||||
operation: M5ModOperation
|
||||
value: number
|
||||
item: string;
|
||||
operation: M5ModOperation;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface M5ModResult {
|
||||
mods: Array<M5ModSource>
|
||||
value: number
|
||||
mods: Array<M5ModSource>;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export interface M5AttributeCalculated extends M5ModResult {
|
||||
bonus: number
|
||||
bonus: number;
|
||||
}
|
||||
|
||||
export interface M5CharacterCalculatedData {
|
||||
level: number
|
||||
level: number;
|
||||
attributes: {
|
||||
st: M5AttributeCalculated
|
||||
gs: M5AttributeCalculated
|
||||
gw: M5AttributeCalculated
|
||||
ko: M5AttributeCalculated
|
||||
in: M5AttributeCalculated
|
||||
zt: M5AttributeCalculated
|
||||
au: M5AttributeCalculated
|
||||
pa: M5AttributeCalculated
|
||||
wk: M5AttributeCalculated
|
||||
}
|
||||
st: M5AttributeCalculated;
|
||||
gs: M5AttributeCalculated;
|
||||
gw: M5AttributeCalculated;
|
||||
ko: M5AttributeCalculated;
|
||||
in: M5AttributeCalculated;
|
||||
zt: M5AttributeCalculated;
|
||||
au: M5AttributeCalculated;
|
||||
pa: M5AttributeCalculated;
|
||||
wk: M5AttributeCalculated;
|
||||
};
|
||||
stats: {
|
||||
lp: M5ModResult
|
||||
ap: M5ModResult
|
||||
armor: number
|
||||
defense: M5ModResult
|
||||
damageBonus: M5ModResult
|
||||
attackBonus: M5ModResult
|
||||
defenseBonus: M5ModResult
|
||||
movementBonus: M5ModResult
|
||||
resistanceMind: M5ModResult
|
||||
resistanceBody: M5ModResult
|
||||
spellCasting: M5ModResult
|
||||
brawl: M5ModResult
|
||||
brawlEw: number
|
||||
poisonResistance: M5ModResult
|
||||
enduranceBonus: number
|
||||
}
|
||||
skillMods: {}
|
||||
lp: M5ModResult;
|
||||
ap: M5ModResult;
|
||||
armor: number;
|
||||
defense: M5ModResult;
|
||||
damageBonus: M5ModResult;
|
||||
attackBonus: M5ModResult;
|
||||
defenseBonus: M5ModResult;
|
||||
movementBonus: M5ModResult;
|
||||
resistanceMind: M5ModResult;
|
||||
resistanceBody: M5ModResult;
|
||||
spellCasting: M5ModResult;
|
||||
brawl: M5ModResult;
|
||||
brawlEw: number;
|
||||
poisonResistance: M5ModResult;
|
||||
enduranceBonus: number;
|
||||
};
|
||||
skillMods: {};
|
||||
skills: {
|
||||
innate: {}
|
||||
general: {}
|
||||
combat: {}
|
||||
language: {}
|
||||
custom: {}
|
||||
}
|
||||
innate: {};
|
||||
general: {};
|
||||
combat: {};
|
||||
language: {};
|
||||
custom: {};
|
||||
};
|
||||
gear: {
|
||||
weapons: {}
|
||||
defensiveWeapons: {}
|
||||
armor: {}
|
||||
items: {}
|
||||
}
|
||||
spells: {}
|
||||
weapons: {};
|
||||
defensiveWeapons: {};
|
||||
armor: {};
|
||||
items: {};
|
||||
effects: {};
|
||||
};
|
||||
spells: {};
|
||||
}
|
||||
|
||||
export function enumKeys<O extends object, K extends keyof O = keyof O>(obj: O): K[] {
|
||||
return Object.keys(obj).filter(k => Number.isNaN(+k)) as K[]
|
||||
return Object.keys(obj).filter((k) => Number.isNaN(+k)) as K[];
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ export class M5Character extends Actor {
|
||||
return -2;
|
||||
}
|
||||
|
||||
derivedData(skip: { mods?: boolean; skills?: boolean; weapons?: boolean; defensiveWeapons?: boolean; armor?: boolean; items?: boolean; spells?: boolean } = {}): M5CharacterCalculatedData {
|
||||
derivedData(
|
||||
skip: { mods?: boolean; skills?: boolean; weapons?: boolean; defensiveWeapons?: boolean; armor?: boolean; items?: boolean; spells?: boolean; effects?: boolean } = {}
|
||||
): M5CharacterCalculatedData {
|
||||
let ret: M5CharacterCalculatedData = {
|
||||
level: 0,
|
||||
attributes: {
|
||||
@@ -68,6 +70,7 @@ export class M5Character extends Actor {
|
||||
defensiveWeapons: {},
|
||||
armor: {},
|
||||
items: {},
|
||||
effects: {},
|
||||
},
|
||||
spells: {},
|
||||
} as M5CharacterCalculatedData;
|
||||
@@ -124,7 +127,7 @@ export class M5Character extends Actor {
|
||||
const aggregate = new M5ModAggregate(data, ret);
|
||||
|
||||
context.items
|
||||
?.filter((item) => item.type === "item")
|
||||
?.filter((item) => item.type === "item" || item.type === "effect")
|
||||
.forEach((item) => {
|
||||
const mods = item.system.mods;
|
||||
//console.log("Actor item mods", mods)
|
||||
@@ -156,6 +159,25 @@ export class M5Character extends Actor {
|
||||
});
|
||||
}
|
||||
|
||||
if (!skip?.items) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "effect")
|
||||
.forEach((item) => {
|
||||
item.prepareDerivedData();
|
||||
|
||||
let label = item.name;
|
||||
if (item.system.magic) {
|
||||
label += "*";
|
||||
}
|
||||
|
||||
ret.gear.effects[item.id] = {
|
||||
label: label,
|
||||
magic: item.system.magic,
|
||||
calc: item.system.calc,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (!skip?.skills) {
|
||||
context.items
|
||||
?.filter((item) => item.type === "skill")
|
||||
|
||||
@@ -31,7 +31,7 @@ export class M5Item extends Item {
|
||||
];
|
||||
|
||||
if (character) {
|
||||
const actorCalc = character.derivedData({ skills: true, weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true });
|
||||
const actorCalc = character.derivedData({ skills: true, weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true });
|
||||
if (actorCalc?.skillMods && Object.keys(actorCalc.skillMods).indexOf(itemId) !== -1) {
|
||||
pairs = pairs.concat(actorCalc.skillMods[itemId]);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ export class M5Item extends Item {
|
||||
calc.combatSkills = null;
|
||||
|
||||
if (actor) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true });
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true });
|
||||
if (actorCalc) {
|
||||
calc.ew += actorCalc.stats.attackBonus.value;
|
||||
calc.combatSkills = actorCalc.skills.combat;
|
||||
@@ -89,7 +89,7 @@ export class M5Item extends Item {
|
||||
calc.combatSkills = null;
|
||||
|
||||
if (actor) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true });
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true });
|
||||
if (actorCalc) {
|
||||
calc.ew += actorCalc.stats.defense.value + actorCalc.stats.defenseBonus.value;
|
||||
calc.combatSkills = actorCalc.skills.combat;
|
||||
@@ -108,12 +108,12 @@ export class M5Item extends Item {
|
||||
} else if (itemType === "spell") {
|
||||
calc.fw = 0;
|
||||
if (actor) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true });
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true });
|
||||
if (actorCalc) {
|
||||
calc.ew = actorCalc.stats.spellCasting.value;
|
||||
}
|
||||
}
|
||||
} else if (itemType === "item") {
|
||||
} else if (itemType === "item" || itemType === "effect") {
|
||||
calc.mods = {};
|
||||
Object.keys(itemData?.mods).forEach((key) => {
|
||||
const mod = itemData.mods[key];
|
||||
@@ -135,7 +135,7 @@ export class M5Item extends Item {
|
||||
}
|
||||
case M5ModType.SKILL: {
|
||||
if (character) {
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true });
|
||||
const actorCalc = character.derivedData({ weapons: true, defensiveWeapons: true, armor: true, items: true, spells: true, effects: true });
|
||||
if (actorCalc) {
|
||||
let category = (game as Game).i18n.localize("midgard5.skill");
|
||||
Object.keys(actorCalc.skills.general).forEach((skillId) => {
|
||||
|
||||
@@ -205,7 +205,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
const item = this.actor.items.get(li.dataset.itemId);
|
||||
|
||||
// limit transfer on personal weapons/armour/gear
|
||||
if (["skill", "item", "weapon", "defensiveWeapon", "armor", "spell"].includes(item.type)) {
|
||||
if (["skill", "item", "weapon", "defensiveWeapon", "armor", "spell", "effect"].includes(item.type)) {
|
||||
const dragData = {
|
||||
type: "Transfer",
|
||||
actorId: this.actor.id,
|
||||
|
||||
Reference in New Issue
Block a user