Fix sur pouvoirs, heritage et 2 pts de tricherie
This commit is contained in:
@@ -55,6 +55,7 @@ export class HeritiersActorSheet extends ActorSheet {
|
||||
desavantages: duplicate(this.actor.getDesavantages()),
|
||||
profils: duplicate(this.actor.getProfils()),
|
||||
pvMalus: this.actor.getPvMalus(),
|
||||
heritage: game.settings.get("fvtt-les-heritiers", "heritiers-heritage"),
|
||||
initiative: this.actor.getFlag("world", "last-initiative") || -1,
|
||||
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
|
||||
revesetranges: await TextEditor.enrichHTML(this.object.system.biodata.revesetranges, {async: true}),
|
||||
|
@@ -501,9 +501,14 @@ export class HeritiersActor extends Actor {
|
||||
incDecTricherie(value) {
|
||||
let tricherie = this.system.rang.tricherie
|
||||
tricherie.value += value
|
||||
if ( tricherie.value < 0 || tricherie.value > tricherie.max) {
|
||||
ui.notifications.warn("Pas assez de points de Tricherie !")
|
||||
return false
|
||||
}
|
||||
tricherie.value = Math.max(tricherie.value, 0)
|
||||
tricherie.value = Math.min(tricherie.value, tricherie.max)
|
||||
this.update({ 'system.rang.tricherie': tricherie })
|
||||
return true
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getPireCompetence(compName1, compName2) {
|
||||
|
@@ -2,6 +2,45 @@
|
||||
import { HeritiersCombat } from "./heritiers-combat.js";
|
||||
import { HeritiersCommands } from "./heritiers-commands.js";
|
||||
|
||||
const __facesAdjacentes = {
|
||||
"d8": {
|
||||
1: [4, 8, 6],
|
||||
2: [7, 5, 3],
|
||||
3: [2, 8, 6],
|
||||
4: [1, 5, 7],
|
||||
5: [2, 4, 8],
|
||||
6: [1, 7, 3],
|
||||
7: [2, 4, 6],
|
||||
8: [1, 3, 5]
|
||||
},
|
||||
"d10": {
|
||||
1: [4, 6, 9, 7],
|
||||
2: [6, 8, 5, 9],
|
||||
3: [7, 5, 8, 10],
|
||||
4: [10, 6, 7, 1],
|
||||
5: [3, 9, 2, 8],
|
||||
6: [1, 4, 2, 9],
|
||||
7: [1, 3, 4, 10],
|
||||
8: [2, 10, 5, 3],
|
||||
9: [1, 5, 6, 2],
|
||||
10: [8, 4, 3, 7]
|
||||
},
|
||||
"d12": {
|
||||
1:[2, 3, 4, 5, 6],
|
||||
2: [1, 6, 8, 12, 3],
|
||||
3: [1, 4, 11, 12, 2],
|
||||
4: [1, 5, 10, 11, 3],
|
||||
5: [1, 6, 9, 10, 4],
|
||||
6: [1, 2, 8, 9, 5],
|
||||
7: [8, 9, 10, 11, 12],
|
||||
8: [2, 6, 9, 7, 12],
|
||||
9: [5, 10, 7, 8, 6],
|
||||
10: [4, 11, 7, 9, 5],
|
||||
11: [7, 10, 4, 3, 12],
|
||||
12: [2, 8, 7, 11, 3]
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class HeritiersUtility {
|
||||
|
||||
@@ -65,6 +104,14 @@ export class HeritiersUtility {
|
||||
const skills = await HeritiersUtility.loadCompendium("fvtt-les-heritiers.competences")
|
||||
this.skills = skills.map(i => i.toObject())
|
||||
|
||||
game.settings.register("fvtt-les-heritiers", "heritiers-heritage", {
|
||||
name: "Points d'héritage",
|
||||
hint: "Points d'héritage du groupe",
|
||||
scope: "world",
|
||||
config: true,
|
||||
default: 0,
|
||||
type: Number
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -96,7 +143,18 @@ export class HeritiersUtility {
|
||||
rollData.competence = duplicate(actor.getCompetence(rollData.competence._id))
|
||||
HeritiersUtility.rollHeritiers(rollData)
|
||||
})
|
||||
|
||||
|
||||
html.on("click", '.roll-tricherie-2', async event => {
|
||||
let messageId = HeritiersUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "heritiers-roll")
|
||||
let actor = this.getActorFromRollData(rollData)
|
||||
if ( await actor.incDecTricherie(-2) ) {
|
||||
rollData.forcedValue = Number($(event.currentTarget).data("dice-value"))
|
||||
HeritiersUtility.rollHeritiers(rollData)
|
||||
}
|
||||
})
|
||||
|
||||
html.on("click", '.roll-chat-degat', async event => {
|
||||
let messageId = HeritiersUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
@@ -290,11 +348,12 @@ export class HeritiersUtility {
|
||||
if (isTricherieHeritage) {
|
||||
let resTab = [rollData.roll.terms[0].results[0].result, rollData.roll.terms[0].results[1].result, rollData.roll.terms[0].results[2].result]
|
||||
rollData.diceResult = resTab[0] + "," + resTab[1] + "," + resTab[2]
|
||||
let foundryTotal = resTab[0] + resTab[1] + resTab[2]
|
||||
let foundryTotal = resTab[0] + resTab[1] + resTab[2]
|
||||
if (resTab[1] == 1) { resTab[1] -= 4 }
|
||||
if (resTab[2] == 1) { resTab[2] -= 6 }
|
||||
if (resTab[2] == 2) { resTab[2] -= 7 }
|
||||
rollData.finalResult = rollData.roll.total - foundryTotal + Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
|
||||
rollData.diceValue = Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
|
||||
rollData.finalResult = rollData.roll.total - foundryTotal + rollData.diceValue
|
||||
|
||||
// Gestion des résultats spéciaux
|
||||
resTab = resTab.sort()
|
||||
@@ -319,8 +378,9 @@ export class HeritiersUtility {
|
||||
|
||||
} else {
|
||||
rollData.finalResult = rollData.roll.total
|
||||
let rollValue = rollData.roll.terms[0].results[0].result
|
||||
rollData.diceResult = rollData.roll.terms[0].results[0].result
|
||||
let rollValue = rollData.forcedValue || rollData.roll.terms[0].results[0].result
|
||||
rollData.diceResult = rollValue
|
||||
rollData.diceValue = rollValue
|
||||
if (rollData.mainDice.includes("d10")) {
|
||||
if (rollValue == 1) {
|
||||
rollData.finalResult -= 3 + rollValue // substract 3 and the 1 value that has been added
|
||||
@@ -331,14 +391,16 @@ export class HeritiersUtility {
|
||||
rollData.finalResult -= 5 + rollValue // Remove also the dice result has it has been added already
|
||||
}
|
||||
}
|
||||
if ( !rollData.forcedValue) {
|
||||
rollData.adjacentFaces = duplicate(__facesAdjacentes[rollData.mainDice][rollData.diceValue])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeArmeDegats(rollData, actor) {
|
||||
rollData.degatsArme = rollData.arme.system.degats + rollData.marge
|
||||
if (rollData.attaqueDeuxArmes != 0 && rollData.secondeArme ) {
|
||||
if (rollData.attaqueDeuxArmes != 0 && rollData.secondeArme) {
|
||||
let secondeArme = actor.items.get(secondeArme)
|
||||
if (secondeArme) {
|
||||
rollData.degatsArme += secondeArme.system.degats
|
||||
@@ -353,7 +415,7 @@ export class HeritiersUtility {
|
||||
}
|
||||
if (rollData.mode == "attaquecharge") {
|
||||
rollData.degatsArme += 3
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rollData.attaqueCible == "membre") {
|
||||
rollData.degatsArme -= 2
|
||||
@@ -396,7 +458,7 @@ export class HeritiersUtility {
|
||||
rollData.defenderValue = valeurDefense
|
||||
rollData.marge = 0
|
||||
this.computeMarge(rollData, valeurDefense)
|
||||
rollData.dureeAssommer = (rollData.marge) ? rollData.marge*2 : 1
|
||||
rollData.dureeAssommer = (rollData.marge) ? rollData.marge * 2 : 1
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-les-heritiers/templates/chat-assommer-result.html`, rollData)
|
||||
}, rollData, "selfroll")
|
||||
@@ -409,10 +471,14 @@ export class HeritiersUtility {
|
||||
//rollData.actionImg = "systems/fvtt-les-heritiers/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp"
|
||||
rollData.carac = duplicate(actor.system.caracteristiques[rollData.caracKey])
|
||||
|
||||
if (rollData.useTricherie || rollData.useHeritage) {
|
||||
rollData.diceFormula = "{1d8, 1d10, 1d12}"
|
||||
if (rollData.forcedValue) {
|
||||
rollData.diceFormula = rollData.forcedValue
|
||||
} else {
|
||||
rollData.diceFormula = "1" + rollData.mainDice + "kh1"
|
||||
if (rollData.useTricherie || rollData.useHeritage) {
|
||||
rollData.diceFormula = "{1d8, 1d10, 1d12}"
|
||||
} else {
|
||||
rollData.diceFormula = "1" + rollData.mainDice + "kh1"
|
||||
}
|
||||
}
|
||||
|
||||
let rangValue = 0
|
||||
@@ -424,7 +490,7 @@ export class HeritiersUtility {
|
||||
let specBonus = (rollData.useSpecialite) ? 1 : 0
|
||||
rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.competence.system.niveau}+${specBonus}+${rollData.bonusMalusContext}+${compmod}`
|
||||
} else if (rollData.pouvoirBase) {
|
||||
rollData.diceFormula += `+${rollData.pouvoirBase.value}+${rangValue}+${rollData.bonusMalusContext}`
|
||||
rollData.diceFormula += `+${rollData.carac.value}+${rollData.pouvoirBase.value}+${rangValue}+${rollData.bonusMalusContext}`
|
||||
} else {
|
||||
rollData.diceFormula += `+${rollData.carac.value}+${rangValue}+${rollData.bonusMalusContext}`
|
||||
}
|
||||
@@ -438,7 +504,7 @@ export class HeritiersUtility {
|
||||
let bonusAttaque = rollData.bonusAttaquePlusieurs
|
||||
if (rollData.attaqueDos) {
|
||||
bonusAttaque = 2
|
||||
if (rollData.bonusAttaquePlusieurs) {
|
||||
if (rollData.bonusAttaquePlusieurs) {
|
||||
bonusAttaque = 3 // Valeur max, cf règle page 197
|
||||
}
|
||||
}
|
||||
@@ -450,13 +516,13 @@ export class HeritiersUtility {
|
||||
}
|
||||
// Gestion des attaques ciblées
|
||||
if (rollData.attaqueCible != "none") {
|
||||
if ( rollData.attaqueCible == "membre") {
|
||||
if (rollData.attaqueCible == "membre") {
|
||||
rollData.diceFormula += `-2`
|
||||
}
|
||||
if ( rollData.attaqueCible == "main") {
|
||||
if (rollData.attaqueCible == "main") {
|
||||
rollData.diceFormula += `-3`
|
||||
}
|
||||
if ( rollData.attaqueCible == "tete") {
|
||||
if (rollData.attaqueCible == "tete") {
|
||||
rollData.diceFormula += `-6`
|
||||
}
|
||||
}
|
||||
@@ -478,9 +544,9 @@ export class HeritiersUtility {
|
||||
}, rollData)
|
||||
|
||||
// Gestion attaque standard
|
||||
if ( (rollData.mode == "arme" || rollData.mode == "attaquebrutale" || rollData.mode == "attaquecharge") &&
|
||||
rollData.defenderTokenId && rollData.arme) {
|
||||
if (rollData.arme.system.categorie != "trait" && rollData.arme.system.categorie != "poing" && rollData.arme.system.categorie != "epaule" ) {
|
||||
if ((rollData.mode == "arme" || rollData.mode == "attaquebrutale" || rollData.mode == "attaquecharge") &&
|
||||
rollData.defenderTokenId && rollData.arme) {
|
||||
if (rollData.arme.system.categorie != "trait" && rollData.arme.system.categorie != "poing" && rollData.arme.system.categorie != "epaule") {
|
||||
await this.displayUneDefense(rollData, actor, "Parade", rollData.defenderParade)
|
||||
await this.displayUneDefense(rollData, actor, "Esquive", rollData.defenderEsquive)
|
||||
} else if (rollData.sdValue) {
|
||||
@@ -492,9 +558,9 @@ export class HeritiersUtility {
|
||||
// Gestion assomer
|
||||
if (rollData.mode == "assommer" && rollData.defenderTokenId && rollData.arme) {
|
||||
await this.displayAsssomer(rollData, actor, "Assommer", "Surprise", rollData.defenderResistancePhysique)
|
||||
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Résistance+6", rollData.defenderResistancePhysique+6)
|
||||
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Parade", rollData.defenderParade)
|
||||
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Esquive", rollData.defenderEsquive+6)
|
||||
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Résistance+6", rollData.defenderResistancePhysique + 6)
|
||||
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Parade", rollData.defenderParade)
|
||||
await this.displayAsssomer(rollData, actor, "Assommer", "Conscient, Esquive", rollData.defenderEsquive + 6)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -617,7 +683,7 @@ export class HeritiersUtility {
|
||||
bonusMalusContext: 0,
|
||||
attaqueCible: "none",
|
||||
config: game.system.lesheritiers.config,
|
||||
rulesMalus : []
|
||||
rulesMalus: []
|
||||
}
|
||||
return rollData
|
||||
}
|
||||
|
Reference in New Issue
Block a user