Support des runes

This commit is contained in:
2022-06-26 18:52:31 +02:00
parent 3f91a161ab
commit 8d43ae6b6e
11 changed files with 174 additions and 14 deletions

View File

@@ -114,6 +114,11 @@ export class MournbladeActorSheet extends ActorSheet {
let compId = li.data("item-id")
this.actor.rollCompetence(attrKey, compId)
})
html.find('.roll-rune').click((event) => {
const li = $(event.currentTarget).parents(".item")
let runeId = li.data("item-id")
this.actor.rollRune(runeId)
})
html.find('.roll-arme-offensif').click((event) => {
const li = $(event.currentTarget).parents(".item")
let armeId = li.data("item-id")

View File

@@ -191,8 +191,8 @@ export class MournbladeActor extends Actor {
this.update({ 'data.sante.base': newSante })
}
let newAme = (this.data.data.attributs.cla.value + this.data.data.attributs.tre.value) * this.data.data.biodata.amemultiplier + 5
if (this.data.data.ame.base != newAme) {
this.update({ 'data.ame.base': newAme })
if (this.data.data.ame.fullmax != newAme) {
this.update({ 'data.ame.fullmax': newAme })
}
}
@@ -266,6 +266,16 @@ export class MournbladeActor extends Actor {
canEclatDoubleD20() {
return (this.getAlignement() == "loyal" && this.data.data.eclat.value > 0)
}
/* -------------------------------------------- */
subPointsAme(runeMode, value) {
let ame = duplicate(this.data.data.ame)
if(runeMode == "prononcer") {
ame.value -= value
} else {
ame.currentmax -= value
}
this.update( {'data.ame': ame})
}
/* -------------------------------------------- */
compareName(a, b) {
@@ -345,7 +355,7 @@ export class MournbladeActor extends Actor {
}
/* -------------------------------------------- */
getCommonRollData(attrKey = undefined, compId = undefined) {
getCommonRollData(attrKey = undefined, compId = undefined, compName = undefined) {
let rollData = MournbladeUtility.getBasicRollData()
rollData.alias = this.name
rollData.actorImg = this.img
@@ -364,7 +374,11 @@ export class MournbladeActor extends Actor {
}
if (compId) {
rollData.competence = duplicate(this.data.items.get(compId) || {})
rollData.actionImg = rollData.competence.img
rollData.actionImg = rollData.competence?.img
}
if (compName) {
rollData.competence = duplicate(this.data.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {})
rollData.actionImg = rollData.competence?.img
}
return rollData
}
@@ -385,6 +399,18 @@ export class MournbladeActor extends Actor {
rollDialog.render(true)
}
/* -------------------------------------------- */
async rollRune(runeId) {
let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes")
rollData.rune = duplicate(this.data.items.get(runeId) || {})
rollData.difficulte = rollData.rune?.data?.seuil || 0
rollData.runemode = "prononcer"
rollData.runeame = 1
console.log("runeData", rollData)
let rollDialog = await MournbladeRollDialog.create(this, rollData)
rollDialog.render(true)
}
/* -------------------------------------------- */
async rollArmeOffensif(armeId) {
let arme = this.data.items.get(armeId)

View File

@@ -5,7 +5,7 @@ export class MournbladeRollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData ) {
let options = { classes: ["MournbladeDialog"], width: 320, height: 380, 'z-index': 99999 };
let options = { classes: ["MournbladeDialog"], width: 340, height: 420, 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-mournblade/templates/roll-dialog-generic.html', rollData);
return new MournbladeRollDialog(actor, rollData, html, options );
@@ -66,6 +66,12 @@ export class MournbladeRollDialog extends Dialog {
html.find('#attrKey').change(async (event) => {
this.rollData.attrKey = String(event.currentTarget.value)
})
html.find('#runemode').change(async (event) => {
this.rollData.runemode = String(event.currentTarget.value)
})
html.find('#runeame').change(async (event) => {
this.rollData.runeame = Number(event.currentTarget.value)
})
html.find('#doubleD20').change(async (event) => {
this.rollData.doubleD20 = event.currentTarget.checked
})

View File

@@ -56,6 +56,15 @@ export class MournbladeUtility {
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" }
@@ -318,10 +327,18 @@ export class MournbladeUtility {
} else {
rollData.diceFormula += `+${rollData.attr.value}*2+${rollData.modificateur}`
}
if (rollData.arme) {
rollData.diceFormula += `+${rollData.arme.data.bonusmaniementoff}`
}
if(rollData.rune) {
rollData.runeduree = Math.ceil((rollData.runeame+3) / 3)
if ( rollData.runemode == "inscrire") {
rollData.runeduree *= 2
}
}
let myRoll = new Roll(rollData.diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"));
rollData.roll = myRoll
@@ -330,6 +347,14 @@ export class MournbladeUtility {
rollData.finalResult = myRoll.total
this.computeResult( rollData)
if (rollData.rune ) {
let subAme = rollData.runeame
if ( rollData.isEchec && !rollData.isDramatique) {
subAme = Math.ceil((subAme+1) / 2)
}
actor.subPointsAme(rollData.runemode, subAme)
}
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-mournblade/templates/chat-generic-result.html`, rollData)
}, rollData)
@@ -440,6 +465,7 @@ export class MournbladeUtility {
rollId: randomID(16),
rollMode: game.settings.get("core", "rollMode"),
modificateursOptions: this.getModificateurOptions(),
pointAmeOptions: this.getPointAmeOptions(),
difficulte: 0,
modificateur: 0,
}