Initial commit

This commit is contained in:
Anthony Murphy
2022-08-29 20:22:04 +10:00
parent 0092d71504
commit 09196a90cc
59 changed files with 3506 additions and 2 deletions

55
rmss/module/config.js Normal file
View File

@ -0,0 +1,55 @@
export const rmss = {};
rmss.curreny_type = {
mp: "rmss.curreny_type.mp",
pp: "rmss.curreny_type.pp",
gp: "rmss.curreny_type.gp",
sp: "rmss.curreny_type.sp",
bp: "rmss.curreny_type.bp",
cp: "rmss.curreny_type.cp"
};
rmss.stats = {
agility: {
fullname: "Agility",
shortname: "Ag"
},
constitution: {
fullname: "Constitution",
shortname: "Co"
},
memory: {
fullname: "Memory",
shortname: "Me"
},
reasoning: {
fullname: "Reasoning",
shortname: "Re"
},
self_discipline: {
fullname: "Self Discipline",
shortname: "SD"
},
empathy: {
fullname: "Empathy",
shortname: "Em"
},
intuition: {
fullname: "Intuition",
shortname: "In"
},
presence: {
fullname: "Presence",
shortname: "Pr"
},
quickness: {
fullname: "Quickness",
shortname: "Qu"
},
strength: {
fullname: "Strength",
shortname: "St"
}
}

View File

@ -0,0 +1,144 @@
export class RMSSActor extends Actor {
/** @override */
prepareData() {
// Prepare data for the actor. Calling the super version of this executes
// the following, in order: data reset (to clear active effects),
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
// prepareDerivedData().
super.prepareData();
}
prepareDerivedData() {
const actorData = this.data;
const data = actorData.data;
const flags = actorData.flags.rmss || {};
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
this._prepareCharacterData(actorData);
this._prepareNpcData(actorData);
}
/**
* Prepare Character type specific data
*/
_prepareCharacterData(actorData) {
if (actorData.type !== 'character') return;
// Calculate Stat Bonuses in Actor
this.prepareStatBonuses(actorData)
// Calculate Resistance Rolls in Actor
this.prepareResistanceRolls(actorData);
// Iterate through and apply Stat bonuses for Skill Category Items
this.prepareSkillCatStatBonuses();
}
/**
* Prepare NPC type specific data.
*/
_prepareNpcData(actorData) {
if (actorData.type !== 'npc') return;
// Make modifications to data here. For example:
const data = actorData.data;
data.xp = (data.cr * data.cr) * 100;
}
prepareStatBonuses(actorData) {
const data = actorData.data;
actorData.data.stats.agility.stat_bonus = Number(data.stats.agility.racial_bonus)+Number(data.stats.agility.special_bonus)+Number(data.stats.agility.basic_bonus);
actorData.data.stats.constitution.stat_bonus = Number(data.stats.constitution.racial_bonus)+Number(data.stats.constitution.special_bonus)+Number(data.stats.constitution.basic_bonus);
actorData.data.stats.memory.stat_bonus = Number(data.stats.memory.racial_bonus)+Number(data.stats.memory.special_bonus)+Number(data.stats.memory.basic_bonus);
actorData.data.stats.reasoning.stat_bonus = Number(data.stats.reasoning.racial_bonus)+Number(data.stats.reasoning.special_bonus)+Number(data.stats.reasoning.basic_bonus);
actorData.data.stats.self_discipline.stat_bonus = Number(data.stats.self_discipline.racial_bonus)+Number(data.stats.self_discipline.special_bonus)+Number(data.stats.self_discipline.basic_bonus);
actorData.data.stats.empathy.stat_bonus = Number(data.stats.empathy.racial_bonus)+Number(data.stats.empathy.special_bonus)+Number(data.stats.empathy.basic_bonus);
actorData.data.stats.intuition.stat_bonus = Number(data.stats.intuition.racial_bonus)+Number(data.stats.intuition.special_bonus)+Number(data.stats.intuition.basic_bonus);
actorData.data.stats.presence.stat_bonus = Number(data.stats.presence.racial_bonus)+Number(data.stats.presence.special_bonus)+Number(data.stats.presence.basic_bonus);
actorData.data.stats.quickness.stat_bonus = Number(data.stats.quickness.racial_bonus)+Number(data.stats.quickness.special_bonus)+Number(data.stats.quickness.basic_bonus);
actorData.data.stats.strength.stat_bonus = Number(data.stats.strength.racial_bonus)+Number(data.stats.strength.special_bonus)+Number(data.stats.strength.basic_bonus);
}
prepareResistanceRolls(actorData) {
const data = actorData.data;
actorData.data.resistance_rolls.essence = Number(actorData.data.stats.empathy.stat_bonus * 3)
actorData.data.resistance_rolls.channeling = Number(actorData.data.stats.intuition.stat_bonus * 3)
actorData.data.resistance_rolls.mentalism = Number(actorData.data.stats.presence.stat_bonus * 3)
actorData.data.resistance_rolls.fear = Number(actorData.data.stats.self_discipline.stat_bonus * 3)
actorData.data.resistance_rolls.poison_disease = Number(actorData.data.stats.constitution.stat_bonus * 3)
actorData.data.resistance_rolls.chann_ess = Number(actorData.data.stats.intuition.stat_bonus) + Number(actorData.data.stats.empathy.stat_bonus)
actorData.data.resistance_rolls.chann_ment = Number(actorData.data.stats.intuition.stat_bonus) + Number(actorData.data.stats.presence.stat_bonus)
actorData.data.resistance_rolls.ess_ment = Number(actorData.data.stats.empathy.stat_bonus) + Number(actorData.data.stats.presence.stat_bonus)
actorData.data.resistance_rolls.arcane = Number(actorData.data.stats.empathy.stat_bonus) + Number(actorData.data.stats.intuition.stat_bonus) + Number(actorData.data.stats.presence.stat_bonus)
}
prepareSkillCatStatBonuses() {
console.log("Getting Items");
for (const item of this.items) {
if (item.type === "skill_category") {
// Get all the applicable stats for this skill category
var app_stat_1 = item.data.data.app_stat_1;
var app_stat_2 = item.data.data.app_stat_2;
var app_stat_3 = item.data.data.app_stat_3;
console.log(item.name + " " + app_stat_1 + " " + app_stat_2 + " " + app_stat_3);
// If the first one is None we don't need to do anything further
if (app_stat_1 === "None") {
continue;
}
else
{
var applicable_stat_bonus = 0;
var app_stat_1_found = false;
var app_stat_2_found = false;
var app_stat_3_found = false;
// Iterate through the applicable stats and find their full names
for (const stat in CONFIG.rmss.stats) {
// If the configured App Stat matches the one of the stats in config
if (app_stat_1 === CONFIG.rmss.stats[stat].shortname) {
console.log("Found first stat: " + stat);
app_stat_1_found = true;
// Get the Stat Bonus
console.log(this.data.data.stats[stat].stat_bonus);
applicable_stat_bonus = applicable_stat_bonus + this.data.data.stats[stat].stat_bonus
//console.log("New Applicable Stat Bonus: " + applicable_stat_bonus)
}
if (app_stat_2 === CONFIG.rmss.stats[stat].shortname) {
console.log("Found second stat: " + stat);
app_stat_2_found = true;
console.log(this.data.data.stats[stat].stat_bonus);
applicable_stat_bonus = applicable_stat_bonus + this.data.data.stats[stat].stat_bonus
//console.log("New Applicable Stat Bonus: " + applicable_stat_bonus)
}
if (app_stat_3 === CONFIG.rmss.stats[stat].shortname) {
console.log("Found third stat: " + stat);
app_stat_3_found = true;
console.log(this.data.data.stats[stat].stat_bonus);
applicable_stat_bonus = applicable_stat_bonus + this.data.data.stats[stat].stat_bonus
//console.log("New Applicable Stat Bonus: " + applicable_stat_bonus)
}
}
console.log("Applicable Stat Bonus: " + applicable_stat_bonus)
if (app_stat_1_found === true && app_stat_2_found === true && app_stat_3_found === true) {
// Apply the update if we found stat bonuses for every applicable stat
item.data.data.stat_bonus = applicable_stat_bonus;
// Update the total in the Item
item.calculateSkillCatTotalBonus(item.data);
}
}
}
}
}
}

View File

@ -0,0 +1,77 @@
export class RMSSItem extends Item {
/** @override */
prepareData() {
// Prepare data for the item. Calling the super version of this executes
// the following, in order: data reset (to clear active effects),
// prepareBaseData(), prepareEmbeddedDocuments() (including active effects),
// prepareDerivedData().
super.prepareData();
}
// Set the images for newly created images (need to fix for copied images).
async _preCreate(data, options, userId) {
await super._preCreate(data, options, userId);
if (!data.img) {
if (this.data.type == "armor") {
await this.data.update({img: "systems/rmss/assets/default/armor.svg"});
}
else if (this.data.type == "weapon") {
await this.data.update({img: "systems/rmss/assets/default/weapon.svg"});
}
else if (this.data.type == "skill") {
await this.data.update({img: "systems/rmss/assets/default/skill.svg"});
}
else if (this.data.type == "skill_category") {
await this.data.update({img: "systems/rmss/assets/default/skill_category.svg"});
}
else if (this.data.type == "spell") {
await this.data.update({img: "systems/rmss/assets/default/spell.svg"});
}
else if (this.data.type == "herb_or_poison") {
await this.data.update({img: "systems/rmss/assets/default/herb_or_poison.svg"});
}
else if (this.data.type == "transport") {
await this.data.update({img: "systems/rmss/assets/default/transport.svg"});
}
}
}
calculateSkillCatTotalBonus(itemData) {
// Calculate Stat Bonuses
const data = itemData.data;
itemData.data.total_bonus = Number(data.rank_bonus)+Number(data.stat_bonus)+Number(data.prof_bonus)+Number(data.special_bonus_1)+Number(data.special_bonus_2);
}
prepareDerivedData() {
const itemData = this.data;
const data = itemData.data;
const flags = itemData.flags.rmss || {};
// Make separate methods for each item type to keep things organized.
this._prepareSkillCategoryData(itemData);
this._prepareSkillData(itemData);
}
_prepareSkillCategoryData(itemData) {
if (itemData.type !== 'skill_category') return;
// Make modifications to data here. For example:
//const data = itemData.data;
// Calculate Stat Bonuses
this.calculateSkillCatTotalBonus(itemData);
}
_prepareSkillData(itemData) {
if (itemData.type !== 'skill') return;
// Make modifications to data here. For example:
const data = itemData.data;
// Calculate Stat Bonuses
itemData.data.total_bonus = Number(data.rank_bonus)+Number(data.category_bonus)+Number(data.item_bonus)+Number(data.special_bonus_1)+Number(data.special_bonus_2);
}
}

View 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});
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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);
});
}
}

View 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;
}
}

View 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;
}
}