Merge branch 'develop'

This commit is contained in:
Byroks 2023-12-15 21:36:50 +01:00
commit 8a3c632c7d
12 changed files with 154 additions and 40 deletions

View File

@ -91,6 +91,10 @@
"midgard5.origin": "Heimat",
"midgard5.faith": "Glaube",
"midgard5.currency-gold": "Gold",
"midgard5.currency-silver": "Silber",
"midgard5.currency-copper": "Kupfer",
"midgard5.exp-overall": "Erfahrungsschatz",
"midgard5.exp-available": "Erfahrungspunkte",
"midgard5.grace": "Göttliche Gnade",
@ -287,6 +291,7 @@
"midgard5.kido-variante-kontrollieren": "Kontrollieren",
"midgard5.mod-operation-add100": "Addieren (max 100)",
"midgard5.mod-operation-roll": "Wurf Modifikation",
"midgard5.mod-operation-add": "Addieren",
"midgard5.mod-operation-set": "Basiswert",
"midgard5.mod-operation-fixed": "Fester Wert",

View File

@ -1,6 +1,6 @@
{
"name": "foundry-system-midgard5",
"version": "2.3.0",
"version": "2.3.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -85,7 +85,7 @@ export enum M5Stats {
PROTECTION_LP = "lpProtection",
PROTECTION_AP = "apProtection",
PERCEPTION = "perception",
DRINKING = "drinking"
DRINKING = "drinking",
}
export enum M5ModType {
@ -96,6 +96,7 @@ export enum M5ModType {
export enum M5ModOperation {
ADD_100 = "add100",
ROLL = "roll",
ADD = "add",
SET = "set",
FIXED = "fixed",

View File

@ -171,12 +171,24 @@ export class M5Character extends Actor {
if (item.system.magic) {
label += "*";
}
let rollable = false;
// console.log(item.system.rolls.formulas.map((p) => p.enabled));
for (let key in item.system.rolls.formulas) {
rollable = item.system.rolls.formulas[key].enabled;
if (rollable) {
break;
}
}
ret.gear.items[item.id] = {
label: label,
magic: item.system.magic,
calc: item.system.calc,
equipped: item.system?.equipped,
value: item.system.value || 0,
currency: item.system.currency || "",
quantity: item.system.quantity || 0,
rollExist: rollable,
};
});
}

View File

@ -258,7 +258,6 @@ export class M5Item extends Item {
}
const roll = new M5Roll(rollData, this.actor, item.name);
console.log(roll);
return roll.toMessage();
} else {
ChatMessage.create({

View File

@ -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: "",

View File

@ -97,6 +97,60 @@ export default class M5CharacterSheet extends ActorSheet {
item.sheet.render(true);
});
html.find(".quantity-increase").on("click", async (event) => {
let row = event.target.parentElement;
let itemId = row.dataset["item"];
while (!itemId) {
row = row.parentElement;
if (!row) return;
itemId = row.dataset["item"];
}
const context = this.actor as any;
const item = context.items.get(itemId);
if (!item.system.quantity) {
item.system.quantity = 0;
}
item.system.quantity += 1;
this.render();
});
html.find(".quantity-decrease").on("click", async (event) => {
let row = event.target.parentElement;
let itemId = row.dataset["item"];
while (!itemId) {
row = row.parentElement;
if (!row) return;
itemId = row.dataset["item"];
}
const context = this.actor as any;
const item = context.items.get(itemId);
if (item.system.quantity > 0) {
item.system.quantity -= 1;
}
this.render();
});
html.find(".roll-consumable-item").on("click", async (event) => {
let row = event.target.parentElement;
let itemId = row.dataset["item"];
while (!itemId) {
row = row.parentElement;
if (!row) return;
itemId = row.dataset["item"];
}
const context = this.actor as any;
const item = context.items.get(itemId);
if (item.system.quantity > 0) {
item.system.quantity -= 1;
}
await item.roll();
this.render();
});
html.find(".item-delete").on("click", async (event) => {
let row = event.target.parentElement;
let itemId = row.dataset["item"];

View File

@ -3,7 +3,7 @@
"name": "midgard5",
"title": "Midgard 5. Edition",
"description": "The German RPG Midgard 5. Edition",
"version": "2.3.0",
"version": "2.3.1",
"compatibility": {
"minimum": "10",
"verified": "11",
@ -154,8 +154,8 @@
"primaryTokenAttribute": "lp",
"secondaryTokenAttribute": "ap",
"url": "https://github.com/Byroks/foundry-vtt-system-midgard5",
"manifest": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.0/system.json",
"download": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.0/midgard5-v2.3.0.zip",
"manifest": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.1/system.json",
"download": "https://github.com/Byroks/foundry-vtt-system-midgard5/releases/download/v2.3.1/midgard5-v2.3.1.zip",
"initiative": "@c.calc.attributes.gw.value",
"license": "LICENSE.txt"
}

View File

@ -16,7 +16,10 @@
"caste": "",
"occupation": "",
"origin": "",
"faith": ""
"faith": "",
"gold": 0,
"silver": 0,
"copper": 0
}
},
"characterBars": {

View File

@ -1,3 +1,20 @@
<table>
<thead>
<tr>
<th class="title" style="text-align: center">{{localize "midgard5.currency-gold"}}</th>
<th class="title" style="text-align: center">{{localize "midgard5.currency-silver"}}</th>
<th class="title" style="text-align: center">{{localize "midgard5.currency-copper"}}</th>
</tr>
</thead>
<tbody>
<tr>
<td class="fixed-value"><input type="number" name="data.info.gold" value="{{data.info.gold}}"></td>
<td class="fixed-value"><input type="number" name="data.info.silver" value="{{data.info.silver}}"></td>
<td class="fixed-value"><input type="number" name="data.info.copper" value="{{data.info.copper}}"></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
@ -106,10 +123,14 @@
<thead>
<tr>
<th class="title">{{localize "TYPES.Item.item"}}</th>
<th class="title center">{{localize "midgard5.item-quantity"}}</th>
<th class="title center">{{localize "midgard5.item-value"}}</th>
<th class="title"></th>
<th class="title"></th>
</tr>
</thead>
<tbody>
</tr>
{{#each data.calc.gear.items as |item itemId|}}
<tr data-item="{{itemId}}">
<td class="padding">
@ -118,6 +139,17 @@
<span class="spell-process">{{localize "midgard5.equipped"}}</span>
{{/if}}
</td>
<td>
<i class="fa fa-minus-circle quantity-decrease" style="cursor: pointer"></i>
<span>{{item.quantity}}</span>
<i class="fa fa-plus-circle quantity-increase" style="cursor: pointer"></i>
</td>
<td style="text-align: start">
{{#unless (or (eq item.value 0) (eq item.currency ""))}}
<span class="spell-process">{{item.value}} {{localize (m5concat "midgard5.currency-" item.currency)}}</span>
{{/unless}}
</td>
<td class="fixed-value">{{#if item.rollExist}}<button class="roll-button roll-consumable-item"></button>{{/if}}</td>
<td class="fixed-value"><a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a></td>
</tr>
{{/each}}

View File

@ -19,16 +19,34 @@
</div>
</td>
</tr>
<tr>
<td>
<div class="flexrow">
<span>{{localize "midgard5.item-quantity"}}</span>
<input id="data.quantity" type="number" name="data.quantity" value="{{data.quantity}}">
</div>
</td>
</tr>
<tr>
<td>
<div class="flexrow">
<span>{{localize "midgard5.item-value"}}</span>
<input name="data.value" type="text" value="{{data.value}}" data-dtype="Number" />
<input name="data.value" type="number" value="{{data.value}}" data-dtype="Number" />
<select class="select-mod-operation" name="data.currency" data-type="String">
{{#select data.currency}}
<option value=""></option>
<option value="copper">{{localize "midgard5.currency-copper"}}</option>
<option value="silver">{{localize "midgard5.currency-silver"}}</option>
<option value="gold">{{localize "midgard5.currency-gold"}}</option>
{{/select}}
</select>
</div>
</td>
</tr>
</table>
{{> "systems/midgard5/templates/sheets/item/rolls.hbs"}}
{{> "systems/midgard5/templates/sheets/partial/mod.hbs" mods=data.mods calc=data.calc}}

View File

@ -36,6 +36,7 @@
{{#select mod.operation}}
{{#if (eq mod.type "attribute")}}
<option value="add100">{{localize "midgard5.mod-operation-add100"}}</option>
<option value="roll">{{localize "midgard5.mod-operation-roll"}}</option>
{{/if}}
<option value="add">{{localize "midgard5.mod-operation-add"}}</option>
<option value="set">{{localize "midgard5.mod-operation-set"}}</option>
@ -48,7 +49,7 @@
</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>
</tr>
{{/each}}