Merge branch 'develop' into lasten

This commit is contained in:
2024-02-23 13:52:05 +01:00
13 changed files with 388 additions and 120 deletions
+7
View File
@@ -61,6 +61,13 @@ export enum M5ItemType {
EFFECT = "effect",
}
export enum M5SkillType {
INNATE = "innate",
GENERAL = "general",
LANGUAGE = "language",
COMBAT = "combat",
}
export enum M5EwResult {
TBD = "",
FUMBLE = "roll-ew-result-fumble",
+3 -2
View File
@@ -1,5 +1,5 @@
import { M5Item } from "../items/M5Item";
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5ModType, M5RollData, M5Skill, M5SkillCalculated } from "../M5Base";
import { M5Attribute, M5CharacterCalculatedData, M5ItemMod, M5ItemType, M5ModOperation, M5ModResult, M5ModType, M5RollData, M5Skill, M5SkillCalculated, M5SkillLearned, M5SkillType } from "../M5Base";
import M5ModAggregate from "./M5ModAggregate";
export class M5Character extends Actor {
// constructor(
@@ -666,10 +666,11 @@ export class M5Character extends Actor {
});
}
async createItem(itemName: string, itemType: M5ItemType): Promise<M5Item> {
createItem(itemName: string, itemType: M5ItemType, options?: any): Promise<M5Item> {
const itemData = {
name: itemName,
type: itemType,
data: options,
};
return (this as any).createEmbeddedDocuments("Item", [itemData]).then((docs) => {
-21
View File
@@ -269,27 +269,6 @@ export class M5Roll {
return new M5Roll(rollData, actor, (game as Game).i18n.localize("midgard5.resistanceMind"));
}
static async initativeRoll(actor: any) {
let newInitiative; // the initiative value for the combatant
// ...
// The intnitiative value is calculated here
// ...
let combatant = game["combat"].getCombatantByActor(actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: actor._id }]);
combatant = game["combat"].getCombatantByActor(actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
static resistanceBody(actor: any) {
const rollData = actor.getRollData() as M5RollData;
rollData.i = {
+86 -33
View File
@@ -1,7 +1,7 @@
import Logger from "../../utils/Logger";
import { M5Character } from "../actors/M5Character";
import { M5Item } from "../items/M5Item";
import { M5ItemType, M5SkillLearned, M5SkillUnlearned } from "../M5Base";
import { M5ItemType, M5SkillLearned, M5SkillType, M5SkillUnlearned } from "../M5Base";
import { M5Roll } from "../rolls/M5Roll";
export default class M5CharacterSheet extends ActorSheet {
@@ -282,14 +282,7 @@ export default class M5CharacterSheet extends ActorSheet {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.item"), M5ItemType.ITEM).then((i) => {
const item = i as any;
item.update({
data: {
quantity: 1,
},
});
});
character.createItem((game as Game).i18n.localize("TYPES.Item.item"), M5ItemType.ITEM, { quantity: 1 });
});
html.find(".add-weapon").on("click", async (event) => {
@@ -317,42 +310,51 @@ export default class M5CharacterSheet extends ActorSheet {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.container"), M5ItemType.CONTAINER).then((i) => {
const item = i as any;
item.update({
data: {
quantity: 1,
},
});
});
character.createItem((game as Game).i18n.localize("TYPES.Item.container"), M5ItemType.CONTAINER, { quantity: 1 });
});
html.find(".add-innate-skill").on("click", async (event) => {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.innate-ability"), M5ItemType.SKILL, { type: M5SkillType.INNATE });
});
html.find(".add-general-skill").on("click", async (event) => {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.skill"), M5ItemType.SKILL, { type: M5SkillType.GENERAL });
});
html.find(".add-combat-skill").on("click", async (event) => {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.weapon-skill"), M5ItemType.SKILL, { type: M5SkillType.COMBAT });
});
html.find(".add-language-skill").on("click", async (event) => {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.language"), M5ItemType.SKILL, { type: M5SkillType.LANGUAGE });
});
html.find(".add-spell").on("click", async (event) => {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.spell"), M5ItemType.SPELL).then((i) => {
const item = i as any;
item.update({
data: {
process: "none",
},
});
});
character.createItem((game as Game).i18n.localize("TYPES.Item.spell"), M5ItemType.SPELL, { process: "none" });
});
html.find(".add-kampfkunst").on("click", async (event) => {
const data = this.actor.system;
const character = this.actor as M5Character;
character.createItem((game as Game).i18n.localize("TYPES.Item.kampfkunst"), M5ItemType.KAMPFKUNST).then((i) => {
const item = i as any;
item.update({
data: {
type: "angriff",
variante: "anstuermen",
},
});
character.createItem((game as Game).i18n.localize("TYPES.Item.kampfkunst"), M5ItemType.KAMPFKUNST, {
type: "angriff",
variante: "anstuermen",
});
});
@@ -363,6 +365,57 @@ export default class M5CharacterSheet extends ActorSheet {
character.createItem((game as Game).i18n.localize("TYPES.Item.effect"), M5ItemType.EFFECT);
});
html.find(".join-combat").on("click", async (event) => {
if (!!game["combat"]) {
let combatant = game["combat"].getCombatantByActor(this.actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
combatant = game["combat"].getCombatantByActor(this.actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: this.actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
});
html.find(".ranged-combat").on("click", async (event) => {
if (!!game["combat"]) {
let combatant = game["combat"].getCombatantByActor(this.actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
combatant = game["combat"].getCombatantByActor(this.actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: 0.01 * this.actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
});
html.find(".spell-combat").on("click", async (event) => {
if (!!game["combat"]) {
let combatant = game["combat"].getCombatantByActor(this.actor._id);
if (!combatant) {
await game["combat"].createEmbeddedDocuments("Combatant", [{ actorId: this.actor._id }]);
combatant = game["combat"].getCombatantByActor(this.actor._id);
}
const initiatives = {
_id: combatant._id,
initiative: 0.001 * this.actor.system.calc.attributes.gw.value,
};
await game["combat"].updateEmbeddedDocuments("Combatant", [initiatives]);
}
});
// Drag & Drop
const dragDrop = new DragDrop({
dragSelector: ".items-list .item",