Merge branch 'develop'

This commit is contained in:
2024-05-27 10:12:33 +02:00
30 changed files with 786 additions and 111 deletions
+5
View File
@@ -15,6 +15,11 @@ const preloadTemplates = async (): Promise<Handlebars.TemplateDelegate<any>[]> =
"sheets/character/spells.hbs",
"sheets/character/combat.hbs",
"sheets/character/effects.hbs",
"sheets/npc/main.hbs",
"sheets/npc/combat.hbs",
"sheets/npc/properties.hbs",
"sheets/npc/description.hbs",
"sheets/npc/attribute.hbs",
"sheets/partial/mod.hbs",
"sheets/item/rolls.hbs",
"chat/roll-m5.hbs",
+1
View File
@@ -162,6 +162,7 @@ export interface M5AttributeCalculated extends M5ModResult {
export interface M5CharacterCalculatedData {
level: number;
movement: number;
attributes: {
st: M5AttributeCalculated;
gs: M5AttributeCalculated;
+25 -18
View File
@@ -152,6 +152,7 @@ export class M5Character extends Actor {
ret.level = M5Character.levelFromExp(data.info.race === "Zwerg" ? Math.min(data.calc.stats?.hoard * 2 || 0, data.es) : data.es);
//Set all values that are not dependent on another Value
ret.attributes.st.value = M5Character.attributeMinMax(data.attributes.st); // TODO item effects
ret.attributes.gs.value = M5Character.attributeMinMax(data.attributes.gs);
ret.attributes.gw.value = M5Character.attributeMinMax(data.attributes.gw);
@@ -176,29 +177,11 @@ export class M5Character extends Actor {
ret.stats.ap = this.modResult(data.ap);
ret.stats.lpProtection = this.modResult(0);
ret.stats.apProtection = this.modResult(0);
ret.stats.defense = this.modResult(M5Character.defenseFromLevel(ret.level));
ret.stats.damageBonus = this.modResult(Math.floor(ret.attributes.st.value / 20) + Math.floor(ret.attributes.gs.value / 30) - 3);
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(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);
ret.stats.poisonResistance = this.modResult(30 + Math.floor(ret.attributes.ko.value / 2));
ret.stats.enduranceBonus = Math.floor(ret.attributes.ko.value / 10) + Math.floor(ret.attributes.st.value / 20);
ret.stats.deprivationCold = this.modResult(Math.floor(ret.attributes.ko.value / 2));
ret.stats.deprivationHeat = this.modResult(Math.floor(ret.attributes.ko.value / 2));
ret.stats.deprivationFood = this.modResult(Math.floor(40 + ret.attributes.ko.value / 2));
ret.stats.hoardMin = M5Character.levelThreshold.at(ret.level - 1) / 2;
ret.stats.hoardNext = M5Character.levelThreshold.at(ret.level) / 2;
ret.stats.wealth = parseFloat((data.info.gold + data.info.silver / 10 + data.info.copper / 100).toPrecision(3));
ret.stats.hoard = 0;
ret.stats.load = M5Character.loadValue(data.attributes.st);
ret.stats.heavyLoad = M5Character.heavyLoadValue(data.attributes.st);
ret.stats.loadMax = M5Character.maxLoadValue(data.attributes.st);
ret.stats.thrustLoad = M5Character.thrustLoadValue(data.attributes.st);
ret.stats.encumbrance = 0;
if (!skip?.mods) {
@@ -221,6 +204,25 @@ export class M5Character extends Actor {
ret.skillMods = aggregate.calculate();
}
ret.stats.defense = this.modResult(M5Character.defenseFromLevel(ret.level));
ret.stats.damageBonus = this.modResult(Math.floor(ret.attributes.st.value / 20) + Math.floor(ret.attributes.gs.value / 30) - 3);
ret.stats.attackBonus = this.modResult(ret.attributes.gs.bonus);
ret.stats.defenseBonus = this.modResult(ret.attributes.gw.bonus);
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);
ret.stats.poisonResistance = this.modResult(30 + Math.floor(ret.attributes.ko.value / 2));
ret.stats.enduranceBonus = Math.floor(ret.attributes.ko.value / 10) + Math.floor(ret.attributes.st.value / 20);
ret.stats.deprivationCold = this.modResult(Math.floor(ret.attributes.ko.value / 2));
ret.stats.deprivationHeat = this.modResult(Math.floor(ret.attributes.ko.value / 2));
ret.stats.deprivationFood = this.modResult(Math.floor(40 + ret.attributes.ko.value / 2));
ret.stats.load = M5Character.loadValue(data.attributes.st);
ret.stats.heavyLoad = M5Character.heavyLoadValue(data.attributes.st);
ret.stats.loadMax = M5Character.maxLoadValue(data.attributes.st);
ret.stats.thrustLoad = M5Character.thrustLoadValue(data.attributes.st);
if (!skip?.containers) {
context.items
?.filter((item) => item.type === "container")
@@ -280,6 +282,7 @@ export class M5Character extends Actor {
if (!!item.system.containerId) {
ret.gear.containers[item.system.containerId].weight += parseFloat((item.system.weight * item.system.quantity).toPrecision(4));
ret.gear.containers[item.system.containerId].value += parseFloat(this.calculateValue(item.system.value * item.system.quantity, item.system.currency).toPrecision(3));
if (ret.gear.containers[item.system.containerId].equipped) {
ret.stats.encumbrance += item.system.weight * item.system.quantity;
}
@@ -302,6 +305,7 @@ export class M5Character extends Actor {
label: label,
icon: icon,
magic: item.system.magic,
abw: item.system.abw || 0,
calc: item.system.calc,
equipped: item.system?.equipped,
valuable: item.system?.valuable,
@@ -352,6 +356,7 @@ export class M5Character extends Actor {
icon: item.img,
skillId: item.system.skillId,
magic: item.system.magic,
abw: item.system.abw || 0,
valuable: item.system?.valuable,
hoarded: item.system?.hoarded,
value: item.system.value || 0,
@@ -395,6 +400,7 @@ export class M5Character extends Actor {
icon: item.img,
skillId: item.system.skillId,
magic: item.system.magic,
abw: item.system.abw || 0,
valuable: item.system?.valuable,
hoarded: item.system?.hoarded,
value: item.system.value || 0,
@@ -438,6 +444,7 @@ export class M5Character extends Actor {
label: label,
icon: item.img,
magic: item.system.magic,
abw: item.system.abw || 0,
valuable: item.system?.valuable,
hoarded: item.system?.hoarded,
value: item.system.value || 0,
+13 -7
View File
@@ -314,7 +314,7 @@ export class M5Item extends Item {
return ret;
}
async roll() {
async roll(toggleAutomatedRoll = false) {
const item = this as any;
// Initialize chat data.
@@ -341,14 +341,20 @@ export class M5Item extends Item {
}
});
if (item.type === "spell" || item.type === "kampfkunst") {
if (this.actor["system"].ap.value >= item.system.ap) {
this.actor["system"].ap.value -= item.system.ap;
const roll = new M5Roll(rollData, this.actor, item.name, item.id);
if (await roll.toMessage(toggleAutomatedRoll)) {
if (item.type === "spell" || item.type === "kampfkunst") {
if (this.actor["system"].ap.value >= item.system.ap) {
this.actor["update"]({
data: {
ap: {
value: this.actor["system"].ap.value - item.system.ap,
},
},
});
}
}
}
const roll = new M5Roll(rollData, this.actor, item.name, item.id);
return roll.toMessage();
} else {
ChatMessage.create({
speaker: speaker,
+26 -8
View File
@@ -11,7 +11,12 @@ export class M5Roll {
public _total: number = 0;
public pool: PoolTerm = null;
constructor(public data: M5RollData, public actor: any, public label: string, public id?: string) {
constructor(
public data: M5RollData,
public actor: any,
public label: string,
public id?: string
) {
//super(null)
//this.data = rollData
}
@@ -26,7 +31,7 @@ export class M5Roll {
.map((rollName, index) => {
indexMap.set(index, rollName);
const formula = this.data.rolls[rollName];
formula.formula = index === 0 && this.id !== "-1" ? formula.formula.replace(/(\d*d\d*)/, `{$1 + ${this.data.b.modifier}}`) : formula.formula;
formula.formula = index === 0 && this.id !== "-1" ? formula.formula + `+ ${this.data.b.modifier}` : formula.formula;
const roll = new Roll(formula.formula, this.data);
return roll;
});
@@ -90,6 +95,7 @@ export class M5Roll {
this.data.res.label = this.label;
if ((game as Game).settings.get("midgard5", "automatedPP") && this.data.iType !== null) {
if ((this.data.i.type === "language" || this.data.i.type === "general") && this.data.rolls[0].dice[0] >= 16) {
ui.notifications.notify(`Praxispunkt eingetragen für ${this.actor.items.get(this.id).name}`);
this.actor.items.get(this.id).update({
system: {
pp: this.data.i.pp + 1,
@@ -97,6 +103,7 @@ export class M5Roll {
});
} else if (this.data.rolls[0].dice[0] === 20) {
if (this.data.i.type === "combat") {
ui.notifications.notify(`Praxispunkt eingetragen für ${this.actor.items.get(this.id).name}`);
// Rolling through skill
this.actor.items.get(this.id).update({
system: {
@@ -104,6 +111,7 @@ export class M5Roll {
},
});
} else if (this.data.iType === "weapon") {
ui.notifications.notify(`Praxispunkt eingetragen für ${this.actor.items.get(this.id).name}`);
// Rolling through Weapon Item
const skill = this.actor.items.get(this.data.i.skillId);
skill.update({
@@ -112,6 +120,7 @@ export class M5Roll {
},
});
} else if (this.data.iType === "defensiveWeapon") {
ui.notifications.notify(`Praxispunkt eingetragen für ${this.actor.items.get(this.id).name}`);
// Rolling through defensiveWeapon Item
const skill = this.actor.items.get(this.data.i.skillId);
skill.update({
@@ -120,6 +129,7 @@ export class M5Roll {
},
});
} else if (this.data.iType === "spell") {
ui.notifications.notify(`Praxispunkt eingetragen für ${this.data.i.process}`);
// Rolling through Spell Item
const klasse = this.actor.items.find((x) => x.type === "class" && x.system.equipped);
klasse.update({
@@ -142,18 +152,26 @@ export class M5Roll {
return renderTemplate(M5Roll.TEMPLATE_PATH, this.data);
}
async toMessage() {
let checkOptions = await this.popUp({ isPW: this.data.rolls[0].label === (game as Game).i18n.localize("midgard5.pw") });
if (checkOptions["cancelled"]) {
return;
async toMessage(toggleAutomatedRoll = false) {
let automatedRoll = (game as Game).settings.get("midgard5", "automatedRoll");
automatedRoll = toggleAutomatedRoll ? !automatedRoll : automatedRoll;
const rMode = (game as Game).settings.get("core", "rollMode");
if (!automatedRoll) {
let checkOptions = await this.popUp({ isPW: this.data.rolls[0].label === (game as Game).i18n.localize("midgard5.pw") });
if (checkOptions["cancelled"]) {
return;
} else {
const rMode = checkOptions["rollMode"];
this.data.b = checkOptions;
}
} else {
this.data.b = checkOptions;
this.data.b = { difficulty: 20, modifier: 0 };
}
if (!this._evaluated) await this.evaluate();
const faces = this.pool.dice.map((x) => x.faces);
const rMode = checkOptions["rollMode"] || (game as Game).settings.get("core", "rollMode");
const chatData = {
type: CONST.CHAT_MESSAGE_TYPES.ROLL,
content: await this.render(),
+48 -16
View File
@@ -7,7 +7,6 @@ import { M5Roll } from "../rolls/M5Roll";
export default class M5CharacterSheet extends ActorSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
template: "systems/midgard5/templates/sheets/character/main.hbs",
width: 1000,
height: 800,
classes: ["midgard5", "sheet", "character"],
@@ -21,7 +20,15 @@ export default class M5CharacterSheet extends ActorSheet {
});
}
// get template() {
get template() {
//console.log("M5CharacterSheet", this.actor.data.type)
if (this.actor.type === "npc") {
return "systems/midgard5/templates/sheets/npc/main.hbs";
}
else {
return "systems/midgard5/templates/sheets/character/main.hbs";
}
}
// return "systems/midgard5/templates/character_sheet/main.hbs"
// }Options extends ActorSheet.Options = ActorSheet.Options, Data extends object = ActorSheet.Data<Options>
@@ -78,7 +85,8 @@ export default class M5CharacterSheet extends ActorSheet {
let attributeValue = target ? parseInt(target.dataset.value) : null;
let attributeStr = target ? target.dataset.attribute : null;
const roll = M5Roll.fromAttributeValue(this.actor, attributeStr, attributeValue);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".edit-item").on("click", async (event) => {
@@ -138,7 +146,8 @@ export default class M5CharacterSheet extends ActorSheet {
});
}
await item.roll();
let toggleAutomatedRoll = (event.shiftKey)
await item.roll(toggleAutomatedRoll);
this.render();
});
@@ -158,7 +167,8 @@ export default class M5CharacterSheet extends ActorSheet {
const actor = this.actor as any;
const item = actor.items.get(skillId) as M5Item;
await item.roll();
let toggleAutomatedRoll = (event.shiftKey)
await item.roll(toggleAutomatedRoll);
});
html.find(".roll-general-button").on("click", async (event) => {
@@ -169,7 +179,8 @@ export default class M5CharacterSheet extends ActorSheet {
const unlearnedSkill = data.skills.general[skillName] as M5SkillUnlearned;
const roll = M5Roll.fromUnlearnedSkill(this.actor, unlearnedSkill, skillName);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".learn-button").on("click", async (event) => {
@@ -267,48 +278,57 @@ export default class M5CharacterSheet extends ActorSheet {
const context = this.actor as any;
const item = context.items.get(itemId) as M5Item;
await item.roll();
let toggleAutomatedRoll = (event.shiftKey)
await item.roll(toggleAutomatedRoll);
this.render();
});
html.find(".roll-brawl-button").on("click", async (event) => {
const roll = M5Roll.brawl(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".roll-cleanSpell-button").on("click", async (event) => {
const roll = M5Roll.cleanSpell(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".roll-deprivationCold-button").on("click", async (event) => {
const roll = M5Roll.deprivationCold(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".roll-deprivationHeat-button").on("click", async (event) => {
const roll = M5Roll.deprivationHeat(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".roll-deprivationFood-button").on("click", async (event) => {
const roll = M5Roll.deprivationFood(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".roll-defense-button").on("click", async (event) => {
const roll = M5Roll.defense(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".roll-resistanceMind-button").on("click", async (event) => {
const roll = M5Roll.resistanceMind(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".roll-resistanceBody-button").on("click", async (event) => {
const roll = M5Roll.resistanceBody(this.actor);
await roll.toMessage();
let toggleAutomatedRoll = (event.shiftKey)
await roll.toMessage(toggleAutomatedRoll);
});
html.find(".change-equipped").on("click", async (event) => {
@@ -526,7 +546,11 @@ export default class M5CharacterSheet extends ActorSheet {
let data = null;
try {
data = JSON.parse(event.dataTransfer.getData("text/plain"));
data.data.system.containerId = ""; //Clean containerId
console.log("Data", data.data);
let target = event.target.closest("[data-container-id]") as HTMLElement;
let containerId = target ? target.dataset.containerId : "";
console.log("Container ID", containerId);
data.data.system.containerId = containerId; //Update containerId
if (data.type !== "Transfer") return false;
} catch (err) {
return false;
@@ -535,6 +559,14 @@ export default class M5CharacterSheet extends ActorSheet {
if (!data.data) return false;
if (data.actorId === this.actor.id) {
let itemId=data.data._id;
const context = this.actor as any;
const item = context.items.get(itemId);
item.update({
data: {
containerId: data.data.system.containerId,
},
});
return this._onSortItem(event, data.data);
}
+9
View File
@@ -13,4 +13,13 @@ export const loadSettings = async function () {
default: true,
type: Boolean,
});
(game as Game).settings.register("midgard5", "automatedRoll", {
name: "Automatische Würfelwürfe",
hint: "Falls aktiv, wird bei Würfelwürfen kein Dialog gezeigt. Das Verhalten kann mit gleichzeitig gedrückter Shift Taste umgekehrt werden.",
scope: "world",
config: true,
default: false,
type: Boolean,
});
};
+23
View File
@@ -0,0 +1,23 @@
// main: midgard5.less
@borderGroove: 2px groove #eeede0;
@attributeBorderColor: rgba(0, 0, 0, 0.5);
.midgard5 {
.sheet-npc {
.attribute-header {
align-items: center;
text-align: center;
font-weight: bold;
border: 0px solid transparent;
}
.attribute-value {
align-items: center;
text-align: center;
border: 0px solid transparent;
}
.fixed-value {
width: 3rem;
text-align: center;
}
}
}
+3 -3
View File
@@ -3,7 +3,7 @@
"name": "midgard5",
"title": "Midgard 5. Edition",
"description": "The German RPG Midgard 5. Edition",
"version": "2.6.0",
"version": "2.7.0",
"compatibility": {
"minimum": "10",
"verified": "11",
@@ -24,8 +24,8 @@
"primaryTokenAttribute": "lp",
"secondaryTokenAttribute": "ap",
"url": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5",
"manifest": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/v2.6.0/system.json",
"download": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/v2.6.0/midgard5-v2.6.0.zip",
"manifest": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/latest/system.json?token=2455375115b92bc8d87c93df7159eec232456f2d",
"download": "https://git.byroks.de/MidgardVTT-Entwicklung/foundry-vtt-system-midgard5/releases/download/latest/midgard5.zip?token=2455375115b92bc8d87c93df7159eec232456f2d",
"initiative": "@c.calc.attributes.gw.value",
"license": "LICENSE.txt"
}
+25 -7
View File
@@ -1,15 +1,18 @@
{
"Actor": {
"types": ["character"],
"types": [
"character",
"npc"
],
"templates": {
"characterDescription": {
"info": {
"description": "",
"background": "",
"class": {},
"npc-class": "",
"race": "",
"magicUsing": false,
"showAllItems": false,
"gender": "",
"weight": "",
"height": "",
@@ -19,9 +22,12 @@
"occupation": "",
"origin": "",
"faith": "",
"level": 1,
"gold": 0,
"silver": 0,
"copper": 0
"copper": 0,
"showAllItems": false,
"showUnlearned": false
}
},
"characterBars": {
@@ -44,6 +50,8 @@
"gp": 0
},
"attributes": {
"level": 1,
"movement": 24,
"attributes": {
"st": { "value": 50, "bonus": 0 },
"gs": { "value": 50, "bonus": 0 },
@@ -53,7 +61,8 @@
"zt": { "value": 50, "bonus": 0 },
"au": { "value": 50, "bonus": 0 },
"pa": { "value": 50, "bonus": 0 },
"wk": { "value": 50, "bonus": 0 }
"wk": { "value": 50, "bonus": 0 },
"git": { "value": 50, "bonus": 0 }
}
},
"skills": {
@@ -156,6 +165,10 @@
"character": {
"templates": ["characterBars", "attributes", "characterDescription", "characterHeader", "skills", "gear"],
"calc": {}
},
"npc": {
"templates": ["characterBars", "attributes", "characterDescription", "skills", "gear"],
"calc": {}
}
},
"Item": {
@@ -224,7 +237,8 @@
"weight": 0,
"capacity": 0,
"containerId": "",
"magic": false
"magic": false,
"abw": 0
},
"durationSelection": {
"durationSelection": {
@@ -314,7 +328,8 @@
"ausweichen": "midgard5.kido-variante-ausweichen",
"blockieren": "midgard5.kido-variante-blockieren",
"bewegen": "midgard5.kido-variante-bewegen",
"kontrollieren": "midgard5.kido-variante-kontrollieren"
"kontrollieren": "midgard5.kido-variante-kontrollieren",
"finte": "midgard5.kido-variante-finte"
}
}
},
@@ -374,6 +389,7 @@
"hoarded": false,
"skillId": "",
"damageBase": "1d6",
"ew": 5,
"rolls": {
"formulas": {
"0": {
@@ -438,6 +454,7 @@
"agens": "",
"reagens": "",
"material": "",
"rank": 0,
"rolls": {
"formulas": {
"0": {
@@ -459,10 +476,11 @@
"ap": "",
"weapon": "",
"ep": "",
"rank": "",
"rank": 0,
"enemy": "",
"color": "",
"style": "",
"grade": "",
"rolls": {
"formulas": {
"0": {