Sante et autrs
This commit is contained in:
@ -3,6 +3,9 @@ import { MournbladeUtility } from "./mournblade-utility.js";
|
||||
import { MournbladeRollDialog } from "./mournblade-roll-dialog.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const __degatsBonus = [-2, -2, -1, -1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 8, 8, 9, 9, 10, 10]
|
||||
const __vitesseBonus = [-2, -2, -1, -1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8]
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
|
||||
@ -44,9 +47,49 @@ export class MournbladeActor extends Actor {
|
||||
return super.create(data, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
prepareArme( arme){
|
||||
arme = duplicate(arme)
|
||||
let combat = this.getCombatValues()
|
||||
if (arme.data.typearme == "contact" || arme.data.typearme == "contactjet") {
|
||||
arme.data.competence = duplicate(this.data.items.find( item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
|
||||
arme.data.attrKey = "pui"
|
||||
arme.data.totalDegats = arme.data.degats + "+" + combat.bonusDegatsTotal
|
||||
arme.data.totalOffensif = this.data.data.attributs.pui.value + arme.data.competence.data.niveau + arme.data.bonusmaniementoff
|
||||
if (arme.data.isdefense) {
|
||||
arme.data.totalDefensif = combat.defenseTotal + arme.data.competence.data.niveau + arme.data.bonusmaniementdef
|
||||
}
|
||||
}
|
||||
if (arme.data.typearme == "jet" || arme.data.typearme == "tir") {
|
||||
arme.data.competence = duplicate(this.data.items.find( item => item.type == "competence" && item.name.toLowerCase() == "armes à distance"))
|
||||
arme.data.attrKey = "adr"
|
||||
arme.data.totalOffensif = this.data.data.attributs.adr.value + arme.data.competence.data.niveau + arme.data.bonusmaniementoff
|
||||
arme.data.totalDegats = arme.data.degats
|
||||
if (arme.data.isdefense) {
|
||||
arme.data.totalDefensif = combat.defenseTotal + arme.data.competence.data.niveau + arme.data.bonusmaniementdef
|
||||
}
|
||||
}
|
||||
return arme
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
return this.data.items.filter(item => item.type == "arme")
|
||||
let armes = []
|
||||
for (let arme of this.data.items ) {
|
||||
if (arme.type == "arme") {
|
||||
armes.push(this.prepareArme( arme) )
|
||||
}
|
||||
}
|
||||
return armes
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDons() {
|
||||
return this.data.items.filter(item => item.type == "don")
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEquipments() {
|
||||
return this.data.items.filter(item => item.type == "equipement")
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getArmors() {
|
||||
@ -80,6 +123,30 @@ export class MournbladeActor extends Actor {
|
||||
return (this.data.data.balance.loi > this.data.data.balance.chaos) ? "loyal" : "chaotique"
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDefenseBase() {
|
||||
return this.data.data.attributs.tre.value + 5
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getVitesseBase() {
|
||||
return __vitesseBonus[this.data.data.attributs.adr.value]
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCombatValues() {
|
||||
let combat = {
|
||||
initBase: this.data.data.attributs.adr.value,
|
||||
initTotal: this.data.data.attributs.adr.value + this.data.data.combat.initbonus,
|
||||
bonusDegats: this.getBonusDegats(),
|
||||
bonusDegatsTotal: this.getBonusDegats() + this.data.data.combat.bonusdegats,
|
||||
vitesseBase: this.getVitesseBase(),
|
||||
vitesseTotal: this.getVitesseBase() + this.data.data.combat.vitessebonus,
|
||||
defenseBase: this.getDefenseBase(),
|
||||
defenseTotal: this.getDefenseBase() + this.data.data.combat.defensebonus
|
||||
}
|
||||
return combat
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
prepareBaseData() {
|
||||
}
|
||||
@ -190,6 +257,11 @@ export class MournbladeActor extends Actor {
|
||||
return this.data.data.attributes[attrKey]
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getBonusDegats() {
|
||||
return __degatsBonus[this.data.data.attributs.pui.value]
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equipGear(equipmentId) {
|
||||
let item = this.data.items.find(item => item.id == equipmentId);
|
||||
@ -287,4 +359,34 @@ export class MournbladeActor extends Actor {
|
||||
rollDialog.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollArmeOffensif(armeId) {
|
||||
let arme = this.data.items.get(armeId)
|
||||
arme = this.prepareArme( arme )
|
||||
let rollData = this.getCommonRollData(arme.data.attrKey, arme.data.competence._id)
|
||||
rollData.arme = arme
|
||||
console.log("ARME!", rollData)
|
||||
let rollDialog = await MournbladeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollArmeDegats(armeId) {
|
||||
let arme = this.data.items.get(armeId)
|
||||
arme = this.prepareArme( arme )
|
||||
let roll = new Roll(arme.data.totalDegats).roll( {async:false})
|
||||
await MournbladeUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"));
|
||||
let rollData = {
|
||||
arme:arme,
|
||||
finalResult: roll.total,
|
||||
alias : this.name,
|
||||
actorImg : this.img,
|
||||
actorId : this.id,
|
||||
actionImg : arme.img,
|
||||
}
|
||||
MournbladeUtility.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-degats-result.html`, rollData)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user