diff --git a/modules/hawkmoon-actor.js b/modules/hawkmoon-actor.js index e457998..2f40f45 100644 --- a/modules/hawkmoon-actor.js +++ b/modules/hawkmoon-actor.js @@ -71,6 +71,7 @@ export class HawkmoonActor extends Actor { } return arme } + /* -------------------------------------------- */ getWeapons() { let armes = [] @@ -78,9 +79,6 @@ export class HawkmoonActor extends Actor { if (arme.type == "arme") { armes.push(this.prepareArme(arme)) } - if (arme.type == "bouclier") { - armes.push(this.prepareBouclier(arme)) - } } return armes } @@ -173,7 +171,10 @@ export class HawkmoonActor extends Actor { prepareDerivedData() { if (this.type == 'personnage') { - // TODO + let vigueur = Math.floor( (this.system.attributs.pui.value + this.system.attributs.tre.value) / 2) + if (vigueur != this.system.sante.vigueur) { + this.update( { 'system.sante.vigueur': vigueur}) + } } super.prepareDerivedData() @@ -350,9 +351,10 @@ export class HawkmoonActor extends Actor { rollData.actorImg = this.img rollData.actorId = this.id rollData.img = this.img - rollData.canEclatDoubleD20 = true - rollData.doubleD20 = false rollData.attributs = HawkmoonUtility.getAttributs() + rollData.maitriseId = "none" + rollData.nbEclat = this.system.eclat.value + rollData.nbBA = this.system.bonneaventure.actuelle if (attrKey) { rollData.attrKey = attrKey @@ -363,6 +365,7 @@ export class HawkmoonActor extends Actor { } if (compId) { rollData.competence = duplicate(this.items.get(compId) || {}) + rollData.maitrises = rollData.competence.system.predilections.filter(p => p.maitrise ) rollData.actionImg = rollData.competence?.img } if (compName) { diff --git a/modules/hawkmoon-item-sheet.js b/modules/hawkmoon-item-sheet.js index 05a4f1d..6986e15 100644 --- a/modules/hawkmoon-item-sheet.js +++ b/modules/hawkmoon-item-sheet.js @@ -134,41 +134,56 @@ export class HawkmoonItemSheet extends ItemSheet { let index = li.data("prediction-index") let pred = duplicate(this.object.system.predilections) pred[index].name = ev.currentTarget.value - this.object.update( { 'data.predilections': pred }) + pred[index].id = pred[index].id || randomID(16) + this.object.update( { 'system.predilections': pred }) }) html.find('.edit-predilection-description').change(ev => { const li = $(ev.currentTarget).parents(".prediction-item") let index = li.data("prediction-index") let pred = duplicate(this.object.system.predilections) pred[index].description = ev.currentTarget.value - this.object.update( { 'data.predilections': pred }) + pred[index].id = pred[index].id || randomID(16) + this.object.update( { 'system.predilections': pred }) }) - html.find('.delete-prediction').click(ev => { + html.find('.predilection-acquise').change(ev => { const li = $(ev.currentTarget).parents(".prediction-item") let index = li.data("prediction-index") let pred = duplicate(this.object.system.predilections) - pred.splice(index,1) - this.object.update( { 'data.predilections': pred }) - }) + pred[index].acquise = ev.currentTarget.checked + pred[index].id = pred[index].id || randomID(16) + this.object.update( { 'system.predilections': pred }) + }) + html.find('.predilection-maitrise').change(ev => { const li = $(ev.currentTarget).parents(".prediction-item") let index = li.data("prediction-index") let pred = duplicate(this.object.system.predilections) pred[index].maitrise = ev.currentTarget.checked - this.object.update( { 'data.predilections': pred }) + pred[index].id = pred[index].id || randomID(16) + this.object.update( { 'system.predilections': pred }) }) html.find('.predilection-used').change(ev => { const li = $(ev.currentTarget).parents(".prediction-item") let index = li.data("prediction-index") let pred = duplicate(this.object.system.predilections) pred[index].used = ev.currentTarget.checked - this.object.update( { 'data.predilections': pred }) + pred[index].id = pred[index].id || randomID(16) + this.object.update( { 'system.predilections': pred }) }) + + html.find('.delete-prediction').click(ev => { + const li = $(ev.currentTarget).parents(".prediction-item") + let index = li.data("prediction-index") + let pred = duplicate(this.object.system.predilections) + pred.splice(index,1) + this.object.update( { 'system.predilections': pred }) + }) + html.find('#add-predilection').click(ev => { let pred = duplicate(this.object.system.predilections) - pred.push( { name: "Nouvelle prédilection", used: false }) - this.object.update( { 'data.predilections': pred }) + pred.push( { name: "Nouvelle prédilection", id: randomID(16), used: false }) + this.object.update( { 'system.predilections': pred }) }) // Update Inventory Item html.find('.item-delete').click(ev => { diff --git a/modules/hawkmoon-roll-dialog.js b/modules/hawkmoon-roll-dialog.js index 5892b9d..ea7222c 100644 --- a/modules/hawkmoon-roll-dialog.js +++ b/modules/hawkmoon-roll-dialog.js @@ -20,12 +20,12 @@ export class HawkmoonRollDialog extends Dialog { rolld10: { icon: '', label: "Lancer 1d10", - callback: () => { this.roll("1d10") } + callback: () => { this.roll("d10") } }, rolld20: { icon: '', label: "Lancer 1d20", - callback: () => { this.roll("1d20") } + callback: () => { this.roll("d20") } }, cancel: { icon: '', @@ -66,14 +66,8 @@ export class HawkmoonRollDialog extends Dialog { html.find('#attrKey').change(async (event) => { this.rollData.attrKey = String(event.currentTarget.value) }) - html.find('#runemode').change(async (event) => { - this.rollData.runemode = String(event.currentTarget.value) + html.find('#select-maitrise').change(async (event) => { + this.rollData.maitriseId = String(event.currentTarget.value) }) - html.find('#runeame').change(async (event) => { - this.rollData.runeame = Number(event.currentTarget.value) - }) - html.find('#doubleD20').change(async (event) => { - this.rollData.doubleD20 = event.currentTarget.checked - }) } } \ No newline at end of file diff --git a/modules/hawkmoon-utility.js b/modules/hawkmoon-utility.js index ee35404..89d136f 100644 --- a/modules/hawkmoon-utility.js +++ b/modules/hawkmoon-utility.js @@ -14,13 +14,10 @@ export class HawkmoonUtility { Hooks.on("getCombatTrackerEntryContext", (html, options) => { HawkmoonUtility.pushInitiativeOptions(html, options); }) - Hooks.on("dropCanvasData", (canvas, data) => { - HawkmoonUtility.dropItemOnToken(canvas, data) - }); this.rollDataStore = {} this.defenderStore = {} - HawkmoonCommands.init(); + HawkmoonCommands.init() Handlebars.registerHelper('count', function (list) { return list.length; @@ -107,7 +104,7 @@ export class HawkmoonUtility { let predIdx = $(event.currentTarget).data("predilection-index") let messageId = HawkmoonUtility.findChatMessageId(event.currentTarget) let message = game.messages.get(messageId) - let rollData = message.getFlag("world", "mournblade-roll") + let rollData = message.getFlag("world", "hawkmoon-roll") let actor = game.actors.get(rollData.actorId) await actor.setPredilectionUsed(rollData.competence._id, predIdx) rollData.competence = duplicate(actor.getCompetence(rollData.competence._id)) @@ -123,7 +120,8 @@ export class HawkmoonUtility { 'systems/fvtt-hawkmoon-cyd/templates/partial-item-description.html', 'systems/fvtt-hawkmoon-cyd/templates/partial-item-nav.html', 'systems/fvtt-hawkmoon-cyd/templates/partial-list-niveau.html', - 'systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html' + 'systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html', + 'systems/fvtt-hawkmoon-cyd/templates/partial-sante-etat.html', ] return loadTemplates(templatePaths); } @@ -303,16 +301,16 @@ export class HawkmoonUtility { rollData.attr = duplicate(actor.system.attributs[rollData.attrKey]) } - rollData.diceFormula = rollData.mainDice - if (rollData.doubleD20) { // Multiply result ! - rollData.diceFormula += "*2" - if (!rollData.isReroll) { - actor.changeEclat(-1) - } + if ( rollData.maitriseId != "none") { + rollData.selectedMaitrise = rollData.maitrises.find(p => p.id == rollData.maitriseId ) + rollData.diceFormula = "2" + rollData.mainDice + "kh" + } else { + rollData.diceFormula = "1" + rollData.mainDice } + //console.log("BEFORE COMP", rollData) if (rollData.competence) { - rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => !pred.used) || []) + rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => pred.acquise && !pred.maitrise && !pred.used) || []) let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0 rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.system.niveau}+${rollData.modificateur}+${compmod}` } else { @@ -341,14 +339,6 @@ export class HawkmoonUtility { rollData.finalResult = myRoll.total this.computeResult(rollData) - if (rollData.rune) { - let subAme = rollData.runeame - if (rollData.isEchec && !rollData.isDramatique) { - subAme = Math.ceil((subAme + 1) / 2) - } - actor.subPointsAme(rollData.runemode, subAme) - } - this.createChatWithRollMode(rollData.alias, { content: await renderTemplate(`systems/fvtt-hawkmoon-cyd/templates/chat-generic-result.html`, rollData) }, rollData) @@ -451,7 +441,7 @@ export class HawkmoonUtility { chatOptions.alias = chatOptions.alias || name let msg = await ChatMessage.create(chatOptions) console.log("=======>", rollData) - msg.setFlag("world", "mournblade-roll", rollData) + msg.setFlag("world", "hawkmoon-roll", rollData) } /* -------------------------------------------- */ @@ -493,7 +483,7 @@ export class HawkmoonUtility { let msgId = li.data("message-id") let msg = game.messages.get(msgId) if (msg) { - let rollData = msg.getFlag("world", "mournblade-roll") + let rollData = msg.getFlag("world", "hawkmoon-roll") let actor = game.actors.get(rollData.actorId) actor.changeBonneAventure(changed) rollData.isReroll = true @@ -512,122 +502,57 @@ export class HawkmoonUtility { let msgId = li.data("message-id") let msg = game.messages.get(msgId) if (msg) { - let rollData = msg.getFlag("world", "mournblade-roll") + let rollData = msg.getFlag("world", "hawkmoon-roll") let actor = game.actors.get(rollData.actorId) actor.changeEclat(changed) rollData.isReroll = true rollData.textBonus = "Bonus d'Eclat" - rollData.addedBonus = addedBonus - HawkmoonUtility.bonusRollHawkmoon(rollData) + if (addedBonus == "reroll") { + HawkmoonUtility.rollHawkmoon(rollData) + } else { + rollData.addedBonus = addedBonus + HawkmoonUtility.bonusRollHawkmoon(rollData) + } } } /* -------------------------------------------- */ static chatRollMenu(html, options) { - let canApply = li => canvas.tokens.controlled.length && li.find(".mournblade-roll").length - let canApplyBALoyal = function (li) { + let canApply = li => canvas.tokens.controlled.length && li.find(".hawkmoon-roll").length + let canApplyBA = function (li) { let message = game.messages.get(li.attr("data-message-id")) - let rollData = message.getFlag("world", "mournblade-roll") + let rollData = message.getFlag("world", "hawkmoon-roll") let actor = game.actors.get(rollData.actorId) - return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "loyal") + return (!rollData.isReroll && actor.getBonneAventure() > 0 ) } - let canApplyPELoyal = function (li) { + let canApplyPE = function (li) { let message = game.messages.get(li.attr("data-message-id")) - let rollData = message.getFlag("world", "mournblade-roll") + let rollData = message.getFlag("world", "hawkmoon-roll") let actor = game.actors.get(rollData.actorId) - return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "loyal") - } - let canApplyBAChaotique = function (li) { - let message = game.messages.get(li.attr("data-message-id")) - let rollData = message.getFlag("world", "mournblade-roll") - let actor = game.actors.get(rollData.actorId) - return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "chaotique") - } - let canApplyBAChaotique3 = function (li) { - let message = game.messages.get(li.attr("data-message-id")) - let rollData = message.getFlag("world", "mournblade-roll") - let actor = game.actors.get(rollData.actorId) - return (!rollData.isReroll && actor.getBonneAventure() > 2 && actor.getAlignement() == "chaotique") - } - let canApplyPEChaotique = function (li) { - let message = game.messages.get(li.attr("data-message-id")) - let rollData = message.getFlag("world", "mournblade-roll") - let actor = game.actors.get(rollData.actorId) - return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique") - } - let hasPredilection = function (li) { - let message = game.messages.get(li.attr("data-message-id")) - let rollData = message.getFlag("world", "mournblade-roll") - let actor = game.actors.get(rollData.actorId) - if (rollData.competence) { - let nbPred = rollData.competence.data.predilections.filter(pred => !pred.used).length - return (!rollData.isReroll && rollData.competence && nbPred > 0) - } - return false - } - let canCompetenceDouble = function (li) { - let message = game.messages.get(li.attr("data-message-id")) - let rollData = message.getFlag("world", "mournblade-roll") - let actor = game.actors.get(rollData.actorId) - if (rollData.competence) { - return rollData.competence.data.doublebonus - } - return false + return (!rollData.isReroll && actor.getEclat() > 0 ) } options.push( { name: "Ajouer +3 (1 point de Bonne Aventure)", icon: "", - condition: canApply && canApplyBALoyal, + condition: canApply && canApplyBA, callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -1, "+3") } ) - options.push( - { - name: "Ajouer +6 (1 point de Bonne Aventure)", - icon: "", - condition: canApply && canApplyBALoyal && canCompetenceDouble, - callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -1, "+6") - } - ) - options.push( - { - name: "Ajouer +1d6 (1 point de Bonne Aventure)", - icon: "", - condition: canApply && canApplyBAChaotique, - callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -1, "+1d6") - } - ) - options.push( - { - name: "Ajouer +2d6 (1 point de Bonne Aventure)", - icon: "", - condition: canApply && canApplyBAChaotique && canCompetenceDouble, - callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -1, "+2d6") - } - ) - options.push( - { - name: "Relancer le dé (3 points de Bonne Aventure)", - icon: "", - condition: canApply && canApplyBAChaotique3, - callback: li => HawkmoonUtility.applyBonneAventureRoll(li, -3, "reroll") - } - ) options.push( { name: "Ajouter +10 (1 Point d'Eclat)", icon: "", - condition: canApply && canApplyPELoyal, + condition: canApply && canApplyPE, callback: li => HawkmoonUtility.applyEclatRoll(li, -1, "+10") } ) options.push( { - name: "Ajouter +20 (1 Point d'Eclat)", + name: "Relancer le dé (1 point d'Eclat)", icon: "", - condition: canApply && canApplyPELoyal && canCompetenceDouble, - callback: li => HawkmoonUtility.applyEclatRoll(li, -1, "+20") + condition: canApply && canApplyPE, + callback: li => HawkmoonUtility.applyEclatRoll(li, -3, "reroll") } ) return options diff --git a/packs/metiers.db b/packs/metiers.db deleted file mode 100644 index e69de29..0000000 diff --git a/packs/origines.db b/packs/origines.db deleted file mode 100644 index e69de29..0000000 diff --git a/packs/runes.db b/packs/runes.db deleted file mode 100644 index e69de29..0000000 diff --git a/packs/tendances.db b/packs/tendances.db deleted file mode 100644 index e69de29..0000000 diff --git a/packs/traits-chaotiques.db b/packs/traits-chaotiques.db deleted file mode 100644 index e69de29..0000000 diff --git a/styles/simple.css b/styles/simple.css index d10f36b..d3649d6 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1112,7 +1112,7 @@ ul, li { text-decoration: none; text-shadow: 0px 1px 0px #4d3534; position: relative; - margin:2px; + /*margin:2px;*/ } .chat-card-button:hover { @@ -1124,9 +1124,10 @@ ul, li { top:1px; } + .button-sheet-roll { box-shadow: inset 0px 1px 0px 0px #a6827e; - background: linear-gradient(to bottom, #21374afc 5%, #152833ab 60%); + background: linear-gradient(to bottom, #41545a 5%, #2e5561 100%); background-color: #7d5d3b00; border-radius: 4px; border: 1px ridge #846109; @@ -1139,13 +1140,15 @@ ul, li { text-shadow: 0px 1px 0px #4d3534; position: relative; max-height:1.8rem; - max-width: 4rem; margin-left:4px; + flex-grow:1; + max-width: 4rem; + min-width: 4rem; } .button-sheet-roll:hover { background: linear-gradient(to bottom, #800000 5%, #3e0101 100%); - background-color: red; + background-color: rgb(56, 33, 33); } .button-sheet-roll:active { position:relative; @@ -1247,28 +1250,6 @@ ul, li { flex-grow: 2; } -/*************************************************************/ -.button-roll-competence { - min-width: 64px; - max-width: 64px; - background-color: rgba(211, 221, 187, 100); - padding-top: 7px; - padding-left: 4px; - margin-left: 4px; - margin-right: 4px; - border-radius: 12px; -} - -/*************************************************************/ -.button-roll-competence-empty { - min-width: 64px; - max-width: 64px; - padding-top: 7px; - padding-left: 4px; - margin-left: 4px; - margin-right: 4px; - border-radius: 12px; -} /*************************************************************/ .item-name-img { diff --git a/system.json b/system.json index a26ed86..347fdff 100644 --- a/system.json +++ b/system.json @@ -21,7 +21,16 @@ "type": "Item", "label": "Compétences", "name": "skills", - "path": "packs/skills.db", + "path": "packs/competences.db", + "system": "fvtt-hawkmoon-cyd", + "private": false, + "flags": {} + }, + { + "type": "Item", + "label": "Historiques", + "name": "historiques", + "path": "packs/historiques.db", "system": "fvtt-hawkmoon-cyd", "private": false, "flags": {} @@ -38,8 +47,8 @@ { "type": "Item", "label": "Protections", - "name": "protection", - "path": "packs/protection.db", + "name": "protections", + "path": "packs/protections.db", "system": "fvtt-hawkmoon-cyd", "private": false, "flags": {} @@ -81,8 +90,8 @@ "flags": {} } ], - "primaryTokenAttribute": "secondary.health", - "secondaryTokenAttribute": "secondary.delirium", + "primaryTokenAttribute": "sante.vigueur", + "secondaryTokenAttribute": "bonneaventure.actuelle", "socket": true, "styles": [ "styles/simple.css" diff --git a/template.json b/template.json index 4516249..00a8abd 100644 --- a/template.json +++ b/template.json @@ -108,6 +108,10 @@ "prixsc": 0, "rarete": 0, "equipped": false + }, + "automation": { + "isautomated": false, + "automations": [] } }, "types": [ @@ -124,10 +128,10 @@ "talent": { "utilisation": "", "prerequis": "", - "isbonus": false, - "bonusformula": "", + "used": false, "templates": [ - "base" + "base", + "automation" ] }, "historique": { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index eddf66e..398cb72 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -81,66 +81,23 @@

Santé

- -

Ame

-

Combat

@@ -168,32 +125,26 @@ {{#each skills as |skill key|}}
  • - {{skill.name}} {{#if (ne skill.system.attribut1 "none")}} - - {{/if}} {{#if (ne skill.system.attribut2 "none")}} - - {{/if}} {{#if (ne skill.system.attribut3 "none")}} - - {{/if}}
     
    diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index c317075..44913c0 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -18,28 +18,27 @@
    diff --git a/templates/item-competence-sheet.html b/templates/item-competence-sheet.html index af91b0b..666f26d 100644 --- a/templates/item-competence-sheet.html +++ b/templates/item-competence-sheet.html @@ -23,8 +23,8 @@
  • - {{#select system.attribut1}} {{#each attributs as |attrLabel attrKey|}} @@ -34,8 +34,8 @@
  • - {{#select system.attribut2}} {{#each attributs as |attrLabel attrKey|}} @@ -46,8 +46,8 @@
  • - {{#select system.attribut3}} {{#each attributs as |attrLabel attrKey|}} @@ -64,19 +64,22 @@