Add consequenes to actor sheet

This commit is contained in:
sladecraven 2021-01-31 17:23:14 +01:00
parent e412f0cb3b
commit 1d2f438235
7 changed files with 64 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{
"SHEET.TabStats": "Stats",
"SHEET.TabSkills": "Skills",
"SHEET.TabFight": "Fight",
"SHEET.TabConsequences": "Consequences",
"SHEET.TabGears": "Gears",
"SHEET.TabDescription": "Description",

View File

@ -32,7 +32,10 @@ export class SoSActorSheet extends ActorSheet {
});
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.consequences = this.actor.data.items.filter( item => item.type == 'consequence').sort( (a, b) => {
if ( a.name > b.name ) return 1;
return -1;
});
data.data.subculture = this.actor.data.items.find( item => item.type == 'subculture');
data.data.geneline = this.actor.data.items.find( item => item.type == 'geneline');
data.data.editStatSkill = this.options.editStatSkill;

View File

@ -34,6 +34,18 @@ export class SoSActor extends Actor {
return actor;
}
data.items = [];
let compendiumName = "foundryvtt-shadows-over-sol.skills";
if ( compendiumName ) {
let skills = await SoSUtility.loadCompendium(compendiumName);
data.items = data.items.concat( skills );
}
compendiumName = "foundryvtt-shadows-over-sol.consequences";
if ( compendiumName ) {
let consequences = await SoSUtility.loadCompendium(compendiumName)
data.items = data.items.concat(consequences);
}
return super.create(data, options);
}

View File

@ -16,12 +16,15 @@ export class SoSCardDeck {
this.data.cardState = [];
this.data.cardEdge = [];
if ( savedDeck.deck && savedDeck.deck.length > 0 ) {}
if ( savedDeck.deck && savedDeck.deck.length > 0 ) {
this.data.deck = duplicate(savedDeck.deck);
if ( savedDeck.discard && savedDeck.discard.length > 0 ) {}
}
if ( savedDeck.discard && savedDeck.discard.length > 0 ) {
this.data.discard = duplicate(savedDeck.discard);
if ( savedDeck.cardEdge && savedDeck.cardEdge.length > 0 ) {}
}
if ( savedDeck.cardEdge && savedDeck.cardEdge.length > 0 ) {
this.data.cardEdge = duplicate(savedDeck.cardEdge);
}
this.data.actor = actor;
if ( this.data.deck.length == 0 && this.data.discard.length == 0) {

View File

@ -19,7 +19,34 @@ export class SoSUtility {
return loadTemplates(templatePaths);
}
/* -------------------------------------------- */
static fillRange (start, end) {
return Array(end - start + 1).fill().map((item, index) => start + index);
}
/* -------------------------------------------- */
static async loadCompendiumNames(compendium) {
const pack = game.packs.get(compendium);
let competences;
await pack.getIndex().then(index => competences = index);
return competences;
}
/* -------------------------------------------- */
static async loadCompendium(compendium, filter = item => true) {
let compendiumItems = await SoSUtility.loadCompendiumNames(compendium);
const pack = game.packs.get(compendium);
let list = [];
for (let compendiumItem of compendiumItems) {
await pack.getEntity(compendiumItem._id).then(it => {
const item = it.data;
if (filter(item)) {
list.push(item);
}
});
};
return list;
}
}

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-shadows-over-sol",
"title": "Shadows over Sol",
"description": "Shadows over Sol for FoundryVTT",
"version": "0.0.10",
"version": "0.0.11",
"manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9",

View File

@ -15,7 +15,7 @@
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="stats">{{localize 'SHEET.TabStats'}}</a>
<a class="item" data-tab="skills">{{localize 'SHEET.TabSkills'}}</a>
<a class="item" data-tab="fight">{{localize 'SHEET.TabFight'}}</a>
<a class="item" data-tab="consequences">{{localize 'SHEET.TabConsequences'}}</a>
<a class="item" data-tab="gears">{{localize 'SHEET.TabGears'}}</a>
<a class="item" data-tab="description">{{localize 'SHEET.TabDescription'}}</a>
</nav>
@ -157,9 +157,19 @@
</div>
{{!-- Fight Tab --}}
<div class="tab fight" data-group="primary" data-tab="fight">
{{!-- Consequences Tab --}}
<div class="tab consequences" data-group="primary" data-tab="consequences">
<ul class="item-list alternate-list">
{{#each data.consequences as |conseq key|}}
<li class="item flexrow list-item" data-item-id="{{conseq._id}}">
<img class="sheet-skill-img" src="{{conseq.img}}"/>
<span class="conseq-label"><a>{{conseq.name}}</a></span>
<div class="item-controls">
<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>
</li>
{{/each}}
</ul>
</div>