Ajout des impacts
This commit is contained in:
@@ -39,9 +39,9 @@ export class EcrymeActorSheet extends ActorSheet {
|
||||
traits: this.actor.getRollTraits(),
|
||||
ideal: this.actor.getIdeal(),
|
||||
spleen: this.actor.getSpleen(),
|
||||
system: duplicate(this.object.system),
|
||||
impacts: this.object.getImpacts(),
|
||||
config: duplicate(game.system.ecryme.config),
|
||||
weapons: duplicate(this.actor.getWeapons()),
|
||||
weapons: this.actor.getWeapons(),
|
||||
archetype: duplicate(this.actor.getArchetype()),
|
||||
equipements: duplicate(this.actor.getEquipements()),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
@@ -121,6 +121,13 @@ export class EcrymeActorSheet extends ActorSheet {
|
||||
this.actor.rollSkillConfront(categKey, skillKey)
|
||||
});
|
||||
|
||||
html.find('.impact-modify').click((event) => {
|
||||
let impactType = $(event.currentTarget).data("impact-type")
|
||||
let impactLevel = $(event.currentTarget).data("impact-level")
|
||||
let modifier = Number($(event.currentTarget).data("impact-modifier"))
|
||||
this.actor.modifyImpact(impactType, impactLevel, modifier)
|
||||
});
|
||||
|
||||
html.find('.roll-weapon').click((event) => {
|
||||
const armeId = $(event.currentTarget).data("arme-id")
|
||||
this.actor.rollArme(armeId)
|
||||
|
@@ -107,7 +107,8 @@ export class EcrymeActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getSpecialization(id) {
|
||||
return this.items.find(it => it.type == "specialization" && it.id == id)
|
||||
let spec = this.items.find(it => it.type == "specialization" && it.id == id)
|
||||
return spec
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getSpecializations(skillKey) {
|
||||
@@ -126,6 +127,11 @@ export class EcrymeActor extends Actor {
|
||||
return skills
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getImpacts() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'impact') || [])
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || [])
|
||||
EcrymeUtility.sortArrayObjectsByName(comp)
|
||||
@@ -214,12 +220,26 @@ export class EcrymeActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async equipGear(equipmentId) {
|
||||
let item = this.items.find(item => item.id == equipmentId);
|
||||
if (item && item.system) {
|
||||
if (item?.system) {
|
||||
let update = { _id: item.id, "system.equipped": !item.system.equipped };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
modifyImpact(impactType, impactLevel, modifier) {
|
||||
console.log(impactType, impactLevel, modifier)
|
||||
let current = this.system.impacts[impactType][impactLevel]
|
||||
if (modifier > 0) {
|
||||
while ( EcrymeUtility.getImpactMax(impactLevel) == current && impactLevel != "major") {
|
||||
impactLevel = EcrymeUtility.getNextImpactLevel(impactLevel)
|
||||
current = this.system.impacts[impactType][impactLevel]
|
||||
}
|
||||
}
|
||||
let newImpact = Math.max(this.system.impacts[impactType][impactLevel] + modifier, 0)
|
||||
this.update({ [`system.impacts.${impactType}.${impactLevel}`]: newImpact})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
clearInitiative() {
|
||||
this.getFlag("world", "initiative", -1)
|
||||
|
@@ -6,6 +6,7 @@ export const ECRYME_CONFIG = {
|
||||
spleen: "Spleen",
|
||||
ideal: "Ideal"
|
||||
},
|
||||
|
||||
traitLevel: [
|
||||
{value: -3, text: "-3"},
|
||||
{value: -2, text: "-2"},
|
||||
@@ -14,6 +15,17 @@ export const ECRYME_CONFIG = {
|
||||
{value: +2, text: "+2"},
|
||||
{value: +3, text: "+3"}
|
||||
],
|
||||
impactTypes: {
|
||||
physical: "ECRY.ui.physical",
|
||||
mental: "ECRY.ui.mental",
|
||||
social: "ECRY.ui.social"
|
||||
},
|
||||
impactLevels: {
|
||||
superficial: "ECRY.ui.superficial",
|
||||
light: "ECRY.ui.light",
|
||||
serious: "ECRY.ui.serious",
|
||||
major: "ECRY.ui.major"
|
||||
},
|
||||
difficulty: {
|
||||
"-1": {difficulty: "ECRY.ui.none", frequency: "ECRY.ui.none", value: "-"},
|
||||
"8": { difficulty: "ECRY.ui.troublesome", frequency: "ECRY.ui.occasional", value: 8 },
|
||||
|
@@ -1,6 +1,9 @@
|
||||
/* -------------------------------------------- */
|
||||
import { EcrymeCommands } from "../app/ecryme-commands.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const __maxImpacts = {superficial: 4, light: 3, serious: 2, major: 1}
|
||||
const __nextImpacts = {superficial: "light", light: "serious", serious: "major", major: "major"}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class EcrymeUtility {
|
||||
@@ -150,7 +153,8 @@ export class EcrymeUtility {
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-nav.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-equipment.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-description.hbs',
|
||||
'systems/fvtt-ecryme/templates/dialogs/partial-common-roll-dialog.hbs'
|
||||
'systems/fvtt-ecryme/templates/dialogs/partial-common-roll-dialog.hbs',
|
||||
'systems/fvtt-ecryme/templates/actors/partial-impacts.hbs'
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
@@ -264,7 +268,13 @@ export class EcrymeUtility {
|
||||
|
||||
return chatData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getImpactMax(impactLevel) {
|
||||
return __maxImpacts[impactLevel]
|
||||
}
|
||||
static getNextImpactLevel(impactLevel) {
|
||||
return __nextImpacts[impactLevel]
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async showDiceSoNice(roll, rollMode) {
|
||||
if (game.modules.get("dice-so-nice")?.active) {
|
||||
@@ -304,7 +314,7 @@ export class EcrymeUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeRollFormula(rollData, isConfrontation = false) {
|
||||
static computeRollFormula(rollData, actor, isConfrontation = false) {
|
||||
// Build the dice formula
|
||||
let diceFormula = (isConfrontation) ? "4d6" : "2d6"
|
||||
if (rollData.useIdeal) {
|
||||
@@ -358,7 +368,7 @@ export class EcrymeUtility {
|
||||
}
|
||||
rollData.difficulty = Number(rollData.difficulty)
|
||||
|
||||
let diceFormula = this.computeRollFormula(rollData)
|
||||
let diceFormula = this.computeRollFormula(rollData, actor)
|
||||
|
||||
// Performs roll
|
||||
let myRoll = new Roll(diceFormula).roll({ async: false })
|
||||
@@ -369,7 +379,7 @@ export class EcrymeUtility {
|
||||
|
||||
this.computeResults(rollData)
|
||||
|
||||
console.log("ERRRRR", rollData)
|
||||
console.log("rollData", rollData)
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
|
@@ -69,7 +69,7 @@ export class EcrymeConfrontDialog extends Dialog {
|
||||
let dataJSON = event.dataTransfer.getData('text/plain')
|
||||
let data = JSON.parse(dataJSON)
|
||||
let idx = Number(data.diceIndex)
|
||||
console.log("DATA", data, event, event.srcElement.className)
|
||||
//console.log("DATA", data, event, event.srcElement.className)
|
||||
if ( event.srcElement.className.includes("execution")) {
|
||||
this.rollData.availableDices[idx].location = "execution"
|
||||
}
|
||||
|
Reference in New Issue
Block a user