diff --git a/lang/en.json b/lang/en.json index 458d7a3..c3cf6ef 100644 --- a/lang/en.json +++ b/lang/en.json @@ -24,6 +24,9 @@ "bonusmalustraits": "Traits Bonus/Malus", "spectranscend": "Self-Transcend : " }, + "warn": { + "notenoughdice": "Execution and Preservation must have 2 dices allocated" + }, "ui": { "traitType": "Trait type", "niveauTrait": "Trait level", @@ -97,7 +100,13 @@ "impactsocial": "Social", "impactmalus": "Impact Malus", "ongoingconfront": "Ongoing confrontation", - "confront":"Confrontation" + "confront":"Confrontation", + "launchconfront": "Launch confrontation", + "execution": "Execution", + "preservation": "Preservation", + "dicepool": "Available dices", + "selectconfront": "Select for confrontation", + "transcendapply": "Apply la Transcend to " } } } \ No newline at end of file diff --git a/lang/fr.json b/lang/fr.json index c3d56a6..61d6176 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -24,6 +24,9 @@ "bonusmalustraits": "Bonus/Malus des Traits", "spectranscend": "Dépassement de soi : " }, + "warn": { + "notenoughdice": "L'Accomplissement et la Préservation doivent avoir 2 dés chacun" + }, "ui": { "traitType": "Type de trait", "niveauTrait": "Niveau du trait", @@ -97,7 +100,13 @@ "impactsocial": "Social", "impactmalus": "Malus d'Impact", "ongoingconfront": "Confrontations en cours", - "confront":"Confrontation" + "confront":"Confrontation", + "launchconfront": "Lancer la confrontation", + "execution": "Accomplissement", + "preservation": "Préservation", + "dicepool": "Dés disponibles", + "selectconfront": "Sélectionner pour la Confrontation", + "transcendapply": "Appliquer la Transcendence à " } } } \ No newline at end of file diff --git a/modules/actors/ecryme-actor.js b/modules/actors/ecryme-actor.js index 9d0ac79..d5d8a61 100644 --- a/modules/actors/ecryme-actor.js +++ b/modules/actors/ecryme-actor.js @@ -314,7 +314,7 @@ export class EcrymeActor extends Actor { rollData.actorId = this.id rollData.img = this.img rollData.isReroll = false - rollData.traits = this.getRollTraits() + rollData.traits = duplicate(this.getRollTraits()) rollData.spleen = this.getSpleen() rollData.ideal = this.getIdeal() @@ -351,8 +351,9 @@ export class EcrymeActor extends Actor { 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 = [] + rollData.executionTotal = rollData.skill.value + rollData.preservationTotal = rollData.skill.value + rollData.applyTranscendence = "execution" let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData) confrontStartDialog.render(true) } diff --git a/modules/common/ecryme-utility.js b/modules/common/ecryme-utility.js index c7c4ed7..5ad9b11 100644 --- a/modules/common/ecryme-utility.js +++ b/modules/common/ecryme-utility.js @@ -157,7 +157,8 @@ export class EcrymeUtility { 'systems/fvtt-ecryme/templates/items/partial-item-equipment.hbs', 'systems/fvtt-ecryme/templates/items/partial-item-description.hbs', 'systems/fvtt-ecryme/templates/dialogs/partial-common-roll-dialog.hbs', - 'systems/fvtt-ecryme/templates/actors/partial-impacts.hbs' + 'systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs', + 'systems/fvtt-ecryme/templates/actors/partial-impacts.hbs', ] return loadTemplates(templatePaths); } @@ -386,10 +387,7 @@ export class EcrymeUtility { 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) - if (rollData.mode == "initiative") { - actor.setFlag("world", "initiative", myRoll.total) - } + msg.setFlag("world", "ecryme-rolldata", rollData) console.log("Rolldata result", rollData) } @@ -407,7 +405,7 @@ export class EcrymeUtility { 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", "ecryme-rolldata", rollData) } /* -------------------------------------------- */ diff --git a/modules/dialogs/ecryme-confront-dialog.js b/modules/dialogs/ecryme-confront-dialog.js index b5d7de5..379bc5e 100644 --- a/modules/dialogs/ecryme-confront-dialog.js +++ b/modules/dialogs/ecryme-confront-dialog.js @@ -22,10 +22,10 @@ export class EcrymeConfrontDialog extends Dialog { title: game.i18n.localize("ECRY.ui.confront"), content: html, buttons: { - rollNormal: { + launchConfront: { icon: '', - label: game.i18n.localize("ECRY.ui.rollnormal"), - callback: () => { this.rollConfront("4d6") } + label: game.i18n.localize("ECRY.ui.launchconfront"), + callback: () => { this.launchConfront().catch("Error when launching Confrontation") } }, cancel: { icon: '', @@ -40,51 +40,159 @@ export class EcrymeConfrontDialog extends Dialog { this.actor = actor; this.rollData = rollData; + + // Ensure button is disabled + setTimeout(function () { $(".launchConfront").attr("disabled", true) }, 180) } /* -------------------------------------------- */ - async roll() { + async launchConfront() { + let msg = await EcrymeUtility.createChatMessage(this.rollData.alias, "blindroll", { + content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-confrontation-pending.hbs`, this.rollData) + }) + msg.setFlag("world", "ecryme-rolldata", this.rollData) + } + + /* -------------------------------------------- */ + async refreshDialog() { + const content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/confront-dialog.hbs", this.rollData) + this.data.content = content + this.render(true) + + let button = this.buttonDisabled + setTimeout(function () { $(".launchConfront").attr("disabled", button) }, 180) + } /* ------------------ -------------------------- */ _onDragStart(event) { super._onDragStart(event) + console.log("DRAG", 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) + diceIndex: $(event.srcElement).data("dice-idx"), + diceValue: $(event.srcElement).data("dice-value"), + } + event.dataTransfer.setData("text/plain", JSON.stringify(diceData)); } /* -------------------------------------------- */ _onDrop(event) { let dataJSON = event.dataTransfer.getData('text/plain') + console.log("DICEDATA", dataJSON) 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("execution")) { + this.rollData.availableDices[idx].location = "execution" } - if ( event.srcElement.className.includes("preservation")) { - this.rollData.availableDices[idx].location = "preservation" + 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" + if (event.srcElement.className.includes("dice-list")) { + this.rollData.availableDices[idx].location = "mainpool" } - this.refreshDialog() + + if (this.rollData.availableDices.filter(d => d.location == "execution").length == 2 && this.rollData.availableDices.filter(d => d.location == "preservation").length == 2) { + this.buttonDisabled = false + } else { + this.buttonDisabled = true + } + + // Manage total values + this.computeTotals().catch("Error on dice pools") + + } + /* -------------------------------------------- */ + processTranscendence() { + // Apply Transcend if needed + if (this.rollData.skillTranscendence > 0) { + if (this.rollData.applyTranscendence == "execution") { + this.rollData.executionTotal += this.rollData.skillTranscendence + } else { + this.rollData.preservationTotal += this.rollData.skillTranscendence + } + } + } + + /* -------------------------------------------- */ + async computeTotals() { + let rollData = this.rollData + let actor = game.actors.get(rollData.actorId) + + rollData.executionTotal = rollData.availableDices.filter(d => d.location == "execution").reduce((previous, current) => { + return previous + current.result + }, rollData.skill.value) + rollData.preservationTotal = rollData.availableDices.filter(d => d.location == "preservation").reduce((previous, current) => { + return previous + current.result + }, rollData.skill.value) + this.processTranscendence() + + if (rollData.selectedSpecs && rollData.selectedSpecs.length > 0) { + rollData.spec = actor.getSpecialization(rollData.selectedSpecs[0]) + this.rollData.executionTotal += "+2" + this.rollData.preservationTotal += "+2" + } + rollData.bonusMalusTraits = 0 + for (let t of rollData.traits) { + t.isBonus = false + t.isMalus = false + } + if (rollData.traitsBonus && rollData.traitsBonus.length > 0) { + rollData.traitsBonusList = [] + for (let id of rollData.traitsBonus) { + let trait = rollData.traits.find(t => t._id == id) + trait.isBonus = true + rollData.traitsBonusList.push(trait) + rollData.bonusMalusTraits += trait.system.level + } + } + if (rollData.traitsMalus && rollData.traitsMalus.length > 0) { + rollData.traitsMalusList = [] + for (let id of rollData.traitsMalus) { + let trait = rollData.traits.find(t => t._id == id) + trait.isMalus = true + rollData.traitsMalusList.push(trait) + rollData.bonusMalusTraits -= trait.system.level + } + } + rollData.executionTotal += rollData.bonusMalusTraits + rollData.executionTotal += rollData.bonusMalusPerso + + rollData.preservationTotal += rollData.bonusMalusTraits + rollData.preservationTotal += rollData.bonusMalusPerso + + this.refreshDialog() } /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); + html.find('#bonusMalusPerso').change((event) => { + this.rollData.bonusMalusPerso = Number(event.currentTarget.value) + this.computeTotals() + }) + html.find('#roll-specialization').change((event) => { + this.rollData.selectedSpecs = $('#roll-specialization').val() + this.computeTotals() + }) + html.find('#roll-trait-bonus').change((event) => { + this.rollData.traitsBonus = $('#roll-trait-bonus').val() + this.computeTotals() + }) + html.find('#roll-trait-malus').change((event) => { + this.rollData.traitsMalus = $('#roll-trait-malus').val() + this.computeTotals() + }) + html.find('#roll-select-transcendence').change((event) => { + this.rollData.skillTranscendence = Number($('#roll-select-transcendence').val()) + this.computeTotals() + }) + html.find('#roll-apply-transcendence').change((event) => { + this.rollData.applyTranscendence = $('#roll-apply-transcendence').val() + this.computeTotals() + }) + + } } \ No newline at end of file diff --git a/postcss/ecryme.css b/postcss/ecryme.css index 79f8c53..aba04ce 100644 --- a/postcss/ecryme.css +++ b/postcss/ecryme.css @@ -1367,9 +1367,11 @@ ul, li { transform: translate(-50%, -80%); } .confront-area { - min-height: 96px; + margin: 2px; + padding: 4px; + min-height: 64px; border-width: 2px; border-color: #000000; - border-radius: 4px; + border-radius: 6px; border: 2px ridge #443307; } diff --git a/styles/ecryme.css b/styles/ecryme.css index 3f7fda3..db96910 100644 --- a/styles/ecryme.css +++ b/styles/ecryme.css @@ -1347,9 +1347,11 @@ ul, li { transform: translate(-50%, -80%); } .confront-area { + margin: 2px; + padding: 4px; min-height: 96px; border-width: 2px; border-color: #000000; - border-radius: 4px; + border-radius: 6px; border: 2px ridge #443307; } diff --git a/templates/chat/chat-confrontation-pending.hbs b/templates/chat/chat-confrontation-pending.hbs new file mode 100644 index 0000000..5bf8c9f --- /dev/null +++ b/templates/chat/chat-confrontation-pending.hbs @@ -0,0 +1,27 @@ +
+ {{#if actorImg}} + {{alias}} + {{/if}} +

{{alias}}

+
+ +
+ +{{#if img}} +
+ {{alias}} +
+{{/if}} + +
+ + +
+ + \ No newline at end of file diff --git a/templates/chat/chat-confrontation-result.hbs b/templates/chat/chat-confrontation-result.hbs deleted file mode 100644 index b5b949d..0000000 --- a/templates/chat/chat-confrontation-result.hbs +++ /dev/null @@ -1,37 +0,0 @@ -
- {{#if actorImg}} - {{alias}} - {{/if}} -

{{alias}}

-
- -
- - {{#if img}} -
- {{name}} -
- {{/if}} - -
-
- -
- -
- - diff --git a/templates/dialogs/confront-dialog.hbs b/templates/dialogs/confront-dialog.hbs index f651682..c159059 100644 --- a/templates/dialogs/confront-dialog.hbs +++ b/templates/dialogs/confront-dialog.hbs @@ -3,55 +3,104 @@ {{#if img}} {{/if}} -

{{title}}

+

{{title}} ({{skill.value}})

-
- {{#each availableDices as |dice idx|}} - {{#if (eq dice.location "execution")}} -
- - - - -
- {{/if}} - {{/each}} +
+

{{localize "ECRY.ui.execution"}} : {{executionTotal}}

+
+ {{> systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs filter="execution"}} +
- -
- {{#each availableDices as |dice idx|}} - {{#if (eq dice.location "preservation")}} -
- - - - -
- {{/if}} - {{/each}} + +
+

{{localize "ECRY.ui.preservation"}} : {{preservationTotal}}

+
+ {{> systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs filter="preservation"}} +
-
- {{#each availableDices as |dice idx|}} - {{#if (eq dice.location "mainpool")}} -
- - - - -
- {{/if}} - {{/each}} +

{{localize "ECRY.ui.dicepool"}}

+
+ {{> systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs filter="mainpool"}} +
+ + {{#if impactMalus}} +
+ {{localize "ECRY.ui.impactmalus"}} : + {{impactMalus}} +
+ {{/if}} + +
+ {{localize "ECRY.ui.skilltranscendence"}} : + +
+
+ {{localize "ECRY.ui.transcendapply"}} : + +
+ +
+ {{localize "ECRY.ui.spec"}} : + +
+ +
+ {{localize "ECRY.ui.traitbonus"}} : + +
+ +
+ {{localize "ECRY.ui.traitmalus"}} : + +
+ + +
+ Bonus/Malus : +
- {{> systems/fvtt-ecryme/templates/dialogs/partial-common-roll-dialog.hbs}}
diff --git a/templates/dialogs/partial-confront-dice-area.hbs b/templates/dialogs/partial-confront-dice-area.hbs new file mode 100644 index 0000000..b948184 --- /dev/null +++ b/templates/dialogs/partial-confront-dice-area.hbs @@ -0,0 +1,11 @@ +{{#each availableDices as |dice idx|}} +{{#if (eq dice.location ../filter)}} +
+ + + + +
+{{/if}} +{{/each}} \ No newline at end of file