Inc release

This commit is contained in:
sladecraven 2021-12-08 13:53:22 +01:00
parent 2b23e9daec
commit 22392fba66
10 changed files with 262 additions and 49 deletions

View File

@ -162,8 +162,7 @@ export class PegasusActorSheet extends ActorSheet {
html.find('.item-equip').click(ev => { html.find('.item-equip').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
this.actor.equipItem( li.data("item-id") ); this.actor.equipItem( li.data("item-id") );
this.render(true); this.render(true);
}); });
html.find('.perk-active').click(ev => { html.find('.perk-active').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");

View File

@ -109,6 +109,45 @@ export class PegasusItemSheet extends ItemSheet {
}); });
} }
/* -------------------------------------------- */
async viewSubitem(ev) {
let field = $(ev.currentTarget).data('type');
let idx = Number($(ev.currentTarget).data('index'));
let itemData = this.object.data.data[field][idx];
if ( itemData.name != 'None') {
let spec = await Item.create(itemData, {temporary: true});
spec.data.origin = "embeddedItem";
new PegasusItemSheet(spec).render(true);
}
}
/* -------------------------------------------- */
async deleteSubitem(ev) {
let field = $(ev.currentTarget).data('type');
let idx = Number($(ev.currentTarget).data('index'));
let oldArray = this.object.data.data[field];
let itemData = this.object.data.data[field][idx];
if ( itemData.name != 'None') {
let newArray = [];
for( var i = 0; i < oldArray.length; i++) {
if ( i != idx) {
newArray.push( oldArray[i]);
}
}
this.object.update( { [`data.${field}`]: newArray} );
}
}
/* -------------------------------------------- */
async manageSpec( ) {
let itemData = this.object.data.data.specialisation[0];
if ( itemData.name != 'None') {
let spec = await Item.create(itemData, {temporary: true});
spec.data.origin = "embeddedItem";
new PegasusItemSheet(spec).render(true);
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
@ -124,44 +163,115 @@ export class PegasusItemSheet extends ItemSheet {
const item = this.object.options.actor.getOwnedItem(li.data("item-id")); const item = this.object.options.actor.getOwnedItem(li.data("item-id"));
item.sheet.render(true); item.sheet.render(true);
}); });
html.find('.delete-spec').click( ev => {
this.object.update( {"data.specialisation": [ { name: 'None'} ]} );
});
html.find('.delete-subitem').click( ev => {
this.deleteSubitem( ev );
});
html.find('.stat-choice-flag').click( ev => {
let idx = $(ev.currentTarget).data("stat-idx");
let array = duplicate(this.object.data.data.statincreasechoice);
array[Number(idx)].flag = !array[Number(idx)].flag;
this.object.update( {"data.statincreasechoice": array} );
});
// Update Inventory Item // Update Inventory Item
html.find('.item-delete').click(ev => { html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
let itemId = li.data("item-id"); let itemId = li.data("item-id");
let itemType = li.data("item-type"); let itemType = li.data("item-type");
let array = duplicate(this.object.data.data[itemType]);
let newArray = array.filter( item => item._id != itemId);
if ( itemType == 'variations') {
this.object.update( {"data.variations": newArray} );
} else if (itemType == "modifications") {
this.object.update( { "data.modifications": newArray} );
} else {
this.object.update( { "data.traits": newArray} );
}
}); });
html.find('.trait-name').click(ev => { html.find('.view-subitem').click(ev => {
const li = $(ev.currentTarget).parents(".item"); this.viewSubitem( ev );
let itemId = li.data("item-id");
this.manageTrait( itemId);
}); });
html.find('.variation-name').click(ev => {
const li = $(ev.currentTarget).parents(".item"); html.find('.view-spec').click(ev => {
let itemId = li.data("item-id"); this.manageSpec( );
this.manageVariation( itemId);
});
html.find('.modification-name').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let itemId = li.data("item-id");
this.manageModification( itemId);
}); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDrop(event) { async searchItem( dataItem) {
let item;
if (dataItem.pack) {
item = await fromUuid(dataItem.id);
} else {
item = game.items.get(dataItem.id )
}
return item;
}
/* -------------------------------------------- */
async addSpecialisation(item, dataItem) {
let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length );
let specArray = [ newItem ];
await this.object.update( { 'data.specialisation': specArray} );
}
/* -------------------------------------------- */
async addRoleSpecialisation(event, item, dataItem) {
let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length );
console.log("Add spec", event, newItem);
if ( event.toElement.className == 'drop-spec1') {
let specArray = duplicate(this.object.data.data.specialisationsplus1);
specArray.push( newItem );
await this.object.update( { 'data.specialisationsplus1': specArray} );
}
if ( event.toElement.className == 'drop-spec2') {
let specArray = duplicate(this.object.data.data.specincrease);
specArray.push( newItem );
await this.object.update( { 'data.specincrease': specArray} );
}
}
/* -------------------------------------------- */
async addRolePerk(event, item, dataItem) {
let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length );
console.log("Add spec", event, newItem);
if ( event.toElement.className == 'drop-perk2') {
let perkArray = duplicate(this.object.data.data.perks);
perkArray.push( newItem );
await this.object.update( { 'data.perks': perkArray} );
}
}
/* -------------------------------------------- */
async _onDrop(event) {
console.log(event);
if (this.object.type == 'perk' || this.object.type == 'ability') {
let data = event.dataTransfer.getData('text/plain');
if (data) {
let dataItem = JSON.parse( data );
let item = await this.searchItem( dataItem);
if ( item.data.type == 'specialisation') {
return this.addSpecialisation( item, dataItem);
}
}
}
if (this.object.type == 'role' ) {
let data = event.dataTransfer.getData('text/plain');
if (data) {
let dataItem = JSON.parse( data );
let item = await this.searchItem( dataItem);
if ( item.data.type == 'specialisation') {
return this.addRoleSpecialisation( event, item, dataItem);
}
if ( item.data.type == 'perk') {
return this.addRolePerk( event, item, dataItem);
}
}
}
ui.notifications.warn("This item can not be dropped over another item");
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -1,15 +1,12 @@
import { PegasusUtility } from "./pegasus-utility.js"; import { PegasusUtility } from "./pegasus-utility.js";
export const defaultItemImg = { export const defaultItemImg = {
skill: "systems/fvtt-pegasus-rpg/images/icons/icon_skill.webp", specialisation: "systems/fvtt-pegasus-rpg/images/icons/icon_spec.webp",
advantage: "systems/fvtt-pegasus-rpg/images/icons/icon_advantage.webp", perk: "systems/fvtt-pegasus-rpg/images/icons/icon_perk.webp",
disadvantage: "systems/fvtt-pegasus-rpg/images/icons/icon_disadvantage.webp", ability: "systems/fvtt-pegasus-rpg/images/icons/icon_ability.webp",
technique: "systems/fvtt-pegasus-rpg/images/icons/icon_technique.webp",
armor: "systems/fvtt-pegasus-rpg/images/icons/icon_armor.webp", armor: "systems/fvtt-pegasus-rpg/images/icons/icon_armor.webp",
art: "systems/fvtt-pegasus-rpg/icons/images/icon_art.webp",
weapon: "systems/fvtt-pegasus-rpg/images/icons/icon_weapon.webp", weapon: "systems/fvtt-pegasus-rpg/images/icons/icon_weapon.webp",
equipment: "systems/fvtt-pegasus-rpg/images/icons/icon_equipment.webp", equipment: "systems/fvtt-pegasus-rpg/images/icons/icon_equipment.webp",
style: "systems/fvtt-pegasus-rpg/images/icons/icon_style.webp",
} }
/** /**

View File

@ -1143,6 +1143,19 @@ ul, li {
font-weight: bold; font-weight: bold;
} }
.ul-level1 {
padding-left: 2rem;
}
.drop-perk2,
.drop-spec1 ,
.drop-spec2 {
background: linear-gradient(to bottom, #6c95b9fc 5%, #105177ab 100%);
background-color: #7d5d3b00;
border-radius: 3px;
border: 2px ridge #846109;
}
/*************************************************************/ /*************************************************************/
#pause #pause
{ {

View File

@ -40,9 +40,9 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 9, "templateVersion": 13,
"title": "Pegasus RPG", "title": "Pegasus RPG",
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
"version": "0.0.9", "version": "0.0.13",
"background" : "./images/ui/pegasus_welcome_page.webp" "background" : "./images/ui/pegasus_welcome_page.webp"
} }

View File

@ -133,13 +133,21 @@
"environment": "", "environment": "",
"society_culture": "", "society_culture": "",
"outlook": "", "outlook": "",
"abilities": "", "abilities": [],
"statistics": "" "statistics": ""
}, },
"role": { "role": {
"description": "", "statincrease1": "",
"abilities": "", "statincrease2": "",
"statistics": "" "specialisationsplus1": [],
"powers1": [],
"specialperk": [],
"statincreasechoice": [ { "name":"AGI", "flag":false }, {"name":"MND", "flag":false }, {"name":"SOC", "flag":false }, {"name":"STR", "flag":false },
{"name":"PHY", "flag":false }, {"name":"COM", "flag":false }, {"name":"DEF", "flag":false }, {"name":"STL", "flag":false },
{"name":"PER", "flag":false }, {"name":"FOC", "flag":false } ],
"specincrease": [],
"perks": [],
"description": ""
}, },
"ability": { "ability": {
"affectedstat": "", "affectedstat": "",
@ -150,7 +158,7 @@
"statusaffected": "", "statusaffected": "",
"statusmodifier": 0, "statusmodifier": 0,
"powergained": 0, "powergained": 0,
"specgained": "", "specialisation": [ {"name": "None"}],
"aoe": "", "aoe": "",
"description": "" "description": ""
}, },
@ -167,7 +175,7 @@
"gainstatdice": "", "gainstatdice": "",
"gainbonusdice": 0, "gainbonusdice": 0,
"gainotherdice": 0, "gainotherdice": 0,
"specialisation": "", "specialisation": [ {"name": "None"}],
"range": "", "range": "",
"aoe": "", "aoe": "",
"nbtargets": 0, "nbtargets": 0,

View File

@ -72,7 +72,12 @@
<input type="text" class="input-numeric-short padd-right" name="data.powergained" value="{{data.powergained}}" data-dtype="Number"/> <input type="text" class="input-numeric-short padd-right" name="data.powergained" value="{{data.powergained}}" data-dtype="Number"/>
</li> </li>
<li class="flexrow"><label class="generic-label">Specialisation Gained</label> <li class="flexrow"><label class="generic-label">Specialisation Gained</label>
<input type="text" class="padd-right" name="data.specgained" value="{{data.specgained}}" data-dtype="String"/> {{#each data.specialisation as |spec idx|}}
<label name="data.specialisation[{{idx}}].name"><a class="view-spec" data-spec-index="{{idx}}">{{spec.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-spec padd-left" data-spec-index="{{idx}}" title="Delete Spec"><i class="fas fa-trash"></i></a>
</div>
{{/each}}
</li> </li>
<li class="flexrow"><label class="generic-label">AoE</label> <li class="flexrow"><label class="generic-label">AoE</label>
<input type="text" class="padd-right" name="data.aoe" value="{{data.aoe}}" data-dtype="String"/> <input type="text" class="padd-right" name="data.aoe" value="{{data.aoe}}" data-dtype="String"/>

View File

@ -59,7 +59,12 @@
</select> </select>
</li> </li>
<li class="flexrow"><label class="generic-label">Specialisation Affected</label> <li class="flexrow"><label class="generic-label">Specialisation Affected</label>
<input type="text" class="padd-right" name="data.specialisation" value="{{data.specialisation}}" data-dtype="String"/> {{#each data.specialisation as |spec idx|}}
<label name="data.specialisation[{{idx}}].name"><a class="view-spec" data-spec-index="{{idx}}">{{spec.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-spec padd-left" data-spec-index="{{idx}}" title="Delete Spec"><i class="fas fa-trash"></i></a>
</div>
{{/each}}
</li> </li>
<li class="flexrow"><label class="generic-label">Range</label> <li class="flexrow"><label class="generic-label">Range</label>
<select class="competence-base flexrow" type="text" name="data.range" value="{{data.range}}" data-dtype="String"> <select class="competence-base flexrow" type="text" name="data.range" value="{{data.range}}" data-dtype="String">

View File

@ -15,6 +15,12 @@
{{editor content=data.statistics target="data.statistics" button=true owner=owner editable=editable}} {{editor content=data.statistics target="data.statistics" button=true owner=owner editable=editable}}
</div> </div>
<label class="generic-label">Abilities</label> <label class="generic-label">Abilities</label>
{{#each data.abilities as |ability idx|}}
<label name="data.abilities[{{idx}}].name"><a class="view-ability" data-spec-index="{{idx}}">{{ability.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-ability padd-left" data-spec-index="{{idx}}" title="Delete Spec"><i class="fas fa-trash"></i></a>
</div>
{{/each}}
<div class="small-editor item-text-long-line"> <div class="small-editor item-text-long-line">
{{editor content=data.abilities target="data.abilities" button=true owner=owner editable=editable}} {{editor content=data.abilities target="data.abilities" button=true owner=owner editable=editable}}
</div> </div>

View File

@ -12,18 +12,88 @@
<section class="sheet-body"> <section class="sheet-body">
<div class="tab" data-group="primary"> <div class="tab" data-group="primary">
<ul>
<li class="flexrow"><label class="generic-label">Stat increase 1</label>
<select class="competence-base flexrow" type="text" name="data.statincrease1" value="{{data.statincrease1}}" data-dtype="String">
{{#select data.statincrease1}}
{{> systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html notapplicable=false mr=false}}
{{/select}}
</select>
</li>
<li class="flexrow"><label class="generic-label">Stat increase 2</label>
<select class="competence-base flexrow" type="text" name="data.statincrease2" value="{{data.statincrease2}}" data-dtype="String">
{{#select data.statincrease2}}
{{> systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html notapplicable=false mr=false}}
{{/select}}
</select>
</li>
<li class="flexrow"><label class="generic-label">Specialisation at +1</label>
</li>
<ul class="ul-level1">
<li class="flexrow"><div class="drop-spec1"><label>Drop Specialisations here !</label></div>
</li>
{{#each data.specialisationsplus1 as |spec idx|}}
<li class="flexrow">
<label name="data.specialisationsplus1[{{idx}}].name"><a class="view-subitem" data-type="specialisationsplus1" data-index="{{idx}}">{{spec.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="specialisationsplus1" data-index="{{idx}}" title="Delete Spec"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
<li class="flexrow"><label class="generic-label">Special perk</label>
{{#each data.specialperk as |perk idx|}}
<label name="data.specialperk[{{idx}}].name"><a class="view-subitem" data-type="specialperk" data-index="{{idx}}">{{perk.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-spec-index="{{idx}}" title="Delete Perk"><i class="fas fa-trash"></i></a>
</div>
{{/each}}
</li>
<li class="flexrow"><label class="generic-label">Statistic increase (Choose 2 at +1 DT)</label>
</li>
<ul class="ul-level1">
<li class="flexrow">
{{#each data.statincreasechoice as |stat idx|}}
<label name="statchoice{{idx}}">{{stat.name}}</label>
<label class="attribute-value checkbox"><input type="checkbox" class="stat-choice-flag" data-stat-idx="{{idx}}" {{checked stat.flag}}/></label>
{{/each}}
</li>
</ul>
<li class="flexrow"><label class="generic-label">Available specialisations (Choose 1 at +2 DT, Choose 2 at +1 DT)</label>
</li>
<ul class="ul-level1">
<li class="flexrow"><div class="drop-spec2"><label>Drop Specialisations here !</label></div>
</li>
{{#each data.specincrease as |spec idx|}}
<li class="flexrow">
<label name="data.specincrease[{{idx}}].name"><a class="view-subitem" data-type="specincrease" data-index="{{idx}}">{{spec.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="specincrease" data-index="{{idx}}" title="Delete Spec"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</li>
<li class="flexrow"><label class="generic-label">Available perks (Choose 2)</label>
</li>
<ul class="ul-level1">
<li class="flexrow"><div class="drop-perk2"><label>Drop Perks here !</label></div>
</li>
{{#each data.perks as |perk idx|}}
<li class="flexrow">
<label name="data.perk[{{idx}}].name"><a class="view-subitem" data-type="perks" data-index="{{idx}}">{{perk.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="perks" data-index="{{idx}}" title="Delete Perk"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</li>
</ul>
<label class="generic-label">Description</label> <label class="generic-label">Description</label>
<div class="small-editor item-text-long-line"> <div class="small-editor item-text-long-line">
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}} {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
</div> </div>
<label class="generic-label">Abilities</label>
<div class="small-editor item-text-long-line">
{{editor content=data.abilities target="data.abilities" button=true owner=owner editable=editable}}
</div>
<label class="generic-label">Statistics</label>
<div class="small-editor item-text-long-line">
{{editor content=data.statistics target="data.statistics" button=true owner=owner editable=editable}}
</div>
</div> </div>
</section> </section>