basis of wound system
This commit is contained in:
+1
-1
@@ -139,7 +139,7 @@
|
|||||||
"reliability": "Fiabilité",
|
"reliability": "Fiabilité",
|
||||||
"reliability_sm": "Fiab.",
|
"reliability_sm": "Fiab.",
|
||||||
"wounds":{
|
"wounds":{
|
||||||
"name":"Blessure",
|
"name":"Blessures",
|
||||||
"threshold": "Seuil",
|
"threshold": "Seuil",
|
||||||
"light":"Légère",
|
"light":"Légère",
|
||||||
"heavy": "Grave",
|
"heavy": "Grave",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {onManageActiveEffect, prepareActiveEffectCategories} from "../system/eff
|
|||||||
import { VermineActorSheet } from "./actor-sheet.mjs";
|
import { VermineActorSheet } from "./actor-sheet.mjs";
|
||||||
import { getRollBox } from "../system/dialogs.mjs";
|
import { getRollBox } from "../system/dialogs.mjs";
|
||||||
import { TotemPicker } from "../system/applications.mjs";
|
import { TotemPicker } from "../system/applications.mjs";
|
||||||
|
import { setCharacterEffort, setCharacterSelfControl, setCharacterThresholds } from "../system/functions.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the basic ActorSheet with some very simple modifications
|
* Extend the basic ActorSheet with some very simple modifications
|
||||||
@@ -71,10 +72,15 @@ export class VermineCharacterSheet extends VermineActorSheet {
|
|||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
_prepareCharacterData(context) {
|
_prepareCharacterData(context) {
|
||||||
|
const actor = game.actors.get(context.data._id);
|
||||||
// Handle ability scores.
|
// Handle ability scores.
|
||||||
for (let [k, v] of Object.entries(context.system.abilities)) {
|
for (let [k, v] of Object.entries(context.system.abilities)) {
|
||||||
v.label = game.i18n.localize(context.system.abilities[k].label) ?? k;
|
v.label = game.i18n.localize(context.system.abilities[k].label) ?? k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCharacterEffort(actor);
|
||||||
|
setCharacterSelfControl(actor);
|
||||||
|
setCharacterThresholds(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,7 +161,7 @@ export class VermineCharacterSheet extends VermineActorSheet {
|
|||||||
let ageType = "2";
|
let ageType = "2";
|
||||||
|
|
||||||
Object.keys(CONFIG.VERMINE.AgeTypes).forEach((type) => {
|
Object.keys(CONFIG.VERMINE.AgeTypes).forEach((type) => {
|
||||||
if(age > parseInt(CONFIG.VERMINE.AgeTypes[type].beginning,10)){
|
if(age >= parseInt(CONFIG.VERMINE.AgeTypes[type].beginning,10)){
|
||||||
ageType = type;
|
ageType = type;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ export const VERMINE = {};
|
|||||||
|
|
||||||
VERMINE.AgeTypes = {
|
VERMINE.AgeTypes = {
|
||||||
1:{ "name":"AGE_TYPES.young", "beginning": 0 },
|
1:{ "name":"AGE_TYPES.young", "beginning": 0 },
|
||||||
2:{ "name":"AGE_TYPES.adult", "beginning": 16 },
|
2:{ "name":"AGE_TYPES.adult", "beginning": 18 },
|
||||||
3:{ "name":"AGE_TYPES.old", "beginning": 45 }
|
3:{ "name":"AGE_TYPES.old", "beginning": 47 }
|
||||||
}
|
}
|
||||||
|
|
||||||
VERMINE.SkillLevels = {
|
VERMINE.SkillLevels = {
|
||||||
|
|||||||
+75
-53
@@ -1,4 +1,5 @@
|
|||||||
import { VERMINE } from './config.mjs'
|
import { VERMINE } from './config.mjs'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renvoie le score d'une compétence d'un actor existant
|
* renvoie le score d'une compétence d'un actor existant
|
||||||
* @param {VermineActor}
|
* @param {VermineActor}
|
||||||
@@ -14,32 +15,6 @@ export function getActorSkillScore(actor, skillLabel, property = "value") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (returnedValue == null){
|
|
||||||
for(let i in actor.system.cskills.data){
|
|
||||||
if (actor.system.cskills.data[i].label == skillLabel){
|
|
||||||
returnedValue = actor.system.cskills.data[i][property];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* renvoie le type d'une compétence
|
|
||||||
* @param {VermineActor}
|
|
||||||
* @return {string||null} Data for rendering or null
|
|
||||||
*/
|
|
||||||
export function getSkillTypeFromLabel(skillLabel) {
|
|
||||||
let returnedValue = null;
|
|
||||||
|
|
||||||
for(let i in VERMINE.skills){
|
|
||||||
for(let j in VERMINE.skills[i].data){
|
|
||||||
if (VERMINE.skills[i].data[j].label == skillLabel){
|
|
||||||
returnedValue = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnedValue;
|
return returnedValue;
|
||||||
}
|
}
|
||||||
@@ -64,46 +39,93 @@ export function updateActorSkillScore(selectedActor, skillLabel, property = "val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updated == false){
|
|
||||||
for (let s in selectedActor.system.cskills.data){
|
|
||||||
if (selectedActor.system.cskills.data[s].label == skillLabel){
|
|
||||||
selectedActor.system.cskills.data[s][property] = updatedValue; // printing the new value
|
|
||||||
const systemSkillKey = `system.cskills.data.${s}.${property}`;
|
|
||||||
selectedActor.update({[systemSkillKey]:updatedValue }); // updating actor's data
|
|
||||||
updated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return updated;
|
return updated;
|
||||||
} catch(e){
|
} catch(e){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* renvoie le score de Sang froid (carac mental + social)
|
||||||
|
* @param {VermineActor}
|
||||||
|
* @return {number||null} Data for rendering or null
|
||||||
|
*/
|
||||||
|
export function setCharacterSelfControl(actor) {
|
||||||
|
let returnedValue = null;
|
||||||
|
|
||||||
|
for(let i in actor.system.abilities){
|
||||||
|
if (actor.system.abilities[i].category == 'mental' || actor.system.abilities[i].category == 'social'){
|
||||||
|
returnedValue += actor.system.abilities[i].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// gestion de l'age
|
||||||
|
if (actor.system.identity.ageType == 1){
|
||||||
|
returnedValue--;
|
||||||
|
}
|
||||||
|
|
||||||
|
actor.update({ "system.attributes.self_control.max": returnedValue });
|
||||||
|
return returnedValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* réinitialise toutes les dépenses d'usure
|
* renvoie le score d'Effort (carac physical + manual)
|
||||||
* @param {VermineActor}
|
* @param {VermineActor}
|
||||||
* @return {boolean} bool
|
* @return {number||null} Data for rendering or null
|
||||||
*/
|
*/
|
||||||
export function resetActorSkillUsure(selectedActor) {
|
export function setCharacterEffort(actor) {
|
||||||
try {
|
let returnedValue = null;
|
||||||
// on recherche les usures des compétences
|
|
||||||
for (let st in selectedActor.system.skills){
|
for(let i in actor.system.abilities){
|
||||||
for (let s in selectedActor.system.skills[st].data){
|
if (actor.system.abilities[i].category == 'physical' || actor.system.abilities[i].category == 'manual'){
|
||||||
const systemSkillKey = `system.skills.${st}.data.${s}.spent`;
|
returnedValue += actor.system.abilities[i].value;
|
||||||
selectedActor.update({[systemSkillKey]:0 }); // updating actor's data
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// on recherche les usures des compétences céphaliques
|
/// gestion de l'age
|
||||||
for (let s in selectedActor.system.cskills.data){
|
if (actor.system.identity.ageType == 1){
|
||||||
const systemSkillKey = `system.cskills.data.${s}.spent`;
|
returnedValue--;
|
||||||
selectedActor.update({[systemSkillKey]:0 }); // updating actor's data
|
} else if (actor.system.identity.ageType == 3){
|
||||||
|
returnedValue -= 2;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} catch(e){
|
actor.update({ "system.attributes.effort.max": returnedValue });
|
||||||
return false;
|
|
||||||
|
return returnedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* définis les scores de seuil
|
||||||
|
* @param {VermineActor}
|
||||||
|
* @return {number||null} Data for rendering or null
|
||||||
|
*/
|
||||||
|
export function setCharacterThresholds(actor) {
|
||||||
|
|
||||||
|
const health = actor.system.abilities.health.value;
|
||||||
|
|
||||||
|
let returnedValue = null;
|
||||||
|
|
||||||
|
actor.update({ "system.minorWound.threshold": health });
|
||||||
|
actor.update({ "system.majorWound.threshold": health + 3});
|
||||||
|
actor.update({ "system.deadlyWound.threshold": (health + 7 < 11) ? health + 7 : 10 });
|
||||||
|
|
||||||
|
let lightWounds = 4;
|
||||||
|
let heavyWounds = 3;
|
||||||
|
let deadlyWounds = 2;
|
||||||
|
|
||||||
|
if (actor.system.identity.ageType == 3){
|
||||||
|
lightWounds--;
|
||||||
|
heavyWounds--;
|
||||||
|
deadlyWounds--;
|
||||||
|
} else if (actor.system.identity.ageType == 1){
|
||||||
|
deadlyWounds--;
|
||||||
|
}
|
||||||
|
|
||||||
|
actor.update({ "system.minorWound.max": lightWounds });
|
||||||
|
actor.update({ "system.majorWound.max": heavyWounds });
|
||||||
|
actor.update({ "system.deadlyWound.max": deadlyWounds });
|
||||||
|
|
||||||
|
// console.log('wounds', actor.system.minorWound, actor.system.majorWound, actor.system.deadlyWound);
|
||||||
|
|
||||||
|
return returnedValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
|
|
||||||
// Actor partials.
|
// Actor partials.
|
||||||
// "systems/vermine2047/templates/actor/parts/actor-features.html",
|
|
||||||
"systems/vermine2047/templates/actor/parts/actor-id.hbs",
|
"systems/vermine2047/templates/actor/parts/actor-id.hbs",
|
||||||
"systems/vermine2047/templates/actor/parts/actor-totem.hbs",
|
"systems/vermine2047/templates/actor/parts/actor-totem.hbs",
|
||||||
"systems/vermine2047/templates/actor/parts/character-features.hbs",
|
"systems/vermine2047/templates/actor/parts/character-features.hbs",
|
||||||
@@ -32,6 +31,37 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produce a range of numbers (positive and/or negative), processing from
|
||||||
|
* `start` up to, but not including, `end`.
|
||||||
|
*
|
||||||
|
* @param {number} start Range start value (inclusive)
|
||||||
|
* @param {number} [end] Range end value (exclusive)
|
||||||
|
* @param {number} [step=1] Value to increment by
|
||||||
|
* @return {number[]} Array of numbers
|
||||||
|
*/
|
||||||
|
function range(start, end, step) {
|
||||||
|
/* jshint eqeqeq:false, maxcomplexity:7 */
|
||||||
|
start = Number(start) || 0;
|
||||||
|
end = end == null ? end : Number(end);
|
||||||
|
step = step == null ? 1 : Number(step);
|
||||||
|
|
||||||
|
if (end == null) {
|
||||||
|
end = start;
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var length = Math.max(Math.ceil((end - start) / (step || 1)), 0);
|
||||||
|
var result = new Array(length);
|
||||||
|
|
||||||
|
for (var i = 0; i < length; i += 1) {
|
||||||
|
result[i] = start;
|
||||||
|
start += step;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
export const registerHandlebarsHelpers = function () {
|
export const registerHandlebarsHelpers = function () {
|
||||||
Handlebars.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
|
Handlebars.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
|
||||||
Handlebars.registerHelper('lower', e => e.toLocaleLowerCase());
|
Handlebars.registerHelper('lower', e => e.toLocaleLowerCase());
|
||||||
@@ -176,4 +206,15 @@ export const registerHandlebarsHelpers = function () {
|
|||||||
if (isNpc) return "npc";
|
if (isNpc) return "npc";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Handlebars.registerHelper('range', function() {
|
||||||
|
var args = Array.prototype.slice.call(arguments),
|
||||||
|
rangeArgs = args.slice(0, -1),
|
||||||
|
options = args[args.length - 1];
|
||||||
|
|
||||||
|
return range.apply(null, rangeArgs)
|
||||||
|
.map(function(num) { return options.fn(num); })
|
||||||
|
.join('');
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
+8
-8
@@ -5,20 +5,20 @@
|
|||||||
"base": {
|
"base": {
|
||||||
"minorWound": {
|
"minorWound": {
|
||||||
"threshold":1,
|
"threshold":1,
|
||||||
"value": 0,
|
"value": 4,
|
||||||
"min": 0,
|
"min": 1,
|
||||||
"max": 4
|
"max": 5
|
||||||
},
|
},
|
||||||
"majorWound": {
|
"majorWound": {
|
||||||
"threshold":4,
|
"threshold":4,
|
||||||
"value": 0,
|
"value": 3,
|
||||||
"min": 0,
|
"min": 1,
|
||||||
"max": 2
|
"max": 4
|
||||||
},
|
},
|
||||||
"deadlyWound": {
|
"deadlyWound": {
|
||||||
"threshold":8,
|
"threshold":8,
|
||||||
"value": 0,
|
"value": 2,
|
||||||
"min": 0,
|
"min": 1,
|
||||||
"max": 2
|
"max": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,33 @@
|
|||||||
<div>
|
<div>
|
||||||
<h4 class="align-center">{{ localize "VERMINE.self_control"}}</h4>
|
<h4 class="align-center">{{ localize "VERMINE.self_control"}}</h4>
|
||||||
<p class="align-center">
|
<p class="align-center">
|
||||||
<input type="number" name="system.attributes.self_control.value" value="{{ system.attributes.self_control.value }}" data-dtype="Number" min="{{ system.attributes.self_control.min }}" max="{{ system.attributes.self_control.max }}" />
|
<input type="number" name="system.attributes.self_control.value" value="{{ system.attributes.self_control.value }}" data-dtype="Number" min="{{ system.attributes.self_control.min }}" max="{{ system.attributes.self_control.max }}" /> / {{ system.attributes.self_control.max }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4 class="align-center">{{ localize "VERMINE.effort"}}</h4>
|
<h4 class="align-center">{{ localize "VERMINE.effort"}}</h4>
|
||||||
<p class="align-center">
|
<p class="align-center">
|
||||||
<input type="number" name="system.attributes.effort.value" value="{{ system.attributes.effort.value }}" data-dtype="Number" min="{{ system.attributes.effort.min }}" max="{{ system.attributes.effort.max }}" />
|
<input type="number" name="system.attributes.effort.value" value="{{ system.attributes.effort.value }}" data-dtype="Number" min="{{ system.attributes.effort.min }}" max="{{ system.attributes.effort.max }}" /> / {{ system.attributes.effort.max }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="item-name effect-name flexrow">{{ localize "VERMINE.wounds.name"}}</h4>
|
<h4 class="item-name effect-name flexrow">{{ localize "VERMINE.wounds.name"}}</h4>
|
||||||
<ul class="unstyled">
|
<ul class="unstyled">
|
||||||
<li>{{ localize 'VERMINE.wounds.light'}}</li>
|
<li class="row mdb">{{ localize 'VERMINE.wounds.light'}} ({{ system.minorWound.threshold }})
|
||||||
<li>{{ localize 'VERMINE.wounds.heavy'}}</li>
|
{{#range system.minorWound.max }}
|
||||||
<li>{{ localize 'VERMINE.wounds.deadly'}}</li>
|
<input type="radio" name="system.minorWound.value" value="{{this}}" {{#if (eq @root.system.minorWound.value this) }}checked="checked"{{/if}} />
|
||||||
|
{{/range}}</li>
|
||||||
|
<li class="row mdb">{{ localize 'VERMINE.wounds.heavy'}} ({{ system.majorWound.threshold }})
|
||||||
|
{{#range system.majorWound.max }}
|
||||||
|
<input type="radio" name="system.majorWound.value" value="{{this}}" {{#if (eq @root.system.majorWound.value this) }}checked{{/if}} />
|
||||||
|
{{/range}}
|
||||||
|
</li>
|
||||||
|
<li class="row mdb">{{ localize 'VERMINE.wounds.deadly'}} ({{ system.deadlyWound.threshold }})
|
||||||
|
{{#range system.deadlyWound.max }}
|
||||||
|
<input type="radio" name="system.deadlyWound.value" value="{{this}}" {{#if (eq @root.system.deadlyWound.value this) }}checked{{/if}} />
|
||||||
|
{{/range}}
|
||||||
|
</li>
|
||||||
|
|
||||||
</l>
|
</l>
|
||||||
<h4 class="item-name effect-name flexrow">{{ localize "UI.effects.name"}}</h4>
|
<h4 class="item-name effect-name flexrow">{{ localize "UI.effects.name"}}</h4>
|
||||||
<ol class="items-list effects-list">
|
<ol class="items-list effects-list">
|
||||||
|
|||||||
Reference in New Issue
Block a user