Gestion des paradigmes

This commit is contained in:
sladecraven 2022-10-20 23:59:31 +02:00
parent b0c59c6104
commit b6dac470e9
9 changed files with 206 additions and 119 deletions

View File

@ -143,22 +143,11 @@ export class Imperium5ActorSheet extends ActorSheet {
this.actor.incDecQuantity( li.data("item-id"), +1 ); 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") const ameKey = $(event.currentTarget).data("ame-key")
this.actor.rollAme(ameKey) 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) => { html.find('.lock-unlock-sheet').click((event) => {
this.options.editScore = !this.options.editScore; this.options.editScore = !this.options.editScore;

View File

@ -111,6 +111,17 @@ export class Imperium5Actor extends Actor {
let item = duplicate(this.items.filter( it => it.type == "contact") || [] ) let item = duplicate(this.items.filter( it => it.type == "contact") || [] )
return item 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 ) { incDecKarma( value ) {
@ -156,10 +167,6 @@ export class Imperium5Actor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getInitiativeScore(combatId, combatantId) { getInitiativeScore(combatId, combatantId) {
if (this.type == 'character') {
this.rollMR(true, combatId, combatantId)
}
console.log("Init required !!!!")
return -1; return -1;
} }
@ -214,6 +221,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 /* ROLL SECTION
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -250,6 +264,8 @@ export class Imperium5Actor extends Actor {
rollData.actorId = this.id rollData.actorId = this.id
rollData.img = this.img rollData.img = this.img
rollData.capacites = this.getUnusedCapacites() rollData.capacites = this.getUnusedCapacites()
rollData.paradigmes = this.getUnusedParadigmes()
rollData.selectedParadigme = "none"
rollData.karma = this.system.karma.value rollData.karma = this.system.karma.value
return rollData return rollData

View File

@ -91,9 +91,13 @@ export class Imperium5Utility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async chatListeners(html) { static async chatListeners(html) {
html.on("click", '.view-item-from-chat', event => { html.on("click", '.button-apply-paradigme', event => {
game.system.pegasus.creator.openItemView(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; 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) { static createDirectOptionList(min, max) {
@ -279,6 +289,16 @@ export class Imperium5Utility {
return Math.max(val, 0) 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) { static async rollImperium5(rollData) {
@ -308,16 +328,24 @@ export class Imperium5Utility {
} }
// Calcul réussites // Calcul réussites
rollData.successPC = myRoll.terms[0].results.filter(res => res.result <= 2).length this.computeReussites(rollData)
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)
let msg = await this.createChatWithRollMode(rollData.alias, { let msg = await this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData) 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, useArchetype: false,
useAide: false, useAide: false,
useKarma: false, useKarma: false,
usedCapacite: "none" usedCapacite: "none",
seuil: 2
} }
Imperium5Utility.updateWithTarget(rollData) Imperium5Utility.updateWithTarget(rollData)
return 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) { static updateWithTarget(rollData) {
let objectDefender let objectDefender

View File

@ -60,7 +60,7 @@
font-size: 1.0rem; font-size: 1.0rem;
} /* For title, sidebar character and scene */ } /* For title, sidebar character and scene */
.sheet nav.sheet-tabs { .sheet nav.sheet-tabs {
font-size: 0.8rem; font-size: 1.2rem;
} /* For nav and title */ } /* 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 { .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; font-size: 0.8rem;
@ -78,7 +78,7 @@
font-weight: bold; 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; text-shadow: 1px 0px 0px #ff6600;
} }
@ -335,20 +335,21 @@ table {border: 1px solid #7a7971;}
} }
.fvtt-imperium5 .tabs { .fvtt-imperium5 .tabs {
height: 40px; height: 24px;
border-top: 1px solid #AAA; border-top: 1px solid #AAA;
border-bottom: 1px solid #AAA; border-bottom: 1px solid #AAA;
color: #000000; color: #000000;
} }
.fvtt-imperium5 .tabs .item { .fvtt-imperium5 .tabs .item {
line-height: 40px; line-height: 24px;
font-weight: bold; font-weight: bold;
} }
.fvtt-imperium5 .tabs .item.active { .fvtt-imperium5 .tabs .item.active {
text-decoration: underline; /*text-decoration: underline;*/
text-shadow: none; background: linear-gradient(to bottom, #B8A799F0 5%, #9c6d47f0 100%);
/*text-shadow: none;*/
} }
.fvtt-imperium5 .items-list { .fvtt-imperium5 .items-list {
@ -445,29 +446,40 @@ section.sheet-body{padding: 0.25rem 0.5rem;}
} }
.sheet nav.sheet-tabs { .sheet nav.sheet-tabs {
font-size: 0.70rem; font-size: 1.0rem;
font-weight: bold; font-weight: bold;
height: 3rem; height: 2.5rem;
flex: 0 0 3rem; flex: 0 0 3rem;
margin: 0; margin: 0;
padding: 0 0 0 0.25rem; padding: 0 0 0 0.25rem;
text-align: center; text-align: center;
text-transform: uppercase; text-transform: uppercase;
line-height: 1.5rem; line-height: 1.5rem;
border-radius: 8px;
border-top: 0 none; border-top: 0 none;
border-bottom: 0 none; border-bottom: 0 none;
border-right: 0 none; border-right: 0 none;
background-color:#B8A799F0; color: #403f3e;
color:beige;
} }
/* background: rgb(245,245,240) url("../images/ui/fond4.webp") repeat left top;*/
nav.sheet-tabs .item { nav.sheet-tabs .item {
position: relative; position: relative;
padding: 0 0.25rem; 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 { nav.sheet-tabs .item:after {
content: ""; content: "";
position: absolute; position: absolute;
@ -1150,47 +1162,46 @@ ul, li {
opacity: 1; opacity: 1;
} }
.river-button { .common-button {
box-shadow: inset 0px 1px 0px 0px #a6827e; box-shadow: inset 0px 1px 0px 0px #a6827e;
background: linear-gradient(to bottom, #21374afc 5%, #152833ab 100%); background: linear-gradient(to bottom, #B8A799F0 5%, #80624af0 100%);
background-color: #7d5d3b00; background-color: #B8A799F0; /*#7d5d3b00;*/
border-radius: 3px; border-radius: 4px;
opacity: 60%;
border: 2px ridge #846109; border: 2px ridge #846109;
display: inline-block; display: inline-block;
cursor: pointer; cursor: pointer;
color: #ffffff; color: #ffffff;
font-size: 0.8rem;
padding: 2px 4px 0px 4px;
text-decoration: none; text-decoration: none;
text-shadow: 0px 1px 0px #4d3534; text-shadow: 0px 1px 0px #4d3534;
position: relative; 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 { .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; font-size: 0.8rem;
padding: 4px 12px 0px 12px; padding: 2px 2px 0px 2px;
text-decoration: none;
text-shadow: 0px 1px 0px #4d3534;
position: relative;
margin:2px; margin:2px;
} }
.chat-card-button:hover {
background: linear-gradient(to bottom, #800000 5%, #3e0101 100%); .li-button-paradigme {
background-color: red; display: flex;
} flex-direction: row;
.chat-card-button:active { flex-wrap: wrap;
position:relative;
top:1px;
} }
.plus-minus-button { .plus-minus-button {
@ -1209,9 +1220,7 @@ ul, li {
margin:0px; margin:0px;
} }
.river-button:hover, .plus-minus-button:hover {
.plus-minus-button:hover,
.chat-card-button:hover {
background: linear-gradient(to bottom, #800000 5%, #3e0101 100%); background: linear-gradient(to bottom, #800000 5%, #3e0101 100%);
background-color: red; background-color: red;
} }
@ -1295,7 +1304,7 @@ ul, li {
/* =================== 1. ACTOR SHEET FONT STYLES =========== *//* /* =================== 1. ACTOR SHEET FONT STYLES =========== *//*
*/ */
.sheet-box { .sheet-box {
border-radius: 5%; border-radius: 12px;
border-width: 1px; border-width: 1px;
padding: 0.4rem; padding: 0.4rem;
margin: 0.2rem; margin: 0.2rem;
@ -1451,3 +1460,6 @@ ul, li {
.color-text-ame { .color-text-ame {
color: #806B64; color: #806B64;
} }
.ame-block {
margin-bottom: 24px;
}

View File

@ -1,9 +1,13 @@
{ {
"id": "fvtt-imperium5", "id": "fvtt-imperium5",
"title": "Imperium5 RPG", "title": "Imperium5 RPG",
"authors": [ {"name":"Uberwald"} ], "authors": [
"version": "10.0.3", {
"compatibleCoreVersion": "9", "name": "Uberwald",
"flags": {}
}
],
"version": "10.0.4",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",
"verified": "10", "verified": "10",
@ -15,12 +19,7 @@
], ],
"gridDistance": 5, "gridDistance": 5,
"gridUnits": "m", "gridUnits": "m",
"languages": [
],
"library": false,
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifestPlusVersion": "1.0.0",
"media": [],
"packs": [ "packs": [
{ {
"type": "Item", "type": "Item",
@ -65,8 +64,7 @@
"styles": [ "styles": [
"styles/simple.css" "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", "url": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5",
"manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/raw/branch/master/system.json", "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" "download": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/archive/fvtt-imperium5-v10.0.3.zip"

View File

@ -1,8 +1,10 @@
<span class="flexrow"> <div class="ame-block">
<span class="flexrow">
<h4 class="ame-margin ame-subtitle">{{typedata.label}}</h4> <h4 class="ame-margin ame-subtitle">{{typedata.label}}</h4>
<div class="item-filler">&nbsp;</div> <div class="item-filler">&nbsp;</div>
<select class="input-numeric-short padd-right status-small-label color-class-common" type="text" name="system.amestype.{{typeame}}.malus" value="{{typedata.malus}}" data-dtype="Number"> <select class="input-numeric-short padd-right status-small-label color-class-common" type="text"
name="system.amestype.{{typeame}}.malus" value="{{typedata.malus}}" data-dtype="Number">
{{#select typedata.malus}} {{#select typedata.malus}}
<option value="0">0</option> <option value="0">0</option>
<option value="-1">-1</option> <option value="-1">-1</option>
@ -17,19 +19,20 @@
<input type="text" class="input-numeric-short padd-right status-small-label color-class-common cohesion-input" <input type="text" class="input-numeric-short padd-right status-small-label color-class-common cohesion-input"
name="system.amestype.{{typeame}}.cohesionmax" value="{{typedata.cohesionmax}}" data-dtype="Number" {{#unless name="system.amestype.{{typeame}}.cohesionmax" value="{{typedata.cohesionmax}}" data-dtype="Number" {{#unless
@root.editScore}}disabled{{/unless}}> @root.editScore}}disabled{{/unless}}>
</span> </span>
<ul class="ame-margin"> <ul class="ame-margin">
<li class="ame-padding item stat flexrow item-ame-roll" data-ame-key="{{key}}">
{{#each system.ames as |ame key|}} {{#each system.ames as |ame key|}}
{{#if (eq ame.type ../typeame)}} {{#if (eq ame.type ../typeame)}}
<li class="ame-padding item stat flexrow item-ame-roll" data-ame-key="{{key}}"> <span class="ame-label ame-margin " name="{{key}}">
<button class="common-button roll-ame-button" data-ame-key="{{key}}">{{ame.label}}</button>
<input type="text" class="input-numeric-short padd-right status-small-label color-class-common" <input type="text" class="input-numeric-short padd-right status-small-label color-class-common"
name="system.ames.{{key}}.value" value="{{ame.value}}" data-dtype="Number" {{#unless name="system.ames.{{key}}.value" value="{{ame.value}}" data-dtype="Number" {{#unless
@root.editScore}}disabled{{/unless}} /> @root.editScore}}disabled{{/unless}} />
<span class="ame-label ame-margin" name="{{key}}">
<a class="roll-ame" data-ame-key="{{key}}">{{ame.label}}</a>
</span> </span>
</li>
{{/if}} {{/if}}
{{/each}} {{/each}}
</ul> </li>
</ul>
</div>

View File

@ -12,11 +12,11 @@
data-dtype="String" {{#unless @root.editScore}}disabled{{/unless}} /> data-dtype="String" {{#unless @root.editScore}}disabled{{/unless}} />
</h4> </h4>
{{else}} {{else}}
<h4 class="ame-margin"><a class="roll-ame ame-margin" data-stat-key="{{key}}">{{para.label}}</a></h4> <h4 class="ame-margin">{{para.label}}</h4>
{{/if}} {{/if}}
</span> </span>
<input type="checkbox"> <input type="checkbox" name="system.paradigmes.{{key}}.used" {{checked para.used}}>
</li> </li>
{{/each}} {{/each}}

View File

@ -8,9 +8,9 @@
<h1 class="charname margin-right"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1> <h1 class="charname margin-right"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
{{!-- Sheet Tab Navigation --}} {{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary"> <nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="principal">Principal</a> <a class="item tab-title" data-tab="principal">Principal</a>
<a class="item" data-tab="ressources">Ressources</a> <a class="item tab-title" data-tab="ressources">Ressources</a>
<a class="item" data-tab="biodata">Bio</a> <a class="item tab-title" data-tab="biodata">Bio</a>
</nav> </nav>
</div> </div>
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" /> <img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
@ -25,7 +25,7 @@
<div class="tab principal" data-group="primary" data-tab="principal"> <div class="tab principal" data-group="primary" data-tab="principal">
<div> <div>
<div class="sheet-box color-bg-ame color-text-ame"> <div class="sheet-box color-bg-ame ">
<div class=flexrow> <div class=flexrow>
<h4 class="ame-margin title-font">KARMA</h4> <h4 class="ame-margin title-font">KARMA</h4>
<span class="item-name-label flexrow">Karma <span class="item-name-label flexrow">Karma
@ -47,7 +47,7 @@
<div class="flexrow"> <div class="flexrow">
<div class="flexrow"> <div class="flexrow">
<div class="sheet-box color-bg-ame color-text-ame"> <div class="sheet-box color-bg-ame ">
<span class="flexrow"> <span class="flexrow">
<img class="ame-icon" src="systems/fvtt-imperium5/images/icons/ame_transparent.webp"> <img class="ame-icon" src="systems/fvtt-imperium5/images/icons/ame_transparent.webp">
<h4 class="ame-margin title-font">AMES</h4> <h4 class="ame-margin title-font">AMES</h4>
@ -62,7 +62,7 @@
</div> </div>
<div class="flexrow"> <div class="flexrow">
<div class="sheet-box color-bg-archetype"> <div class="sheet-box color-bg-archetype ">
<span class="flexrow"> <span class="flexrow">
<img class="ame-icon" src="systems/fvtt-imperium5/images/icons/archetype_transparent.webp"> <img class="ame-icon" src="systems/fvtt-imperium5/images/icons/archetype_transparent.webp">
<h4 class="ame-margin title-font">ARCHETYPE</h4> <h4 class="ame-margin title-font">ARCHETYPE</h4>
@ -116,7 +116,7 @@
<div class="flexrow"> <div class="flexrow">
<div class="sheet-box color-bg-paradigme"> <div class="sheet-box color-bg-paradigme ">
<span class="flexrow"> <span class="flexrow">
<img class="ame-icon" src="systems/fvtt-imperium5/images/icons/paradigme_transparent.webp"> <img class="ame-icon" src="systems/fvtt-imperium5/images/icons/paradigme_transparent.webp">
@ -127,7 +127,7 @@
</ul> </ul>
</div> </div>
<div class="sheet-box color-bg-archetype"> <div class="sheet-box color-bg-archetype ">
<span class="flexrow"> <span class="flexrow">
<img class="ame-icon" src="systems/fvtt-imperium5/images/icons/nature_transparent.webp"> <img class="ame-icon" src="systems/fvtt-imperium5/images/icons/nature_transparent.webp">

View File

@ -13,6 +13,27 @@
<div> <div>
<ul> <ul>
<li>Réserve : {{humanFormula}}</li> <li>Réserve : {{humanFormula}}</li>
<li>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}}
)
</li>
{{#if usedParadigme}}
<li>Paradigme utilisé : {{usedParadigme}}</li>
{{/if}}
<li>Seuil : {{seuil}}</li>
<li>Succés : {{successPC}}</li> <li>Succés : {{successPC}}</li>
<li>Succés de Réalité : {{successGM}}</li> <li>Succés de Réalité : {{successGM}}</li>
<li>Unités de narration : {{nbUnitesNarration}}</li> <li>Unités de narration : {{nbUnitesNarration}}</li>
@ -27,6 +48,14 @@
<li>Mauvais Présage !</li> <li>Mauvais Présage !</li>
{{/if}} {{/if}}
{{#if (count paradigmes)}}
<li class="li-button-paradigme">
{{#each paradigmes as |para key|}}
<button class="common-button chat-card-button button-apply-paradigme" data-para-key="{{para.key}}">Utiliser {{para.label}} ({{para.value}})</button>
{{/each}}
</li>
{{/if}}
</ul> </ul>
</div> </div>