Ajout des impacts

This commit is contained in:
LeRatierBretonnien 2023-05-30 22:22:52 +02:00
parent dbb22bbeb7
commit 0392263666
15 changed files with 309 additions and 87 deletions

View File

@ -1,6 +1,6 @@
{
"TYPES": {
"Actor":{
"Actor": {
"Personnage": "PC"
},
"Item": {
@ -54,12 +54,12 @@
"ecrymology": "Ecrymology",
"traumatology": "Traumatology",
"traversology": "Traversology",
"urbatechnology": "Urbatechnology",
"urbatechnology": "Urbatechnology",
"quibbling": "Quibbling",
"creativity": "Creativity",
"loquacity": "Loquacity",
"guile": "Guile",
"performance" :"Performance",
"performance": "Performance",
"skill": "Skill",
"troublesome": "Troublesome",
"occasional": "Occasional",
@ -84,8 +84,16 @@
"confrontation": "Confrontation",
"rollnormal": "Normal (4d6)",
"rollspleen": "With Spleen (5d6, worst 4 are kept)",
"rollideal": "With Ideal (5d6, best 4 are kept)"
"rollideal": "With Ideal (5d6, best 4 are kept)",
"superficial": "Superficial",
"light": "Light",
"serious": "Serious",
"major": "Major",
"impactType": "Impact type",
"impactLevel": "Impact level",
"impactphysical": "Physical",
"impactmental": "Mental",
"impactsocial": "Social"
}
}
}

View File

@ -84,7 +84,16 @@
"confrontation": "Confrontation",
"rollnormal": "Normal (4d6)",
"rollspleen": "Avec le Spleen (5d6, 4 plus bas conservés)",
"rollideal": "Avec l'Idéal (5d6, 4 plus haut conservés)"
"rollideal": "Avec l'Idéal (5d6, 4 plus haut conservés)",
"superficial": "Superficiel",
"light": "Léger",
"serious": "Grave",
"major": "Majeur",
"impactType": "Type d'Impact",
"impactLevel": "Niveau d'impact",
"impactphysical": "Physique",
"impactmental": "Mental",
"impactsocial": "Social"
}
}
}

View File

@ -39,9 +39,9 @@ export class EcrymeActorSheet extends ActorSheet {
traits: this.actor.getRollTraits(),
ideal: this.actor.getIdeal(),
spleen: this.actor.getSpleen(),
system: duplicate(this.object.system),
impacts: this.object.getImpacts(),
config: duplicate(game.system.ecryme.config),
weapons: duplicate(this.actor.getWeapons()),
weapons: this.actor.getWeapons(),
archetype: duplicate(this.actor.getArchetype()),
equipements: duplicate(this.actor.getEquipements()),
subActors: duplicate(this.actor.getSubActors()),
@ -121,6 +121,13 @@ export class EcrymeActorSheet extends ActorSheet {
this.actor.rollSkillConfront(categKey, skillKey)
});
html.find('.impact-modify').click((event) => {
let impactType = $(event.currentTarget).data("impact-type")
let impactLevel = $(event.currentTarget).data("impact-level")
let modifier = Number($(event.currentTarget).data("impact-modifier"))
this.actor.modifyImpact(impactType, impactLevel, modifier)
});
html.find('.roll-weapon').click((event) => {
const armeId = $(event.currentTarget).data("arme-id")
this.actor.rollArme(armeId)

View File

@ -107,7 +107,8 @@ export class EcrymeActor extends Actor {
}
/* -------------------------------------------- */
getSpecialization(id) {
return this.items.find(it => it.type == "specialization" && it.id == id)
let spec = this.items.find(it => it.type == "specialization" && it.id == id)
return spec
}
/* -------------------------------------------- */
getSpecializations(skillKey) {
@ -126,6 +127,11 @@ export class EcrymeActor extends Actor {
return skills
}
/* -------------------------------------------- */
getImpacts() {
let comp = duplicate(this.items.filter(item => item.type == 'impact') || [])
return comp;
}
/* -------------------------------------------- */
getWeapons() {
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || [])
EcrymeUtility.sortArrayObjectsByName(comp)
@ -214,12 +220,26 @@ export class EcrymeActor extends Actor {
/* -------------------------------------------- */
async equipGear(equipmentId) {
let item = this.items.find(item => item.id == equipmentId);
if (item && item.system) {
if (item?.system) {
let update = { _id: item.id, "system.equipped": !item.system.equipped };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
modifyImpact(impactType, impactLevel, modifier) {
console.log(impactType, impactLevel, modifier)
let current = this.system.impacts[impactType][impactLevel]
if (modifier > 0) {
while ( EcrymeUtility.getImpactMax(impactLevel) == current && impactLevel != "major") {
impactLevel = EcrymeUtility.getNextImpactLevel(impactLevel)
current = this.system.impacts[impactType][impactLevel]
}
}
let newImpact = Math.max(this.system.impacts[impactType][impactLevel] + modifier, 0)
this.update({ [`system.impacts.${impactType}.${impactLevel}`]: newImpact})
}
/* -------------------------------------------- */
clearInitiative() {
this.getFlag("world", "initiative", -1)

View File

@ -6,6 +6,7 @@ export const ECRYME_CONFIG = {
spleen: "Spleen",
ideal: "Ideal"
},
traitLevel: [
{value: -3, text: "-3"},
{value: -2, text: "-2"},
@ -14,6 +15,17 @@ export const ECRYME_CONFIG = {
{value: +2, text: "+2"},
{value: +3, text: "+3"}
],
impactTypes: {
physical: "ECRY.ui.physical",
mental: "ECRY.ui.mental",
social: "ECRY.ui.social"
},
impactLevels: {
superficial: "ECRY.ui.superficial",
light: "ECRY.ui.light",
serious: "ECRY.ui.serious",
major: "ECRY.ui.major"
},
difficulty: {
"-1": {difficulty: "ECRY.ui.none", frequency: "ECRY.ui.none", value: "-"},
"8": { difficulty: "ECRY.ui.troublesome", frequency: "ECRY.ui.occasional", value: 8 },

View File

@ -1,6 +1,9 @@
/* -------------------------------------------- */
import { EcrymeCommands } from "../app/ecryme-commands.js";
/* -------------------------------------------- */
const __maxImpacts = {superficial: 4, light: 3, serious: 2, major: 1}
const __nextImpacts = {superficial: "light", light: "serious", serious: "major", major: "major"}
/* -------------------------------------------- */
export class EcrymeUtility {
@ -150,7 +153,8 @@ export class EcrymeUtility {
'systems/fvtt-ecryme/templates/items/partial-item-nav.hbs',
'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/dialogs/partial-common-roll-dialog.hbs',
'systems/fvtt-ecryme/templates/actors/partial-impacts.hbs'
]
return loadTemplates(templatePaths);
}
@ -264,7 +268,13 @@ export class EcrymeUtility {
return chatData;
}
/* -------------------------------------------- */
static getImpactMax(impactLevel) {
return __maxImpacts[impactLevel]
}
static getNextImpactLevel(impactLevel) {
return __nextImpacts[impactLevel]
}
/* -------------------------------------------- */
static async showDiceSoNice(roll, rollMode) {
if (game.modules.get("dice-so-nice")?.active) {
@ -304,7 +314,7 @@ export class EcrymeUtility {
}
/* -------------------------------------------- */
static computeRollFormula(rollData, isConfrontation = false) {
static computeRollFormula(rollData, actor, isConfrontation = false) {
// Build the dice formula
let diceFormula = (isConfrontation) ? "4d6" : "2d6"
if (rollData.useIdeal) {
@ -358,7 +368,7 @@ export class EcrymeUtility {
}
rollData.difficulty = Number(rollData.difficulty)
let diceFormula = this.computeRollFormula(rollData)
let diceFormula = this.computeRollFormula(rollData, actor)
// Performs roll
let myRoll = new Roll(diceFormula).roll({ async: false })
@ -369,7 +379,7 @@ export class EcrymeUtility {
this.computeResults(rollData)
console.log("ERRRRR", rollData)
console.log("rollData", rollData)
let msg = await this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-generic-result.hbs`, rollData)
})

View File

@ -69,7 +69,7 @@ export class EcrymeConfrontDialog extends Dialog {
let dataJSON = event.dataTransfer.getData('text/plain')
let data = JSON.parse(dataJSON)
let idx = Number(data.diceIndex)
console.log("DATA", data, event, event.srcElement.className)
//console.log("DATA", data, event, event.srcElement.className)
if ( event.srcElement.className.includes("execution")) {
this.rollData.availableDices[idx].location = "execution"
}

View File

@ -1201,7 +1201,17 @@ ul, li {
color: rgba(19, 18, 18, 0.95);
}
.impact-box {
border-width: 2px;
border-color: #000000;
border-radius: 6px;
border: 2px ridge #443307;
margin: 2px;
}
.items-title-text {
text-align: center;
font-family: MailartRubberstamp;
margin-left: 4px;
}
.lock-icon {

View File

@ -1181,7 +1181,16 @@ ul, li {
color: rgba(19, 18, 18, 0.95);
}
.impact-box {
border-width: 2px;
border-color: #000000;
border-radius: 6px;
border: 2px ridge #443307;
}
.items-title-text {
text-align: center;
font-family: MailartRubberstamp;
margin-left: 4px;
}
.lock-icon {

View File

@ -43,7 +43,7 @@
],
"title": "Ecryme, le Jeu de Rôles",
"url": "https://www.uberwald.me/gitea/uberwald/fvtt-ecryme",
"version": "10.0.4",
"version": "11.0.1",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-ecryme/archive/fvtt-ecryme-v10.0.0.zip",
"background": "systems/fvtt-ecryme/images/assets/ecryme_extract_panel_01.webp"
}

View File

@ -115,6 +115,26 @@
}
}
}
},
"impacts": {
"physical": {
"superficial": 0,
"light": 0,
"serious": 0,
"major": 0
},
"mental": {
"superficial": 0,
"light": 0,
"serious": 0,
"major": 0
},
"social": {
"superficial": 0,
"light": 0,
"serious": 0,
"major": 0
}
}
},
"npccore": {
@ -130,7 +150,16 @@
}
},
"Item": {
"types": ["equipment", "trait", "weapon", "specialization","annency", "boheme", "contact"],
"types": [
"equipment",
"trait",
"weapon",
"specialization",
"annency",
"boheme",
"contact",
"impact"
],
"templates": {
"common": {
"description": ""
@ -141,46 +170,75 @@
"costunit": ""
}
},
"impact": {
"templates": [
"common"
],
"impacttype": "physical",
"impactlevel": "superficial"
},
"equipment": {
"templates": ["common","equipement"],
"templates": [
"common",
"equipement"
],
"quantity": 1,
"weight": 0
},
"trait": {
"templates": ["common"],
"templates": [
"common"
],
"traitype": "normal",
"level": 1
},
"weapon": {
"templates": ["common", "equipement"],
"templates": [
"common",
"equipement"
],
"effect": 0
},
"specialization": {
"templates": ["common"],
"templates": [
"common"
],
"skillkey": ""
},
"scar": {
"templates": ["common"],
"skillcategory": ["physical", "mental", "social", "cephalie"],
"templates": [
"common"
],
"skillcategory": [
"physical",
"mental",
"social",
"cephalie"
],
"scarLevel": 1
},
"annency": {
"templates": ["common"],
"templates": [
"common"
],
"collective": false,
"multiple": false,
"improvements": ""
},
"boheme": {
"templates": ["common"],
"templates": [
"common"
],
"ideals": "",
"political": ""
},
"contact": {
"templates": ["common"],
"templates": [
"common"
],
"attitude": "neutral",
"organization": "",
"location":""
"location": ""
}
}
}

View File

@ -8,11 +8,11 @@
<div class="profile-img-container">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
</div>
<div class="flexcol">
<h1 class="charname margin-right"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
<div class="flexrow">
<div class="flexrow">
<ul>
<li class="flexrow item" data-item-id="{{spleen.id}}">
<label class="item-name-label-medium">Spleen :</label>
@ -39,10 +39,19 @@
</ul>
</div>
<div class="flexrow">
{{> systems/fvtt-ecryme/templates/actors/partial-impacts.hbs impacts=system.impacts.physical
impacttype="physical"}}
{{> systems/fvtt-ecryme/templates/actors/partial-impacts.hbs impacts=system.impacts.mental
impacttype="mental"}}
{{> systems/fvtt-ecryme/templates/actors/partial-impacts.hbs impacts=system.impacts.social
impacttype="social"}}
</div>
</div>
</div>
</div>
</div>
</header>
@ -60,56 +69,60 @@
{{!-- Skills Tab --}}
<div class="tab competences" data-group="primary" data-tab="competences">
<div class="grid grid-3col">
{{#each skills as |category categkey|}}
<div>
<ul class="stat-list alternate-list item-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<h3><label class="items-title-text">{{localize category.name}}</label></h3>
</span>
</li>
{{#each category.skilllist as |skill skillkey|}}
<li class="item flexrow list-item">
<span class="item-name-label-long">
<a class="roll-skill-confront" data-category-key="{{categkey}}" data-skill-key="{{skillkey}}">
<i class="fa-regular fa-swords"></i>
</a>
<a class="roll-skill" data-category-key="{{categkey}}" data-skill-key="{{skillkey}}">
<ul class="stat-list alternate-list item-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header title-center">
<h3><label class="items-title-text">{{localize category.name}}</label></h3>
</span>
</li>
{{#each category.skilllist as |skill skillkey|}}
<li class="item flexrow list-item">
<span class="item-name-label-long">
<a class="roll-skill-confront" data-category-key="{{categkey}}" data-skill-key="{{skillkey}}">
<i class="fa-regular fa-swords"></i>
</a>
<a class="roll-skill" data-category-key="{{categkey}}" 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.skills.{{categkey}}.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>
<li class="item flexrow list-item">
<ul class="ul-level1">
{{#each skill.spec as |spec idx|}}
<li class="item flexrow list-item" data-item-id="{{spec._id}}" data-item-type="specialization">
<a class="roll-spec" data-spec-id="{{spec._id}}">
<i class="fa-solid fa-dice-d6"></i>
{{localize skill.name}}
</a></span>
<select class="item-field-label-short" type="text" name="system.skills.{{categkey}}.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>
<li class="item flexrow list-item">
<ul class="ul-level1">
{{#each skill.spec as |spec idx|}}
<li class="item flexrow list-item" data-item-id="{{spec._id}}" data-item-type="specialization">
<a class="roll-spec" data-spec-id="{{spec._id}}">
<i class="fa-solid fa-dice-d6"></i>
{{spec.name}}
</a>
<div class="item-controls item-controls-fixed">
<a class="item-control item-edit" data-type="specialization" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-add" data-type="specialization" title="Delete Item"><i class="fas fa-plus"></i></a>
</div>
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
{{spec.name}}
</a>
<div class="item-controls item-controls-fixed">
<a class="item-control item-edit" data-type="specialization" title="Edit Item"><i
class="fas fa-edit"></i></a>
<a class="item-control item-add" data-type="specialization" title="Delete Item"><i
class="fas fa-plus"></i></a>
</div>
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</div>
{{/each}}
{{/each}}
</div>
</div>
@ -150,7 +163,7 @@
<div class="tab equipment" data-group="primary" data-tab="equipment">
<span class="item-name-label-header items-title-bg">
<h3><label class="items-title-text">Equipements (saisie libre)</label></h3>
<h3><label class="items-title-text">Equipements (saisie libre)</label></h3>
</span>
<div class="form-group small-editor">
{{editor equipementlibre target="system.equipementlibre" button=true owner=owner editable=editable}}
@ -266,33 +279,37 @@
</li>
<li class="item flexrow">
<label class="item-name-label-medium">Age</label>
<input type="text" class="" name="system.biodata.age" value="{{system.biodata.age}}" data-dtype="String" />
<input type="text" class="" name="system.biodata.age" value="{{system.biodata.age}}"
data-dtype="String" />
</li>
</ul>
</div>
<div>
<div>
<ul>
<li class="item flexrow">
<label class="item-name-label-medium">Résidence</label>
<input type="text" class="" name="system.biodata.residence" value="{{system.biodata.residence}}" data-dtype="String" />
<input type="text" class="" name="system.biodata.residence" value="{{system.biodata.residence}}"
data-dtype="String" />
</li>
<li class="item flexrow">
<label class="item-name-label-medium">Nationalité</label>
<input type="text" class="" name="system.biodata.nationalite" value="{{system.biodata.nationalite}}" data-dtype="String" />
<input type="text" class="" name="system.biodata.nationalite" value="{{system.biodata.nationalite}}"
data-dtype="String" />
</li>
<li class="item flexrow">
<label class="item-name-label-medium">Enfance</label>
<input type="text" class="" name="system.biodata.enfance" value="{{system.biodata.enfance}}" data-dtype="String" />
<input type="text" class="" name="system.biodata.enfance" value="{{system.biodata.enfance}}"
data-dtype="String" />
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="tab notes" data-group="primary" data-tab="notes">
<div class="tab notes" data-group="primary" data-tab="notes">
<hr>
<span class="item-name-label-header items-title-bg">
<h3><label class="items-title-text">Background</label></h3>
<h3><label class="items-title-text">Background</label></h3>
</span>
<div class="form-group editor">
{{editor description target="system.biodata.description" button=true owner=owner
@ -300,7 +317,7 @@
</div>
<hr>
<span class="item-name-label-header items-title-bg">
<h3><label class="items-title-text">Notes</label></h3>
<h3><label class="items-title-text">Notes</label></h3>
</span>
<div class="form-group editor">
{{editor notes target="system.biodata.notes" button=true owner=owner editable=editable}}
@ -308,7 +325,7 @@
<hr>
</article>
</div>
</div>
</div>
</section>
</form>

View File

@ -0,0 +1,14 @@
<div class="impact-box">
<span class="item-field-label-medium"><label>{{localize (concat "ECRY.ui.impact" impacttype)}}</label></span>
<ul>
{{#each impacts as |value key|}}
<li class="flexrow" data-impact-type="{{../impacttype}}">
<span class="item-field-label-medium"><label>{{localize (concat "ECRY.ui." key)}}</label></span>
<a class="impact-modify" data-impact-modifier="+1" data-impact-type="{{../impacttype}}" data-impact-level="{{key}}"><i class="fas fa-plus-square"></i></a>
<span class="">{{value}}</span>
<a class="impact-modify" data-impact-modifier="-1" data-impact-type="{{../impacttype}}" data-impact-level="{{key}}"><i class="fas fa-minus-square"></i></a>
</li>
{{/each}}
</ul>
</div>

View File

@ -20,8 +20,8 @@
<div class="flexrow">
<span class="roll-dialog-label">{{localize "ECRY.ui.spec"}} : </span>
<select class="" id="roll-specialization" data-type="String" multiple>
{{#each skill.spec as | spec idx|}}
<option value="{{spec._id}}">{{spec.name}}</option>
{{#each skill.spec as |spec idx|}}
<option value="{{spec.id}}">{{spec.name}}</option>
{{/each}}
</select>
</div>

View File

@ -0,0 +1,48 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="item-sheet-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{> systems/fvtt-ecryme/templates/items/partial-item-nav.hbs}}
{{!-- Sheet Body --}}
<section class="sheet-body">
{{> systems/fvtt-ecryme/templates/items/partial-item-description.hbs}}
<div class="tab details" data-group="primary" data-tab="details">
<div class="tab" data-group="primary">
<ul>
<li class="flexrow">
<label class="item-name-label-long">{{localize "ECRY.ui.impactType"}}</label>
<select class="item-field-label-medium" type="text" name="system.impacttype" value="{{system.impacttype}}" data-dtype="String">
{{#select system.impacttype}}
{{#each config.impactTypes as |type key| }}
<option value="{{key}}">{{localize type}}</option>
{{/each}}
{{/select}}
</select>
</li>
<li class="flexrow">
<label class="item-name-label-long">{{localize "ECRY.ui.impactLevel"}}</label>
<select class="item-field-label-medium" type="text" name="system.impactlevel" value="{{system.impactlevel}}" data-dtype="String">
{{#select system.impactlevel}}
{{#each config.impactLevels as |level key| }}
<option value="{{key}}">{{localize level}}</option>
{{/each}}
{{/select}}
</select>
</li>
</ul>
</div>
</div>
</section>
</form>