Initial commit
This commit is contained in:
139
rmss/module/sheets/actors/rmss_player_sheet.js
Normal file
139
rmss/module/sheets/actors/rmss_player_sheet.js
Normal file
@ -0,0 +1,139 @@
|
||||
export default class RMSSPlayerSheet extends ActorSheet {
|
||||
|
||||
// Override Default Options, Set CSS Classes, Set Default Sheet, Set up Sheet Tabs
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
template: "systems/rmss/templates/sheets/actors/rmss-character-sheet.html",
|
||||
classes: ["rmss", "sheet", "actor"],
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
|
||||
});
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const context = super.getData();
|
||||
|
||||
// Use a safe clone of the actor data for further operations.
|
||||
const actorData = this.actor.data.toObject(false);
|
||||
|
||||
// Add the actor's data to context.data for easier access, as well as flags.
|
||||
context.data = actorData.data;
|
||||
context.flags = actorData.flags;
|
||||
|
||||
// Prepare character data and items.
|
||||
if (actorData.type == 'character') {
|
||||
this._prepareItems(context);
|
||||
this._prepareCharacterData(context);
|
||||
}
|
||||
|
||||
// Prepare NPC data and items.
|
||||
if (actorData.type == 'npc') {
|
||||
this._prepareItems(context);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
_prepareCharacterData(context) {
|
||||
}
|
||||
|
||||
_prepareItems(context) {
|
||||
// Initialize containers.
|
||||
const gear = [];
|
||||
const playerskill= [];
|
||||
const skillcat = [];
|
||||
|
||||
// Iterate through items, allocating to containers
|
||||
for (let i of context.items) {
|
||||
i.img = i.img || DEFAULT_TOKEN;
|
||||
// Append to gear.
|
||||
if (i.type === 'item' || i.type === 'armor' || i.type === 'weapon' || i.type === 'herb_or_poison') {
|
||||
gear.push(i);
|
||||
}
|
||||
// Append to skill categories.
|
||||
else if (i.type === 'skill_category') {
|
||||
skillcat.push(i);
|
||||
}
|
||||
// Append to playerskill
|
||||
else if (i.type === 'skill') {
|
||||
playerskill.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort Skill/Skillcat Arrays
|
||||
skillcat.sort(function (a, b){
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
playerskill.sort(function (a, b){
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
||||
// Assign and return
|
||||
context.gear = gear;
|
||||
context.skillcat = skillcat;
|
||||
context.playerskill = playerskill;
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// NOTE: Can you do skill/item favorites this way?
|
||||
|
||||
// Render the item sheet for viewing/editing prior to the editable check.
|
||||
html.find('.item-edit').click(ev => {
|
||||
const item = this.actor.items.get(ev.currentTarget.getAttribute("data-item-id"));
|
||||
console.log(this);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.isEditable) return;
|
||||
|
||||
// Add Item
|
||||
html.find('.item-create').click(this._onItemCreate.bind(this));
|
||||
|
||||
// Delete Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const item = this.actor.items.get(ev.currentTarget.getAttribute("data-item-id"));
|
||||
console.log(ev.currentTarget.getAttribute("data-item-id"));
|
||||
item.delete();
|
||||
});
|
||||
}
|
||||
|
||||
async _onItemCreate(event) {
|
||||
event.preventDefault();
|
||||
const header = event.currentTarget;
|
||||
// Get the type of item to create.
|
||||
const type = header.dataset.type;
|
||||
// Grab any data associated with this control.
|
||||
const data = duplicate(header.dataset);
|
||||
// Initialize a default name.
|
||||
const name = `New ${type.capitalize()}`;
|
||||
// Prepare the item object.
|
||||
const itemData = {
|
||||
name: name,
|
||||
type: type,
|
||||
data: data
|
||||
};
|
||||
// Remove the type from the dataset since it's in the itemData.type prop.
|
||||
delete itemData.data["type"];
|
||||
|
||||
// Finally, create the item!
|
||||
return await Item.create(itemData, {parent: this.actor});
|
||||
}
|
||||
}
|
33
rmss/module/sheets/items/rmss_armor_sheet.js
Normal file
33
rmss/module/sheets/items/rmss_armor_sheet.js
Normal file
@ -0,0 +1,33 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSArmorSheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
template: "systems/rmss/templates/sheets/items/rmss-armor-sheet.html",
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/items/rmss-armor-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
33
rmss/module/sheets/items/rmss_herb_or_poison_sheet.js
Normal file
33
rmss/module/sheets/items/rmss_herb_or_poison_sheet.js
Normal file
@ -0,0 +1,33 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSHerbAndPoisonSheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
template: "systems/rmss/templates/sheets/items/rmss-herb-or-poison-sheet.html",
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/items/rmss-herb-or-poison-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
33
rmss/module/sheets/items/rmss_item_sheet.js
Normal file
33
rmss/module/sheets/items/rmss_item_sheet.js
Normal file
@ -0,0 +1,33 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSItemSheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
template: "systems/rmss/templates/sheets/items/rmss-item-sheet.html",
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/items/rmss-item-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
33
rmss/module/sheets/items/rmss_transport_sheet.js
Normal file
33
rmss/module/sheets/items/rmss_transport_sheet.js
Normal file
@ -0,0 +1,33 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSTransportSheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
template: "systems/rmss/templates/sheets/items/rmss-transport-sheet.html",
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/items/rmss-transport-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
33
rmss/module/sheets/items/rmss_weapon_sheet.js
Normal file
33
rmss/module/sheets/items/rmss_weapon_sheet.js
Normal file
@ -0,0 +1,33 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSWeaponSheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
template: "systems/rmss/templates/sheets/items/rmss-weapon-sheet.html",
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/items/rmss-weapon-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
111
rmss/module/sheets/skills/rmss_skill_category_sheet.js
Normal file
111
rmss/module/sheets/skills/rmss_skill_category_sheet.js
Normal file
@ -0,0 +1,111 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSSkillCategorySheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
template: "systems/rmss/templates/sheets/skills/rmss-skill-category-sheet.html",
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/skills/rmss-skill-category-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
// Get a list of stats that can be used as applicable stats
|
||||
var applicable_stat_list = this.prepareApplicableStatValues(CONFIG);
|
||||
|
||||
//Get the currently selected value for all three applicable stats
|
||||
var applicable_stat_1_selected = this.prepareApplicableSelectedStat("app_stat_1");
|
||||
var applicable_stat_2_selected = this.prepareApplicableSelectedStat("app_stat_2");
|
||||
var applicable_stat_3_selected = this.prepareApplicableSelectedStat("app_stat_3");
|
||||
|
||||
// Build the string for Applicable Stats
|
||||
var applicable_stat_text = this.buildApplicableStatsText(applicable_stat_1_selected, applicable_stat_2_selected, applicable_stat_3_selected)
|
||||
baseData.item.data.data['applicable_stats'] = applicable_stat_text
|
||||
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss,
|
||||
applicable_stat_list: applicable_stat_list,
|
||||
applicable_stat_1_selected: applicable_stat_1_selected,
|
||||
applicable_stat_2_selected: applicable_stat_2_selected,
|
||||
applicable_stat_3_selected: applicable_stat_3_selected
|
||||
};
|
||||
|
||||
console.log(this.item)
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
async _setApplicableStat(item, ev) {
|
||||
// Build a JSON Object from the select tag value and select name (item data attribute key)
|
||||
var update_key = ev.currentTarget.getAttribute("name");
|
||||
var update_data = ev.target.value;
|
||||
|
||||
// Update Item Data
|
||||
await item.update({[update_key]: update_data});
|
||||
}
|
||||
|
||||
prepareApplicableStatValues(CONFIG) {
|
||||
var applicable_stat_1_list = {None: "None"}
|
||||
|
||||
// Get a list of stat shortnames from the config
|
||||
for (const item in CONFIG.rmss.stats) {
|
||||
applicable_stat_1_list[CONFIG.rmss.stats[item]['shortname']] = CONFIG.rmss.stats[item]['shortname'];
|
||||
}
|
||||
return applicable_stat_1_list;
|
||||
}
|
||||
|
||||
// Determine which Stat is selected for applicable stats
|
||||
prepareApplicableSelectedStat(app_stat) {
|
||||
var applicable_stat_selected = "";
|
||||
applicable_stat_selected = this.item.data.data[app_stat];
|
||||
return applicable_stat_selected;
|
||||
}
|
||||
|
||||
// Build the text that is displayed in the Applicable Stats field
|
||||
buildApplicableStatsText(app_stat_1, app_stat_2, app_stat_3) {
|
||||
|
||||
if (app_stat_1 === "None") {
|
||||
return("None")
|
||||
}
|
||||
else if (app_stat_1 !== "None" && app_stat_2 === "None") {
|
||||
return(app_stat_1)
|
||||
}
|
||||
else if (app_stat_1 !== "None" && app_stat_2 !== "None" && app_stat_3 === "None" ) {
|
||||
return(app_stat_1 + "/" + app_stat_2 )
|
||||
}
|
||||
else if (app_stat_1 !== "None" && app_stat_2 !== "None" && app_stat_3 !== "None" ) {
|
||||
return(app_stat_1 + "/" + app_stat_2 + "/" + app_stat_3 )
|
||||
}
|
||||
else {
|
||||
return("None")
|
||||
}
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.isEditable) return;
|
||||
|
||||
// Update Applicable Stats for Skill Categories
|
||||
html.find('.stat-selector').change(ev => {
|
||||
this._setApplicableStat(this.item, ev);
|
||||
});
|
||||
}
|
||||
}
|
33
rmss/module/sheets/skills/rmss_skill_sheet.js
Normal file
33
rmss/module/sheets/skills/rmss_skill_sheet.js
Normal file
@ -0,0 +1,33 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSSkillSheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
template: "systems/rmss/templates/sheets/skills/rmss-skill-sheet.html",
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/skills/rmss-skill-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
32
rmss/module/sheets/spells/rmss_spell_sheet.js
Normal file
32
rmss/module/sheets/spells/rmss_spell_sheet.js
Normal file
@ -0,0 +1,32 @@
|
||||
// Our Item Sheet extends the default
|
||||
export default class RMSSSpellSheet extends ItemSheet {
|
||||
|
||||
// Set the height and width
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
width: 530,
|
||||
height: 440,
|
||||
classes: ["rmss", "sheet", "item"]
|
||||
});
|
||||
}
|
||||
|
||||
// If our sheet is called here it is.
|
||||
get template() {
|
||||
return `systems/rmss/templates/sheets/spells/rmss-spell-sheet.html`;
|
||||
}
|
||||
|
||||
// Make the data available to the sheet template
|
||||
getData() {
|
||||
const baseData = super.getData();
|
||||
|
||||
let sheetData = {
|
||||
owner: this.item.isOwner,
|
||||
editable :this.isEditable,
|
||||
item: baseData.item,
|
||||
data: baseData.item.data.data,
|
||||
config: CONFIG.rmss
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user