#7 - Manage container
This commit is contained in:
parent
2353ba5ff9
commit
baf84bee35
@ -31,16 +31,35 @@ export class SoSActorSheet extends ActorSheet {
|
|||||||
data.data.deckSize = this.actor.getDeckSize();
|
data.data.deckSize = this.actor.getDeckSize();
|
||||||
|
|
||||||
data.data.skills = this.actor.data.items.filter( item => item.type == 'skill').sort( (a, b) => {
|
data.data.skills = this.actor.data.items.filter( item => item.type == 'skill').sort( (a, b) => {
|
||||||
if ( a.name > b.name ) return 1;
|
if ( a.name > b.name ) return 1;
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
data.data.skill1 = data.data.skills.slice(0, Math.ceil(data.data.skills.length/2) )
|
data.data.skill1 = data.data.skills.slice(0, Math.ceil(data.data.skills.length/2) )
|
||||||
data.data.skill2 = data.data.skills.slice(Math.ceil(data.data.skills.length/2), data.data.skills.length )
|
data.data.skill2 = data.data.skills.slice(Math.ceil(data.data.skills.length/2), data.data.skills.length )
|
||||||
data.data.consequences = this.actor.data.items.filter( item => item.type == 'consequence').sort( (a, b) => {
|
data.data.consequences = this.actor.data.items.filter( item => item.type == 'consequence').sort( (a, b) => {
|
||||||
if ( a.name > b.name ) return 1;
|
if ( a.name > b.name ) return 1;
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
data.data.gears = this.actor.data.items.filter( item => item.type == 'gear').concat( this.actor.data.items.filter( item => item.type == 'container') );
|
data.data.gears = this.actor.data.items.filter( item => item.type == 'gear').concat( this.actor.data.items.filter( item => item.type == 'container') );
|
||||||
|
|
||||||
|
// Build the gear tree
|
||||||
|
data.data.gearsRoot = data.data.gears.filter(item => item.data.containerid == "");
|
||||||
|
for ( let container of data.data.gearsRoot) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data.data.weapons = this.actor.data.items.filter( item => item.type == 'weapon');
|
data.data.weapons = this.actor.data.items.filter( item => item.type == 'weapon');
|
||||||
data.data.armors = this.actor.data.items.filter( item => item.type == 'armor');
|
data.data.armors = this.actor.data.items.filter( item => item.type == 'armor');
|
||||||
data.data.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items);
|
data.data.totalEncumbrance = SoSUtility.computeEncumbrance(this.actor.data.items);
|
||||||
@ -57,16 +76,11 @@ export class SoSActorSheet extends ActorSheet {
|
|||||||
data.data.weaknessList = this.actor.data.items.filter( item => item.type == 'weakness');
|
data.data.weaknessList = this.actor.data.items.filter( item => item.type == 'weakness');
|
||||||
data.data.geneline = this.actor.data.items.find( item => item.type == 'geneline');
|
data.data.geneline = this.actor.data.items.find( item => item.type == 'geneline');
|
||||||
data.data.editStatSkill = this.options.editStatSkill;
|
data.data.editStatSkill = this.options.editStatSkill;
|
||||||
console.log("stats", data);
|
//console.log("stats", data);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async _onDrop(event) {
|
|
||||||
super._onDrop(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/** @override */
|
/** @override */
|
||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
@ -164,6 +178,14 @@ export class SoSActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async _onDrop(event) {
|
||||||
|
let toSuper = await SoSUtility.processItemDropEvent(this, event);
|
||||||
|
if ( toSuper) {
|
||||||
|
super._onDrop(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/** @override */
|
/** @override */
|
||||||
setPosition(options = {}) {
|
setPosition(options = {}) {
|
||||||
|
@ -372,6 +372,26 @@ export class SoSActor extends Actor {
|
|||||||
this.checkDeath();
|
this.checkDeath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
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 );
|
||||||
|
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 ) {
|
||||||
|
ui.notifications.warn("Container is already full !");
|
||||||
|
} else {
|
||||||
|
await this.updateOwnedItem( { _id: object._id, 'data.containerid':containerId });
|
||||||
|
}
|
||||||
|
} else if ( object && object.data.containerid) { // remove from container
|
||||||
|
await this.updateOwnedItem( { _id: object._id, 'data.containerid':"" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async applyWounds( flipData ) {
|
async applyWounds( flipData ) {
|
||||||
if ( flipData.damageStatus == 'no_damage') {
|
if ( flipData.damageStatus == 'no_damage') {
|
||||||
|
@ -382,4 +382,16 @@ export class SoSUtility extends Entity {
|
|||||||
defender.applyWounds( flipData );
|
defender.applyWounds( flipData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static async processItemDropEvent(actorSheet, event) {
|
||||||
|
let dragData = JSON.parse(event.dataTransfer.getData("text/plain"));
|
||||||
|
let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
|
||||||
|
let objectID = dragData.id || dragData.data._id;
|
||||||
|
//console.log("drag/drop", dragData, actorSheet.actor._id, dropID, objectID);
|
||||||
|
if (dragData.type == 'Item' && dropID) {
|
||||||
|
actorSheet.actor.addObjectToContainer(objectID, dropID );
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -550,6 +550,9 @@ ul, li {
|
|||||||
.alternate-list > .list-item:nth-child(odd) {
|
.alternate-list > .list-item:nth-child(odd) {
|
||||||
background: rgb(160, 130, 100, 0.05);
|
background: rgb(160, 130, 100, 0.05);
|
||||||
}
|
}
|
||||||
|
.list-item-margin1 {
|
||||||
|
margin-left: 1rem;
|
||||||
|
}
|
||||||
.xp-level-up {
|
.xp-level-up {
|
||||||
margin: 0.125rem;
|
margin: 0.125rem;
|
||||||
box-shadow: inset 0px 0px 1px #00000096;
|
box-shadow: inset 0px 0px 1px #00000096;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "foundryvtt-shadows-over-sol",
|
"name": "foundryvtt-shadows-over-sol",
|
||||||
"title": "Shadows over Sol",
|
"title": "Shadows over Sol",
|
||||||
"description": "Shadows over Sol for FoundryVTT",
|
"description": "Shadows over Sol for FoundryVTT",
|
||||||
"version": "0.1.13",
|
"version": "0.1.14",
|
||||||
"manifestPlusVersion": "1.0.0",
|
"manifestPlusVersion": "1.0.0",
|
||||||
"minimumCoreVersion": "0.7.5",
|
"minimumCoreVersion": "0.7.5",
|
||||||
"compatibleCoreVersion": "0.7.9",
|
"compatibleCoreVersion": "0.7.9",
|
||||||
|
@ -259,7 +259,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div><h4>Equipment/Gears</h4></div>
|
<div><h4>Equipment/Gears</h4></div>
|
||||||
<ul class="item-list alternate-list">
|
<ul class="item-list alternate-list">
|
||||||
{{#each data.gears as |gear key|}}
|
{{#each data.gearsRoot as |gear key|}}
|
||||||
<li class="item flexrow list-item" data-item-id="{{gear._id}}">
|
<li class="item flexrow list-item" data-item-id="{{gear._id}}">
|
||||||
<img class="sheet-skill-img" src="{{gear.img}}"/>
|
<img class="sheet-skill-img" src="{{gear.img}}"/>
|
||||||
<span class="conseq-label">{{gear.name}}</span>
|
<span class="conseq-label">{{gear.name}}</span>
|
||||||
@ -269,6 +269,18 @@
|
|||||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<ul class="item-list alternate-list list-item-margin1">
|
||||||
|
{{#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.name}}</span>
|
||||||
|
<div class="item-controls">
|
||||||
|
<a class="item-control item-equip" title="Worn">{{#if armor.data.worn}}<i class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
|
||||||
|
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||||
|
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user