|
|
@ -56,9 +56,8 @@ export class HawkmoonActor extends Actor {
|
|
|
|
arme.system.attrKey = "pui"
|
|
|
|
arme.system.attrKey = "pui"
|
|
|
|
arme.system.totalDegats = arme.system.degats + "+" + combat.bonusDegatsTotal
|
|
|
|
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.totalOffensif = this.system.attributs.pui.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
|
|
|
|
if (arme.system.isdefense) {
|
|
|
|
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense
|
|
|
|
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
|
|
|
|
arme.system.isdefense = true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (arme.system.typearme == "jet" || arme.system.typearme == "tir") {
|
|
|
|
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.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance"))
|
|
|
@ -66,7 +65,7 @@ export class HawkmoonActor extends Actor {
|
|
|
|
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
|
|
|
|
arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff
|
|
|
|
arme.system.totalDegats = arme.system.degats
|
|
|
|
arme.system.totalDegats = arme.system.degats
|
|
|
|
if (arme.system.isdefense) {
|
|
|
|
if (arme.system.isdefense) {
|
|
|
|
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef
|
|
|
|
arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.seuildefense
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return arme
|
|
|
|
return arme
|
|
|
@ -135,13 +134,26 @@ export class HawkmoonActor extends Actor {
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
getDefenseBase() {
|
|
|
|
getDefenseBase() {
|
|
|
|
return this.system.attributs.tre.value
|
|
|
|
return Math.max(this.system.attributs.tre.value, this.system.attributs.pui.value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
getVitesseBase() {
|
|
|
|
getVitesseBase() {
|
|
|
|
return 5 + __vitesseBonus[this.system.attributs.adr.value]
|
|
|
|
return 5 + __vitesseBonus[this.system.attributs.adr.value]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
getProtection() {
|
|
|
|
|
|
|
|
let equipProtection = 0
|
|
|
|
|
|
|
|
for(let armor in this.items) {
|
|
|
|
|
|
|
|
if (armor.type == "protection" && armor.system.equipped) {
|
|
|
|
|
|
|
|
equipProtection += Number(armor.system.protection)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (equipProtection < 4) {
|
|
|
|
|
|
|
|
return 4 + equipProtection // Cas des boucliers + sans armure
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return equipProtection // Uniquement la protection des armures + boucliers
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
getCombatValues() {
|
|
|
|
getCombatValues() {
|
|
|
@ -153,7 +165,8 @@ export class HawkmoonActor extends Actor {
|
|
|
|
vitesseBase: this.getVitesseBase(),
|
|
|
|
vitesseBase: this.getVitesseBase(),
|
|
|
|
vitesseTotal: this.getVitesseBase() + this.system.combat.vitessebonus,
|
|
|
|
vitesseTotal: this.getVitesseBase() + this.system.combat.vitessebonus,
|
|
|
|
defenseBase: this.getDefenseBase(),
|
|
|
|
defenseBase: this.getDefenseBase(),
|
|
|
|
defenseTotal: this.getDefenseBase() + this.system.combat.defensebonus
|
|
|
|
protection : this.getProtection(),
|
|
|
|
|
|
|
|
defenseTotal: this.getDefenseBase() + this.system.combat.defensebonus + this.getProtection() - this.getTotalAdversite()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return combat
|
|
|
|
return combat
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -171,9 +184,9 @@ export class HawkmoonActor extends Actor {
|
|
|
|
prepareDerivedData() {
|
|
|
|
prepareDerivedData() {
|
|
|
|
|
|
|
|
|
|
|
|
if (this.type == 'personnage') {
|
|
|
|
if (this.type == 'personnage') {
|
|
|
|
let vigueur = Math.floor( (this.system.attributs.pui.value + this.system.attributs.tre.value) / 2)
|
|
|
|
let vigueur = Math.floor((this.system.attributs.pui.value + this.system.attributs.tre.value) / 2)
|
|
|
|
if (vigueur != this.system.sante.vigueur) {
|
|
|
|
if (vigueur != this.system.sante.vigueur) {
|
|
|
|
this.update( { 'system.sante.vigueur': vigueur})
|
|
|
|
this.update({ 'system.sante.vigueur': vigueur })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -221,44 +234,44 @@ export class HawkmoonActor extends Actor {
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
checkAttribut(attribut, minLevel) {
|
|
|
|
checkAttribut(attribut, minLevel) {
|
|
|
|
let attr = this.system.attributs.find( at => at.labelnorm == attribut.toLowerCase() )
|
|
|
|
let attr = this.system.attributs.find(at => at.labelnorm == attribut.toLowerCase())
|
|
|
|
if (attr && attr.value >= minLevel) {
|
|
|
|
if (attr && attr.value >= minLevel) {
|
|
|
|
return {isValid: true, attr: duplicate(attr) }
|
|
|
|
return { isValid: true, attr: duplicate(attr) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {isValid: false}
|
|
|
|
return { isValid: false }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
checkAttributOrCompetenceLevel(compName, minLevel) {
|
|
|
|
checkAttributOrCompetenceLevel(compName, minLevel) {
|
|
|
|
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase() && i.system.niveau >= minLevel)
|
|
|
|
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase() && i.system.niveau >= minLevel)
|
|
|
|
if ( comp) {
|
|
|
|
if (comp) {
|
|
|
|
return {isValid: true, item: duplicate(comp) }
|
|
|
|
return { isValid: true, item: duplicate(comp) }
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
for (let attrKey in this.system.attributs) {
|
|
|
|
for (let attrKey in this.system.attributs) {
|
|
|
|
if ( this.system.attributs[attrKey].label.toLowerCase() == compName.toLowerCase() && this.system.attributs[attrKey].value >= minLevel ) {
|
|
|
|
if (this.system.attributs[attrKey].label.toLowerCase() == compName.toLowerCase() && this.system.attributs[attrKey].value >= minLevel) {
|
|
|
|
return {isValid: true, item: duplicate(this.system.attributs[attrKey]) }
|
|
|
|
return { isValid: true, item: duplicate(this.system.attributs[attrKey]) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {isValid: false, warningMessage: `Prérequis insuffisant : la compétence/attribut ${compName} doit être de niveau ${minLevel} au minimum`}
|
|
|
|
return { isValid: false, warningMessage: `Prérequis insuffisant : la compétence/attribut ${compName} doit être de niveau ${minLevel} au minimum` }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
addCompetenceBonus(compName, bonus, baCost) {
|
|
|
|
addCompetenceBonus(compName, bonus, baCost) {
|
|
|
|
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
|
|
|
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
|
|
|
if ( comp) {
|
|
|
|
if (comp) {
|
|
|
|
comp = duplicate(comp)
|
|
|
|
comp = duplicate(comp)
|
|
|
|
comp.system.bonus = bonus
|
|
|
|
comp.system.bonus = bonus
|
|
|
|
comp.system.baCost = baCost
|
|
|
|
comp.system.baCost = baCost
|
|
|
|
return {isValid: true, item: comp }
|
|
|
|
return { isValid: true, item: comp }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {isValid: false, warningMessage: `Compétence ${compName} non trouvée`}
|
|
|
|
return { isValid: false, warningMessage: `Compétence ${compName} non trouvée` }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
checkIfCompetence( compName ) {
|
|
|
|
checkIfCompetence(compName) {
|
|
|
|
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
|
|
|
let comp = this.items.find(i => i.type == "competence" && i.name.toLowerCase() == compName.toLowerCase())
|
|
|
|
if ( comp) {
|
|
|
|
if (comp) {
|
|
|
|
return {isValid: true, item: comp}
|
|
|
|
return { isValid: true, item: comp }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {isValid: false }
|
|
|
|
return { isValid: false }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
getBonneAventure() {
|
|
|
|
getBonneAventure() {
|
|
|
@ -305,7 +318,7 @@ export class HawkmoonActor extends Actor {
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
getBonusDegats() {
|
|
|
|
getBonusDegats() {
|
|
|
|
return __degatsBonus[this.system.attributs.pui.value]
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
@ -342,11 +355,24 @@ export class HawkmoonActor extends Actor {
|
|
|
|
await this.update({ 'system.subactors': newArray });
|
|
|
|
await this.update({ 'system.subactors': newArray });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
getTotalAdversite() {
|
|
|
|
|
|
|
|
return this.system.adversite.bleue + this.system.adversite.rouge + this.system.adversite.noire
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
async incDecAdversite(adv, incDec = 0) {
|
|
|
|
|
|
|
|
let adversite = duplicate(this.system.adversite)
|
|
|
|
|
|
|
|
adversite[adv] += Number(incDec)
|
|
|
|
|
|
|
|
adversite[adv] = Math.max(adversite[adv], 0)
|
|
|
|
|
|
|
|
this.update({ 'system.adversite': adversite })
|
|
|
|
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async incDecQuantity(objetId, incDec = 0) {
|
|
|
|
async incDecQuantity(objetId, incDec = 0) {
|
|
|
|
let objetQ = this.items.get(objetId)
|
|
|
|
let objetQ = this.items.get(objetId)
|
|
|
|
if (objetQ) {
|
|
|
|
if (objetQ) {
|
|
|
|
let newQ = objetQ.system.quantity + incDec;
|
|
|
|
let newQ = objetQ.system.quantity + incDec
|
|
|
|
|
|
|
|
newQ = Math.max(newQ, 0)
|
|
|
|
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -365,22 +391,22 @@ export class HawkmoonActor extends Actor {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
getInitiativeScore( ) {
|
|
|
|
getInitiativeScore() {
|
|
|
|
return Number(this.system.attributs.adr.value) + Number(this.system.combat.initbonus)
|
|
|
|
return Number(this.system.attributs.adr.value) + Number(this.system.combat.initbonus)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
getBestDefenseValue() {
|
|
|
|
getBestDefenseValue() {
|
|
|
|
let defenseList = this.items.filter(item => (item.type =="arme" || item.type == "bouclier") && item.system.equipped)
|
|
|
|
let defenseList = this.items.filter(item => (item.type == "arme" || item.type == "bouclier") && item.system.equipped)
|
|
|
|
let maxDef = 0
|
|
|
|
let maxDef = 0
|
|
|
|
let bestArme
|
|
|
|
let bestArme
|
|
|
|
for(let arme of defenseList) {
|
|
|
|
for (let arme of defenseList) {
|
|
|
|
if (arme.type == "arme" && arme.system.isdefense) {
|
|
|
|
if (arme.type == "arme" && arme.system.isdefense) {
|
|
|
|
arme = this.prepareArme(arme)
|
|
|
|
arme = this.prepareArme(arme)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (arme.type == "bouclier" ) {
|
|
|
|
if (arme.type == "bouclier") {
|
|
|
|
arme = this.prepareBouclier(arme)
|
|
|
|
arme = this.prepareBouclier(arme)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( arme.system.totalDefensif > maxDef) {
|
|
|
|
if (arme.system.totalDefensif > maxDef) {
|
|
|
|
maxDef = arme.system.totalDefensif
|
|
|
|
maxDef = arme.system.totalDefensif
|
|
|
|
bestArme = duplicate(arme)
|
|
|
|
bestArme = duplicate(arme)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -392,15 +418,15 @@ export class HawkmoonActor extends Actor {
|
|
|
|
searchRelevantTalents(competence) {
|
|
|
|
searchRelevantTalents(competence) {
|
|
|
|
let talents = []
|
|
|
|
let talents = []
|
|
|
|
|
|
|
|
|
|
|
|
for( let talent of this.items) {
|
|
|
|
for (let talent of this.items) {
|
|
|
|
if (talent.type == "talent" && talent.system.isautomated && talent.system.automations.length > 0) {
|
|
|
|
if (talent.type == "talent" && talent.system.isautomated && talent.system.automations.length > 0) {
|
|
|
|
for (let auto of talent.system.automations) {
|
|
|
|
for (let auto of talent.system.automations) {
|
|
|
|
if (auto.eventtype === "prepare-roll") {
|
|
|
|
if (auto.eventtype === "prepare-roll") {
|
|
|
|
if (auto.competence.toLowerCase() == competence.name.toLowerCase() ) {
|
|
|
|
if (auto.competence.toLowerCase() == competence.name.toLowerCase()) {
|
|
|
|
talent = duplicate(talent)
|
|
|
|
talent = duplicate(talent)
|
|
|
|
talent.system.bonus = auto.bonus
|
|
|
|
talent.system.bonus = auto.bonus
|
|
|
|
talent.system.baCost = auto.baCost
|
|
|
|
talent.system.baCost = auto.baCost
|
|
|
|
talents.push( talent )
|
|
|
|
talents.push(talent)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -420,22 +446,24 @@ export class HawkmoonActor extends Actor {
|
|
|
|
rollData.maitriseId = "none"
|
|
|
|
rollData.maitriseId = "none"
|
|
|
|
rollData.nbEclat = this.system.eclat.value
|
|
|
|
rollData.nbEclat = this.system.eclat.value
|
|
|
|
rollData.nbBA = this.system.bonneaventure.actuelle
|
|
|
|
rollData.nbBA = this.system.bonneaventure.actuelle
|
|
|
|
|
|
|
|
rollData.nbAdversites = this.getTotalAdversite()
|
|
|
|
|
|
|
|
rollData.talents = []
|
|
|
|
|
|
|
|
|
|
|
|
if (attrKey) {
|
|
|
|
if (attrKey) {
|
|
|
|
rollData.attrKey = attrKey
|
|
|
|
rollData.attrKey = attrKey
|
|
|
|
if (attrKey != "tochoose") {
|
|
|
|
if (attrKey != "tochoose") {
|
|
|
|
rollData.actionImg = "systems/fvtt-mournblade-cyd/assets/icons/" + this.system.attributs[attrKey].labelnorm + ".webp"
|
|
|
|
rollData.actionImg = "systems/fvtt-hawkmoon-cyd/assets/icons/" + this.system.attributs[attrKey].labelnorm + ".webp"
|
|
|
|
rollData.attr = duplicate(this.system.attributs[attrKey])
|
|
|
|
rollData.attr = duplicate(this.system.attributs[attrKey])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (compId) {
|
|
|
|
if (compId) {
|
|
|
|
rollData.competence = duplicate(this.items.get(compId) || {})
|
|
|
|
rollData.competence = duplicate(this.items.get(compId) || {})
|
|
|
|
rollData.maitrises = rollData.competence.system.predilections.filter(p => p.maitrise )
|
|
|
|
rollData.maitrises = rollData.competence.system.predilections.filter(p => p.maitrise)
|
|
|
|
rollData.actionImg = rollData.competence?.img
|
|
|
|
rollData.actionImg = rollData.competence?.img
|
|
|
|
rollData.talents = this.searchRelevantTalents( rollData.competence)
|
|
|
|
rollData.talents = this.searchRelevantTalents(rollData.competence)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (compName) {
|
|
|
|
if (compName) {
|
|
|
|
rollData.competence = duplicate(this.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {})
|
|
|
|
rollData.competence = duplicate(this.items.find(item => item.name.toLowerCase() == compName.toLowerCase()) || {})
|
|
|
|
rollData.actionImg = rollData.competence?.img
|
|
|
|
rollData.actionImg = rollData.competence?.img
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rollData
|
|
|
|
return rollData
|
|
|
@ -481,7 +509,8 @@ export class HawkmoonActor extends Actor {
|
|
|
|
if (arme.type == "bouclier") {
|
|
|
|
if (arme.type == "bouclier") {
|
|
|
|
arme = this.prepareBouclier(arme)
|
|
|
|
arme = this.prepareBouclier(arme)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let roll = new Roll(arme.system.totalDegats).roll({ async: false })
|
|
|
|
console.log("DEGATS", arme)
|
|
|
|
|
|
|
|
let roll = new Roll( "1d10+"+arme.system.totalDegats).roll({ async: false })
|
|
|
|
await HawkmoonUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"));
|
|
|
|
await HawkmoonUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"));
|
|
|
|
let rollData = {
|
|
|
|
let rollData = {
|
|
|
|
arme: arme,
|
|
|
|
arme: arme,
|
|
|
@ -492,7 +521,7 @@ export class HawkmoonActor extends Actor {
|
|
|
|
actionImg: arme.img,
|
|
|
|
actionImg: arme.img,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HawkmoonUtility.createChatWithRollMode(rollData.alias, {
|
|
|
|
HawkmoonUtility.createChatWithRollMode(rollData.alias, {
|
|
|
|
content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-degats-result.html`, rollData)
|
|
|
|
content: await renderTemplate(`systems/fvtt-hawkmoon-cyd/templates/chat-degats-result.html`, rollData)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|