Fix gears and containers
This commit is contained in:
parent
e608945133
commit
ae2d926324
@ -63,11 +63,12 @@ export class SoSActorSheet extends ActorSheet {
|
||||
if ( container.type == 'container') {
|
||||
container.data.contains = []
|
||||
container.data.containerEnc = 0;
|
||||
for (let gear of data.data.gears) {
|
||||
if ( gear.data.containerid == container.id) {
|
||||
container.data.contains.push( gear );
|
||||
if ( !gear.data.neg && !gear.data.software ) {
|
||||
container.data.containerEnc += (gear.big > 0) ? gear.big : 1;
|
||||
for (let gear of formData.gears) {
|
||||
console.log("GEAR", gear, container)
|
||||
if ( gear.data.data.containerid == container.id) {
|
||||
container.data.contains.push( gear )
|
||||
if ( !gear.data.data.neg && !gear.data.data.software ) {
|
||||
container.data.containerEnc += (gear.data.data.big > 0) ? gear.data.data.big : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async wornObject( itemID) {
|
||||
let item = this.getOwnedItem(itemID);
|
||||
let item = this.items.get(itemID);
|
||||
if (item && item.data.data) {
|
||||
let update = { _id: item.id, "data.worn": !item.data.data.worn };
|
||||
await this.updateEmbeddedDocuments("Item", [update]);
|
||||
@ -178,7 +178,7 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equipObject(itemID) {
|
||||
let item = this.getOwnedItem(itemID);
|
||||
let item = this.items.get(itemID)
|
||||
if (item && item.data.data) {
|
||||
let update = { _id: item.id, "data.equiped": !item.data.data.equiped };
|
||||
await this.updateEmbeddedDocuments("Item", [update]);
|
||||
@ -376,21 +376,22 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addObjectToContainer( itemId, containerId ) {
|
||||
let container = this.data.items.find( item => item._id == containerId && item.type == 'container');
|
||||
let object = this.data.items.find( item => item._id == itemId );
|
||||
let container = this.data.items.find( item => item.id == containerId && item.type == 'container')
|
||||
let object = this.data.items.find( item => item.id == itemId )
|
||||
//console.log("Found", container, object)
|
||||
if ( container ) {
|
||||
if ( object.type == 'container') {
|
||||
ui.notifications.warn("Only 1 level of container... sorry");
|
||||
return
|
||||
}
|
||||
let alreadyInside = this.data.items.filter( item => item.data.containerid && item.data.containerid == containerId);
|
||||
if ( alreadyInside.length >= container.data.container ) {
|
||||
let alreadyInside = this.data.items.filter( item => item.data.data.containerid && item.data.data.containerid == containerId);
|
||||
if ( alreadyInside.length >= container.data.data.container ) {
|
||||
ui.notifications.warn("Container is already full !");
|
||||
} else {
|
||||
await this.updateOwnedItem( { _id: object.id, 'data.containerid':containerId });
|
||||
await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'data.containerid':containerId }]);
|
||||
}
|
||||
} else if ( object && object.data.containerid) { // remove from container
|
||||
await this.updateOwnedItem( { _id: object.id, 'data.containerid':"" });
|
||||
} else if ( object && object.data.data.containerid) { // remove from container
|
||||
await this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'data.containerid':"" }]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ export class SoSUtility {
|
||||
label: "Yes, delete it",
|
||||
callback: () => {
|
||||
console.log("Delete : ", itemId);
|
||||
actorSheet.actor.deleteOwnedItem(itemId);
|
||||
actorSheet.actor.deleteEmbeddedDocuments("Item", [itemId]);
|
||||
li.slideUp(200, () => actorSheet.render(false));
|
||||
}
|
||||
},
|
||||
|
@ -7,7 +7,7 @@
|
||||
"url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/",
|
||||
"license": "LICENSE.txt",
|
||||
"flags": {},
|
||||
"version": "2.0.3",
|
||||
"version": "2.0.4",
|
||||
"minimumCoreVersion": "0.8.0",
|
||||
"compatibleCoreVersion": "9",
|
||||
"scripts": [],
|
||||
|
@ -270,7 +270,7 @@
|
||||
</div>
|
||||
</li>
|
||||
<ul class="item-list alternate-list list-item-margin1">
|
||||
{{#each data.data.contains as |subgear key|}}
|
||||
{{#each data.contains as |subgear key|}}
|
||||
<li class="item flexrow list-item" data-item-id="{{subgear.id}}">
|
||||
<img class="sheet-skill-img" src="{{subgear.img}}"/>
|
||||
<span class="conseq-label">{{subgear.data.name}}</span>
|
||||
|
Loading…
Reference in New Issue
Block a user