Fiche acteur, WIP
This commit is contained in:
@ -44,30 +44,20 @@ export class HeritiersUtility {
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getModificateurOptions() {
|
||||
let opt = []
|
||||
for (let i = -15; i <= 15; i++) {
|
||||
opt.push(`<option value="${i}">${i}</option>`)
|
||||
}
|
||||
return opt.concat("\n")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getPointAmeOptions() {
|
||||
let opt = []
|
||||
for (let i = 1; i <= 20; i++) {
|
||||
opt.push(`<option value="${i}">${i}</option>`)
|
||||
}
|
||||
return opt.concat("\n")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getAttributs() {
|
||||
return { adr: "Adresse", pui: "Puissance", cla: "Clairvoyance", pre: "Présence", tre: "Trempe" }
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static pushInitiativeOptions(html, options) {
|
||||
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;
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -77,7 +67,7 @@ export class HeritiersUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async ready() {
|
||||
const skills = await HeritiersUtility.loadCompendium("fvtt-les-heritiers.skills")
|
||||
const skills = await HeritiersUtility.loadCompendium("fvtt-les-heritiers.competences")
|
||||
this.skills = skills.map(i => i.toObject())
|
||||
|
||||
}
|
||||
@ -129,11 +119,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-list-niveau.html',
|
||||
'systems/fvtt-les-heritiers/templates/partial-item-prix.html',
|
||||
'systems/fvtt-les-heritiers/templates/partial-sante-etat.html',
|
||||
'systems/fvtt-les-heritiers/templates/partial-automation.html',
|
||||
'systems/fvtt-les-heritiers/templates/hud-adversites.html',
|
||||
'systems/fvtt-les-heritiers/templates/partial-list-niveau.html'
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
@ -297,77 +283,42 @@ export class HeritiersUtility {
|
||||
/* -------------------------------------------- */
|
||||
static computeResult(rollData) {
|
||||
rollData.diceResult = rollData.roll.terms[0].results[0].result
|
||||
if (rollData.mainDice.includes("d20")) {
|
||||
let diceValue = rollData.roll.terms[0].results[0].result
|
||||
if (diceValue % 2 == 1) {
|
||||
//console.log("PAIR/IMP2", diceValue)
|
||||
rollData.finalResult -= rollData.roll.terms[0].results[0].result // Substract value
|
||||
if (diceValue == 1 || diceValue == 11) {
|
||||
rollData.isDramatique = true
|
||||
rollData.isSuccess = false
|
||||
}
|
||||
if (rollData.mainDice.includes("d10")) {
|
||||
if ( rollData.diceResult == 1) {
|
||||
rollData.finalResult -= 3
|
||||
}
|
||||
}
|
||||
|
||||
//console.log("Result : ", rollData)
|
||||
if (rollData.difficulte > 0 && !rollData.isDramatique) {
|
||||
rollData.isSuccess = (rollData.finalResult >= rollData.difficulte)
|
||||
rollData.isHeroique = ((rollData.finalResult - rollData.difficulte) >= 10)
|
||||
rollData.isDramatique = ((rollData.finalResult - rollData.difficulte) <= -10)
|
||||
if (rollData.mainDice.includes("d12")) {
|
||||
if ( rollData.diceResult == 1 || rollData.diceResult == 2) {
|
||||
rollData.finalResult -= 5
|
||||
}
|
||||
}
|
||||
//rollData.finalResult = Math.max(rollData.finalResult, 0)
|
||||
//console.log("Result : ", rollData)
|
||||
if (rollData.sdValue > 0 ) {
|
||||
rollData.marge = rollData.finalResult - rollData.sdValue
|
||||
rollData.isSuccess = (rollData.finalResult >= rollData.sdValue)
|
||||
rollData.isCriticalSuccess = ((rollData.finalResult - rollData.sdValue) >= 7)
|
||||
rollData.isCriticalFailure = ((rollData.finalResult - rollData.sdValue) <= -7)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollHeritiers(rollData) {
|
||||
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
if (rollData.attrKey == "tochoose") { // No attr selected, force address
|
||||
rollData.attrKey = "adr"
|
||||
}
|
||||
if (!rollData.attr) {
|
||||
rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
|
||||
rollData.attr = duplicate(actor.system.attributs[rollData.attrKey])
|
||||
}
|
||||
|
||||
if (rollData.maitriseId != "none") {
|
||||
rollData.selectedMaitrise = rollData.maitrises.find(p => p.id == rollData.maitriseId)
|
||||
rollData.diceFormula = "2" + rollData.mainDice + "kh"
|
||||
} else {
|
||||
rollData.diceFormula = "1" + rollData.mainDice
|
||||
}
|
||||
//rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
|
||||
rollData.carac = duplicate(actor.system.caracteristiques[rollData.caracKey])
|
||||
rollData.diceFormula = rollData.mainDice
|
||||
|
||||
//console.log("BEFORE COMP", rollData)
|
||||
if (rollData.competence) {
|
||||
rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => pred.acquise && !pred.maitrise && !pred.used) || [])
|
||||
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
|
||||
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.system.niveau}+${rollData.modificateur}+${compmod}`
|
||||
|
||||
if (rollData.selectedTalents && rollData.selectedTalents.length > 0) {
|
||||
for (let id of rollData.selectedTalents) {
|
||||
let talent = rollData.talents.find(t => t._id == id)
|
||||
let bonusOK = true
|
||||
if (talent.system.baCost) {
|
||||
bonusOK = actor.checkBonneAventure(talent.system.baCost)
|
||||
if (bonusOK) {
|
||||
actor.changeBonneAventure(-talent.system.baCost)
|
||||
} else {
|
||||
ui.notifications.warn("Vous n'avez pas assez de points de Bonne Aventure !")
|
||||
}
|
||||
}
|
||||
if (bonusOK) {
|
||||
rollData.diceFormula += `+${talent.system.bonus}`
|
||||
}
|
||||
}
|
||||
}
|
||||
rollData.diceFormula += `+${rollData.bonusMalusContext}`
|
||||
rollData.diceFormula += `+${rollData.carac.value}+${rollData.competence.system.niveau}+${rollData.bonusMalusContext}+${compmod}`
|
||||
} else {
|
||||
rollData.diceFormula += `+${rollData.attr.value}*${rollData.multiplier}+${rollData.modificateur}+${rollData.bonusMalusContext}`
|
||||
}
|
||||
|
||||
// Ajout adversités
|
||||
rollData.diceFormula += `-${rollData.nbAdversites}`
|
||||
|
||||
if (rollData.arme && rollData.arme.type == "arme") {
|
||||
rollData.diceFormula += `+${rollData.arme.system.bonusmaniementoff}`
|
||||
}
|
||||
@ -495,10 +446,8 @@ export class HeritiersUtility {
|
||||
let rollData = {
|
||||
rollId: randomID(16),
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
modificateursOptions: this.getModificateurOptions(),
|
||||
pointAmeOptions: this.getPointAmeOptions(),
|
||||
difficulte: 0,
|
||||
modificateur: 0,
|
||||
sdList: game.system.lesheritiers.config.seuilsDifficulte,
|
||||
sdValue: 0,
|
||||
bonusMalusContext: 0
|
||||
}
|
||||
return rollData
|
||||
|
Reference in New Issue
Block a user