forked from xdy/twodsix-foundryvtt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): Another new (old) direction, this time with some help incoming.
Added Kevin to "author", brought back a lot of old code, and compendiums, but this time in the ce directory (as these are intended for ce), we need to decide how to handle other variants (maybe simply name them like 'ce-skills'? Or, maybe foundry supports folders for compendiums, I *think* I've seen that in a system. Figured this was enough for a bump of minor version.
- Loading branch information
Showing
22 changed files
with
681 additions
and
149 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export class TwodsixSystem { | ||
//Nothing to do yet | ||
|
||
//TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Namespace TWODSIX Configuration Values | ||
export const TWODSIX:any = {}; | ||
|
||
/** | ||
* The sets of rules variants one can use | ||
* @type {Object} | ||
*/ | ||
TWODSIX.variant = { | ||
"ce": "Cepheus Engine", | ||
} | ||
|
||
|
||
//TODO Start with skills, should do for others as well I guess | ||
export class TwodsixItemList { | ||
static async getItems(itemType?:string, metadataName?:string, labels_only = true):Promise<string[] | Item[]> { | ||
// First, retrieve any custom or overridden items so that we can prioritize those. | ||
const items = game.items; | ||
if (items == null) { | ||
return null; | ||
} | ||
let allItems = items.entities.filter(item => item.type == itemType); | ||
// Next, retrieve compendium items and merge them in. | ||
let c:any; | ||
for (c of game.packs) { | ||
if (c.metadata.entity && c.metadata.entity == 'Item' && c.metadata.name == metadataName) { | ||
allItems = allItems.concat(c ? await c.getContent() : []); | ||
} | ||
} | ||
// Reduce duplicates. Because item classes happen first, this will prevent | ||
// duplicate compendium entries from overriding the items. | ||
const charItemNames:string[] = []; | ||
for (const charItem of allItems) { | ||
const charItemName = charItem.data.name; | ||
if (charItemNames.includes(charItemName) !== false) { | ||
allItems = allItems.filter(item => item._id != charItem._id); | ||
} else { | ||
charItemNames.push(charItemName); | ||
} | ||
} | ||
|
||
// Sort the charItemNames list. | ||
if (labels_only) { | ||
charItemNames.sort((a, b) => { | ||
const aSort = a.toLowerCase(); | ||
const bSort = b.toLowerCase(); | ||
if (aSort < bSort) { | ||
return -1; | ||
} | ||
if (aSort > bSort) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
|
||
return charItemNames; | ||
} | ||
// Sort the class objects list. | ||
else { | ||
allItems.sort((a, b) => { | ||
const aSort = a.data.name.toLowerCase(); | ||
const bSort = b.data.name.toLowerCase(); | ||
if (aSort < bSort) { | ||
return -1; | ||
} | ||
if (aSort > bSort) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
|
||
return allItems; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.