kristov condensed versions

This commit is contained in:
François-Xavier Guillois
2023-09-06 07:45:56 +02:00
parent 11b8b01fda
commit 615148e4f7
2 changed files with 48 additions and 196 deletions
+26 -45
View File
@@ -118,39 +118,11 @@ export class VermineActor extends Actor {
} }
_setCharacterSelfControl() { _setCharacterSelfControl() {
let self_control = 0; this.system.attributes.self_control.max = 0 + Object.values(this.system.abilities).filter(i => i.category === "mental" || i.category === "social").map((i) => i.value).reduce((acc, curr) => acc + curr, 0) + this.modFromAgeSelfControl;
for(let i in this.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() { _setCharacterEffort() {
let effort = 0; this.system.attributes.effort.max = 0 + Object.values(this.system.abilities).filter(i => i.category === "physical" || i.category === "manual").map((i) => i.value).reduce((acc, curr) => acc + curr, 0) + this.modFromAgeEffort;
// 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() { _setCharacterThresholds() {
@@ -160,22 +132,11 @@ export class VermineActor extends Actor {
this.system.majorWound.threshold = health + 3; this.system.majorWound.threshold = health + 3;
this.system.deadlyWound.threshold = (health + 7 < 11) ? health + 7 : 10; this.system.deadlyWound.threshold = (health + 7 < 11) ? health + 7 : 10;
let lightWounds = 4; this.system.minorWound.max = 4 + this.modFromAgeWounds.l;
let heavyWounds = 3; this.system.majorWound.max = 3 + this.modFromAgeWounds.h;
let deadlyWounds = 2; this.system.deadlyWound.max = 2 + this.modFromAgeWounds.d;
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;
} }
_setAgeType(){ _setAgeType(){
Object.keys(CONFIG.VERMINE.AgeTypes).forEach((type) => { Object.keys(CONFIG.VERMINE.AgeTypes).forEach((type) => {
@@ -185,4 +146,24 @@ export class VermineActor extends Actor {
}); });
} }
get ageType() {
return this.system.identity.ageType;
}
get modFromAgeSelfControl() {
return this.ageType == 1 ? -1 : 0;
}
get modFromAgeEffort() {
if (this.ageType == 1) return -1;
if (this.ageType == 3) return -2;
return 0;
}
get modFromAgeWounds() {
if (this.ageType == 1) return {l : 0, h : 0, d: -1};
if (this.ageType == 3) return {l : -1, h : -1, d: -1};
return {l : 0, h : 0, d: 0};
}
} }
+22 -151
View File
@@ -121,75 +121,18 @@ export class VermineActorSheet extends ActorSheet {
* @return {undefined} * @return {undefined}
*/ */
_prepareCharacterItems(context) { _prepareCharacterItems(context) {
// Initialize containers. context.gear = this.actor.itemTypes['item'];
const gear = []; context.weapons = this.actor.itemTypes['weapon'];
const traits = []; context.defenses = this.actor.itemTypes['defense'];
const defenses = []; context.traits = this.actor.itemTypes['trait'];
const specialties = []; context.specialties = this.actor.itemTypes['specialty'];
const abilities = []; context.abilities = this.actor.itemTypes['ability'];
const weapons = []; context.evolutions = this.actor.itemTypes['evolution'];
const evolutions = []; context.traumas = this.actor.itemTypes['trauma'];
const traumas = []; context.backgrounds = this.actor.itemTypes['background'];
const backgrounds = []; context.rumors = this.actor.itemTypes['rumor'];
const rumors = [];
// Iterate through items, allocating to containers
for (let i of context.items) {
i.img = i.img || DEFAULT_TOKEN;
// Append to gear.
if (i.type === 'item') {
gear.push(i);
}
else if (i.type === 'trait') {
traits.push(i);
}
else if (i.type === 'defense') {
defenses.push(i);
}
else if (i.type === 'weapon') {
weapons.push(i);
}
else if (i.type === 'specialty') {
specialties.push(i);
}
else if (i.type === 'ability') {
abilities.push(i);
}
else if (i.type === 'evolution') {
evolutions.push(i);
}
else if (i.type === 'trauma') {
traumas.push(i);
}
else if (i.type === 'background') {
backgrounds.push(i);
}
else if (i.type === 'rumor') {
rumors.push(i);
}
/* // Append to cephalie.
else if (i.type === 'spell') {
if (i.system.spellLevel != undefined) {
cephalie[i.system.spellLevel].push(i);
}
}*/
} }
// Assign and return
context.gear = gear;
context.weapons = weapons;
context.defenses = defenses;
context.traits = traits;
context.specialties = specialties;
context.abilities = abilities;
context.evolutions = evolutions;
context.traumas = traumas;
context.backgrounds = backgrounds;
context.rumors = rumors;
// console.log("context", context);
}
/** /**
* Organize and classify Items for Npc sheets. * Organize and classify Items for Npc sheets.
* *
@@ -198,27 +141,8 @@ export class VermineActorSheet extends ActorSheet {
* @return {undefined} * @return {undefined}
*/ */
_prepareNpcItems(context) { _prepareNpcItems(context) {
// Initialize containers. context.gear = this.actor.itemTypes['item'];
const gear = []; context.traits = this.actor.itemTypes['trait'];
const traits = [];
// Iterate through items, allocating to containers
for (let i of context.items) {
i.img = i.img || DEFAULT_TOKEN;
// Append to gear.
if (i.type === 'item') {
gear.push(i);
}
else if (i.type === 'trait') {
traits.push(i);
}
}
// Assign and return
context.gear = gear;
} }
@@ -231,49 +155,14 @@ export class VermineActorSheet extends ActorSheet {
* @return {undefined} * @return {undefined}
*/ */
_prepareGroupItems(context) { _prepareGroupItems(context) {
// Initialize containers. context.gear = this.actor.itemTypes['item'];
const gear = []; context.weapons = this.actor.itemTypes['weapon'];
const defenses = []; context.defenses = this.actor.itemTypes['defense'];
const abilities = []; context.vehicles = this.actor.itemTypes['vehicle'];
const totem_abilities = [];
const weapons = [];
const vehicles = [];
// Iterate through items, allocating to containers context.totem_abilities = this.actor.itemTypes['ability'].filter(i=>i.type !== 'totem');
for (let i of context.items) { context.abilities = this.actor.itemTypes['ability'].filter(i=>i.type === 'totem');
i.img = i.img || DEFAULT_TOKEN;
// Append to gear.
if (i.type === 'item') {
gear.push(i);
}
else if (i.type === 'defense') {
defenses.push(i);
}
else if (i.type === 'weapon') {
weapons.push(i);
}
else if (i.type === 'ability') {
if (i.system.type == 'totem'){
totem_abilities.push(i);
} else {
abilities.push(i);
}
}
else if (i.type === 'vehicle') {
vehicles.push(i);
}
}
// Assign and return
context.gear = gear;
context.weapons = weapons;
context.defenses = defenses;
context.abilities = abilities;
context.totem_abilities = totem_abilities;
context.vehicles = vehicles;
} }
/** /**
@@ -284,29 +173,11 @@ export class VermineActorSheet extends ActorSheet {
* @return {undefined} * @return {undefined}
*/ */
_prepareCreatureItems(context) { _prepareCreatureItems(context) {
// Initialize containers. context.gear = this.actor.itemTypes['item'];
const gear = []; context.traits = this.actor.itemTypes['trait'];
const traits = [];
// Iterate through items, allocating to containers
for (let i of context.items) {
i.img = i.img || DEFAULT_TOKEN;
// Append to gear.
if (i.type === 'item') {
gear.push(i);
}
else if (i.type === 'trait') {
traits.push(i);
}
}
// Assign and return
context.gear = gear;
} }
async _onItemCreate(event) { async _onItemCreate(event) {
event.preventDefault(); event.preventDefault();
const header = event.currentTarget; const header = event.currentTarget;