WIP: create class-shet.js and first aproach for skills on class
This commit is contained in:
+10
-3
@@ -20,9 +20,14 @@
|
||||
"Mosh.Calm": "Calm",
|
||||
"Mosh.Cargo": "Cargo",
|
||||
"Mosh.CarryingCapacity": "Carrying Capacity",
|
||||
"Mosh.CharacterGenerator": "Character Generator",
|
||||
"Mosh.CharacterGeneratorStatOptionPopupTitle": "Class Attribute and Saves option",
|
||||
"Mosh.CharacterGeneratorStatOptionPopupText":"Choose where to apply the bonus of:",
|
||||
"Mosh.CharacterGenerator.name": "Character Generator",
|
||||
"Mosh.CharacterGenerator.StatOption":"Stats & Saves",
|
||||
"Mosh.CharacterGenerator.StatOptionPopupTitle": "Class Attribute and Saves option",
|
||||
"Mosh.CharacterGenerator.StatOptionPopupText":"Choose where to apply the bonus of:",
|
||||
"Mosh.CharacterGenerator.Tables":"Tables",
|
||||
"Mosh.CharacterGenerator.Table.Loadout":"Loadout Table",
|
||||
"Mosh.CharacterGenerator.Table.Patch":"Patch Table",
|
||||
"Mosh.CharacterGenerator.Table.Trinket":"Trinket Table",
|
||||
"Mosh.CLASS": "CLASS",
|
||||
"Mosh.Combat": "Combat",
|
||||
"Mosh.Condition": "Condition",
|
||||
@@ -110,6 +115,8 @@
|
||||
"Mosh.SkillName": "Skill Name",
|
||||
"Mosh.SkillRank": "Skill Rank",
|
||||
"Mosh.Skills": "Skills",
|
||||
"Mosh.SkillsFixed": "Fixed Skills",
|
||||
"Mosh.SkillsOptional": "Optional Skills",
|
||||
"Mosh.SkillTraining": "Skill Training",
|
||||
"Mosh.SpecialAbilities": "Special Abilities",
|
||||
"Mosh.Speed": "Speed",
|
||||
|
||||
@@ -643,7 +643,7 @@ export class MothershipActorSheet extends ActorSheet {
|
||||
const canConfigure = game.user.isGM || this.actor.isOwner;
|
||||
if (this.options.editable && canConfigure) {
|
||||
buttons = [{
|
||||
label: game.i18n.localize("Mosh.CharacterGenerator"),
|
||||
label: game.i18n.localize("Mosh.CharacterGenerator.name"),
|
||||
class: 'configure-actor',
|
||||
icon: 'fas fa-cogs',
|
||||
onclick: (ev) => this._onConfigureCreature(ev),
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Extend the basic MothershipItemSheet with class modification
|
||||
* @extends {MothershipItemSheet}
|
||||
*/
|
||||
import { MothershipItemSheet } from "./item-sheet.js";
|
||||
export class MothershipClassSheet extends MothershipItemSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
var options = {
|
||||
classes: ["mosh", "sheet", "item"],
|
||||
width: 820,
|
||||
height: 820,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }]
|
||||
};
|
||||
options.dragDrop = [{dragSelector: null, dropSelector: ".dropitem"}];
|
||||
|
||||
if (game.release.generation >= 12) {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, options);
|
||||
} else {
|
||||
return mergeObject(super.defaultOptions, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @override */
|
||||
getData() {
|
||||
const data = super.getData();
|
||||
if (typeof data.system.base_adjustment.skills_granted == 'undefined'){
|
||||
data.system.base_adjustment.skills_granted=[];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
async _onDrop(event){
|
||||
await super._onDrop(event);
|
||||
const droppedUuid = TextEditor.getDragEventData(event);
|
||||
if (droppedUuid.type != "Item"){
|
||||
return;
|
||||
}
|
||||
const droppedObject = await fromUuid(droppedUuid.uuid);
|
||||
if (droppedObject.type == "skill"){
|
||||
//this.object.system.base_adjustment.skills_granted.push(droppedObject);
|
||||
let skills = this.object.system.base_adjustment.skills_granted;
|
||||
skills.push(droppedObject);
|
||||
this.object.update({"system.base_adjustment.skills_granted":skills});
|
||||
return this.render(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
|
||||
let skills = this.object.system.base_adjustment.skills_granted.filter(function( obj ) {
|
||||
return obj._id !== li.data("itemId");
|
||||
});
|
||||
this.object.update({"system.base_adjustment.skills_granted":skills});
|
||||
return this.render(false);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
/****
|
||||
async _updateObject(event, formData) {
|
||||
const item = this.object;
|
||||
|
||||
var updateData;
|
||||
if (game.release.generation >= 12) {
|
||||
updateData = foundry.utils.expandObject(formData);
|
||||
} else {
|
||||
updateData = expandObject(formData);
|
||||
}
|
||||
|
||||
await item.update(updateData, {
|
||||
diff: false
|
||||
});
|
||||
}*/
|
||||
}
|
||||
|
||||
+14
-1
@@ -7,6 +7,8 @@ import { MothershipShipSheetSBT } from "./actor/ship-sheet-sbt.js";
|
||||
|
||||
import { MothershipItem } from "./item/item.js";
|
||||
import { MothershipItemSheet } from "./item/item-sheet.js";
|
||||
import { MothershipClassSheet } from "./item/class-sheet.js";
|
||||
|
||||
import {
|
||||
registerSettings
|
||||
} from "./settings.js";
|
||||
@@ -65,7 +67,18 @@ Hooks.once('init', async function () {
|
||||
});
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("mosh", MothershipItemSheet, { makeDefault: true });
|
||||
Items.registerSheet("mosh", MothershipClassSheet, {types: ['class'], makeDefault: true });
|
||||
Items.registerSheet("mosh", MothershipItemSheet, {
|
||||
types: ["item",
|
||||
"skill",
|
||||
"weapon",
|
||||
"armor",
|
||||
"ability",
|
||||
"module",
|
||||
"condition",
|
||||
"crew",
|
||||
"repair",],
|
||||
makeDefault: true });
|
||||
|
||||
// If you need to add Handlebars helpers, here are a few useful examples:
|
||||
Handlebars.registerHelper('concat', function () {
|
||||
|
||||
@@ -15,7 +15,7 @@ export class DLActorGenerator extends FormApplication {
|
||||
* @type {String}
|
||||
*/
|
||||
get title() {
|
||||
return `${this.object.name}: ${game.i18n.localize("Mosh.CharacterGenerator")}`;
|
||||
return `${this.object.name}: ${game.i18n.localize("Mosh.CharacterGenerator.name")}`;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
|
||||
@@ -189,7 +189,8 @@ export class DLActorGenerator extends FormApplication {
|
||||
this.patchTable = droppedObject.system.roll_tables.patch;
|
||||
this.loadoutTable = droppedObject.system.roll_tables.loadout;
|
||||
|
||||
try{
|
||||
// Skills
|
||||
//try{
|
||||
//let skills = JSON.parse(droppedObject.system.skills.replaceAll("<p>","").replaceAll("</p>","").replaceAll("<div>","").replaceAll("</div>","").replaceAll(" ",""));
|
||||
let skillsUuid = [];
|
||||
|
||||
@@ -197,28 +198,31 @@ export class DLActorGenerator extends FormApplication {
|
||||
|
||||
let fixed_skills = droppedObject.system.base_adjustment.skills_granted;
|
||||
for (let i = 0;i<fixed_skills.length;i++){
|
||||
let skillUuid = fixed_skills[i];
|
||||
/**we need to keep only the Uuid of the item, not the complete string (for now) */
|
||||
skillsUuid.push(skillUuid.replace(/(])+(.*)/i,"").replace(/(.*)(\.)/i,""));
|
||||
let li_html = `<li>${await TextEditor.enrichHTML(skillUuid, {async: true})}</li>`;
|
||||
this._element.find(`ul[id="system.class.skils.text"]`).append(li_html);
|
||||
}
|
||||
let skill = fixed_skills[i];
|
||||
/**we need to keep only the Uuid of the item, not the complete string (for now) */
|
||||
skillsUuid.push(skill._id);
|
||||
let li_html = `<li><img src="${skill.img}" title="${skill.name}" width="24" height="24"/> ${await TextEditor.enrichHTML(skill.name, {async: true})}</li>`;
|
||||
this._element.find(`ul[id="system.class.skils.text"]`).append(li_html);
|
||||
}
|
||||
|
||||
|
||||
let option_skills_1 = droppedObject.system.selected_adjustment.choose_skill_and;
|
||||
let option_skills_2 = droppedObject.system.selected_adjustment.choose_skill_or;
|
||||
//todo: add popups to choose skils from (following the skill tree and type)
|
||||
|
||||
this._element.find(`input[id="system.class.skills.uuid"]`).prop("value", skillsUuid);
|
||||
}catch{
|
||||
ui.notifications.error("Class has invalid skills configuration.");
|
||||
}
|
||||
//}catch{
|
||||
// ui.notifications.error("Class has invalid skills configuration.");
|
||||
//}
|
||||
|
||||
try{
|
||||
//Stats
|
||||
///try{
|
||||
//let statsandsaves = JSON.parse(droppedObject.system.statsandsaves.replaceAll("<p>","").replaceAll("</p>","").replaceAll("<div>","").replaceAll("</div>","").replaceAll(" ",""));
|
||||
let fix_stats_and_saves = droppedObject.system.base_adjustment;
|
||||
delete fix_stats_and_saves["skills_granted"];
|
||||
|
||||
Object.entries(fix_stats_and_saves).forEach(([key, value]) => {
|
||||
//this sets all the bonuses of base_adjustment including max_wounds
|
||||
this._element.find(`input[name="system.stats.${key}.bonus"]`).prop("value",value);
|
||||
});
|
||||
|
||||
@@ -233,8 +237,8 @@ export class DLActorGenerator extends FormApplication {
|
||||
};
|
||||
}
|
||||
let d = new Dialog({
|
||||
title: game.i18n.localize("Mosh.CharacterGeneratorStatOptionPopupTitle"),
|
||||
content: `<p>${ game.i18n.localize("Mosh.CharacterGeneratorStatOptionPopupTitle")} (${option_stats_and_saves.modification})</p>`,
|
||||
title: game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupTitle"),
|
||||
content: `<p>${ game.i18n.localize("Mosh.CharacterGenerator.StatOptionPopupText")} (${option_stats_and_saves.modification})</p>`,
|
||||
buttons: buttons_options,
|
||||
default: "1",
|
||||
//render: html => console.log("Register interactivity in the rendered dialog"),
|
||||
@@ -269,9 +273,9 @@ export class DLActorGenerator extends FormApplication {
|
||||
d.render(true);
|
||||
}
|
||||
}*/
|
||||
}catch{
|
||||
ui.notifications.error("Class has invalid stats and saves configuration.");
|
||||
}
|
||||
//}catch{
|
||||
// ui.notifications.error("Class has invalid stats and saves configuration.");
|
||||
//}
|
||||
//todo: add robotic flag.
|
||||
return;
|
||||
}
|
||||
@@ -456,7 +460,6 @@ export class DLActorGenerator extends FormApplication {
|
||||
|
||||
|
||||
if(formData["system.removepreviousitems"]){
|
||||
|
||||
let itemTypesToDelete = ["item", "armor", "weapon","skill","condition"];
|
||||
let itemsToDelete = this.object.items.filter(item => itemTypesToDelete.includes(item.type));
|
||||
await this.object.deleteEmbeddedDocuments("Item", itemsToDelete.map(item => item.id));
|
||||
|
||||
@@ -29,9 +29,17 @@
|
||||
<input type="hidden" id="system.class.traumaresponse" name="system.class.traumaresponse"class="noborder"/>
|
||||
</div>
|
||||
|
||||
<!-- Wounds -->
|
||||
<div class="">
|
||||
<div class="headerinputtext">{{ localize 'Mosh.Wounds'}}</div>
|
||||
<div class="headerinputfield charname">
|
||||
<input id="system.stats.max_wounds.bonus" name="system.stats.max_wounds.bonus" class="noborder" type="text"
|
||||
value="{{system.stats.max_wounds.bonus}}" placeholder="" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- Credits -->
|
||||
<div class="">
|
||||
<div class="headerinputtext">Credits</div>
|
||||
<div class="headerinputtext">{{ localize 'Mosh.Credits' }}</div>
|
||||
<div class="headerinputfield charname">
|
||||
|
||||
<img class="clicable-item credit-img circle-input" id="system.credits.value" src="icons/svg/d20-black.svg" alt="roll">
|
||||
@@ -124,7 +132,7 @@
|
||||
<input class="mainstatmod-input" type="text" name="system.health.bonus" value="{{system.health.bonus}}"
|
||||
data-dtype="Number" />
|
||||
<div class="mainstatmod-title">+</div>
|
||||
<input type="hidden" id="system.stats.max_wounds.bonus" name="system.stats.max_wounds.bonus"class="noborder" data-dtype="Number" />
|
||||
<!--input type="hidden" id="system.stats.max_wounds.bonus" name="system.stats.max_wounds.bonus"class="noborder" data-dtype="Number" /-->
|
||||
</div>
|
||||
|
||||
<!-- Sanity -->
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
<input id="system.base_adjustment.strength" class="circle-input" type="text"
|
||||
name="system.base_adjustment.strength" value="{{system.base_adjustment.strength}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div class="mainstatmod-title">+</div>
|
||||
</div>
|
||||
|
||||
<!-- Speed -->
|
||||
@@ -42,7 +41,6 @@
|
||||
<input class="circle-input" id="system.base_adjustment.speed" type="text" name="system.base_adjustment.speed"
|
||||
value="{{system.base_adjustment.speed}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div class="mainstatmod-title">+</div>
|
||||
</div>
|
||||
|
||||
<!-- Intellect -->
|
||||
@@ -54,7 +52,6 @@
|
||||
<input class="circle-input" id="system.base_adjustment.intellect" type="text"
|
||||
name="system.base_adjustment.intellect" value="{{system.base_adjustment.intellect}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div class="mainstatmod-title">+</div>
|
||||
</div>
|
||||
|
||||
<!-- Combat -->
|
||||
@@ -66,7 +63,6 @@
|
||||
<input class="circle-input" id="system.base_adjustment.combat" type="text"
|
||||
name="system.base_adjustment.combat" value="{{system.base_adjustment.combat}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div class="mainstatmod-title">+</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -101,7 +97,6 @@
|
||||
<input id="system.base_adjustment.sanity" class="circle-input" type="text"
|
||||
name="system.base_adjustment.sanity" value="{{system.base_adjustment.sanity}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div class="mainstatmod-title">+</div>
|
||||
</div>
|
||||
|
||||
<!-- Fear -->
|
||||
@@ -113,7 +108,6 @@
|
||||
<input id="system.base_adjustment.fear" class="circle-input" type="text" name="system.base_adjustment.fear"
|
||||
value="{{system.base_adjustment.fear}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div class="mainstatmod-title">+</div>
|
||||
</div>
|
||||
|
||||
<!-- body -->
|
||||
@@ -125,7 +119,6 @@
|
||||
<input id="system.base_adjustment.body" class="circle-input" type="text" name="system.base_adjustment.body"
|
||||
value="{{system.base_adjustment.body}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div class="mainstatmod-title">+</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -143,10 +136,11 @@
|
||||
|
||||
{{!-- Sheet Tab Navigation --}}
|
||||
<nav class="mosh sheet-tabs tabs" style="height: auto;" data-group="primary">
|
||||
<a class="tab-select" data-tab="description">Description</a>
|
||||
<a class="tab-select" data-tab="stats&saves">Stats&Saves</a>
|
||||
<a class="tab-select" data-tab="skills">Skills</a>
|
||||
<a class="tab-select" data-tab="tables">tables</a>
|
||||
<a class="tab-select" data-tab="description">{{ localize 'Mosh.Description' }}</a>
|
||||
<a class="tab-select" data-tab="stats&saves">{{ localize 'Mosh.CharacterGenerator.StatOption' }}</a>
|
||||
<a class="tab-select" data-tab="skills.fixed">{{ localize 'Mosh.SkillsFixed' }}</a>
|
||||
<a class="tab-select" data-tab="skills.optional">{{ localize 'Mosh.SkillsOptional' }}</a>
|
||||
<a class="tab-select" data-tab="tables">{{ localize 'Mosh.CharacterGenerator.Tables' }}</a>
|
||||
</nav>
|
||||
|
||||
{{!-- Sheet Body --}}
|
||||
@@ -158,19 +152,53 @@
|
||||
</div>
|
||||
{{!-- stats&saves Tab --}}
|
||||
<div class="tab" data-group="primary" data-tab="stats&saves">
|
||||
|
||||
{{editor system.base_adjustmentandsaves target="system.base_adjustmentandsaves" button=true owner=owner editable=true}}
|
||||
|
||||
<div class="resource mainstat">
|
||||
<div class="mainstatlabel">
|
||||
<span class=" mainstattext" data-key="stat.modification" data-label="{{ localize 'Mosh.Value' }}">{{ localize 'Mosh.Value' }}</span>
|
||||
</div>
|
||||
<input id="system.selected_adjustment.choose_stat.modification" class="circle-input" type="text" name="system.selected_adjustment.choose_stat.modification"
|
||||
value="{{system.selected_adjustment.choose_stat.modification}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div>
|
||||
todo: editor to add or SELECT the optional stats
|
||||
</div>
|
||||
</div>
|
||||
{{!-- skills Tab --}}
|
||||
<div class="tab" data-group="primary" data-tab="skills">
|
||||
{{editor enriched.skills target="system.skills" button=true owner=owner editable=true}}
|
||||
<div class="tab dropitem items" data-group="primary" data-tab="skills.fixed">
|
||||
|
||||
<!-- SKILLS -->
|
||||
<ol class="items-list" style="margin-bottom : 10px;">
|
||||
<li class="item flexrow item-header">
|
||||
<div class="item-image"></div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.SkillName' }}</div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.SkillRank' }}</div>
|
||||
<div class="skill-stat">{{ localize 'Mosh.SkillBonus' }}</div>
|
||||
<div class="item-controls">
|
||||
</div>
|
||||
</li>
|
||||
{{#each system.base_adjustment.skills_granted as |skill id|}}
|
||||
<li class="item flexrow dropitem" data-item-id="{{skill._id}}">
|
||||
<div class="item-image"><img src="{{skill.img}}" title="{{skill.name}}" width="24" height="24"/></div>
|
||||
<div class="skill-name skill-roll list-roll">{{skill.name}}</div>
|
||||
<div class="skill-stat">{{skill.system.rank}}</div>
|
||||
<div class="skill-stat">{{skill.system.bonus}}</div>
|
||||
<div class="item-controls">
|
||||
<a class="item-control item-delete" title="{{ localize 'Mosh.DeleteSkill' }}"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="tab" data-group="primary" data-tab="skills.optional">
|
||||
</div>
|
||||
|
||||
<!-- Tables -->
|
||||
<div class="tab" data-group="primary" data-tab="tables"></divclass>
|
||||
<div class="circle-statwrapper-horizontal">
|
||||
<!-- PatchTable -->
|
||||
<div class="resource healthspread minmaxtopstat flex-center" style="grid-template-rows: max-content;">
|
||||
<label for="system.roll_tables.patch" class="resource-label minmaxtext">Patch Table</label>
|
||||
<label for="system.roll_tables.patch" class="resource-label minmaxtext">{{ localize 'Mosh.CharacterGenerator.Table.Patch' }}</label>
|
||||
|
||||
<div class="textvaluewrapper" style="width: 180px; background: white;">
|
||||
<input class="textvaluewrapper-input darkGreyText" type="text" name="system.roll_tables.patch"
|
||||
@@ -179,7 +207,7 @@
|
||||
</div>
|
||||
<!-- TrinketTable -->
|
||||
<div class="resource healthspread minmaxtopstat flex-center" style="grid-template-rows: max-content;">
|
||||
<label for="system.roll_tables.trinket" class="resource-label minmaxtext">Trinket Table</label>
|
||||
<label for="system.roll_tables.trinket" class="resource-label minmaxtext">{{ localize 'Mosh.CharacterGenerator.Table.Trinket' }}</label>
|
||||
|
||||
<div class="textvaluewrapper" style="width: 180px; background: white;">
|
||||
<input class="textvaluewrapper-input darkGreyText" type="text" name="system.roll_tables.trinket"
|
||||
@@ -188,7 +216,7 @@
|
||||
</div>
|
||||
<!-- LoadoutTable -->
|
||||
<div class="resource healthspread minmaxtopstat flex-center" style="grid-template-rows: max-content;">
|
||||
<label for="system.roll_tables.loadout" class="resource-label minmaxtext">Loadout Table</label>
|
||||
<label for="system.roll_tables.loadout" class="resource-label minmaxtext">{{ localize 'Mosh.CharacterGenerator.Table.Loadout' }}</label>
|
||||
|
||||
<div class="textvaluewrapper" style="width: 180px; background: white;">
|
||||
<input class="textvaluewrapper-input darkGreyText" type="text" name="system.roll_tables.loadout"
|
||||
|
||||
Reference in New Issue
Block a user