Gestion assommer/charge
This commit is contained in:
@@ -55,25 +55,7 @@ export class HeritiersActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
prepareArme(arme) {
|
||||
arme = duplicate(arme)
|
||||
let combat = this.getCombatValues()
|
||||
if (arme.system.typearme == "contact" || arme.system.typearme == "contactjet") {
|
||||
let bonusDefense = 0
|
||||
arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
|
||||
arme.system.attrKey = "pui"
|
||||
arme.system.totalDegats = arme.system.degats + "+" + combat.bonusDegatsTotal
|
||||
arme.system.totalOffensif = this.system.attributs.pui.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
|
||||
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense + bonusDefense
|
||||
arme.system.isdefense = true
|
||||
}
|
||||
if (arme.system.typearme == "jet" || arme.system.typearme == "tir") {
|
||||
arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance"))
|
||||
arme.system.attrKey = "adr"
|
||||
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
|
||||
arme.system.totalDegats = arme.system.degats
|
||||
if (arme.system.isdefense) {
|
||||
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense
|
||||
}
|
||||
}
|
||||
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
|
||||
return arme
|
||||
}
|
||||
|
||||
@@ -104,46 +86,46 @@ export class HeritiersActor extends Actor {
|
||||
}
|
||||
|
||||
/* ----------------------- --------------------- */
|
||||
getItemSorted( types) {
|
||||
let items = this.items.filter(item => types.includes(item.type )) || []
|
||||
getItemSorted(types) {
|
||||
let items = this.items.filter(item => types.includes(item.type)) || []
|
||||
HeritiersUtility.sortArrayObjectsByName(items)
|
||||
return items
|
||||
}
|
||||
getEquipments() {
|
||||
return this.getItemSorted( ["equipement", "accessoire"] )
|
||||
return this.getItemSorted(["equipement", "accessoire"])
|
||||
}
|
||||
getAvantages() {
|
||||
return this.getItemSorted( ["avantage"])
|
||||
return this.getItemSorted(["avantage"])
|
||||
}
|
||||
getDesavantages() {
|
||||
return this.getItemSorted( ["desavantage"])
|
||||
return this.getItemSorted(["desavantage"])
|
||||
}
|
||||
getMonnaies() {
|
||||
return this.getItemSorted( ["monnaie"])
|
||||
return this.getItemSorted(["monnaie"])
|
||||
}
|
||||
getArmors() {
|
||||
return this.getItemSorted( ["protection"])
|
||||
return this.getItemSorted(["protection"])
|
||||
}
|
||||
getTalents() {
|
||||
return this.getItemSorted( ["talent"])
|
||||
return this.getItemSorted(["talent"])
|
||||
}
|
||||
getContacts() {
|
||||
return this.getItemSorted( ["contact"])
|
||||
return this.getItemSorted(["contact"])
|
||||
}
|
||||
getAtouts() {
|
||||
return this.getItemSorted( ["atoutfeerique"])
|
||||
return this.getItemSorted(["atoutfeerique"])
|
||||
}
|
||||
getCapacites() {
|
||||
return this.getItemSorted( ["capacitenaturelle"])
|
||||
return this.getItemSorted(["capacitenaturelle"])
|
||||
}
|
||||
getFee() {
|
||||
return this.items.find(item => item.type =="fee")
|
||||
return this.items.find(item => item.type == "fee")
|
||||
}
|
||||
getProfils() {
|
||||
return this.getItemSorted( ["profil"])
|
||||
return this.getItemSorted(["profil"])
|
||||
}
|
||||
getPouvoirs() {
|
||||
return this.getItemSorted( ["pouvoir"])
|
||||
return this.getItemSorted(["pouvoir"])
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getSkills() {
|
||||
@@ -173,8 +155,8 @@ export class HeritiersActor extends Actor {
|
||||
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] = { skills: [], niveau: this.system.competences[key].niveau }
|
||||
if (game.system.lesheritiers.config.competenceProfil[key].kind == kind)
|
||||
comp[key] = { skills: [], niveau: this.system.competences[key].niveau }
|
||||
}
|
||||
for (let item of this.items) {
|
||||
if (item.type == "competence") {
|
||||
@@ -297,7 +279,7 @@ export class HeritiersActor extends Actor {
|
||||
let item = this.items.find(item => item.id == itemId)
|
||||
if (item) {
|
||||
console.log("Item ", item, itemField, dataType, value)
|
||||
if (dataType) {
|
||||
if (dataType) {
|
||||
if (dataType.toLowerCase() == "number") {
|
||||
value = Number(value)
|
||||
} else {
|
||||
@@ -313,14 +295,14 @@ export class HeritiersActor extends Actor {
|
||||
getPvMalus() {
|
||||
if (this.system.pv.value > 0) {
|
||||
if (this.system.pv.value < this.system.pv.max / 2) {
|
||||
return -1
|
||||
return { name: "Santé", value: -1 }
|
||||
}
|
||||
if (this.system.pv.value < 5) {
|
||||
return -2
|
||||
return { name: "Santé", value: -2 }
|
||||
}
|
||||
return 0
|
||||
return { name: "Santé", value: 0 }
|
||||
}
|
||||
return "Moribond(e)"
|
||||
return { name: "Moribond(e)", value: -50 }
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -482,19 +464,21 @@ export class HeritiersActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCurrentParade() {
|
||||
if ( this.system.statutmasque == "masque") {
|
||||
if (this.system.statutmasque == "masque") {
|
||||
return this.system.combat.parade.masquee
|
||||
}
|
||||
return this.system.combat.parade.demasquee
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCurrentEsquive() {
|
||||
if ( this.system.statutmasque == "masque") {
|
||||
if (this.system.statutmasque == "masque") {
|
||||
return this.system.combat.esquive.masquee
|
||||
}
|
||||
return this.system.combat.esquive.demasquee
|
||||
}
|
||||
|
||||
getCurrentResistancePhysique() {
|
||||
return this.system.combat.resistancephysique.value
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getTricherie() {
|
||||
return this.system.rang.tricherie.value
|
||||
@@ -511,7 +495,19 @@ export class HeritiersActor extends Actor {
|
||||
tricherie.value = Math.min(tricherie.value, tricherie.max)
|
||||
this.update({ 'system.rang.tricherie': tricherie })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getPireCompetence(compName1, compName2) {
|
||||
let comp1 = this.items.find( it => it.name == compName1)
|
||||
let comp2 = this.items.find( it => it.name == compName2)
|
||||
if ( comp1 && comp2 ) {
|
||||
if (comp1.system.niveau > comp2.system.niveau) {
|
||||
return comp1
|
||||
} else {
|
||||
return comp2
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData(compId = undefined, compName = undefined) {
|
||||
let rollData = HeritiersUtility.getBasicRollData()
|
||||
@@ -527,7 +523,7 @@ export class HeritiersActor extends Actor {
|
||||
rollData.useTricherie = false
|
||||
rollData.useSpecialite = false
|
||||
rollData.useHeritage = false
|
||||
rollData.pvMalus = this.getPvMalus()
|
||||
rollData.rulesMalus.push(this.getPvMalus())
|
||||
|
||||
if (compId) {
|
||||
rollData.competence = duplicate(this.items.get(compId) || {})
|
||||
@@ -538,7 +534,7 @@ export class HeritiersActor extends Actor {
|
||||
rollData.competence = duplicate(this.items.find(item => item.name.toLowerCase() == compName.toLowerCase()) || {})
|
||||
if (rollData.competence && rollData.competence.name) {
|
||||
this.prepareUtileSkill(rollData.competence)
|
||||
rollData.actionImg = rollData.competence?.img
|
||||
rollData.actionImg = rollData.competence?.img
|
||||
} else {
|
||||
rollData.competence = undefined
|
||||
}
|
||||
@@ -585,7 +581,7 @@ export class HeritiersActor extends Actor {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "competence"
|
||||
console.log("Compkey", compKey)
|
||||
rollData.competence = {name: this.system.competences[compKey].label, system: { niveau: this.system.competences[compKey].niveau }}
|
||||
rollData.competence = { name: this.system.competences[compKey].label, system: { niveau: this.system.competences[compKey].niveau } }
|
||||
console.log("RollDatra", rollData)
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
@@ -599,13 +595,15 @@ export class HeritiersActor extends Actor {
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAttaqueArme(armeId) {
|
||||
let arme = this.items.get(armeId)
|
||||
if (arme) {
|
||||
let competenceName = "Tir"
|
||||
let key = "prec"
|
||||
if (arme.system.categorie == "blanche" || arme.system.categorie == "improvise") {
|
||||
arme.system.isMelee = HeritiersUtility.isArmeMelee(arme)
|
||||
if ( arme.system.isMelee) {
|
||||
competenceName = "Mêlée"
|
||||
key = "agi"
|
||||
}
|
||||
@@ -614,16 +612,70 @@ export class HeritiersActor extends Actor {
|
||||
rollData.caracKey = key
|
||||
rollData.arme = duplicate(arme)
|
||||
rollData.mode = "arme"
|
||||
if (rollData.defenderTokenId && arme.system.isMelee ) {
|
||||
rollData.cacheDifficulte = true
|
||||
}
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAttaqueBrutaleArme(armeId) {
|
||||
let arme = this.items.get(armeId)
|
||||
if (arme) {
|
||||
let key = "for"
|
||||
let competenceName = "Mêlée"
|
||||
let rollData = this.getCommonRollData(undefined, competenceName)
|
||||
rollData.carac = this.system.caracteristiques[key]
|
||||
rollData.caracKey = key
|
||||
rollData.arme = duplicate(arme)
|
||||
rollData.mode = "attaquebrutale"
|
||||
rollData.rulesMalus.push({ name: "Attaque brutale", value: -2 } )
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async rollAttaqueChargeArme(armeId) {
|
||||
let arme = this.items.get(armeId)
|
||||
if (arme) {
|
||||
let key = "agi"
|
||||
let pireCompetence = this.getPireCompetence("Mêlée", "Mouvement")
|
||||
let rollData = this.getCommonRollData(undefined, pireCompetence.name)
|
||||
rollData.carac = this.system.caracteristiques[key]
|
||||
rollData.caracKey = key
|
||||
rollData.arme = duplicate(arme)
|
||||
rollData.mode = "attaquecharge"
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAssomerArme(armeId) {
|
||||
let arme = this.items.get(armeId)
|
||||
if (arme) {
|
||||
let competenceName = "Mêlée"
|
||||
let rollData = this.getCommonRollData(undefined, competenceName)
|
||||
rollData.carac = this.system.caracteristiques["agi"]
|
||||
rollData.caracKey = "agi"
|
||||
rollData.arme = duplicate(arme)
|
||||
rollData.mode = "assommer"
|
||||
if (rollData.defenderTokenId) {
|
||||
rollData.cacheDifficulte = true
|
||||
}
|
||||
let rollDialog = await HeritiersRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollPouvoir(pouvoirId) {
|
||||
let pouvoir = this.items.get(pouvoirId)
|
||||
if (pouvoir) {
|
||||
let rollData = this.getCommonRollData(undefined, undefined)
|
||||
if ( pouvoir.system.feeriemasque != "autre") {
|
||||
if (pouvoir.system.feeriemasque != "autre") {
|
||||
rollData.pouvoirBase = duplicate(this.system.rang[pouvoir.system.feeriemasque.toLowerCase()])
|
||||
rollData.pouvoirBase.label = "Féerie"
|
||||
rollData.carac = duplicate(this.system.caracteristiques[pouvoir.system.carac])
|
||||
|
Reference in New Issue
Block a user