Update sheet
This commit is contained in:
@@ -106,33 +106,30 @@ export class HeritiersActor extends Actor {
|
||||
getEquipments() {
|
||||
return this.items.filter(item => item.type == "equipement")
|
||||
}
|
||||
/* ----------------------- --------------------- */
|
||||
getArtefacts() {
|
||||
return this.items.filter(item => item.type == "artefact")
|
||||
getAvantages() {
|
||||
return this.items.filter(item => item.type == "avantage")
|
||||
}
|
||||
getDesavantages() {
|
||||
return this.items.filter(item => item.type == "desavantage")
|
||||
}
|
||||
/* ----------------------- --------------------- */
|
||||
getMonnaies() {
|
||||
return this.items.filter(item => item.type == "monnaie")
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getArmors() {
|
||||
return this.items.filter(item => item.type == "protection")
|
||||
}
|
||||
getHistoriques() {
|
||||
return this.items.filter(item => item.type == "historique")
|
||||
}
|
||||
getProfils() {
|
||||
return this.items.filter(item => item.type == "profil")
|
||||
}
|
||||
getTalents() {
|
||||
return this.items.filter(item => item.type == "talent")
|
||||
}
|
||||
getRessources() {
|
||||
return this.items.filter(item => item.type == "ressource")
|
||||
}
|
||||
getContacts() {
|
||||
return this.items.filter(item => item.type == "contact")
|
||||
}
|
||||
getAtouts() {
|
||||
return this.items.filter(item => item.type == "atoutfeerique")
|
||||
}
|
||||
getCapacites() {
|
||||
return this.items.filter(item => item.type == "capacitenaturelle")
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getSkills() {
|
||||
let comp = []
|
||||
@@ -262,90 +259,17 @@ export class HeritiersActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
checkAttribut(attribut, minLevel) {
|
||||
let attr = this.system.attributs.find(at => at.labelnorm == attribut.toLowerCase())
|
||||
if (attr && attr.value >= minLevel) {
|
||||
return { isValid: true, attr: duplicate(attr) }
|
||||
}
|
||||
return { isValid: false }
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
checkAttributOrCompetenceLevel(compName, minLevel) {
|
||||
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase() && i.system.niveau >= minLevel)
|
||||
if (comp) {
|
||||
return { isValid: true, item: duplicate(comp) }
|
||||
} else {
|
||||
for (let attrKey in this.system.attributs) {
|
||||
if (this.system.attributs[attrKey].label.toLowerCase() == compName.toLowerCase() && this.system.attributs[attrKey].value >= minLevel) {
|
||||
return { isValid: true, item: duplicate(this.system.attributs[attrKey]) }
|
||||
}
|
||||
getPvMalus() {
|
||||
if (this.system.pv.value > 0) {
|
||||
if (this.system.pv.value < this.system.pv.max / 2) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
return { isValid: false, warningMessage: `Prérequis insuffisant : la compétence/attribut ${compName} doit être de niveau ${minLevel} au minimum` }
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
addCompetenceBonus(compName, bonus, baCost) {
|
||||
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
||||
if (comp) {
|
||||
comp = duplicate(comp)
|
||||
comp.system.bonus = bonus
|
||||
comp.system.baCost = baCost
|
||||
return { isValid: true, item: comp }
|
||||
}
|
||||
return { isValid: false, warningMessage: `Compétence ${compName} non trouvée` }
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
checkIfCompetence(compName) {
|
||||
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
||||
if (comp) {
|
||||
return { isValid: true, item: comp }
|
||||
}
|
||||
return { isValid: false }
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getVigueur() {
|
||||
return this.system.sante.vigueur
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getVigueurBonus() {
|
||||
let talents = this.items.filter(item => item.type == "talent" && item.system.isautomated)
|
||||
let bonus = 0
|
||||
for (let talent of talents) {
|
||||
for (let auto of talent.system.automations) {
|
||||
if (auto.eventtype == "bonus-permanent" && auto.bonusname == "vigueur") {
|
||||
bonus += Number(auto.bonus || 0)
|
||||
}
|
||||
if (this.system.pv.value < 5) {
|
||||
return -2
|
||||
}
|
||||
return 0
|
||||
}
|
||||
return bonus
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getBonneAventure() {
|
||||
return this.system.bonneaventure.actuelle
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
checkBonneAventure(cost) {
|
||||
return (this.system.bonneaventure.actuelle >= cost)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
changeBonneAventure(value) {
|
||||
let newBA = this.system.bonneaventure.actuelle
|
||||
newBA += value
|
||||
this.update({ 'system.bonneaventure.actuelle': newBA })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getEclat() {
|
||||
return this.system.eclat.value
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
changeEclat(value) {
|
||||
let newE = this.system.eclat.value
|
||||
newE += value
|
||||
this.update({ 'system.eclat.value': newE })
|
||||
return "Moribond(e)"
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -514,6 +438,14 @@ export class HeritiersActor extends Actor {
|
||||
getHeritages() {
|
||||
return this.system.rang.heritage.value
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
incDecTricherie(value) {
|
||||
let tricherie = this.system.rang.tricherie
|
||||
tricherie.value += value
|
||||
tricherie.value = Math.max(tricherie.value, 0)
|
||||
tricherie.value = Math.min(tricherie.value, tricherie.max)
|
||||
this.update({ 'system.rang.tricherie': tricherie })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData(compId = undefined, compName = undefined) {
|
||||
@@ -529,6 +461,7 @@ export class HeritiersActor extends Actor {
|
||||
rollData.heritage = this.getHeritages()
|
||||
rollData.useTricherie = false
|
||||
rollData.useHeritage = false
|
||||
rollData.pvMalus = this.getPvMalus()
|
||||
|
||||
if (compId) {
|
||||
rollData.competence = duplicate(this.items.get(compId) || {})
|
||||
@@ -542,10 +475,11 @@ export class HeritiersActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAttribut(attrKey, isInit = false) {
|
||||
let rollData = this.getCommonRollData(attrKey)
|
||||
rollData.multiplier = (isInit) ? 1 : 2
|
||||
rollData.isInit = isInit
|
||||
async rollCarac(key, isInit = false) {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "carac"
|
||||
rollData.carac = this.system.caracteristiques[key]
|
||||
rollData.caracKey = key
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
@@ -553,7 +487,7 @@ export class HeritiersActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence(compId) {
|
||||
let rollData = this.getCommonRollData(compId)
|
||||
rollData.multiplier = 1 // Attr multiplier, always 1 in competence mode
|
||||
rollData.mode = "competence"
|
||||
console.log("RollDatra", rollData)
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
|
Reference in New Issue
Block a user