Gestion des singularites
This commit is contained in:
@@ -154,7 +154,7 @@ export class Imperium5ActorSheet extends ActorSheet {
|
||||
this.render(true);
|
||||
});
|
||||
html.find('.item-link a').click((event) => {
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
const itemId = $(event.currentTarget).data("item-id")
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ Hooks.once("ready", function () {
|
||||
let sidebar = document.getElementById("sidebar")
|
||||
sidebar.style.width = "min-content"
|
||||
}
|
||||
|
||||
|
||||
welcomeMessage()
|
||||
})
|
||||
|
||||
|
||||
@@ -50,13 +50,33 @@ export class Imperium5Utility {
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static registerSettings() {
|
||||
game.settings.register("fvtt-imperium5", "use-entropie-reussite", {
|
||||
name: "Utilisation du dé d'Entropie dans les réussites",
|
||||
hint: "Si coché, ajoute 1 succès au joueur sur un 2, et 1 succés au MJ sur un 7.",
|
||||
scope: "world",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean
|
||||
})
|
||||
game.settings.register("fvtt-imperium5", "use-singularite", {
|
||||
name: "Utilisation complémentaire des Singularités",
|
||||
hint: "Si coché, les Singularités peuvent permettre de réduire de 1 la valeur d'un dé",
|
||||
scope: "world",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static pushInitiativeOptions(html, options) {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async ready() {
|
||||
|
||||
this.registerSettings()
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -90,14 +110,19 @@ export class Imperium5Utility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
html.on("click", '.button-apply-paradigme', event => {
|
||||
let paraKey = $(event.currentTarget).data("para-key")
|
||||
html.on("change", '.select-apply-paradigme', event => {
|
||||
let paraKey = event.currentTarget.value
|
||||
let rollData = this.getRollDataFromMessage(event)
|
||||
rollData.previousMessageId = Imperium5Utility.findChatMessageId(event.currentTarget)
|
||||
this.applyParadigme(rollData, paraKey)
|
||||
})
|
||||
|
||||
|
||||
html.on("click", '.apply-singularite', event => {
|
||||
let resultIndex = $(event.currentTarget).data("result-index")
|
||||
let rollData = this.getRollDataFromMessage(event)
|
||||
rollData.previousMessageId = Imperium5Utility.findChatMessageId(event.currentTarget)
|
||||
this.applySingularite(rollData, resultIndex)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -292,29 +317,39 @@ export class Imperium5Utility {
|
||||
/* -------------------------------------------- */
|
||||
static computeReussites(rollData) {
|
||||
let myRoll = rollData.roll
|
||||
rollData.successPC = myRoll.terms[0].results.filter(res => res.result <= rollData.seuil).length
|
||||
rollData.successGM = myRoll.terms[4].results.filter(res => res.result <= rollData.seuil).length
|
||||
// Calcul des réussites sur les 2 pools
|
||||
rollData.successPC = rollData.resultsPC.filter(res => res.result <= rollData.seuil).length
|
||||
rollData.successGM = myRoll.terms[4].results.filter(res => res.result <= 2).length
|
||||
// Calcul du présage
|
||||
rollData.bonPresage = myRoll.terms[2].results[0].result == 1
|
||||
rollData.mauvaisPresage = myRoll.terms[2].results[0].result == 8
|
||||
rollData.nbUnitesNarration = Math.max( rollData.successPC-1, 0)
|
||||
// gestion règle optionnelle de l'Entropie
|
||||
if (rollData.useEntropieReussite && myRoll.terms[2].results[0].result == 2) {
|
||||
rollData.successPC++
|
||||
}
|
||||
if (rollData.useEntropieReussite && myRoll.terms[2].results[0].result == 7) {
|
||||
rollData.successGM++
|
||||
}
|
||||
// Calcul unité de narration
|
||||
rollData.nbUnitesNarration = Math.max(rollData.successPC - 1, 0)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollImperium5(rollData) {
|
||||
static async rollImperium5(rollData) {
|
||||
|
||||
// Karma management
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
rollData.nbKarma = 0
|
||||
if ( rollData.useKarma ) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
rollData.nbKarma = 0
|
||||
if (rollData.useKarma) {
|
||||
actor.incDecKarma(-1)
|
||||
rollData.nbKarma++
|
||||
}
|
||||
if ( rollData.usedCapacite != "none" ) {
|
||||
if (rollData.usedCapacite != "none") {
|
||||
actor.incDecKarma(-1)
|
||||
rollData.nbKarma++
|
||||
}
|
||||
|
||||
let nbAmeDice = this.computeDiceReserve( rollData )
|
||||
let nbAmeDice = this.computeDiceReserve(rollData)
|
||||
let diceFormula = `${nbAmeDice}d8[green] + 1d8[blue] + ${rollData.realiteDice}d8[red]`
|
||||
let humanFormula = `${nbAmeDice}d8, 1d8, ${rollData.realiteDice}d8`
|
||||
// Performs roll
|
||||
@@ -326,7 +361,8 @@ export class Imperium5Utility {
|
||||
rollData.diceFormula = diceFormula
|
||||
rollData.humanFormula = humanFormula
|
||||
}
|
||||
|
||||
// local copy of results to allow changes
|
||||
rollData.resultsPC = duplicate(myRoll.terms[0].results)
|
||||
// Calcul réussites
|
||||
this.computeReussites(rollData)
|
||||
|
||||
@@ -334,20 +370,39 @@ export class Imperium5Utility {
|
||||
content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "imperium5-roll-data", rollData)
|
||||
console.log("Final rollData", rollData)
|
||||
}
|
||||
|
||||
/* ------------------------- ------------------- */
|
||||
static async processParadigmeRoll(rollData) {
|
||||
/* -------------------------------------------- */
|
||||
static async applyParadigme(rollData, paraKey) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let para = actor.system.paradigmes[paraKey]
|
||||
rollData.seuil = para.value
|
||||
rollData.usedParadigme = para.label
|
||||
actor.setParadigmeUsed(paraKey)
|
||||
|
||||
this.computeReussites(rollData)
|
||||
rollData.paradigmes = []
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "imperium5-roll-data", rollData)
|
||||
|
||||
this.removeChatMessageId(rollData.previousMessageId)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async applySingularite(rollData, resultIndex) {
|
||||
let res = rollData.resultsPC[resultIndex]
|
||||
res.result = (res.result > 1) ? res.result-1 : res.result
|
||||
this.computeReussites(rollData)
|
||||
rollData.useSingularites = false
|
||||
rollData.singulariteApplied = true
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "imperium5-roll-data", rollData)
|
||||
}
|
||||
|
||||
/* ------------------------- ------------------- */
|
||||
static async updateRoll(rollData) {
|
||||
|
||||
@@ -474,22 +529,14 @@ export class Imperium5Utility {
|
||||
useAide: false,
|
||||
useKarma: false,
|
||||
usedCapacite: "none",
|
||||
seuil: 2
|
||||
seuil: 2,
|
||||
useSingularites: game.settings.get("fvtt-imperium5", "use-singularite"),
|
||||
useEntropieReussite: game.settings.get("fvtt-imperium5", "use-entropie-reussite")
|
||||
}
|
||||
Imperium5Utility.updateWithTarget(rollData)
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static applyParadigme(rollData, paraKey) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let para = actor.system.paradigmes[paraKey]
|
||||
rollData.seuil = para.value
|
||||
rollData.usedParadigme = para.label
|
||||
actor.setParadigmeUsed(paraKey)
|
||||
|
||||
this.processParadigmeRoll(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateWithTarget(rollData) {
|
||||
|
||||
Reference in New Issue
Block a user