refactoring 1
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 0.1.7
|
||||||
|
- sang-froid, effort, et santé
|
||||||
|
|
||||||
## 0.1.6
|
## 0.1.6
|
||||||
- finition de l'onglet totem
|
- finition de l'onglet totem
|
||||||
- ajout du logo de totem dans la sidebar
|
- ajout du logo de totem dans la sidebar
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 508 KiB |
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the base Actor document by defining a custom roll data structure which is ideal for the Simple system.
|
* Extend the base Actor document by defining a custom roll data structure which is ideal for the Simple system.
|
||||||
* @extends {Actor}
|
* @extends {Actor}
|
||||||
@@ -11,12 +12,19 @@ export class VermineActor extends Actor {
|
|||||||
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
|
||||||
// prepareDerivedData().
|
// prepareDerivedData().
|
||||||
super.prepareData();
|
super.prepareData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
prepareBaseData() {
|
prepareBaseData() {
|
||||||
// Data modifications in this step occur before processing embedded
|
// Data modifications in this step occur before processing embedded
|
||||||
// documents or derived data.
|
// documents or derived data.
|
||||||
|
|
||||||
|
if (this.type == 'character'){
|
||||||
|
this._setCharacterEffort();
|
||||||
|
this._setCharacterSelfControl();
|
||||||
|
this._setCharacterThresholds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,4 +116,64 @@ export class VermineActor extends Actor {
|
|||||||
// Process additional NPC data here.
|
// Process additional NPC data here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setCharacterSelfControl() {
|
||||||
|
let self_control = 0;
|
||||||
|
|
||||||
|
for(let i in actor.system.abilities){
|
||||||
|
if (this.system.abilities[i].category == 'mental' || this.system.abilities[i].category == 'social'){
|
||||||
|
self_control += this.system.abilities[i].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// gestion de l'age
|
||||||
|
if (this.system.identity.ageType == 1){
|
||||||
|
self_control--;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.system.attributes.self_control.max = self_control;
|
||||||
|
}
|
||||||
|
|
||||||
|
_setCharacterEffort() {
|
||||||
|
let effort = 0;
|
||||||
|
|
||||||
|
// calcul de l'effort
|
||||||
|
for(let i in this.system.abilities){
|
||||||
|
if (this.system.abilities[i].category == 'physical' || this.system.abilities[i].category == 'manual'){
|
||||||
|
effort += this.system.abilities[i].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// gestion de l'age
|
||||||
|
if (this.system.identity.ageType == 1){
|
||||||
|
effort--;
|
||||||
|
} else if (this.system.identity.ageType == 3){
|
||||||
|
effort -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.system.attributes.effort.max = effort;
|
||||||
|
}
|
||||||
|
|
||||||
|
_setCharacterThresholds() {
|
||||||
|
const health = this.system.abilities.health.value;
|
||||||
|
|
||||||
|
this.system.minorWound.threshold = health;
|
||||||
|
this.system.majorWound.threshold = health + 3;
|
||||||
|
this.system.deadlyWound.threshold = (health + 7 < 11) ? health + 7 : 10;
|
||||||
|
|
||||||
|
let lightWounds = 4;
|
||||||
|
let heavyWounds = 3;
|
||||||
|
let deadlyWounds = 2;
|
||||||
|
|
||||||
|
if (this.system.identity.ageType == 3){
|
||||||
|
lightWounds--;
|
||||||
|
heavyWounds--;
|
||||||
|
deadlyWounds--;
|
||||||
|
} else if (this.system.identity.ageType == 1){
|
||||||
|
deadlyWounds--;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.system.minorWound.max = lightWounds;
|
||||||
|
this.system.majorWound.max = heavyWounds;
|
||||||
|
this.system.deadlyWound.max = deadlyWounds;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@ 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
|
||||||
@@ -72,15 +71,10 @@ 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,87 +45,3 @@ export function updateActorSkillScore(selectedActor, skillLabel, property = "val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* renvoie le score d'Effort (carac physical + manual)
|
|
||||||
* @param {VermineActor}
|
|
||||||
* @return {number||null} Data for rendering or null
|
|
||||||
*/
|
|
||||||
export function setCharacterEffort(actor) {
|
|
||||||
let returnedValue = null;
|
|
||||||
|
|
||||||
for(let i in actor.system.abilities){
|
|
||||||
if (actor.system.abilities[i].category == 'physical' || actor.system.abilities[i].category == 'manual'){
|
|
||||||
returnedValue += actor.system.abilities[i].value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// gestion de l'age
|
|
||||||
if (actor.system.identity.ageType == 1){
|
|
||||||
returnedValue--;
|
|
||||||
} else if (actor.system.identity.ageType == 3){
|
|
||||||
returnedValue -= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
actor.update({ "system.attributes.effort.max": returnedValue });
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user