Gestion des jets opposés
This commit is contained in:
@ -42,6 +42,7 @@ export class TeDeumActorPJSheet extends ActorSheet {
|
||||
providence: this.actor.prepareProvidence(),
|
||||
arbreCompetences: this.actor.prepareArbreCompetences(),
|
||||
equipements: this.actor.getEquipements(),
|
||||
armures: this.actor.getArmures(),
|
||||
graces: this.actor.getGraces(),
|
||||
description: await TextEditor.enrichHTML(this.object.system.description, { async: true }),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.notes, { async: true }),
|
||||
|
@ -34,6 +34,16 @@ export class TeDeumActor extends Actor {
|
||||
return actor;
|
||||
}
|
||||
|
||||
if (data.type == 'pj') {
|
||||
const skills = await TeDeumUtility.loadCompendium("fvtt-te-deum.competences")
|
||||
data.items = data.items || []
|
||||
for (let skill of skills) {
|
||||
if (skill.system.isBase || skill.system.score == 1) {
|
||||
data.items.push(skill.toObject())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.create(data, options);
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ export const TEDEUM_CONFIG = {
|
||||
facile: { label: "Facile", value: 5 },
|
||||
pardefaut: { label: "Par Défaut", value: 7 },
|
||||
malaise: { label: "Malaisé", value: 9 },
|
||||
difficile: { label: "difficile", value: 11 },
|
||||
difficile: { label: "Difficile", value: 11 },
|
||||
perilleux: { label: "Perilleux", value: 13 },
|
||||
desespere: { label: "Désespéré", value: 15 }
|
||||
},
|
||||
|
@ -133,36 +133,44 @@ export class TeDeumUtility {
|
||||
return actor
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */ /* -------------------------------------------- */
|
||||
static async manageOpposition(rollData) {
|
||||
if (!this.currentOpposition) {
|
||||
// Store rollData as current GM opposition
|
||||
this.currentOpposition = rollData
|
||||
ui.notifications.info("Opposition démarrée avec " + rollData.alias );
|
||||
} else {
|
||||
// Perform the opposition
|
||||
let rWinner = this.currentOpposition
|
||||
let rLooser = rollData
|
||||
if (rWinner.total < rLooser.total) {
|
||||
rWinner = rollData
|
||||
rLooser = this.currentOpposition
|
||||
}
|
||||
this.currentOpposition = undefined // Reset opposition
|
||||
let oppositionData = {
|
||||
winner: rWinner,
|
||||
looser: rLooser
|
||||
}
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-te-deum/templates/chat/chat-opposition-result.hbs`, oppositionData)
|
||||
})
|
||||
await msg.setFlag("world", "te-deum-rolldata", rollData)
|
||||
console.log("Rolldata result", rollData)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */ /* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
html.on("click", '.button-select-confront', event => {
|
||||
html.on("click", '.chat-command-button', event => {
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "te-deum-rolldata")
|
||||
ui.notifications.info( game.i18n.localize("ECRY.chat.confrontselect"))
|
||||
TeDeumUtility.manageConfrontation(rollData)
|
||||
if (rollData) {
|
||||
TeDeumUtility.manageOpposition(rollData, messageId)
|
||||
}
|
||||
})
|
||||
html.on("click", '.button-apply-cephaly-difficulty', event => {
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "te-deum-rolldata")
|
||||
let difficulty = $("#" + rollData.rollId + "-cephaly-difficulty").val()
|
||||
TeDeumUtility.manageCephalyDifficulty(rollData, difficulty)
|
||||
})
|
||||
html.on("click", '.button-apply-impact', event => {
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let actor = game.actors.get($(event.currentTarget).data("actor-id"))
|
||||
actor.modifyImpact($(event.currentTarget).data("impact-type"), $(event.currentTarget).data("impact"), 1)
|
||||
})
|
||||
html.on("click", '.button-apply-bonus', event => {
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let actor = game.actors.get($(event.currentTarget).data("actor-id"))
|
||||
actor.modifyConfrontBonus($(event.currentTarget).data("bonus"))
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -46,7 +46,9 @@ export class TeDeumPJSchema extends foundry.abstract.TypeDataModel {
|
||||
schema.statutocial = new fields.StringField({ required: false, blank: true, initial: undefined });
|
||||
schema.chargestitre = new fields.StringField({ required: false, blank: true, initial: undefined });
|
||||
schema.charges = new fields.StringField({ required: false, blank: true, initial: undefined });
|
||||
|
||||
schema.religion = new fields.StringField({ required: false, blank: true, initial: undefined });
|
||||
schema.lieunaissance = new fields.StringField({ required: false, blank: true, initial: undefined });
|
||||
|
||||
return schema;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user