From b6dac470e98213a98fbd65104a032b728af76006 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Thu, 20 Oct 2022 23:59:31 +0200 Subject: [PATCH] Gestion des paradigmes --- modules/imperium5-actor-sheet.js | 13 +--- modules/imperium5-actor.js | 24 +++++-- modules/imperium5-utility.js | 58 ++++++++++++--- styles/simple.css | 96 ++++++++++++++----------- system.json | 20 +++--- templates/actor-partial-ames.html | 65 +++++++++-------- templates/actor-partial-paradigmes.html | 4 +- templates/actor-sheet.html | 16 ++--- templates/chat-generic-result.html | 29 ++++++++ 9 files changed, 206 insertions(+), 119 deletions(-) diff --git a/modules/imperium5-actor-sheet.js b/modules/imperium5-actor-sheet.js index 4b434e1..a6f25e0 100644 --- a/modules/imperium5-actor-sheet.js +++ b/modules/imperium5-actor-sheet.js @@ -143,22 +143,11 @@ export class Imperium5ActorSheet extends ActorSheet { this.actor.incDecQuantity( li.data("item-id"), +1 ); } ); - html.find('.roll-ame').click((event) => { + html.find('.roll-ame-button').click((event) => { const ameKey = $(event.currentTarget).data("ame-key") this.actor.rollAme(ameKey) }); - html.find('.roll-spec').click((event) => { - const li = $(event.currentTarget).parents(".item"); - const specId = li.data("item-id"); - this.actor.rollSpec(specId); - }); - - html.find('.weapon-damage-roll').click((event) => { - const li = $(event.currentTarget).parents(".item"); - const weaponId = li.data("item-id"); - this.actor.rollWeapon(weaponId, true); - }); html.find('.lock-unlock-sheet').click((event) => { this.options.editScore = !this.options.editScore; diff --git a/modules/imperium5-actor.js b/modules/imperium5-actor.js index 32d1528..87233a3 100644 --- a/modules/imperium5-actor.js +++ b/modules/imperium5-actor.js @@ -111,6 +111,17 @@ export class Imperium5Actor extends Actor { let item = duplicate(this.items.filter( it => it.type == "contact") || [] ) return item } + getUnusedParadigmes() { + let paraList = [] + for(let k in this.system.paradigmes) { + let para = this.system.paradigmes[k] + if (!para.used) { + para.key = k + paraList.push(duplicate(para)) + } + } + return paraList + } /* -------------------------------------------- */ incDecKarma( value ) { @@ -156,10 +167,6 @@ export class Imperium5Actor extends Actor { /* -------------------------------------------- */ getInitiativeScore(combatId, combatantId) { - if (this.type == 'character') { - this.rollMR(true, combatId, combatantId) - } - console.log("Init required !!!!") return -1; } @@ -213,6 +220,13 @@ export class Imperium5Actor extends Actor { } } } + + /* -------------------------------------------- */ + setParadigmeUsed(paraKey) { + let para = duplicate(this.system.paradigmes) + para[paraKey].used = true + this.update( {'system.paradigmes': para} ) + } /* -------------------------------------------- */ /* ROLL SECTION @@ -250,6 +264,8 @@ export class Imperium5Actor extends Actor { rollData.actorId = this.id rollData.img = this.img rollData.capacites = this.getUnusedCapacites() + rollData.paradigmes = this.getUnusedParadigmes() + rollData.selectedParadigme = "none" rollData.karma = this.system.karma.value return rollData diff --git a/modules/imperium5-utility.js b/modules/imperium5-utility.js index d2318ae..87b6b3a 100644 --- a/modules/imperium5-utility.js +++ b/modules/imperium5-utility.js @@ -91,9 +91,13 @@ export class Imperium5Utility { /* -------------------------------------------- */ static async chatListeners(html) { - html.on("click", '.view-item-from-chat', event => { - game.system.pegasus.creator.openItemView(event) + html.on("click", '.button-apply-paradigme', event => { + let paraKey = $(event.currentTarget).data("para-key") + let rollData = this.getRollDataFromMessage(event) + rollData.previousMessageId = Imperium5Utility.findChatMessageId(event.currentTarget) + this.applyParadigme(rollData, paraKey) }) + } /* -------------------------------------------- */ @@ -152,6 +156,12 @@ export class Imperium5Utility { } return undefined; } + /* -------------------------------------------- */ + static getRollDataFromMessage(event) { + let messageId = Imperium5Utility.findChatMessageId(event.currentTarget) + let message = game.messages.get(messageId) + return message.getFlag("world", "imperium5-roll-data") + } /* -------------------------------------------- */ static createDirectOptionList(min, max) { @@ -279,6 +289,16 @@ export class Imperium5Utility { return Math.max(val, 0) } + /* -------------------------------------------- */ + static computeReussites(rollData) { + let myRoll = rollData.roll + rollData.successPC = myRoll.terms[0].results.filter(res => res.result <= rollData.seuil).length + rollData.successGM = myRoll.terms[4].results.filter(res => res.result <= rollData.seuil).length + rollData.bonPresage = myRoll.terms[2].results[0].result == 1 + rollData.mauvaisPresage = myRoll.terms[2].results[0].result == 8 + rollData.nbUnitesNarration = Math.max( rollData.successPC-1, 0) + } + /* -------------------------------------------- */ static async rollImperium5(rollData) { @@ -308,16 +328,24 @@ export class Imperium5Utility { } // Calcul réussites - rollData.successPC = myRoll.terms[0].results.filter(res => res.result <= 2).length - rollData.successGM = myRoll.terms[4].results.filter(res => res.result <= 2).length - rollData.bonPresage = myRoll.terms[2].results[0].result == 1 - rollData.mauvaisPresage = myRoll.terms[2].results[0].result == 8 - rollData.nbUnitesNarration = Math.max( rollData.successPC-1, 0) + this.computeReussites(rollData) let msg = await this.createChatWithRollMode(rollData.alias, { content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData) }) - msg.setFlag("world", "rolldata", rollData) + msg.setFlag("world", "imperium5-roll-data", rollData) + } + + /* ------------------------- ------------------- */ + static async processParadigmeRoll(rollData) { + this.computeReussites(rollData) + rollData.paradigmes = [] + let msg = await this.createChatWithRollMode(rollData.alias, { + content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData) + }) + msg.setFlag("world", "imperium5-roll-data", rollData) + + this.removeChatMessageId(rollData.previousMessageId) } /* ------------------------- ------------------- */ @@ -445,12 +473,24 @@ export class Imperium5Utility { useArchetype: false, useAide: false, useKarma: false, - usedCapacite: "none" + usedCapacite: "none", + seuil: 2 } Imperium5Utility.updateWithTarget(rollData) return rollData } + /* -------------------------------------------- */ + static applyParadigme(rollData, paraKey) { + let actor = game.actors.get(rollData.actorId) + let para = actor.system.paradigmes[paraKey] + rollData.seuil = para.value + rollData.usedParadigme = para.label + actor.setParadigmeUsed(paraKey) + + this.processParadigmeRoll(rollData) + } + /* -------------------------------------------- */ static updateWithTarget(rollData) { let objectDefender diff --git a/styles/simple.css b/styles/simple.css index 8318f6b..8f21492 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -60,7 +60,7 @@ font-size: 1.0rem; } /* For title, sidebar character and scene */ .sheet nav.sheet-tabs { - font-size: 0.8rem; + font-size: 1.2rem; } /* For nav and title */ .window-app input, .foundryvtt-vadentis .item-form, .sheet header.sheet-header .flex-group-center.flex-compteurs, .sheet header.sheet-header .flex-group-center.flex-fatigue, select, button, .item-checkbox, #sidebar, #players, #navigation #nav-toggle { font-size: 0.8rem; @@ -78,7 +78,7 @@ font-weight: bold; } -.tabs .item.active, .blessures-list li ul li:first-child:hover, a:hover { +.tabs .item.active, a:hover { text-shadow: 1px 0px 0px #ff6600; } @@ -335,20 +335,21 @@ table {border: 1px solid #7a7971;} } .fvtt-imperium5 .tabs { - height: 40px; + height: 24px; border-top: 1px solid #AAA; border-bottom: 1px solid #AAA; color: #000000; } .fvtt-imperium5 .tabs .item { - line-height: 40px; + line-height: 24px; font-weight: bold; } .fvtt-imperium5 .tabs .item.active { - text-decoration: underline; - text-shadow: none; + /*text-decoration: underline;*/ + background: linear-gradient(to bottom, #B8A799F0 5%, #9c6d47f0 100%); + /*text-shadow: none;*/ } .fvtt-imperium5 .items-list { @@ -445,29 +446,40 @@ section.sheet-body{padding: 0.25rem 0.5rem;} } .sheet nav.sheet-tabs { - font-size: 0.70rem; + font-size: 1.0rem; font-weight: bold; - height: 3rem; + height: 2.5rem; flex: 0 0 3rem; margin: 0; padding: 0 0 0 0.25rem; text-align: center; text-transform: uppercase; line-height: 1.5rem; + border-radius: 8px; border-top: 0 none; border-bottom: 0 none; border-right: 0 none; - background-color:#B8A799F0; - color:beige; + color: #403f3e; } -/* background: rgb(245,245,240) url("../images/ui/fond4.webp") repeat left top;*/ - nav.sheet-tabs .item { position: relative; padding: 0 0.25rem; } +.tab-title { + background-color:#B8A799F0; + border-radius: 4px; +} +.tab-title:hover { + background: linear-gradient(to bottom, #B8A799F0 5%, #9c6d47f0 100%); + background-color: red; +} +.tab-title:active { + position:relative; + top:1px; +} + nav.sheet-tabs .item:after { content: ""; position: absolute; @@ -1150,47 +1162,46 @@ ul, li { opacity: 1; } -.river-button { +.common-button { box-shadow: inset 0px 1px 0px 0px #a6827e; - background: linear-gradient(to bottom, #21374afc 5%, #152833ab 100%); - background-color: #7d5d3b00; - border-radius: 3px; + background: linear-gradient(to bottom, #B8A799F0 5%, #80624af0 100%); + background-color: #B8A799F0; /*#7d5d3b00;*/ + border-radius: 4px; + opacity: 60%; border: 2px ridge #846109; display: inline-block; cursor: pointer; color: #ffffff; - font-size: 0.8rem; - padding: 2px 4px 0px 4px; text-decoration: none; text-shadow: 0px 1px 0px #4d3534; position: relative; - margin:4px; +} + +.common-button:hover { + background: linear-gradient(to bottom, #97B5AEFF 5%, rgb(101, 167, 151) 100%); + background-color: #97B5AEFF; +} +.common-button:active { + position:relative; + top:1px; +} + +.roll-ame-button { + width: 80px; + min-width: 80px; } .chat-card-button { - box-shadow: inset 0px 1px 0px 0px #a6827e; - background: linear-gradient(to bottom, #21374afc 5%, #152833ab 100%); - background-color: #7d5d3b00; - border-radius: 3px; - border: 2px ridge #846109; - display: inline-block; - cursor: pointer; - color: #ffffff; font-size: 0.8rem; - padding: 4px 12px 0px 12px; - text-decoration: none; - text-shadow: 0px 1px 0px #4d3534; - position: relative; + padding: 2px 2px 0px 2px; margin:2px; } -.chat-card-button:hover { - background: linear-gradient(to bottom, #800000 5%, #3e0101 100%); - background-color: red; -} -.chat-card-button:active { - position:relative; - top:1px; + +.li-button-paradigme { + display: flex; + flex-direction: row; + flex-wrap: wrap; } .plus-minus-button { @@ -1209,9 +1220,7 @@ ul, li { margin:0px; } -.river-button:hover, -.plus-minus-button:hover, -.chat-card-button:hover { +.plus-minus-button:hover { background: linear-gradient(to bottom, #800000 5%, #3e0101 100%); background-color: red; } @@ -1295,7 +1304,7 @@ ul, li { /* =================== 1. ACTOR SHEET FONT STYLES =========== *//* */ .sheet-box { - border-radius: 5%; + border-radius: 12px; border-width: 1px; padding: 0.4rem; margin: 0.2rem; @@ -1450,4 +1459,7 @@ ul, li { } .color-text-ame { color: #806B64; +} +.ame-block { + margin-bottom: 24px; } \ No newline at end of file diff --git a/system.json b/system.json index e8592c2..6138034 100644 --- a/system.json +++ b/system.json @@ -1,9 +1,13 @@ { "id": "fvtt-imperium5", "title": "Imperium5 RPG", - "authors": [ {"name":"Uberwald"} ], - "version": "10.0.3", - "compatibleCoreVersion": "9", + "authors": [ + { + "name": "Uberwald", + "flags": {} + } + ], + "version": "10.0.4", "compatibility": { "minimum": "10", "verified": "10", @@ -15,12 +19,7 @@ ], "gridDistance": 5, "gridUnits": "m", - "languages": [ - ], - "library": false, "license": "LICENSE.txt", - "manifestPlusVersion": "1.0.0", - "media": [], "packs": [ { "type": "Item", @@ -65,9 +64,8 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 47, - "background" : "./images/ui/imperium5_welcome_page.webp", + "background": "images/ui/imperium5_welcome_page.webp", "url": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5", "manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/raw/branch/master/system.json", "download": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/archive/fvtt-imperium5-v10.0.3.zip" -} +} \ No newline at end of file diff --git a/templates/actor-partial-ames.html b/templates/actor-partial-ames.html index 9240b69..29fa111 100644 --- a/templates/actor-partial-ames.html +++ b/templates/actor-partial-ames.html @@ -1,35 +1,38 @@ - -

{{typedata.label}}

-
 
+
+ +

{{typedata.label}}

+
 
- + - / -
+ name="system.amestype.{{typeame}}.cohesion" value="{{typedata.cohesion}}" data-dtype="Number" {{#unless + @root.editScore}}disabled{{/unless}} /> / + + -
    - {{#each system.ames as |ame key|}} - {{#if (eq ame.type ../typeame)}} -
  • - - - {{ame.label}} - -
  • - {{/if}} - {{/each}} -
\ No newline at end of file +
    +
  • + {{#each system.ames as |ame key|}} + {{#if (eq ame.type ../typeame)}} + + + + + {{/if}} + {{/each}} +
  • +
+
\ No newline at end of file diff --git a/templates/actor-partial-paradigmes.html b/templates/actor-partial-paradigmes.html index 2c5dc3b..4a3318f 100644 --- a/templates/actor-partial-paradigmes.html +++ b/templates/actor-partial-paradigmes.html @@ -12,11 +12,11 @@ data-dtype="String" {{#unless @root.editScore}}disabled{{/unless}} /> {{else}} -

{{para.label}}

+

{{para.label}}

{{/if}}
- + {{/each}} \ No newline at end of file diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 1641e64..a397f98 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -8,9 +8,9 @@

{{!-- Sheet Tab Navigation --}} @@ -25,7 +25,7 @@
-
+

KARMA

Karma @@ -47,7 +47,7 @@
-
+

AMES

@@ -62,7 +62,7 @@
-
+

ARCHETYPE

@@ -116,7 +116,7 @@
-
+
@@ -127,7 +127,7 @@
-
+
diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index 8ff8f3e..74ac37a 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -13,6 +13,27 @@
  • Réserve : {{humanFormula}}
  • +
  • Score : + ( + {{#each roll.terms.0.results as |r k|}} + {{r.result}} + {{/each}} + ) + ( + {{#each roll.terms.2.results as |r k|}} + {{r.result}} + {{/each}} + ) + ( + {{#each roll.terms.4.results as |r k|}} + {{r.result}} + {{/each}} + ) +
  • + {{#if usedParadigme}} +
  • Paradigme utilisé : {{usedParadigme}}
  • + {{/if}} +
  • Seuil : {{seuil}}
  • Succés : {{successPC}}
  • Succés de Réalité : {{successGM}}
  • Unités de narration : {{nbUnitesNarration}}
  • @@ -27,6 +48,14 @@
  • Mauvais Présage !
  • {{/if}} + {{#if (count paradigmes)}} +
  • + {{#each paradigmes as |para key|}} + + {{/each}} +
  • + {{/if}} +