Merge branch 'develop' into entbehrungen

This commit is contained in:
2024-03-24 15:45:05 +01:00
17 changed files with 612 additions and 181 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ export interface M5RollData {
c: any;
i: any;
iType: string;
rolls: {};
rolls: any;
res: {
label: string;
};
+25 -22
View File
@@ -1,18 +1,5 @@
import { M5Item } from "../items/M5Item";
import {
M5Attribute,
M5CharacterCalculatedData,
M5ItemMod,
M5ItemType,
M5ModOperation,
M5ModResult,
M5ModType,
M5RollData,
M5Skill,
M5SkillCalculated,
M5SkillLearned,
M5SkillType,
} from "../M5Base";
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5RollData, M5Skill, M5SkillCalculated } from "../M5Base";
import M5ModAggregate from "./M5ModAggregate";
export class M5Character extends Actor {
// constructor(
@@ -94,6 +81,7 @@ export class M5Character extends Actor {
containers?: boolean;
kampfkuenste?: boolean;
encumbrance?: boolean;
class?: boolean;
} = {}
): M5CharacterCalculatedData {
let ret: M5CharacterCalculatedData = {
@@ -193,12 +181,8 @@ export class M5Character extends Actor {
ret.stats.attackBonus = this.modResult(ret.attributes.gs.bonus);
ret.stats.defenseBonus = this.modResult(ret.attributes.gw.bonus);
ret.stats.movement = this.modResult(data.movement);
ret.stats.resistanceMind = this.modResult(
(data.info.magicUsing ? 2 : 0) + ret.stats.defense.value + (data.info.race === "Mensch" ? ret.attributes.in.bonus : this.raceBonus(data.info.race))
);
ret.stats.resistanceBody = this.modResult(
(data.info.magicUsing ? 2 : 1) + ret.stats.defense.value + (data.info.race === "Mensch" ? ret.attributes.ko.bonus : this.raceBonus(data.info.race))
);
ret.stats.resistanceMind = this.modResult(ret.stats.defense.value + (data.info.race === "Mensch" ? ret.attributes.in.bonus : this.raceBonus(data.info.race)));
ret.stats.resistanceBody = this.modResult(ret.stats.defense.value + (data.info.race === "Mensch" ? ret.attributes.ko.bonus : this.raceBonus(data.info.race)));
ret.stats.spellCasting = this.modResult((data.info.magicUsing ? M5Character.spellCastingFromLevel(ret.level) : 3) + ret.attributes.zt.bonus);
ret.stats.brawl = this.modResult(Math.floor((ret.attributes.st.value + ret.attributes.gw.value) / 20));
ret.stats.brawlFw = ret.stats.brawl.value + ret.stats.attackBonus.value + (data.info.race === "Zwerg" ? 1 : 0);
@@ -221,7 +205,7 @@ export class M5Character extends Actor {
const aggregate = new M5ModAggregate(data, ret);
context.items
?.filter((item) => (item.type === "item" || item.type === "effect" || item.type === "armor" || item.type === "container") && item.system.equipped)
?.filter((item) => (item.type === "item" || item.type === "effect" || item.type === "armor" || item.type === "container" || item.type === "class") && item.system.equipped)
.forEach((item) => {
const mods = item.system.mods;
//console.log("Actor item mods", mods)
@@ -498,6 +482,25 @@ export class M5Character extends Actor {
//}
}
if (!skip?.class) {
context.items
?.filter((item) => item.type === "class")
.sort((a, b) => b?.system.magicUsing - a?.system.magicUsing)
.forEach((item, index) => {
if (index !== 0) {
item.system.equipped = false;
} else {
item.system.equipped = true;
data.info.magicUsing = item.system.magicUsing;
}
if (typeof data.info.class === "string") {
data.info.class = {};
}
data.info.class[item.id] = item.name;
});
}
if (!skip?.effects) {
context.items
?.filter((item) => item.type === "effect")
@@ -579,7 +582,7 @@ export class M5Character extends Actor {
type: item.system.type,
castDuration: item.system.castDuration || 0,
ap: item.system.ap || 0,
range: item.system.range|| 0,
range: item.system.range || 0,
effectTarget: item.system.effectTarget,
effectArea: item.system.effectArea,
effectDuration: item.system.effectDuration || 0,
+12 -7
View File
@@ -18,7 +18,7 @@ export class M5Item extends Item {
calc.containers = null;
if (actor) {
const actorCalc = actor.derivedData({ containers: false, items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
const actorCalc = actor.derivedData({ containers: false, items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true, class: true });
if (actorCalc) {
calc.containers = actorCalc.gear.containers;
}
@@ -47,12 +47,14 @@ export class M5Item extends Item {
if (character) {
const actorCalc = character.derivedData({
containers: true,
skills: true,
items: true,
spells: true,
effects: true,
kampfkuenste: true,
encumbrance: true,
class: true,
});
if (actorCalc?.skillMods && Object.keys(actorCalc.skillMods).indexOf(itemId) !== -1) {
pairs = pairs.concat(actorCalc.skillMods[itemId]);
@@ -89,7 +91,7 @@ export class M5Item extends Item {
calc.containers = null;
if (actor) {
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true, class: true });
if (actorCalc) {
calc.ew += actorCalc.stats.attackBonus.value;
calc.combatSkills = actorCalc.skills.combat;
@@ -124,7 +126,7 @@ export class M5Item extends Item {
calc.containers = null;
if (actor) {
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true, class: true });
if (actorCalc) {
calc.ew += actorCalc.stats.defense.value + actorCalc.stats.defenseBonus.value;
calc.combatSkills = actorCalc.skills.combat;
@@ -157,7 +159,7 @@ export class M5Item extends Item {
itemData.mods[5] = { type: "stat", id: "apProtection", operation: "set", value: itemData.apProtection };
calc.containers = null;
if (actor) {
const actorCalc = actor.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
const actorCalc = actor.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true, class: true });
if (actorCalc) {
calc.containers = actorCalc.gear.containers;
}
@@ -171,7 +173,7 @@ export class M5Item extends Item {
} else if (itemType === "spell") {
calc.fw = 0;
if (actor) {
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
const actorCalc = character.derivedData({ containers: true, items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true, class: true });
if (actorCalc) {
calc.ew = actorCalc.stats.spellCasting.value;
}
@@ -183,7 +185,7 @@ export class M5Item extends Item {
calc.generalSkills = null;
if (actor) {
const actorCalc = character.derivedData({ items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true });
const actorCalc = character.derivedData({ containers: true, items: true, spells: true, effects: true, kampfkuenste: true, encumbrance: true, class: true });
if (actorCalc) {
calc.generalSkills = actorCalc.skills.general;
}
@@ -197,6 +199,9 @@ export class M5Item extends Item {
itemData.rolls.formulas[0].label = skill.name;
}
}
} else if (itemType === "class") {
itemData.mods[0] = { type: "stat", id: "resistanceBody", operation: "add", value: itemData.resistanceBody };
itemData.mods[1] = { type: "stat", id: "resistanceMind", operation: "add", value: itemData.resistanceMind };
}
if (itemData?.mods) {
calc.mods = {};
@@ -318,7 +323,7 @@ export class M5Item extends Item {
}
}
const roll = new M5Roll(rollData, this.actor, item.name);
const roll = new M5Roll(rollData, this.actor, item.name, item.id);
return roll.toMessage();
} else {
ChatMessage.create({
+62 -1
View File
@@ -11,7 +11,7 @@ export class M5Roll {
public _total: number = 0;
public pool: PoolTerm = null;
constructor(public data: M5RollData, public actor: any, public label: string) {
constructor(public data: M5RollData, public actor: any, public label: string, public id?: string) {
//super(null)
//this.data = rollData
}
@@ -88,6 +88,50 @@ export class M5Roll {
});
this.data.res.label = this.label;
if ((game as Game).settings.get("midgard5", "automatedPP")) {
if ((this.data.i.type === "language" || this.data.i.type === "general") && this.data.rolls[0].dice[0] >= 16) {
this.actor.items.get(this.id).update({
system: {
pp: this.data.i.pp + 1,
},
});
} else if (this.data.rolls[0].dice[0] === 20) {
if (this.data.i.type === "combat") {
// Rolling through skill
this.actor.items.get(this.id).update({
system: {
pp: this.data.i.pp + 1,
},
});
} else if (this.data.iType === "weapon") {
// Rolling through Weapon Item
const skill = this.actor.items.get(this.data.i.skillId);
skill.update({
system: {
pp: skill.system.pp + 1,
},
});
} else if (this.data.iType === "defensiveWeapon") {
// Rolling through defensiveWeapon Item
const skill = this.actor.items.get(this.data.i.skillId);
skill.update({
system: {
pp: skill.system.pp + 1,
},
});
} else if (this.data.iType === "spell") {
// Rolling through Spell Item
const klasse = this.actor.items.find((x) => x.type === "class" && x.system.equipped);
klasse.update({
system: {
lernKostenZauber: {
[this.data.i.process]: { pp: klasse.system.lernKostenZauber[this.data.i.process].pp + 1 },
},
},
});
}
}
}
this._evaluated = true;
return this;
@@ -246,6 +290,23 @@ export class M5Roll {
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.deprivationFood"));
}
static cleanSpell(actor: any) {
const rollData = actor.getRollData() as M5RollData;
rollData.rolls["0"] = {
formula: "1d20 + @c.calc.stats.spellCasting.value",
enabled: true,
label: (game as Game).i18n.localize("midgard5.spellCasting"),
result: "",
total: 0,
totalStr: "",
dice: {},
css: "",
} as M5RollResult;
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.spellCasting"));
}
static defense(actor: any) {
const rollData = actor.getRollData() as M5RollData;
rollData.i = {
+13
View File
@@ -247,6 +247,11 @@ export default class M5CharacterSheet extends ActorSheet {
await roll.toMessage();
});
html.find(".roll-cleanSpell-button").on("click", async (event) => {
const roll = M5Roll.cleanSpell(this.actor);
await roll.toMessage();
});
html.find(".roll-deprivationCold-button").on("click", async (event) => {
const roll = M5Roll.deprivationCold(this.actor);
await roll.toMessage();
@@ -438,6 +443,14 @@ export default class M5CharacterSheet extends ActorSheet {
}
});
html.find(".class-item-edit").on("click", async (event) => {
this.actor.items.find((x) => x.type === "class").sheet.render(true);
});
html.find(".class-item-delete").on("click", async (event) => {
this.actor.items.find((x) => x.type === "class").delete();
});
// Drag & Drop
const dragDrop = new DragDrop({
dragSelector: ".items-list .item",
+7
View File
@@ -7,6 +7,13 @@ export class M5ItemSheet extends ItemSheet {
width: 640,
height: 480,
classes: ["midgard5", "sheet", "item"],
tabs: [
{
navSelector: ".sheet-navigation",
contentSelector: ".sheet-content",
initial: "base_values",
},
],
});
}