Various fixes

This commit is contained in:
2023-03-11 12:11:27 +01:00
parent 02f8207fb7
commit f26cd7670c
11 changed files with 111 additions and 71 deletions

View File

@@ -14,8 +14,8 @@ export class HeritiersActorSheet extends ActorSheet {
return mergeObject(super.defaultOptions, {
classes: ["fvtt-les-heritiers", "sheet", "actor"],
template: "systems/fvtt-les-heritiers/templates/actor-sheet.html",
width: 640,
height: 720,
width: 780,
height: 840,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
editScore: false
@@ -38,7 +38,8 @@ export class HeritiersActorSheet extends ActorSheet {
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
limited: this.object.limited,
skills: this.actor.getSkills(),
utileSkills :this.actor.organizeUtileSkills(),
utileSkillsMental :this.actor.organizeUtileSkills("mental"),
utileSkillsPhysical :this.actor.organizeUtileSkills("physical"),
futileSkills :this.actor.organizeFutileSkills(),
contacts: this.actor.organizeContacts(),
armes: duplicate(this.actor.getWeapons()),
@@ -136,6 +137,10 @@ export class HeritiersActorSheet extends ActorSheet {
const key = $(event.currentTarget).data("key")
this.actor.rollCarac(key, false)
})
html.find('.roll-rang').click((event) => {
const key = $(event.currentTarget).data("rang-key")
this.actor.rollRang(key, false)
})
html.find('.roll-competence').click((event) => {
const li = $(event.currentTarget).parents(".item")
let compId = li.data("item-id")

View File

@@ -141,7 +141,7 @@ export class HeritiersActor extends Actor {
return this.getItemSorted( ["capacitenaturelle"])
}
getFee() {
return this.items.filter(item => item.type =="fee")
return this.items.find(item => item.type =="fee")
}
getProfils() {
return this.getItemSorted( ["profil"])
@@ -174,23 +174,25 @@ export class HeritiersActor extends Actor {
}
/* -------------------------------------------- */
organizeUtileSkills() {
organizeUtileSkills(kind = "mental") {
let comp = {}
for (let key in game.system.lesheritiers.config.competenceProfil) {
if ( game.system.lesheritiers.config.competenceProfil[key].kind == kind)
comp[key] = []
}
for (let item of this.items) {
if (item.type == "competence") {
if (item.system.categorie == "utile") {
if (item.system.categorie == "utile" && comp[item.system.profil]) {
this.prepareUtileSkill(item)
comp[item.system.profil].push(item)
}
}
}
for (let key in comp) {
HeritiersUtility.sortArrayObjectsByName(comp[key])
}
return comp
return Object.fromEntries(Object.entries(comp).sort())
}
/* -------------------------------------------- */
organizeContacts() {
@@ -553,6 +555,16 @@ export class HeritiersActor extends Actor {
rollDialog.render(true)
}
/* -------------------------------------------- */
async rollRang(key, isInit = false) {
let rollData = this.getCommonRollData()
rollData.mode = "rang"
rollData.rang = this.system.rang[key]
rollData.rangKey = key
let rollDialog = await HeritiersRollDialog.create(this, rollData)
rollDialog.render(true)
}
/* -------------------------------------------- */
async rollCompetence(compId) {
let rollData = this.getCommonRollData(compId)

View File

@@ -25,12 +25,12 @@ export const HERITIERS_CONFIG = {
},
competenceProfil : {
"aventurier": "Aventurier",
"roublard": "Roublard",
"combattant": "Combattant",
"erudit": "Erudit",
"savant": "Savant",
"gentleman": "Gentleman"
"aventurier": {kind: "physical", name: "Aventurier"},
"roublard": {kind: "physical",name: "Roublard"},
"combattant": {kind: "physical",name:"Combattant"},
"erudit": {kind: "mental",name:"Erudit"},
"savant": {kind: "mental",name:"Savant"},
"gentleman": {kind: "mental",name:"Gentleman"}
},
baseTestPouvoir: {
"feerie": "Féerie",

View File

@@ -44,30 +44,14 @@ export class HeritiersUtility {
/* -------------------------------------------- */
static sortByName(table) {
return table.sort(function (a, b) {
let fa = a.name.toLowerCase(),
fb = b.name.toLowerCase();
if (fa < fb) {
return -1;
}
if (fa > fb) {
return 1;
}
return 0;
return a.name.localeCompare(b.name);
})
}
/* -------------------------------------------- */
static sortArrayObjectsByName(myArray) {
myArray.sort((a, b) => {
let fa = a.name.toLowerCase();
let fb = b.name.toLowerCase();
if (fa < fb) {
return -1;
}
if (fa > fb) {
return 1;
}
return 0;
return a.name.localeCompare(b.name);
})
}
@@ -130,6 +114,7 @@ export class HeritiersUtility {
'systems/fvtt-les-heritiers/templates/partial-item-header.html',
'systems/fvtt-les-heritiers/templates/partial-item-description.html',
'systems/fvtt-les-heritiers/templates/partial-item-nav.html',
'systems/fvtt-les-heritiers/templates/partial-utile-skills.html',
'systems/fvtt-les-heritiers/templates/partial-list-niveau.html'
]
return loadTemplates(templatePaths);
@@ -358,14 +343,19 @@ export class HeritiersUtility {
rollData.nbDice = (rollData.useTricherie || rollData.useHeritage) ? 3 : 1
rollData.diceFormula = rollData.nbDice + rollData.mainDice + "kh1"
//console.log("BEFORE COMP", rollData)
let rangValue = 0
if (rollData.rang) {
rangValue = rollData.rang.value
}
if (rollData.competence) {
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
let specBonus = (rollData.useSpecialite) ? 1 : 0
rollData.diceFormula += `+${rollData.carac.value}+${rollData.competence.system.niveau}+${specBonus}+${rollData.bonusMalusContext}+${compmod}`
rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.competence.system.niveau}+${specBonus}+${rollData.bonusMalusContext}+${compmod}`
} else if (rollData.pouvoirBase) {
rollData.diceFormula += `+${rollData.pouvoirBase.value}+${rollData.bonusMalusContext}`
rollData.diceFormula += `+${rollData.pouvoirBase.value}+${rangValue}+${rollData.bonusMalusContext}`
} else {
rollData.diceFormula += `+${rollData.carac.value}+${rollData.bonusMalusContext}`
rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.bonusMalusContext}`
}
rollData.diceFormula += `+${rollData.pvMalus}`