most things now working

This commit is contained in:
TheLastScrub
2021-05-01 23:06:20 -07:00
parent 9794019876
commit 086ec8483e
17 changed files with 150 additions and 156 deletions
+16 -10
View File
@@ -35,10 +35,11 @@ export class DeltaGreenActorSheet extends ActorSheet {
const data = super.getData();
// Prepare items.
if (this.actor.data.type == 'character') {
if (this.actor.data.type == 'agent') {
this._prepareCharacterItems(data);
}
//console.log(data);
//return data.data;
return data;
}
@@ -56,9 +57,6 @@ export class DeltaGreenActorSheet extends ActorSheet {
const armor = [];
const weapons = [];
// total armor rating
let armorRating = 0;
// Iterate through items, allocating to containers
// let totalWeight = 0;
for (let i of sheetData.items) {
@@ -146,14 +144,19 @@ export class DeltaGreenActorSheet extends ActorSheet {
// Update Inventory Item
html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.getOwnedItem(li.data("itemId"));
//const item = this.actor.getOwnedItem(li.data("itemId"));
const item = this.actor.items.get(li.data("itemId"));
item.sheet.render(true);
});
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
this.actor.deleteOwnedItem(li.data("itemId"));
//this.actor.deleteOwnedItem(li.data("itemId"));
let options = {};
this.actor.deleteEmbeddedDocuments("Item", [li.data("itemId")], options);
li.slideUp(200, () => this.render(false));
});
@@ -165,7 +168,7 @@ export class DeltaGreenActorSheet extends ActorSheet {
html.find('.equipped-item').mousedown(this._onEquippedStatusChange.bind(this));
// Drag events for macros.
if (this.actor.owner) {
if (this.actor.isOwner) {
let handler = ev => this._onDragStart(ev);
html.find('li.item').each((i, li) => {
if (li.classList.contains("inventory-header")) return;
@@ -277,6 +280,7 @@ export class DeltaGreenActorSheet extends ActorSheet {
type: type,
data: data
};
// Remove the type from the dataset since it's in the itemData.type prop.
delete itemData.data["type"];
@@ -293,7 +297,8 @@ export class DeltaGreenActorSheet extends ActorSheet {
}
// Finally, create the item!
return this.actor.createOwnedItem(itemData);
//return this.actor.createOwnedItem(itemData);
return this.actor.createEmbeddedDocuments("Item", [itemData]);
}
/**
@@ -395,7 +400,8 @@ export class DeltaGreenActorSheet extends ActorSheet {
const dataset = element.dataset;
try{
const item = this.actor.getOwnedItem(dataset.id);
//const item = this.actor.getOwnedItem(dataset.id);
const item = this.actor.items.get(dataset.id);
var isEquipped = item.data.data.equipped;
isEquipped = !isEquipped;
item.update({data:{equipped: isEquipped}});
+6 -1
View File
@@ -14,9 +14,14 @@ export class DeltaGreenActor extends Actor {
const data = actorData.data;
const flags = actorData.flags;
//console.log('actor.js prepareData');
//console.log(this);
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
if (actorData.type === 'agent') this._prepareAgentData(this);
if (actorData.type === 'agent'){
this._prepareAgentData(this);
}
}
/**
+13 -6
View File
@@ -99,15 +99,22 @@ Hooks.once('init', async function() {
});
Handlebars.registerHelper('getActorSkillProp', function(actorData, skillName, prop) {
if(skillName != "" && prop != ""){
let skills = actorData.skills;
let skill = skills[skillName];
let propVal = skill[prop];
return propVal;
try{
if(skillName != "" && prop != ""){
let skills = actorData.data.skills;
let skill = skills[skillName];
let propVal = skill[prop];
return propVal;
}
else{
return "";
}
}
else{
catch(ex){
console.log(ex);
return "";
}
});
// looks at system setting for what font to use and returns the class that is then used in the handlebars template that
+6 -6
View File
@@ -1,7 +1,7 @@
import {localizeWithFallback} from "../other/utility-functions.js"
export function sendPercentileTestToChat(actor, skill, target){
let roll = new Roll('1D100', actor.data.data).roll();
let roll = new Roll('1D100', actor.data.data).evaluate(false);
let total = roll.total;
let isCritical = false;
let isSuccess = false;
@@ -96,7 +96,7 @@ export function sendPercentileTestToChat(actor, skill, target){
speaker: ChatMessage.getSpeaker({actor: actor}),
content: html,
flavor: label,
type: CHAT_MESSAGE_TYPES.ROLL,
type: 5, //CHAT_MESSAGE_TYPES.ROLL,
roll: roll,
rollMode: game.settings.get("core", "rollMode")
};
@@ -123,7 +123,7 @@ export function skillCheckResultIsCritical(rollResult){
}
export function sendLethalityTestToChat(actor, weaponName, target){
let roll = new Roll('1D100', actor.data.data).roll();
let roll = new Roll('1D100', actor.data.data).evaluate(false);
let isCritical = false;
let skillCheckTotal = roll.total;
@@ -202,7 +202,7 @@ export function sendLethalityTestToChat(actor, weaponName, target){
speaker: ChatMessage.getSpeaker({actor: actor}),
content: html,
flavor: label,
type: CHAT_MESSAGE_TYPES.ROLL,
type: 5, //CHAT_MESSAGE_TYPES.ROLL,
roll: roll,
rollMode: game.settings.get("core", "rollMode")
};
@@ -223,10 +223,10 @@ export function sendDamageRollToChat(actor, label, diceFormula){
label = `Rolling <b>DAMAGE</b> for <b>${label.toUpperCase()}</b>`
}
roll.roll().toMessage({
roll.evaluate(false).toMessage({
speaker: ChatMessage.getSpeaker({ actor: actor }),
flavor: label,
type: CHAT_MESSAGE_TYPES.ROLL,
type: 5, //CHAT_MESSAGE_TYPES.ROLL,
roll: roll,
rollMode: game.settings.get("core", "rollMode")
});