Fix rolls

This commit is contained in:
LeRatierBretonnien 2023-07-21 18:57:41 +02:00
parent debd401d58
commit 0551d7812f
9 changed files with 139 additions and 40 deletions

View File

@ -123,7 +123,13 @@
"type": "Type", "type": "Type",
"applyimpact": "Apply impact", "applyimpact": "Apply impact",
"applybonus": "Apply bonus", "applybonus": "Apply bonus",
"bonuspool": "Available bonuses" "bonuspool": "Available bonuses",
"cephaly": "Cephaly",
"elegy": "Elegy",
"entelechy": "Entelechy",
"mekany": "Mekany",
"psyche": "Psyche",
"scoria": "Scoria"
} }
} }
} }

View File

@ -123,7 +123,13 @@
"type": "Type", "type": "Type",
"applyimpact": "Appliquer l'impact", "applyimpact": "Appliquer l'impact",
"applybonus": "Appliquer le bonus", "applybonus": "Appliquer le bonus",
"bonuspool": "Bonus disponibles" "bonuspool": "Bonus disponibles",
"cephaly": "Cephalie",
"elegy": "Elégie",
"entelechy": "Entéléchie",
"mekany": "Mekanë",
"psyche": "Psyché",
"scoria": "Scorie"
} }
} }
} }

View File

@ -46,6 +46,8 @@ export class EcrymeActorSheet extends ActorSheet {
impactsMalus: this.actor.getImpactsMalus(), impactsMalus: this.actor.getImpactsMalus(),
archetype: duplicate(this.actor.getArchetype()), archetype: duplicate(this.actor.getArchetype()),
equipements: this.actor.getEquipments(), equipements: this.actor.getEquipments(),
hasCephaly: EcrymeUtility.hasCephaly(),
cephalySkills: this.actor.getCephalySkills(),
subActors: duplicate(this.actor.getSubActors()), subActors: duplicate(this.actor.getSubActors()),
description: await TextEditor.enrichHTML(this.object.system.description, { async: true }), description: await TextEditor.enrichHTML(this.object.system.description, { async: true }),
notes: await TextEditor.enrichHTML(this.object.system.notes, { async: true }), notes: await TextEditor.enrichHTML(this.object.system.notes, { async: true }),
@ -122,6 +124,10 @@ export class EcrymeActorSheet extends ActorSheet {
let skillKey = $(event.currentTarget).data("skill-key") let skillKey = $(event.currentTarget).data("skill-key")
this.actor.rollSkillConfront(categKey, skillKey) this.actor.rollSkillConfront(categKey, skillKey)
}); });
html.find('.roll-cephaly').click((event) => {
let skillKey = $(event.currentTarget).data("skill-key")
this.actor.rollCephalySkillConfront(skillKey)
});
html.find('.roll-weapon-confront').click((event) => { html.find('.roll-weapon-confront').click((event) => {
const li = $(event.currentTarget).parents(".item") const li = $(event.currentTarget).parents(".item")
let weaponId = li.data("item-id"); let weaponId = li.data("item-id");

View File

@ -109,6 +109,11 @@ export class EcrymeActor extends Actor {
return skills return skills
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getCephalySkills() {
let skills = duplicate(this.system.cephaly.skilllist)
return skills
}
/* -------------------------------------------- */
getImpacts() { getImpacts() {
let comp = duplicate(this.items.filter(item => item.type == 'impact') || []) let comp = duplicate(this.items.filter(item => item.type == 'impact') || [])
return comp; return comp;
@ -323,7 +328,7 @@ export class EcrymeActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getCommonRollData() { getCommonRollData() {
this.system.internals.confrontbonus = 5 // TO BE REMOVED!!!! //this.system.internals.confrontbonus = 5 // TO BE REMOVED!!!!
let rollData = EcrymeUtility.getBasicRollData() let rollData = EcrymeUtility.getBasicRollData()
rollData.alias = this.name rollData.alias = this.name
rollData.actorImg = this.img rollData.actorImg = this.img
@ -371,6 +376,24 @@ export class EcrymeActor extends Actor {
rollData.executionTotal = rollData.skill.value rollData.executionTotal = rollData.skill.value
rollData.preservationTotal = rollData.skill.value rollData.preservationTotal = rollData.skill.value
rollData.applyTranscendence = "execution" rollData.applyTranscendence = "execution"
rollData.traitsBonus = duplicate(rollData.traits)
rollData.traitsMalus = duplicate(rollData.traits)
let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData)
confrontStartDialog.render(true)
}
/* -------------------------------------------- */
async rollCephalySkillConfront(skillKey) {
let rollData = this.getCommonRollData()
rollData.mode = "cephaly"
rollData.skill = duplicate(this.system.cephaly.skilllist[skillKey])
rollData.img = rollData.skill.img
rollData.skill.categKey = "cephaly"
rollData.skill.skillKey = skillKey
//rollData.impactMalus = this.getImpactMalus(categKey)
rollData.title = game.i18n.localize("ECRY.ui.cephaly") + " : " + game.i18n.localize(rollData.skill.name)
rollData.executionTotal = rollData.skill.value
rollData.preservationTotal = rollData.skill.value
rollData.applyTranscendence = "execution"
let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData) let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData)
confrontStartDialog.render(true) confrontStartDialog.render(true)
} }

View File

@ -76,6 +76,12 @@ export class EcrymeUtility {
} }
/*-------------------------------------------- */
static hasCephaly() {
let level = game.settings.get("fvtt-ecryme", "ecryme-game-level")
return level != "level_e"
}
/*-------------------------------------------- */ /*-------------------------------------------- */
static buildSkillConfig() { static buildSkillConfig() {
game.system.ecryme.config.skills = {} game.system.ecryme.config.skills = {}

View File

@ -54,6 +54,25 @@ export class EcrymeConfrontDialog extends Dialog {
msg.setFlag("world", "ecryme-rolldata", this.rollData) msg.setFlag("world", "ecryme-rolldata", this.rollData)
} }
/* -------------------------------------------- */
async refreshDice() {
this.rollData.filter = "execution"
let content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs", this.rollData )
content += await renderTemplate("systems/fvtt-ecryme/templates/dialogs/partial-confront-bonus-area.hbs", this.rollData )
$("#confront-execution").html(content)
this.rollData.filter = "preservation"
content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs", this.rollData )
content += await renderTemplate("systems/fvtt-ecryme/templates/dialogs/partial-confront-bonus-area.hbs", this.rollData )
$("#confront-preservation").html(content)
this.rollData.filter = "mainpool"
content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs", this.rollData )
$("#confront-dice-pool").html(content)
content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/partial-confront-bonus-area.hbs", this.rollData )
$("#confront-bonus-pool").html(content)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async refreshDialog() { async refreshDialog() {
const content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/confront-dialog.hbs", this.rollData) const content = await renderTemplate("systems/fvtt-ecryme/templates/dialogs/confront-dialog.hbs", this.rollData)
@ -69,7 +88,7 @@ export class EcrymeConfrontDialog extends Dialog {
super._onDragStart(event) super._onDragStart(event)
let dragType = $(event.srcElement).data("drag-type") let dragType = $(event.srcElement).data("drag-type")
let diceData = {} let diceData = {}
console.log("DRAGTYPE", dragType) //console.log("DRAGTYPE", dragType)
if (dragType == "dice") { if (dragType == "dice") {
diceData = { diceData = {
dragType: "dice", dragType: "dice",
@ -157,43 +176,45 @@ export class EcrymeConfrontDialog extends Dialog {
rollData.preservationTotal = rollData.confrontBonus.filter(d => d.location == "preservation").reduce((previous, current) => { rollData.preservationTotal = rollData.confrontBonus.filter(d => d.location == "preservation").reduce((previous, current) => {
return previous + 1 return previous + 1
}, rollData.preservationTotal) }, rollData.preservationTotal)
this.processTranscendence() this.processTranscendence()
if (rollData.selectedSpecs && rollData.selectedSpecs.length > 0) { if (rollData.selectedSpecs && rollData.selectedSpecs.length > 0) {
rollData.spec = duplicate(actor.getSpecialization(rollData.selectedSpecs[0])) rollData.spec = duplicate(actor.getSpecialization(rollData.selectedSpecs[0]))
this.rollData.executionTotal += "+2" rollData.specApplied = true
this.rollData.preservationTotal += "+2" rollData.executionTotal += 2
rollData.preservationTotal += 2
}
if ( rollData.specApplied && rollData.selectedSpecs.length == 0) {
rollData.spec = undefined
rollData.specApplied = false
} }
rollData.bonusMalusTraits = 0 rollData.bonusMalusTraits = 0
for (let t of rollData.traits) { for (let t of rollData.traitsBonus) {
t.isBonus = false t.activated = false
t.isMalus = false
} }
if (rollData.traitsBonus && rollData.traitsBonus.length > 0) { for (let t of rollData.traitsMalus) {
rollData.traitsBonusList = [] t.activated = false
for (let id of rollData.traitsBonus) { }
let trait = rollData.traits.find(t => t._id == id) if (rollData.traitsBonusSelected && rollData.traitsBonusSelected.length > 0) {
trait.isBonus = true for (let id of rollData.traitsBonusSelected) {
rollData.traitsBonusList.push(trait) let trait = rollData.traitsBonus.find(t => t._id == id)
trait.activated = true
rollData.bonusMalusTraits += trait.system.level rollData.bonusMalusTraits += trait.system.level
} }
} }
if (rollData.traitsMalus && rollData.traitsMalus.length > 0) { if (rollData.traitsMalusSelected && rollData.traitsMalusSelected.length > 0) {
rollData.traitsMalusList = [] for (let id of rollData.traitsMalusSelected) {
for (let id of rollData.traitsMalus) { let trait = rollData.traitsMalus.find(t => t._id == id)
let trait = rollData.traits.find(t => t._id == id) trait.activated = true
trait.isMalus = true
rollData.traitsMalusList.push(trait)
rollData.bonusMalusTraits -= trait.system.level rollData.bonusMalusTraits -= trait.system.level
} }
} }
rollData.executionTotal += rollData.bonusMalusTraits
rollData.executionTotal += rollData.bonusMalusPerso
rollData.preservationTotal += rollData.bonusMalusTraits rollData.executionTotal += rollData.bonusMalusTraits + rollData.bonusMalusPerso
rollData.preservationTotal += rollData.bonusMalusPerso rollData.preservationTotal += rollData.bonusMalusTraits + rollData.bonusMalusPerso
this.refreshDialog().catch("Error on refresh confrontation dialog") this.refreshDialog()
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -209,11 +230,11 @@ export class EcrymeConfrontDialog extends Dialog {
this.computeTotals() this.computeTotals()
}) })
html.find('#roll-trait-bonus').change((event) => { html.find('#roll-trait-bonus').change((event) => {
this.rollData.traitsBonus = $('#roll-trait-bonus').val() this.rollData.traitsBonusSelected = $('#roll-trait-bonus').val()
this.computeTotals() this.computeTotals()
}) })
html.find('#roll-trait-malus').change((event) => { html.find('#roll-trait-malus').change((event) => {
this.rollData.traitsMalus = $('#roll-trait-malus').val() this.rollData.traitsMalusSelected = $('#roll-trait-malus').val()
this.computeTotals() this.computeTotals()
}) })
html.find('#roll-select-transcendence').change((event) => { html.find('#roll-select-transcendence').change((event) => {

View File

@ -42,7 +42,7 @@
], ],
"title": "Ecryme, le Jeu de Rôles", "title": "Ecryme, le Jeu de Rôles",
"url": "https://www.uberwald.me/gitea/uberwald/fvtt-ecryme", "url": "https://www.uberwald.me/gitea/uberwald/fvtt-ecryme",
"version": "11.0.6", "version": "11.0.7",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-ecryme/archive/fvtt-ecryme-v11.0.6.zip", "download": "https://www.uberwald.me/gitea/uberwald/fvtt-ecryme/archive/fvtt-ecryme-v11.0.7.zip",
"background": "systems/fvtt-ecryme/images/assets/ecryme_extract_panel_01.webp" "background": "systems/fvtt-ecryme/images/assets/ecryme_extract_panel_01.webp"
} }

View File

@ -51,6 +51,9 @@
<a class="item" data-tab="competences">{{localize "ECRY.ui.skills"}}</a> <a class="item" data-tab="competences">{{localize "ECRY.ui.skills"}}</a>
<a class="item" data-tab="traits">{{localize "ECRY.ui.traits"}}</a> <a class="item" data-tab="traits">{{localize "ECRY.ui.traits"}}</a>
<a class="item" data-tab="combat">{{localize "ECRY.ui.healthcombat"}}</a> <a class="item" data-tab="combat">{{localize "ECRY.ui.healthcombat"}}</a>
{{#if hasCephaly}}
<a class="item" data-tab="cephaly">{{localize "ECRY.ui.cephaly"}}</a>
{{/if}}
<a class="item" data-tab="equipements">{{localize "ECRY.ui.equipment"}}</a> <a class="item" data-tab="equipements">{{localize "ECRY.ui.equipment"}}</a>
<a class="item" data-tab="biodata">{{localize "ECRY.ui.bionotes"}}</a> <a class="item" data-tab="biodata">{{localize "ECRY.ui.bionotes"}}</a>
</nav> </nav>
@ -119,6 +122,34 @@
</div> </div>
{{#if hasCephaly}}
{{!-- Cephaly Tab --}}
<div class="tab cephaly" data-group="primary" data-tab="cephaly">
<div>
<ul class="stat-list alternate-list item-list">
{{#each cephalySkills as |skill skillkey|}}
<li class="item flexrow list-item">
<span class="item-name-label-long">
<a class="roll-cephaly" data-category-key="cephaly" data-skill-key="{{skillkey}}">
<i class="fa-solid fa-dice-d6"></i>
{{localize skill.name}}
</a></span>
<select class="item-field-label-short" type="text"
name="system.cephaly.skilllist.{{skillkey}}.value" value="{{skill.value}}"
data-dtype="Number">
{{#select skill.value}}
{{#each @root.config.skillLevel as |level key| }}
<option value="{{level}}">{{level}}</option>
{{/each}}
{{/select}}
</select>
</li>
{{/each}}
</ul>
</div>
</div>
{{/if}}
<div class="tab traits" data-group="primary" data-tab="traits"> <div class="tab traits" data-group="primary" data-tab="traits">

View File

@ -14,7 +14,6 @@
<h3>{{localize "ECRY.ui.execution"}} : <span id="execution-total">{{executionTotal}}</span> </h3> <h3>{{localize "ECRY.ui.execution"}} : <span id="execution-total">{{executionTotal}}</span> </h3>
<div id="confront-execution" class="flexrow confront-area confront-execution-area"> <div id="confront-execution" class="flexrow confront-area confront-execution-area">
{{> systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs filter="execution"}} {{> systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs filter="execution"}}
<br>
{{> systems/fvtt-ecryme/templates/dialogs/partial-confront-bonus-area.hbs filter="execution"}} {{> systems/fvtt-ecryme/templates/dialogs/partial-confront-bonus-area.hbs filter="execution"}}
</div> </div>
</div> </div>
@ -73,20 +72,22 @@
</select> </select>
</div> </div>
{{#if skill.spec}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">{{localize "ECRY.ui.spec"}} : </span> <span class="roll-dialog-label">{{localize "ECRY.ui.spec"}} : </span>
<select class="" id="roll-specialization" data-type="String" multiple> <select class="" id="roll-specialization" data-type="String" multiple>
{{#each skill.spec as |spec idx|}} {{#each skill.spec as |spec idx|}}
<option value="{{spec.id}}">{{spec.name}}</option> <option value="{{spec.id}}" {{#if (eq spec.name @root.spec.name)}}selected{{/if}}>{{spec.name}}</option>
{{/each}} {{/each}}
</select> </select>
</div> </div>
{{/if}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">{{localize "ECRY.ui.traitbonus"}} : </span> <span class="roll-dialog-label">{{localize "ECRY.ui.traitbonus"}} : </span>
<select class="" id="roll-trait-bonus" data-type="String" multiple> <select class="" id="roll-trait-bonus" data-type="String" multiple>
{{#each traits as | trait idx|}} {{#each traitsBonus as |trait idx|}}
<option value="{{trait._id}}" {{#if trait.isBonus}}selected{{/if}}>{{trait.name}} ({{trait.system.level}})</option> <option value="{{trait._id}}" {{#if trait.activated}}selected{{/if}}>{{trait.name}} ({{trait.system.level}})</option>
{{/each}} {{/each}}
</select> </select>
</div> </div>
@ -94,13 +95,12 @@
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">{{localize "ECRY.ui.traitmalus"}} : </span> <span class="roll-dialog-label">{{localize "ECRY.ui.traitmalus"}} : </span>
<select class="" id="roll-trait-malus" data-type="String" multiple> <select class="" id="roll-trait-malus" data-type="String" multiple>
{{#each traits as | trait idx|}} {{#each traitsMalus as |trait idx|}}
<option value="{{trait._id}}" {{#if trait.isMalus}}selected{{/if}}">{{trait.name}} ({{trait.system.level}})</option> <option value="{{trait._id}}" {{#if trait.activated}}selected{{/if}}>{{trait.name}} ({{trait.system.level}})</option>
{{/each}} {{/each}}
</select> </select>
</div> </div>
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">Bonus/Malus : </span> <span class="roll-dialog-label">Bonus/Malus : </span>
<select id="bonusMalusPerso" name="bonusMalusPerso"> <select id="bonusMalusPerso" name="bonusMalusPerso">