#70-classes-as-items (#92)

Co-authored-by: LeFrique <lefrique@live.de>
Reviewed-on: #92
This commit was merged in pull request #92.
This commit is contained in:
2024-03-23 19:17:54 +01:00
co-authored by Le-Frique
parent af6fdbbf89
commit 12e6412a9f
11 changed files with 399 additions and 75 deletions
+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 = {
@@ -194,12 +182,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);
@@ -223,7 +207,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)
@@ -499,6 +483,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")
@@ -565,7 +568,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,
+11 -6
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 = {};
+8
View File
@@ -433,6 +433,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",
},
],
});
}
+23
View File
@@ -365,4 +365,27 @@
}
}
}
.chip {
display: inline-block;
padding: 0 25px;
height: 35px;
font-size: 16px;
line-height: 35px;
border-radius: 25px;
background-color: #f1f1f1;
}
.closebtn {
padding-left: 10px;
color: #888;
font-weight: bold;
float: right;
font-size: 20px;
cursor: pointer;
}
.closebtn:hover {
color: #000;
}
}
+5 -4
View File
@@ -1,6 +1,6 @@
// main: midgard5.less
.midgard5.sheet.item {
.midgard5.sheet.item {
form {
display: flex;
flex-direction: column;
@@ -15,10 +15,11 @@
}
.item-img {
height: 64px;
width: 64px;
width: 64px;
}
td, th {
td,
th {
padding: 0 0.5rem 0 0.5rem;
&.center {
@@ -40,7 +41,7 @@
.col-create {
width: 3rem;
text-align: center;
button {
background: rgba(255, 255, 255, 0.5);
}
+179 -25
View File
@@ -6,7 +6,7 @@
"info": {
"description": "",
"background": "",
"class": "",
"class": {},
"race": "",
"magicUsing": false,
"showAllItems": false,
@@ -140,12 +140,11 @@
"wahrsagen": { "fw": 0, "attribute": "zt", "initial": 8, "pp": 0 },
"wasserkampf": { "fw": 0, "attribute": "gw", "initial": 8, "pp": 0 },
"zauberkunde": { "fw": 0, "attribute": "in", "initial": 8, "pp": 0 }
}
}
}
},
"gear": {
"gear": {
}
"gear": {}
}
},
"character": {
@@ -154,7 +153,7 @@
}
},
"Item": {
"types": ["skill", "weapon", "defensiveWeapon", "armor", "spell", "kampfkunst", "item", "effect", "container"],
"types": ["skill", "weapon", "defensiveWeapon", "armor", "spell", "kampfkunst", "item", "effect", "container", "class"],
"templates": {
"itemDescription": {
"description": ""
@@ -207,11 +206,11 @@
"equipped": false
},
"valuable": {
"valuable": false,
"valuable": false,
"item-wealth": true
},
"hoarded": {
"hoarded": false,
"hoarded": false,
"inHoard": true
},
"physical": {
@@ -231,29 +230,36 @@
"spellSelection": {
"spellProcessSelection": {
"none": "midgard5.spell-process-none",
"artefakte": "midgard5.spell-process-artefakte",
"beherrschen": "midgard5.spell-process-beherrschen",
"bewegen": "midgard5.spell-process-bewegen",
"blutzauber": "midgard5.spell-process-blutzauber",
"beschwoeren": "midgard5.spell-process-beschwoeren",
"blutmagie": "midgard5.spell-process-blutmagie",
"chaoswunder": "midgard5.spell-process-chaoswunder",
"dweomer": "midgard5.spell-process-dweomer",
"erhaltung": "midgard5.spell-process-erhaltung",
"erkennen": "midgard5.spell-process-erkennen",
"erschaffen": "midgard5.spell-process-erschaffen",
"formen": "midgard5.spell-process-formen",
"finstere_magie": "midgard5.spell-process-finstere_magie",
"veraendern": "midgard5.spell-process-veraendern",
"zerstoeren": "midgard5.spell-process-zerstoeren",
"wundertat": "midgard5.spell-process-wundertat",
"dweomer": "midgard5.spell-process-dweomer",
"wilder_dweomer": "midgard5.spell-process-wilder_dweomer",
"zauberlied": "midgard5.spell-process-zauberlied",
"salz": "midgard5.spell-process-salz",
"thaumagraphie": "midgard5.spell-process-thaumagraphie",
"beschwoeren": "midgard5.spell-process-beschwoeren",
"kampfverse": "midgard5.spell-process-kampfverse",
"namensmagie": "midgard5.spell-process-namensmagie",
"nekromantie": "midgard5.spell-process-nekromantie",
"thaumatherapie": "midgard5.spell-process-thaumatherapie",
"runenstaebe": "midgard5.spell-process-zauberrunen",
"thaumatherapie": "midgard5.spell-process-runenstaebe",
"veraendern": "midgard5.spell-process-veraendern",
"vigilsignien": "midgard5.spell-process-vigilsignien",
"wilder_dweomer": "midgard5.spell-process-wilder_dweomer",
"wundertat": "midgard5.spell-process-wundertat",
"zauberblaetter": "midgard5.spell-process-zauberblaetter",
"zauberlied": "midgard5.spell-process-zauberlied",
"zaubermittel": "midgard5.spell-process-zaubermittel",
"zauberschutz": "midgard5.spell-process-zauberschutz",
"zauberrunen": "midgard5.spell-process-zauberrunen",
"zaubersiegel": "midgard5.spell-process-siegel"
"zaubersalz": "midgard5.spell-process-zaubersalz",
"zauberschutz": "midgard5.spell-process-zauberschutz",
"zaubersiegel": "midgard5.spell-process-zaubersiegel",
"zaubertaenze": "midgard5.spell-process-zaubertaenze",
"zerstoeren": "midgard5.spell-process-zerstoeren"
},
"spellTypeSelection": {
"gedanke": "midgard5.spell-type-gedanke",
@@ -289,7 +295,7 @@
"fechten": "midgard5.kampfkunst-variante-fechten",
"schusstechnik": "midgard5.kampfkunst-variante-schusstechnik",
"finten": "midgard5.kampfkunst-variante-finten",
"geistestechnik": "midgard5.kampfkunst-variante-geistestechnik",
"geistestechnik": "midgard5.kampfkunst-variante-geistestechnik",
"verteidigung": "midgard5.kampfkunst-variante-verteidigung"
},
"kidoVarianteSelection": {
@@ -325,7 +331,7 @@
"calc": {}
},
"item": {
"templates": ["itemDescription", "equippable", "physical","valuable","hoarded"],
"templates": ["itemDescription", "equippable", "physical", "valuable", "hoarded"],
"rolls": {
"formulas": {},
"output": ""
@@ -352,7 +358,7 @@
"calc": {}
},
"weapon": {
"templates": ["itemDescription", "stats", "equippable", "physical","valuable","hoarded"],
"templates": ["itemDescription", "stats", "equippable", "physical", "valuable", "hoarded"],
"special": false,
"ranged": false,
"valuable": false,
@@ -377,7 +383,7 @@
"calc": {}
},
"defensiveWeapon": {
"templates": ["itemDescription", "stats", "equippable", "physical","valuable","hoarded"],
"templates": ["itemDescription", "stats", "equippable", "physical", "valuable", "hoarded"],
"special": false,
"valuable": false,
"hoarded": false,
@@ -395,7 +401,7 @@
"calc": {}
},
"armor": {
"templates": ["itemDescription", "stats", "equippable", "attributeMod", "physical","valuable","hoarded"],
"templates": ["itemDescription", "stats", "equippable", "attributeMod", "physical", "valuable", "hoarded"],
"lpProtection": 0,
"apProtection": 0,
"valuable": false,
@@ -459,6 +465,154 @@
"output": ""
},
"calc": {}
},
"class": {
"templates": ["itemDescription"],
"magicUsing": false,
"equipped": true,
"resistanceBody": 1,
"resistanceMind": 0,
"calc": {},
"mods": {},
"lernKostenAllgemein": {
"alltag": 20,
"freiland": 20,
"halbwelt": 20,
"kampf": 20,
"koerper": 20,
"sozial": 20,
"unterwelt": 20,
"waffen": 20,
"wissen": 20
},
"lernKostenZauber": {
"beherrschen": {
"kosten": 0,
"pp": 0
},
"bewegen": {
"kosten": 0,
"pp": 0
},
"erkennen": {
"kosten": 0,
"pp": 0
},
"erschaffen": {
"kosten": 0,
"pp": 0
},
"formen": {
"kosten": 0,
"pp": 0
},
"veraendern": {
"kosten": 0,
"pp": 0
},
"zerstoeren": {
"kosten": 0,
"pp": 0
},
"wundertat": {
"kosten": 0,
"pp": 0
},
"dweomer": {
"kosten": 0,
"pp": 0
},
"zauberlied": {
"kosten": 0,
"pp": 0
},
"kampfverse": {
"kosten": 0,
"pp": 0
},
"zaubertaenze": {
"kosten": 0,
"pp": 0
},
"zaubersalz": {
"kosten": 0,
"pp": 0
},
"runenstaebe": {
"kosten": 0,
"pp": 0
},
"zaubersiegel": {
"kosten": 0,
"pp": 0
},
"zauberrunen": {
"kosten": 0,
"pp": 0
},
"thaumagraphie": {
"kosten": 0,
"pp": 0
},
"erhaltung": {
"kosten": 0,
"pp": 0
},
"zaubermittel": {
"kosten": 0,
"pp": 0
},
"zauberschutz": {
"kosten": 0,
"pp": 0
},
"zauberblaetter": {
"kosten": 0,
"pp": 0
},
"vigilsignien": {
"kosten": 0,
"pp": 0
},
"artefakte": {
"kosten": 0,
"pp": 0
},
"chaoswunder": {
"kosten": 0,
"pp": 0
},
"wilder_dweomer": {
"kosten": 0,
"pp": 0
},
"nekromantie": {
"kosten": 0,
"pp": 0
},
"finstere_magie": {
"kosten": 0,
"pp": 0
},
"blutmagie": {
"kosten": 0,
"pp": 0
},
"beschwoeren": {
"kosten": 0,
"pp": 0
},
"namensmagie": {
"kosten": 0,
"pp": 0
}
},
"lernKostenKamptechnik": {
"kampfkunst": 90,
"fechtkunst": 90,
"schiesskunst": 90,
"kido": 90
}
}
}
}