Confrontation stuff
This commit is contained in:
@ -115,6 +115,12 @@ export class EcrymeActorSheet extends ActorSheet {
|
||||
let skillKey = $(event.currentTarget).data("skill-key")
|
||||
this.actor.rollSkill(categKey, skillKey)
|
||||
});
|
||||
html.find('.roll-skill-confront').click((event) => {
|
||||
let categKey = $(event.currentTarget).data("category-key")
|
||||
let skillKey = $(event.currentTarget).data("skill-key")
|
||||
this.actor.rollSkillConfront(categKey, skillKey)
|
||||
});
|
||||
|
||||
html.find('.roll-weapon').click((event) => {
|
||||
const armeId = $(event.currentTarget).data("arme-id")
|
||||
this.actor.rollArme(armeId)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* -------------------------------------------- */
|
||||
import { EcrymeUtility } from "../common/ecryme-utility.js";
|
||||
import { EcrymeRollDialog } from "../dialogs/ecryme-roll-dialog.js";
|
||||
|
||||
import { EcrymeConfrontStartDialog } from "../dialogs/ecryme-confront-start-dialog.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* -------------------------------------------- */
|
||||
@ -82,7 +82,7 @@ export class EcrymeActor extends Actor {
|
||||
return comp;
|
||||
}
|
||||
getArchetype() {
|
||||
let comp = duplicate(this.items.find(item => item.type == 'archetype') || {name: "Pas d'archetype"})
|
||||
let comp = duplicate(this.items.find(item => item.type == 'archetype') || { name: "Pas d'archetype" })
|
||||
if (comp && comp.system) {
|
||||
comp.tarot = EcrymeUtility.getTarot(comp.system.lametutelaire)
|
||||
}
|
||||
@ -116,9 +116,9 @@ export class EcrymeActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
prepareSkills() {
|
||||
let skills = duplicate(this.system.skills)
|
||||
for (let categKey in skills) {
|
||||
for (let categKey in skills) {
|
||||
let category = skills[categKey]
|
||||
for (let skillKey in category.skilllist) {
|
||||
for (let skillKey in category.skilllist) {
|
||||
let skill = category.skilllist[skillKey]
|
||||
skill.spec = this.getSpecializations(skillKey)
|
||||
}
|
||||
@ -221,13 +221,13 @@ export class EcrymeActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
clearInitiative(){
|
||||
clearInitiative() {
|
||||
this.getFlag("world", "initiative", -1)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore(combatId, combatantId) {
|
||||
let init = Math.floor( (this.system.attributs.physique.value+this.system.attributs.habilite.value) / 2)
|
||||
let subvalue = new Roll("1d20").roll({async: false})
|
||||
let init = Math.floor((this.system.attributs.physique.value + this.system.attributs.habilite.value) / 2)
|
||||
let subvalue = new Roll("1d20").roll({ async: false })
|
||||
return init + (subvalue.total / 100)
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ export class EcrymeActor extends Actor {
|
||||
spentSkillTranscendence(skill, value) {
|
||||
let newValue = this.system.skills[skill.categKey].skilllist[skill.skillKey].value - value
|
||||
newValue = Math.max(0, newValue)
|
||||
this.update( { [`system.skills.${skill.categKey}.skilllist.${skill.skillKey}.value`]: newValue})
|
||||
this.update({ [`system.skills.${skill.categKey}.skilllist.${skill.skillKey}.value`]: newValue })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -298,13 +298,13 @@ export class EcrymeActor extends Actor {
|
||||
rollData.isReroll = false
|
||||
rollData.traits = this.getRollTraits()
|
||||
rollData.spleen = this.getSpleen()
|
||||
rollData.ideal = this.getIdeal()
|
||||
rollData.ideal = this.getIdeal()
|
||||
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollSkill(categKey, skillKey) {
|
||||
getCommonSkill(categKey, skillKey) {
|
||||
let skill = this.system.skills[categKey].skilllist[skillKey]
|
||||
let rollData = this.getCommonRollData()
|
||||
skill = duplicate(skill)
|
||||
@ -312,12 +312,29 @@ export class EcrymeActor extends Actor {
|
||||
skill.skillKey = skillKey
|
||||
skill.spec = this.getSpecializations(skillKey)
|
||||
rollData.skill = skill
|
||||
rollData.mode = "skill"
|
||||
rollData.title = game.i18n.localize(skill.name)
|
||||
rollData.img = skill.img
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollSkill(categKey, skillKey) {
|
||||
let rollData = this.getCommonSkill(categKey, skillKey)
|
||||
rollData.mode = "skill"
|
||||
rollData.title = game.i18n.localize(rollData.skill.name)
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollSkillConfront(categKey, skillKey) {
|
||||
let rollData = this.getCommonSkill(categKey, skillKey)
|
||||
rollData.mode = "skill"
|
||||
rollData.title = game.i18n.localize("ECRY.ui.confrontation") + " : " + game.i18n.localize(rollData.skill.name)
|
||||
rollData.executionDices = []
|
||||
rollData.preservationDices = []
|
||||
let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData)
|
||||
confrontStartDialog.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollWeapon(weaponId) {
|
||||
let weapon = this.items.get(weaponId)
|
||||
@ -325,7 +342,7 @@ export class EcrymeActor extends Actor {
|
||||
weapon = duplicate(weapon)
|
||||
let rollData = this.getCommonRollData()
|
||||
if (weapon.system.armetype == "mainsnues" || weapon.system.armetype == "epee") {
|
||||
rollData.attr = { label: "(Physique+Habilité)/2", value: Math.floor( (this.getPhysiqueMalus()+this.system.attributs.physique.value+this.system.attributs.habilite.value) / 2) }
|
||||
rollData.attr = { label: "(Physique+Habilité)/2", value: Math.floor((this.getPhysiqueMalus() + this.system.attributs.physique.value + this.system.attributs.habilite.value) / 2) }
|
||||
} else {
|
||||
rollData.attr = duplicate(this.system.attributs.habilite)
|
||||
}
|
||||
@ -338,10 +355,9 @@ export class EcrymeActor extends Actor {
|
||||
ui.notifications.warn("Impossible de trouver l'arme concernée ")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async startRoll(rollData) {
|
||||
console.log("ROLLDATA", rollData)
|
||||
let rollDialog = await EcrymeRollDialog.create(this, rollData)
|
||||
rollDialog.render(true)
|
||||
}
|
||||
|
@ -100,24 +100,24 @@ export class EcrymeUtility {
|
||||
/* -------------------------------------------- */
|
||||
static chatMenuManager(html, options) {
|
||||
let canTranscendRoll = []
|
||||
for(let i=1; i<=10; i++ ) {
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
canTranscendRoll[i] = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "rolldata")
|
||||
//console.log(">>>>>>>>>>>>>>>>>>>>>>>>>> Menu !!!!", rollData)
|
||||
if (rollData.skill && i <= rollData.skill.value && !rollData.transcendUsed && rollData.spec ) {
|
||||
if (rollData.skill && i <= rollData.skill.value && !rollData.transcendUsed && rollData.spec) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
options.push({
|
||||
name: game.i18.localize("ECRY.chat.spectranscend") + i,
|
||||
name: game.i18n.localize("ECRY.chat.spectranscend") + i,
|
||||
icon: '<i class="fas fa-plus-square"></i>',
|
||||
condition: canTranscendRoll[i],
|
||||
callback: li => {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "rolldata")
|
||||
EcrymeUtility.transcendFromSpec(rollData, i)
|
||||
EcrymeUtility.transcendFromSpec(rollData, i)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -149,7 +149,8 @@ export class EcrymeUtility {
|
||||
'systems/fvtt-ecryme/templates/actors/editor-notes-gm.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-nav.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-equipment.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-description.hbs'
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-description.hbs',
|
||||
'systems/fvtt-ecryme/templates/dialogs/partial-common-roll-dialog.hbs'
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
@ -303,22 +304,14 @@ export class EcrymeUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollEcryme(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
// Fix difficulty
|
||||
if (!rollData.difficulty || rollData.difficulty == "-") {
|
||||
rollData.difficulty = 0
|
||||
}
|
||||
rollData.difficulty = Number(rollData.difficulty)
|
||||
|
||||
static computeRollFormula(rollData, isConfrontation = false) {
|
||||
// Build the dice formula
|
||||
let diceFormula = "2d6"
|
||||
let diceFormula = (isConfrontation) ? "4d6" : "2d6"
|
||||
if (rollData.useIdeal) {
|
||||
diceFormula = "3d6kh2"
|
||||
diceFormula = (isConfrontation) ? "5d6kh2" : "3d6kh2"
|
||||
}
|
||||
if (rollData.useSpleen) {
|
||||
diceFormula = "3d6kl2"
|
||||
diceFormula = (isConfrontation) ? "5d6kl2" : "3d6kl2"
|
||||
}
|
||||
if (rollData.skill) {
|
||||
diceFormula += "+" + rollData.skill.value
|
||||
@ -352,6 +345,20 @@ export class EcrymeUtility {
|
||||
diceFormula += "+" + rollData.bonusMalusTraits
|
||||
diceFormula += "+" + rollData.bonusMalusPerso
|
||||
rollData.diceFormula = diceFormula
|
||||
return diceFormula
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollEcryme(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
// Fix difficulty
|
||||
if (!rollData.difficulty || rollData.difficulty == "-") {
|
||||
rollData.difficulty = 0
|
||||
}
|
||||
rollData.difficulty = Number(rollData.difficulty)
|
||||
|
||||
let diceFormula = this.computeRollFormula(rollData)
|
||||
|
||||
// Performs roll
|
||||
let myRoll = new Roll(diceFormula).roll({ async: false })
|
||||
@ -380,14 +387,14 @@ export class EcrymeUtility {
|
||||
rollData.transcendUsed = true
|
||||
this.computeResults(rollData)
|
||||
//console.log("Adding spec", value, rollData.total)
|
||||
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.spentSkillTranscendence(rollData.skill, value)
|
||||
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "rolldata", rollData)
|
||||
msg.setFlag("world", "rolldata", rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
90
modules/dialogs/ecryme-confront-dialog.js
Normal file
90
modules/dialogs/ecryme-confront-dialog.js
Normal file
@ -0,0 +1,90 @@
|
||||
import { EcrymeUtility } from "../common/ecryme-utility.js";
|
||||
import { EcrymeRollDialog } from "./ecryme-roll-dialog.js";
|
||||
|
||||
export class EcrymeConfrontDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async create(actor, rollData) {
|
||||
|
||||
let options = mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-ecryme ecryme-confrontation-dialog"],
|
||||
dragDrop: [{ dragSelector: ".confront-dice-container", dropSelector: null }],
|
||||
width: 540, height: 'fit-content', 'z-index': 99999
|
||||
});
|
||||
|
||||
let html = await renderTemplate('systems/fvtt-ecryme/templates/dialogs/confront-dialog.hbs', rollData);
|
||||
return new EcrymeConfrontDialog(actor, rollData, html, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(actor, rollData, html, options, close = undefined) {
|
||||
let conf = {
|
||||
title: game.i18n.localize("ECRY.ui.confront"),
|
||||
content: html,
|
||||
buttons: {
|
||||
rollNormal: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("ECRY.ui.rollnormal"),
|
||||
callback: () => { this.rollConfront("4d6") }
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize("ECRY.ui.cancel"),
|
||||
callback: () => { this.close() }
|
||||
}
|
||||
},
|
||||
close: close
|
||||
}
|
||||
|
||||
super(conf, options);
|
||||
|
||||
this.actor = actor;
|
||||
this.rollData = rollData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async roll() {
|
||||
}
|
||||
|
||||
/* ------------------ -------------------------- */
|
||||
_onDragStart(event) {
|
||||
super._onDragStart(event)
|
||||
const diceData = {
|
||||
diceIndex : $(event.srcElement).data("dice-idx"),
|
||||
diceValue : $(event.srcElement).data("dice-value"),
|
||||
}
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify( diceData ));
|
||||
console.log(">>>>> DRAG START!!!!", event)
|
||||
}
|
||||
|
||||
/* ------------------ -------------------------- */
|
||||
async refreshDialog() {
|
||||
const content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/confront-dialog.hbs", this.rollData)
|
||||
this.data.content = content
|
||||
this.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onDrop(event) {
|
||||
let dataJSON = event.dataTransfer.getData('text/plain')
|
||||
let data = JSON.parse(dataJSON)
|
||||
let idx = Number(data.diceIndex)
|
||||
console.log("DATA", data, event, event.srcElement.className)
|
||||
if ( event.srcElement.className.includes("execution")) {
|
||||
this.rollData.availableDices[idx].location = "execution"
|
||||
}
|
||||
if ( event.srcElement.className.includes("preservation")) {
|
||||
this.rollData.availableDices[idx].location = "preservation"
|
||||
}
|
||||
if ( event.srcElement.className.includes("dice-list")) {
|
||||
this.rollData.availableDices[idx].location = "mainpool"
|
||||
}
|
||||
this.refreshDialog()
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
}
|
||||
}
|
74
modules/dialogs/ecryme-confront-start-dialog.js
Normal file
74
modules/dialogs/ecryme-confront-start-dialog.js
Normal file
@ -0,0 +1,74 @@
|
||||
import { EcrymeUtility } from "../common/ecryme-utility.js";
|
||||
import {EcrymeConfrontDialog } from "./ecryme-confront-dialog.js";
|
||||
|
||||
export class EcrymeConfrontStartDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async create(actor, rollData) {
|
||||
|
||||
let options = { classes: ["fvtt-ecryme ecryme-confront-dialog"], width: 540, height: 'fit-content', 'z-index': 99999 }
|
||||
let html = await renderTemplate('systems/fvtt-ecryme/templates/dialogs/confront-start-dialog.hbs', rollData);
|
||||
return new EcrymeConfrontStartDialog(actor, rollData, html, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(actor, rollData, html, options, close = undefined) {
|
||||
let conf = {
|
||||
title: game.i18n.localize("ECRY.ui.confront"),
|
||||
content: html,
|
||||
buttons: {
|
||||
rollNormal: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("ECRY.ui.rollnormal"),
|
||||
callback: () => { this.rollConfront("4d6") }
|
||||
},
|
||||
rollSpleen: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("ECRY.ui.rollspleen"),
|
||||
callback: () => { this.rollConfront("5d6kl4") }
|
||||
},
|
||||
rollIdeal: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("ECRY.ui.rollideal"),
|
||||
callback: () => { this.rollConfront("5d6kh4") }
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize("ECRY.ui.cancel"),
|
||||
callback: () => { this.close() }
|
||||
}
|
||||
},
|
||||
close: close
|
||||
}
|
||||
|
||||
super(conf, options);
|
||||
|
||||
this.actor = actor;
|
||||
this.rollData = rollData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollConfront( diceFormula ) {
|
||||
// Do the initial roll
|
||||
let myRoll = new Roll(diceFormula).roll({async: false})
|
||||
await EcrymeUtility.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
// Fill the available dice table
|
||||
let rollData = this.rollData
|
||||
rollData.roll = duplicate(myRoll)
|
||||
rollData.availableDices = []
|
||||
for (let result of myRoll.terms[0].results) {
|
||||
if ( !result.discarded) {
|
||||
let resultDup = duplicate(result)
|
||||
resultDup.location = "mainpool"
|
||||
rollData.availableDices.push(resultDup)
|
||||
}
|
||||
}
|
||||
let confrontDialog = await EcrymeConfrontDialog.create(this.actor, rollData)
|
||||
confrontDialog.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ export class EcrymeRollDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(actor, rollData, html, options, close = undefined) {
|
||||
let isCard = rollData.attr && rollData.attr.iscard
|
||||
let conf = {
|
||||
title: game.i18n.localize("ECRY.ui.rolltitle"),
|
||||
content: html,
|
||||
|
@ -8,7 +8,6 @@ export class EcrymeItemSheet extends ItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-ecryme", "sheet", "item"],
|
||||
template: "systems/fvtt-ecryme/templates/item-sheet.hbs",
|
||||
|
Reference in New Issue
Block a user