Character generator #52 - working class item base_adjustment stat
This commit is contained in:
@@ -29,6 +29,9 @@ export class MothershipClassSheet extends MothershipItemSheet {
|
||||
if (typeof data.system.base_adjustment.skills_granted == 'undefined'){
|
||||
data.system.base_adjustment.skills_granted=[];
|
||||
}
|
||||
if (typeof data.system.selected_adjustment.choose_stat.stats == 'undefined'){
|
||||
data.system.selected_adjustment.choose_stat.stats=[];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -54,7 +57,7 @@ export class MothershipClassSheet extends MothershipItemSheet {
|
||||
super.activateListeners(html);
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
html.find('.skill-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
|
||||
let skills = this.object.system.base_adjustment.skills_granted.filter(function( obj ) {
|
||||
@@ -64,8 +67,69 @@ export class MothershipClassSheet extends MothershipItemSheet {
|
||||
return this.render(false);
|
||||
});
|
||||
|
||||
html.find('.stat-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
|
||||
let stats = this.object.system.selected_adjustment.choose_stat.stats.filter(function( obj ) {
|
||||
return obj !== li.data("itemId");
|
||||
});
|
||||
this.object.update({"system.selected_adjustment.choose_stat.stats":stats});
|
||||
return this.render(false);
|
||||
});
|
||||
|
||||
html.find('.stat-create').click(this._onStatCreate.bind(this));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle creating a new stat for the class selected adjustment
|
||||
* @param {Event} event The originating click event
|
||||
* @private
|
||||
*/
|
||||
_onStatCreate(event) {
|
||||
event.preventDefault();
|
||||
|
||||
let d = new Dialog({
|
||||
title: "Select Stat",
|
||||
content: `<h2>Stat</h2>\
|
||||
<select style='margin-bottom:10px;'name='system.selected_adjustment.choose_stat.stats' id='system.selected_adjustment.choose_stat.stats'>\
|
||||
<option value='strength'>${game.i18n.localize("Mosh.Strength")}</option>\
|
||||
<option value='speed'>${game.i18n.localize("Mosh.Speed")}</option>\
|
||||
<option value='intellect'>${game.i18n.localize("Mosh.Intelect")}</option>\
|
||||
<option value='combat'>${game.i18n.localize("Mosh.Combat")}</option>\
|
||||
<option value='sanity'>${game.i18n.localize("Mosh.Sanity")}</option>\
|
||||
<option value='fear'>${game.i18n.localize("Mosh.Fear")}</option>\
|
||||
<option value='body'>${game.i18n.localize("Mosh.Body")}</option>\
|
||||
</select> <br/>`,
|
||||
buttons: {
|
||||
roll: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Create",
|
||||
callback: (html) => {
|
||||
|
||||
let statname = html.find('[id=\"system.selected_adjustment.choose_stat.stats\"]')[0].value
|
||||
|
||||
let stats = this.object.system.selected_adjustment.choose_stat.stats;
|
||||
stats.push(statname);
|
||||
this.object.update({"system.selected_adjustment.choose_stat.stats":stats});
|
||||
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Cancel",
|
||||
callback: () => { }
|
||||
}
|
||||
},
|
||||
default: "roll",
|
||||
close: () => { }
|
||||
});
|
||||
d.render(true);
|
||||
|
||||
// Finally, create the item!
|
||||
return;
|
||||
}
|
||||
/****
|
||||
async _updateObject(event, formData) {
|
||||
const item = this.object;
|
||||
|
||||
@@ -160,7 +160,22 @@
|
||||
value="{{system.selected_adjustment.choose_stat.modification}}" data-dtype="Number" />
|
||||
</div>
|
||||
<div>
|
||||
todo: editor to add or SELECT the optional stats
|
||||
<ol class="items-list" style="margin-bottom : 10px;">
|
||||
<li class="item flexrow item-header">
|
||||
<div class="stat-stat">{{ localize 'Mosh.Name' }}</div>
|
||||
<div class="item-controls">
|
||||
<a class="item-control stat-create" title="{{ localize 'Mosh.CreateSkill' }}" data-type="stat"><i class="fas fa-plus"></i> {{ localize 'Mosh.Add' }}</a>
|
||||
</div>
|
||||
</li>
|
||||
{{#each system.selected_adjustment.choose_stat.stats as |stat id|}}
|
||||
<li class="item flexrow dropitem" data-item-id="{{stat}}">
|
||||
<div class="stat-name">{{stat}}</div>
|
||||
<div class="item-controls">
|
||||
<a class="item-control stat-delete" title="{{ localize 'Mosh.DeleteSkill' }}"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
{{!-- skills Tab --}}
|
||||
@@ -183,7 +198,7 @@
|
||||
<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>
|
||||
<a class="item-control skill-delete" title="{{ localize 'Mosh.DeleteSkill' }}"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
|
||||
Reference in New Issue
Block a user