Fix various issues

This commit is contained in:
sladecraven 2021-12-16 21:41:09 +01:00
parent 71d61f1387
commit c1849edaf4
7 changed files with 105 additions and 22 deletions

View File

@ -256,7 +256,39 @@ export class PegasusItemSheet extends ItemSheet {
await this.object.update( { 'data.specialperk': perkArray} ); await this.object.update( { 'data.specialperk': perkArray} );
} }
} }
/* -------------------------------------------- */
async addPower( event, item, dataItem) {
let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length );
if ( event.toElement.className == 'drop-spec-power') {
let powArray = duplicate(this.object.data.data.powers);
powArray.push( newItem );
await this.object.update( { 'data.powers': powArray} );
}
}
/* -------------------------------------------- */
async addAbilityPower( event, item, dataItem) {
let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length );
if ( event.toElement.className == 'drop-ability-power') {
let powArray = duplicate(this.object.data.data.powersgained);
powArray.push( newItem );
await this.object.update( { 'data.powersgained': powArray} );
}
}
/* -------------------------------------------- */
async addAbilitySpec( event, item, dataItem) {
let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length );
if ( event.toElement.className == 'drop-ability-spec') {
let powArray = duplicate(this.object.data.data.specialisations);
powArray.push( newItem );
await this.object.update( { 'data.specialisations': powArray} );
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDrop(event) { async _onDrop(event) {
//console.log(event); //console.log(event);
@ -270,6 +302,29 @@ export class PegasusItemSheet extends ItemSheet {
} }
} }
} }
if (this.object.type == 'specialisation' ) {
let data = event.dataTransfer.getData('text/plain');
if (data) {
let dataItem = JSON.parse( data );
let item = await this.searchItem( dataItem);
if ( item.data.type == 'power') {
return this.addPower( event, item, dataItem);
}
}
}
if (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 == 'power') {
return this.addAbilityPower( event, item, dataItem);
}
if ( item.data.type == 'specialisation') {
return this.addAbilitySpec( event, item, dataItem);
}
}
}
if (this.object.type == 'perk' || this.object.type == 'ability') { if (this.object.type == 'perk' || this.object.type == 'ability') {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');

View File

@ -1147,6 +1147,9 @@ ul, li {
padding-left: 2rem; padding-left: 2rem;
} }
.drop-ability-power,
.drop-ability-spec,
.drop-spec-power,
.drop-abilities, .drop-abilities,
.drop-specialperk1, .drop-specialperk1,
.drop-perk2, .drop-perk2,

View File

@ -50,9 +50,9 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 17, "templateVersion": 18,
"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.17", "version": "0.0.18",
"background" : "./images/ui/pegasus_welcome_page.webp" "background" : "./images/ui/pegasus_welcome_page.webp"
} }

View File

@ -158,8 +158,8 @@
"otherdice": 0, "otherdice": 0,
"statusaffected": "", "statusaffected": "",
"statusmodifier": 0, "statusmodifier": 0,
"powergained": 0, "powersgained": [],
"specialisation": [ {"name": "None"}], "specialisations": [],
"aoe": "", "aoe": "",
"description": "" "description": ""
}, },

View File

@ -20,21 +20,25 @@
<li class="flexrow"><label class="generic-label">Stat modifier</label> <li class="flexrow"><label class="generic-label">Stat modifier</label>
<select class="competence-base flexrow" type="text" name="data.statmodifier" value="{{data.statmodifier}}" data-dtype="Number"> <select class="competence-base flexrow" type="text" name="data.statmodifier" value="{{data.statmodifier}}" data-dtype="Number">
{{#select data.statmodifier}} {{#select data.statmodifier}}
<option value="-3">-3</option>
<option value="-2">-2</option>
<option value="-1">-1</option> <option value="-1">-1</option>
<option value="0">0</option> <option value="0">0</option>
<option value="+1">+1</option> <option value="+1">+1</option>
<option value="+2">+2</option>
<option value="+3">+3</option>
{{/select}} {{/select}}
</select> </select>
</li> </li>
<li class="flexrow"><label class="generic-label">Stat level increase</label> <li class="flexrow"><label class="generic-label">Stat level increase</label>
<select class="competence-base flexrow" type="text" name="data.statlevelincrease" value="{{data.statlevelincrease}}" data-dtype="Number"> <select class="competence-base flexrow" type="text" name="data.statlevelincrease" value="{{data.statlevelincrease}}" data-dtype="Number">
{{#select data.statlevelincrease}} {{#select data.statlevelincrease}}
<option value="0">0</option> <option value="0">0 DT</option>
<option value="+1">+1</option> <option value="+1">+1 DT</option>
<option value="+2">+2</option> <option value="+2">+2 DT</option>
<option value="+3">+3</option> <option value="+3">+3 DT</option>
<option value="+4">+4</option> <option value="+4">+4 DT</option>
<option value="+5">+5</option> <option value="+5">+5 DT</option>
{{/select}} {{/select}}
</select> </select>
</li> </li>
@ -69,15 +73,36 @@
</select> </select>
</li> </li>
<li class="flexrow"><label class="generic-label">Power Gained</label> <li class="flexrow"><label class="generic-label">Power Gained</label>
<input type="text" class="input-numeric-short padd-right" name="data.powergained" value="{{data.powergained}}" data-dtype="Number"/> </li>
<li>
<ul class="ul-level1">
<li class="flexrow"><div class="drop-ability-power"><label>Drop Powers here !</label></div>
</li>
{{#each data.powersgained as |power idx|}}
<li class="flexrow">
<label name="data.powersgained[{{idx}}].name"><a class="view-subitem" data-type="powersgained" data-index="{{idx}}">{{power.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="powersgained" data-index="{{idx}}" title="Delete Power"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</li> </li>
<li class="flexrow"><label class="generic-label">Specialisation Gained</label> <li class="flexrow"><label class="generic-label">Specialisation Gained</label>
{{#each data.specialisation as |spec idx|}} <li>
<label name="data.specialisation[{{idx}}].name"><a class="view-spec" data-spec-index="{{idx}}">{{spec.name}}</a></label> <ul class="ul-level1">
<div class="item-controls padd-left"> <li class="flexrow"><div class="drop-ability-spec"><label>Drop Specialisations here !</label></div>
<a class="item-control delete-spec padd-left" data-spec-index="{{idx}}" title="Delete Spec"><i class="fas fa-trash"></i></a> </li>
</div> {{#each data.specialisations as |spec idx|}}
{{/each}} <li class="flexrow">
<label name="data.specialisations[{{idx}}].name"><a class="view-subitem" data-type="specialisations" data-index="{{idx}}">{{spec.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="specialisations" data-index="{{idx}}" title="Delete Specialisation"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</li>
</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

@ -28,11 +28,11 @@
</select> </select>
</li> </li>
<li class="flexrow"> <li class="flexrow">
<label class="generic-label">Specialisation at +1</label> <label class="generic-label">Starting Specialisation at +1 DT</label>
</li> </li>
<ul class="ul-level1"> <ul class="ul-level1">
<li class="flexrow"> <li class="flexrow">
<label class="generic-label">Specific specialisation choose message : </label> <label class="generic-label">Starting Specialisations : </label>
</li> </li>
<li class="flexrow"> <li class="flexrow">
<input type="text" class="padd-right" name="data.messagespecplus1" value="{{data.messagespecplus1}}" data-dtype="String"/> <input type="text" class="padd-right" name="data.messagespecplus1" value="{{data.messagespecplus1}}" data-dtype="String"/>
@ -49,7 +49,7 @@
{{/each}} {{/each}}
</ul> </ul>
<li class="flexrow"> <li class="flexrow">
<label class="generic-label">Special perk</label> <label class="generic-label">Role Perk</label>
</li> </li>
<ul class="ul-level1"> <ul class="ul-level1">
<li class="flexrow"><div class="drop-specialperk1"><label>Drop Perks here !</label></div> <li class="flexrow"><div class="drop-specialperk1"><label>Drop Perks here !</label></div>

View File

@ -37,7 +37,7 @@
<li class="flexrow"><label class="generic-label">Available Powers</label> <li class="flexrow"><label class="generic-label">Available Powers</label>
</li> </li>
<ul class="ul-level1"> <ul class="ul-level1">
<li class="flexrow"><div class="drop-perk2"><label>Drop Powers here !</label></div> <li class="flexrow"><div class="drop-spec-power"><label>Drop Powers here !</label></div>
</li> </li>
{{#each data.powers as |power idx|}} {{#each data.powers as |power idx|}}
<li class="flexrow"> <li class="flexrow">