Merge pull request #5 from sladecraven/master

Fix auto-compute
This commit is contained in:
ZigmundKreud 2022-01-03 00:36:28 +01:00 committed by GitHub
commit e9eb9e2cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 59 deletions

View File

@ -108,27 +108,32 @@ export class BoLActorSheet extends ActorSheet {
/** @override */ /** @override */
getData(options) { getData(options) {
const data = super.getData(options); const data = super.getData(options);
const actorData = data.data; const actorData = duplicate(data.data);
data.config = game.bol.config; let formData = duplicate(data)
data.data = actorData.data; formData.config = game.bol.config;
data.details = this.actor.details; formData.data = actorData.data;
data.attributes = this.actor.attributes; formData.details = this.actor.details;
data.aptitudes = this.actor.aptitudes; formData.attributes = this.actor.attributes;
data.resources = this.actor.resources; formData.aptitudes = this.actor.aptitudes;
data.equipment = this.actor.equipment; formData.resources = this.actor.resources;
data.weapons = this.actor.weapons; formData.equipment = this.actor.equipment;
data.protections = this.actor.protections; formData.weapons = this.actor.weapons;
data.containers = this.actor.containers; formData.protections = this.actor.protections;
data.treasure = this.actor.treasure; formData.containers = this.actor.containers;
data.vehicles = this.actor.vehicles; formData.treasure = this.actor.treasure;
data.ammos = this.actor.ammos; formData.vehicles = this.actor.vehicles;
data.misc = this.actor.misc; formData.ammos = this.actor.ammos;
data.combat = this.actor.buildCombat(); formData.misc = this.actor.misc;
data.features = this.actor.buildFeatures(); formData.combat = this.actor.buildCombat();
data.isGM = game.user.isGM; formData.features = this.actor.buildFeatures();
formData.isGM = game.user.isGM;
formData.options= this.options,
formData.owner= this.document.isOwner,
formData.editScore= this.options.editScore,
formData.isGM= game.user.isGM
console.log("ACTORDATA", data); console.log("ACTORDATA", formData);
return data; return formData;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -159,7 +164,6 @@ export class BoLActorSheet extends ActorSheet {
return this.actor.createEmbeddedDocuments("Item", [itemData]); return this.actor.createEmbeddedDocuments("Item", [itemData]);
} }
_onToggleEquip(event) { _onToggleEquip(event) {
event.preventDefault(); event.preventDefault();
const li = $(event.currentTarget).closest(".item"); const li = $(event.currentTarget).closest(".item");

View File

@ -6,32 +6,41 @@ export class BoLActor extends Actor {
/** @override */ /** @override */
prepareData() { prepareData() {
super.prepareData();
const actorData = this.data; const actorData = this.data;
// console.log(actorData); // console.log(actorData);
// const data = actorData.data; // const data = actorData.data;
// const flags = actorData.flags; // const flags = actorData.flags;
// Make separate methods for each Actor type (character, npc, etc.) to keep things organized. // Make separate methods for each Actor type (character, npc, etc.) to keep things organized.
if (actorData.type === 'character') { if (actorData.type === 'character') {
this._prepareCharacterData(actorData); //this._prepareCharacterData(actorData);
} }
super.prepareData();
} }
/** /* -------------------------------------------- */
* Prepare Character type specific data //_onUpdate(changed, options, user) {
*/ //
_prepareCharacterData(actorData) { //}
let newVitality = 10 + this.data.data.attributes.vigor.value;
if ( newVitality != this.data.data.resources.hp.max) { /* -------------------------------------------- */
this.data.data.resources.hp.max = newVitality; updateResourcesData( ) {
let newVitality = 10 + this.data.data.attributes.vigor.value + this.data.data.resources.hp.bonus
if ( this.data.data.resources.hp.max != newVitality) {
this.update( {'data.resources.hp.max': newVitality} ); this.update( {'data.resources.hp.max': newVitality} );
} }
let newPower = 10 + this.data.data.attributes.mind.value + this.data.data.resources.power.bonus
if ( this.data.data.resources.power.max != newPower) {
this.update( {'data.resources.power.max': newPower} );
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_onUpdate() { prepareDerivedData() {
this.manageHealthState() super.prepareDerivedData()
this.updateResourcesData()
this.manageHealthState();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
get itemData(){ get itemData(){
return Array.from(this.data.items.values()).map(i => i.data); return Array.from(this.data.items.values()).map(i => i.data);

View File

@ -393,31 +393,6 @@ export class BoLUtility {
let formula = nbDice + "d" + res[2] + postForm + ((res[modIndex]) ? res[modIndex] : ""); let formula = nbDice + "d" + res[2] + postForm + ((res[modIndex]) ? res[modIndex] : "");
return formula; return formula;
} }
/* -------------------------------------------- */
static async showDiceSoNice(roll, rollMode) {
if (game.modules.get("dice-so-nice")?.active) {
if (game.dice3d) {
let whisper = null;
let blind = false;
rollMode = rollMode ?? game.settings.get("core", "rollMode");
switch (rollMode) {
case "blindroll": //GM only
blind = true;
case "gmroll": //GM + rolling player
whisper = BoLUtility.getUsers(user => user.isGM);
break;
case "roll": //everybody
whisper = BoLUtility.getUsers(user => user.active);
break;
case "selfroll":
whisper = [game.user.id];
break;
}
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
}
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async confirmDelete(actorSheet, li) { static async confirmDelete(actorSheet, li) {
let itemId = li.data("item-id"); let itemId = li.data("item-id");

View File

@ -7,7 +7,8 @@
"url": "https://github.com/ZigmundKreud/bol", "url": "https://github.com/ZigmundKreud/bol",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"flags": {}, "flags": {},
"version": "0.8.9.1", "version": "0.8.9.2",
"templateVersion": 10,
"minimumCoreVersion": "0.8.6", "minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",
"scripts": [], "scripts": [],

View File

@ -111,12 +111,14 @@
"faith": { "faith": {
"key" : "faith", "key" : "faith",
"label" : "BOL.resources.faith", "label" : "BOL.resources.faith",
"bonus": 0,
"value": 0, "value": 0,
"max": 0 "max": 0
}, },
"power": { "power": {
"key" : "power", "key" : "power",
"label" : "BOL.resources.power", "label" : "BOL.resources.power",
"bonus": 0,
"value": 0, "value": 0,
"max": 0 "max": 0
} }