Allow items

This commit is contained in:
sladecraven 2022-02-16 17:43:51 +01:00
parent 7da8f7d9f1
commit 04afb7a424
15 changed files with 348 additions and 194 deletions

View File

@ -116,6 +116,17 @@ export class PegasusActorSheet extends ActorSheet {
this.actor.specPowerDeactivate( itemId) this.actor.specPowerDeactivate( itemId)
}); });
html.find('.equip-activate').click(ev => {
const li = $(ev.currentTarget).parents(".item")
let itemId = li.data("item-id")
this.actor.equipActivate( itemId)
});
html.find('.equip-deactivate').click(ev => {
const li = $(ev.currentTarget).parents(".item")
let itemId = li.data("item-id")
this.actor.equipDeactivate( itemId)
});
html.find('.effect-used').click(ev => { html.find('.effect-used').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");

View File

@ -435,6 +435,36 @@ export class PegasusActor extends Actor {
this.updateEmbeddedDocuments('Item', [{ _id: specId, 'data.powersactivated': false }]) this.updateEmbeddedDocuments('Item', [{ _id: specId, 'data.powersactivated': false }])
} }
/* -------------------------------------------- */
equipActivate(itemId) {
let item = this.items.get(itemId)
if (item) {
let effects = []
for (let effect of item.data.data.effects) {
effect.data.itemId = itemId // Keep link
effects.push(effect)
}
if (effects.length > 0) {
this.createEmbeddedDocuments('Item', effects )
}
this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.activated': true }])
}
}
/* -------------------------------------------- */
equipDeactivate(itemId) {
let toRem = []
for (let item of this.data.items) {
if (item.data.data.itemId && item.data.data.itemId == itemId) {
toRem.push(item.id)
}
}
if (toRem.length > 0) {
this.deleteEmbeddedDocuments('Item', toRem)
}
this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.activated': false }])
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async perkEffectUsed(itemId) { async perkEffectUsed(itemId) {
let effect = this.items.get(itemId) let effect = this.items.get(itemId)
@ -547,6 +577,10 @@ export class PegasusActor extends Actor {
await this.update({ 'data.nrg': nrg }) await this.update({ 'data.nrg': nrg })
} }
this.disableWeaverPerk(item) this.disableWeaverPerk(item)
PegasusUtility.createChatWithRollMode(item.name, {
content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-perk-ready.html`, { name: this.name, perk: item })
});
} }
if (status == "activated") { if (status == "activated") {
// Add effects linked to the perk // Add effects linked to the perk
@ -875,10 +909,10 @@ export class PegasusActor extends Actor {
&& (effect.data.stataffected != "notapplicable" || effect.data.specaffected.length > 0) && (effect.data.stataffected != "notapplicable" || effect.data.specaffected.length > 0)
&& effect.data.stataffected != "special") { && effect.data.stataffected != "special") {
if (effect.data.effectstatlevel) { if (effect.data.effectstatlevel) {
if ( effect.data.effectstat == rollData.statKey ) { if (effect.data.effectstat == rollData.statKey) {
effect.data.effectlevel = rollData.statDicesLevel effect.data.effectlevel = rollData.statDicesLevel
} }
if ( effect.data.stataffected == "all") { // Real nightmare if (effect.data.stataffected == "all") { // Real nightmare
effect.data.effectlevel = this.data.data.statistics[effect.data.effectstat].value effect.data.effectlevel = this.data.data.statistics[effect.data.effectstat].value
} }
} }

View File

@ -7,16 +7,16 @@ import { PegasusUtility } from "./pegasus-utility.js";
export class PegasusItemSheet extends ItemSheet { export class PegasusItemSheet extends ItemSheet {
/** @override */ /** @override */
static get defaultOptions() { static get defaultOptions() {
return mergeObject(super.defaultOptions, { return mergeObject(super.defaultOptions, {
classes: ["fvtt-pegasus-rpg", "sheet", "item"], classes: ["fvtt-pegasus-rpg", "sheet", "item"],
template: "systems/fvtt-pegasus-rpg/templates/item-sheet.html", template: "systems/fvtt-pegasus-rpg/templates/item-sheet.html",
dragDrop: [{dragSelector: null, dropSelector: null}], dragDrop: [{ dragSelector: null, dropSelector: null }],
width: 620, width: 620,
height: 550 height: 550
//tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}] //tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
}); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -28,19 +28,19 @@ export class PegasusItemSheet extends ItemSheet {
{ {
class: "post", class: "post",
icon: "fas fa-comment", icon: "fas fa-comment",
onclick: ev => {} onclick: ev => { }
}) })
return buttons return buttons
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
setPosition(options={}) { setPosition(options = {}) {
const position = super.setPosition(options); const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body"); const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192; const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight); sheetBody.css("height", bodyHeight);
if ( this.item.type.includes('weapon')) { if (this.item.type.includes('weapon')) {
position.width = 640; position.width = 640;
} }
return position; return position;
@ -114,8 +114,8 @@ export class PegasusItemSheet extends ItemSheet {
let field = $(ev.currentTarget).data('type'); let field = $(ev.currentTarget).data('type');
let idx = Number($(ev.currentTarget).data('index')); let idx = Number($(ev.currentTarget).data('index'));
let itemData = this.object.data.data[field][idx]; let itemData = this.object.data.data[field][idx];
if ( itemData.name != 'None') { if (itemData.name != 'None') {
let spec = await Item.create(itemData, {temporary: true}); let spec = await Item.create(itemData, { temporary: true });
spec.data.origin = "embeddedItem"; spec.data.origin = "embeddedItem";
new PegasusItemSheet(spec).render(true); new PegasusItemSheet(spec).render(true);
} }
@ -127,22 +127,22 @@ export class PegasusItemSheet extends ItemSheet {
let idx = Number($(ev.currentTarget).data('index')); let idx = Number($(ev.currentTarget).data('index'));
let oldArray = this.object.data.data[field]; let oldArray = this.object.data.data[field];
let itemData = this.object.data.data[field][idx]; let itemData = this.object.data.data[field][idx];
if ( itemData.name != 'None') { if (itemData.name != 'None') {
let newArray = []; let newArray = [];
for( var i = 0; i < oldArray.length; i++) { for (var i = 0; i < oldArray.length; i++) {
if ( i != idx) { if (i != idx) {
newArray.push( oldArray[i]); newArray.push(oldArray[i]);
} }
} }
this.object.update( { [`data.${field}`]: newArray} ); this.object.update({ [`data.${field}`]: newArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async manageSpec( ) { async manageSpec() {
let itemData = this.object.data.data.specialisation[0]; let itemData = this.object.data.data.specialisation[0];
if ( itemData.name != 'None') { if (itemData.name != 'None') {
let spec = await Item.create(itemData, {temporary: true}); let spec = await Item.create(itemData, { temporary: true });
spec.data.origin = "embeddedItem"; spec.data.origin = "embeddedItem";
new PegasusItemSheet(spec).render(true); new PegasusItemSheet(spec).render(true);
} }
@ -150,7 +150,7 @@ export class PegasusItemSheet extends ItemSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
@ -164,19 +164,19 @@ export class PegasusItemSheet extends ItemSheet {
item.sheet.render(true); item.sheet.render(true);
}); });
html.find('.delete-spec').click( ev => { html.find('.delete-spec').click(ev => {
this.object.update( {"data.specialisation": [ { name: 'None'} ]} ); this.object.update({ "data.specialisation": [{ name: 'None' }] });
}); });
html.find('.delete-subitem').click( ev => { html.find('.delete-subitem').click(ev => {
this.deleteSubitem( ev ); this.deleteSubitem(ev);
}); });
html.find('.stat-choice-flag').click( ev => { html.find('.stat-choice-flag').click(ev => {
let idx = $(ev.currentTarget).data("stat-idx"); let idx = $(ev.currentTarget).data("stat-idx");
let array = duplicate(this.object.data.data.statincreasechoice); let array = duplicate(this.object.data.data.statincreasechoice);
array[Number(idx)].flag = !array[Number(idx)].flag; array[Number(idx)].flag = !array[Number(idx)].flag;
this.object.update( {"data.statincreasechoice": array} ); this.object.update({ "data.statincreasechoice": array });
}); });
// Update Inventory Item // Update Inventory Item
@ -187,11 +187,11 @@ export class PegasusItemSheet extends ItemSheet {
}); });
html.find('.view-subitem').click(ev => { html.find('.view-subitem').click(ev => {
this.viewSubitem( ev ); this.viewSubitem(ev);
}); });
html.find('.view-spec').click(ev => { html.find('.view-spec').click(ev => {
this.manageSpec( ); this.manageSpec();
}); });
} }
@ -199,273 +199,294 @@ export class PegasusItemSheet extends ItemSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
async addAbility(event, item, dataItem) { async addAbility(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
console.log("ABB", event, item, dataItem) console.log("ABB", event, item, dataItem)
if ( event.toElement.className == 'drop-abilities') { if (event.toElement.className == 'drop-abilities') {
let abilityArray = duplicate(this.object.data.data.abilities); let abilityArray = duplicate(this.object.data.data.abilities);
abilityArray.push( newItem); abilityArray.push(newItem);
await this.object.update( { 'data.abilities': abilityArray} ); await this.object.update({ 'data.abilities': abilityArray });
} }
if ( event.toElement.className == 'drop-optionnal-abilities') { if (event.toElement.className == 'drop-optionnal-abilities') {
let abilityArray = duplicate(this.object.data.data.optionnalabilities); let abilityArray = duplicate(this.object.data.data.optionnalabilities);
abilityArray.push( newItem); abilityArray.push(newItem);
await this.object.update( { 'data.optionnalabilities': abilityArray} ); await this.object.update({ 'data.optionnalabilities': abilityArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addRacePerk(event, item, dataItem) { async addRacePerk(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
if ( event.toElement.className == 'drop-race-perk') { if (event.toElement.className == 'drop-race-perk') {
let perkArray = duplicate(this.object.data.data.perks); let perkArray = duplicate(this.object.data.data.perks);
perkArray.push( newItem); perkArray.push(newItem);
await this.object.update( { 'data.perks': perkArray} ); await this.object.update({ 'data.perks': perkArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addSpecialisation(item, dataItem) { async addSpecialisation(item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
let specArray = [ newItem ]; let specArray = [newItem];
await this.object.update( { 'data.specialisation': specArray} ); await this.object.update({ 'data.specialisation': specArray });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addRoleSpecialisation(event, item, dataItem) { async addRoleSpecialisation(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
console.log("Add spec", event, newItem); console.log("Add spec", event, newItem);
if ( event.toElement.className == 'drop-spec1') { if (event.toElement.className == 'drop-spec1') {
let specArray = duplicate(this.object.data.data.specialisationsplus1); let specArray = duplicate(this.object.data.data.specialisationsplus1);
specArray.push( newItem ); specArray.push(newItem);
await this.object.update( { 'data.specialisationsplus1': specArray} ); await this.object.update({ 'data.specialisationsplus1': specArray });
} }
if ( event.toElement.className == 'drop-spec2') { if (event.toElement.className == 'drop-spec2') {
let specArray = duplicate(this.object.data.data.specincrease); let specArray = duplicate(this.object.data.data.specincrease);
specArray.push( newItem ); specArray.push(newItem);
await this.object.update( { 'data.specincrease': specArray} ); await this.object.update({ 'data.specincrease': specArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addRolePerk(event, item, dataItem) { async addRolePerk(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
console.log("Add spec", event, newItem); console.log("Add spec", event, newItem);
if ( event.toElement.className == 'drop-perk2') { if (event.toElement.className == 'drop-perk2') {
let perkArray = duplicate(this.object.data.data.perks); let perkArray = duplicate(this.object.data.data.perks);
perkArray.push( newItem ); perkArray.push(newItem);
await this.object.update( { 'data.perks': perkArray} ); await this.object.update({ 'data.perks': perkArray });
} }
if ( event.toElement.className == 'drop-specialperk1') { if (event.toElement.className == 'drop-specialperk1') {
let perkArray = duplicate(this.object.data.data.specialperk); let perkArray = duplicate(this.object.data.data.specialperk);
perkArray.push( newItem ); perkArray.push(newItem);
await this.object.update( { 'data.specialperk': perkArray} ); await this.object.update({ 'data.specialperk': perkArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addPower( event, item, dataItem) { async addPower(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
if ( event.toElement.className == 'drop-spec-power') { if (event.toElement.className == 'drop-spec-power') {
let powArray = duplicate(this.object.data.data.powers); let powArray = duplicate(this.object.data.data.powers);
powArray.push( newItem ); powArray.push(newItem);
await this.object.update( { 'data.powers': powArray} ); await this.object.update({ 'data.powers': powArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addAbilityPower( event, item, dataItem) { async addAbilityPower(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
if ( event.toElement.className == 'drop-ability-power') { if (event.toElement.className == 'drop-ability-power') {
let powArray = duplicate(this.object.data.data.powersgained); let powArray = duplicate(this.object.data.data.powersgained);
powArray.push( newItem ); powArray.push(newItem);
await this.object.update( { 'data.powersgained': powArray} ); await this.object.update({ 'data.powersgained': powArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addAbilityEffect( event, item, dataItem) { async addAbilityEffect(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
if ( event.toElement.className == 'drop-ability-effect') { if (event.toElement.className == 'drop-ability-effect') {
let powArray = duplicate(this.object.data.data.effectsgained); let powArray = duplicate(this.object.data.data.effectsgained);
powArray.push( newItem ); powArray.push(newItem);
await this.object.update( { 'data.effectsgained': powArray} ); await this.object.update({ 'data.effectsgained': powArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addAbilitySpec( event, item, dataItem) { async addAbilitySpec(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
if ( event.toElement.className == 'drop-ability-spec') { if (event.toElement.className == 'drop-ability-spec') {
let powArray = duplicate(this.object.data.data.specialisations); let powArray = duplicate(this.object.data.data.specialisations);
powArray.push( newItem ); powArray.push(newItem);
await this.object.update( { 'data.specialisations': powArray} ); await this.object.update({ 'data.specialisations': powArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addAbilityWeaponArmor( event, item, dataItem) { async addAbilityWeaponArmor(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
newItem._id = randomID( dataItem.id.length ); newItem._id = randomID(dataItem.id.length);
if ( event.toElement.className == 'drop-ability-weapon') { if (event.toElement.className == 'drop-ability-weapon') {
let weaponArray = duplicate(this.object.data.data.attackgained); let weaponArray = duplicate(this.object.data.data.attackgained);
weaponArray.push( newItem ); weaponArray.push(newItem);
await this.object.update( { 'data.attackgained': weaponArray} ); await this.object.update({ 'data.attackgained': weaponArray });
} }
if ( event.toElement.className == 'drop-ability-armor') { if (event.toElement.className == 'drop-ability-armor') {
let armorArray = duplicate(this.object.data.data.armorgained); let armorArray = duplicate(this.object.data.data.armorgained);
armorArray.push( newItem ); armorArray.push(newItem);
await this.object.update( { 'data.armorgained': armorArray} ); await this.object.update({ 'data.armorgained': armorArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addPerkSpecialisation( event, item, dataItem) { async addPerkSpecialisation(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
if ( event.toElement.className == 'drop-spec-perk') { if (event.toElement.className == 'drop-spec-perk') {
//console.log("PER SPEC", event) //console.log("PER SPEC", event)
let key = event.toElement.dataset["key"]; let key = event.toElement.dataset["key"];
if ( key == 'affectedspec') { if (key == 'affectedspec') {
await this.object.update( { 'data.features.affectedspec.value': newItem.name} ); await this.object.update({ 'data.features.affectedspec.value': newItem.name });
} else { } else {
await this.object.update( { 'data.features.gainspecdice.value': newItem.name} ); await this.object.update({ 'data.features.gainspecdice.value': newItem.name });
} }
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addPerkEffect( event, item, dataItem) { async addPerkEffect(event, item, dataItem) {
let newItem = duplicate(item.data) let newItem = duplicate(item.data)
if ( event.toElement.className == 'drop-perk-effect') { if (event.toElement.className == 'drop-perk-effect') {
let effectArray = duplicate(this.object.data.data.effectsgained) let effectArray = duplicate(this.object.data.data.effectsgained)
effectArray.push( newItem ) effectArray.push(newItem)
await this.object.update( { 'data.effectsgained': effectArray} ) await this.object.update({ 'data.effectsgained': effectArray })
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addEffectPower( event, item, dataItem) { async addEffectPower(event, item, dataItem) {
let newItem = duplicate(item.data) let newItem = duplicate(item.data)
if ( event.toElement.className == 'drop-power-effect') { if (event.toElement.className == 'drop-power-effect') {
let effectArray = duplicate(this.object.data.data.effectsgained) let effectArray = duplicate(this.object.data.data.effectsgained)
effectArray.push( newItem ); effectArray.push(newItem);
await this.object.update( { 'data.effectsgained': effectArray} ) await this.object.update({ 'data.effectsgained': effectArray })
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async addEffectSpec( event, item, dataItem) { async addEffectSpec(event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
if ( event.toElement.className == 'drop-effect-spec') { if (event.toElement.className == 'drop-effect-spec') {
let specArray = duplicate(this.object.data.data.recoveryrollspec); let specArray = duplicate(this.object.data.data.recoveryrollspec);
specArray.push( newItem ); specArray.push(newItem);
await this.object.update( { 'data.recoveryrollspec': specArray} ); await this.object.update({ 'data.recoveryrollspec': specArray });
} }
if ( event.toElement.className =='drop-effect-specaffected') { if (event.toElement.className == 'drop-effect-specaffected') {
let specArray = duplicate(this.object.data.data.specaffected); let specArray = duplicate(this.object.data.data.specaffected);
specArray.push( newItem ); specArray.push(newItem);
await this.object.update( { 'data.specaffected': specArray} ); await this.object.update({ 'data.specaffected': specArray });
}
}
/* -------------------------------------------- */
async addEffectItem(event, item, dataItem) {
let newItem = duplicate(item.data);
if (event.toElement.className == 'drop-equipment-effect') {
let effectArray = duplicate(this.object.data.data.effects);
effectArray.push(newItem);
await this.object.update({ 'data.effects': effectArray });
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDrop(event) { async _onDrop(event) {
if (this.object.type == 'power' ) { if (this.object.type == 'weapon' || this.object.type == 'shield' || this.object.type == 'armor' || this.object.type == 'shield') {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {
let dataItem = JSON.parse( data ); let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem( dataItem); let item = await PegasusUtility.searchItem(dataItem);
if ( item.data.type == 'effect') { if (item.data.type == 'effect') {
return this.addEffectPower( event, item, dataItem); return this.addEffectItem(event, item, dataItem);
} }
} }
} }
if (this.object.type == 'effect' ) { if (this.object.type == 'power') {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {
let dataItem = JSON.parse( data ); let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem( dataItem); let item = await PegasusUtility.searchItem(dataItem);
if ( item.data.type == 'specialisation') { if (item.data.type == 'effect') {
return this.addEffectSpec( event, item, dataItem); return this.addEffectPower(event, item, dataItem);
} }
} }
} }
if (this.object.type == 'race' ) { if (this.object.type == 'effect') {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {
let dataItem = JSON.parse( data ); let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem( dataItem); let item = await PegasusUtility.searchItem(dataItem);
if ( item.data.type == 'ability') { if (item.data.type == 'specialisation') {
return this.addAbility( event, item, dataItem); return this.addEffectSpec(event, item, dataItem);
}
if ( item.data.type == 'perk') {
return this.addRacePerk( event, item, dataItem);
} }
} }
} }
if (this.object.type == 'perk' ) { if (this.object.type == 'race') {
let data = event.dataTransfer.getData('text/plain');
if (data) {
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'ability') {
return this.addAbility(event, item, dataItem);
}
if (item.data.type == 'perk') {
return this.addRacePerk(event, item, dataItem);
}
}
}
if (this.object.type == 'perk') {
let data = event.dataTransfer.getData('text/plain') let data = event.dataTransfer.getData('text/plain')
if (data) { if (data) {
let dataItem = JSON.parse( data ); let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem( dataItem) let item = await PegasusUtility.searchItem(dataItem)
if ( item.data.type == 'specialisation') { if (item.data.type == 'specialisation') {
return this.addPerkSpecialisation( event, item, dataItem) return this.addPerkSpecialisation(event, item, dataItem)
} }
if ( item.data.type == 'effect') { if (item.data.type == 'effect') {
return this.addPerkEffect( event, item, dataItem); return this.addPerkEffect(event, item, dataItem);
} }
} }
} }
if (this.object.type == 'specialisation' ) { if (this.object.type == 'specialisation') {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {
let dataItem = JSON.parse( data ); let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem( dataItem); let item = await PegasusUtility.searchItem(dataItem);
if ( item.data.type == 'power') { if (item.data.type == 'power') {
return this.addPower( event, item, dataItem); return this.addPower(event, item, dataItem);
} }
} }
} }
if (this.object.type == 'ability' ) { if (this.object.type == 'ability') {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {
let dataItem = JSON.parse( data ); let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem( dataItem); let item = await PegasusUtility.searchItem(dataItem);
if ( item.data.type == 'effect') { if (item.data.type == 'effect') {
return this.addAbilityEffect( event, item, dataItem); return this.addAbilityEffect(event, item, dataItem);
} }
if ( item.data.type == 'power') { if (item.data.type == 'power') {
return this.addAbilityPower( event, item, dataItem); return this.addAbilityPower(event, item, dataItem);
} }
if ( item.data.type == 'specialisation') { if (item.data.type == 'specialisation') {
return this.addAbilitySpec( event, item, dataItem); return this.addAbilitySpec(event, item, dataItem);
} }
if ( item.data.type == 'weapon' || item.data.type == 'armor') { if (item.data.type == 'weapon' || item.data.type == 'armor') {
return this.addAbilityWeaponArmor( event, item, dataItem); return this.addAbilityWeaponArmor(event, item, dataItem);
} }
} }
} }
if (this.object.type == 'role' ) { if (this.object.type == 'role') {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {
let dataItem = JSON.parse( data ); let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem( dataItem); let item = await PegasusUtility.searchItem(dataItem);
if ( item.data.type == 'specialisation') { if (item.data.type == 'specialisation') {
return this.addRoleSpecialisation( event, item, dataItem); return this.addRoleSpecialisation(event, item, dataItem);
} }
if ( item.data.type == 'perk') { if (item.data.type == 'perk') {
return this.addRolePerk( event, item, dataItem); return this.addRolePerk(event, item, dataItem);
} }
} }
} }

View File

@ -187,7 +187,8 @@ export class PegasusUtility {
'systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html',
'systems/fvtt-pegasus-rpg/templates/partial-options-level.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-level.html',
'systems/fvtt-pegasus-rpg/templates/partial-options-range.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-range.html',
'systems/fvtt-pegasus-rpg/templates/partial-options-equipment-types.html' 'systems/fvtt-pegasus-rpg/templates/partial-options-equipment-types.html',
'systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html'
] ]
return loadTemplates(templatePaths); return loadTemplates(templatePaths);
} }

View File

@ -1164,6 +1164,7 @@ ul, li {
padding-left: 2rem; padding-left: 2rem;
} }
.drop-equipment-effect,
.drop-power-effect, .drop-power-effect,
.drop-perk-effect, .drop-perk-effect,
.drop-ability-effect, .drop-ability-effect,

View File

@ -180,9 +180,9 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 78, "templateVersion": 80,
"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.4.14", "version": "0.4.16",
"background" : "./images/ui/pegasus_welcome_page.webp" "background" : "./images/ui/pegasus_welcome_page.webp"
} }

View File

@ -339,6 +339,8 @@
"idr": "", "idr": "",
"equipped": false, "equipped": false,
"locationprotected": "", "locationprotected": "",
"effects": [],
"activated": false,
"description":"" "description":""
}, },
"shield": { "shield": {
@ -348,6 +350,8 @@
"cost": 0, "cost": 0,
"idr": "", "idr": "",
"equipped": false, "equipped": false,
"effects": [],
"activated": false,
"description":"" "description":""
}, },
"equipment": { "equipment": {
@ -362,6 +366,8 @@
"statdice": false, "statdice": false,
"bonusdice": false, "bonusdice": false,
"otherdice": false, "otherdice": false,
"effects": [],
"activated": false,
"description":"" "description":""
}, },
"money" : { "money" : {
@ -390,6 +396,8 @@
"ammocurrent": 0, "ammocurrent": 0,
"ammomax": 0, "ammomax": 0,
"equipped": false, "equipped": false,
"effects": [],
"activated": false,
"description": "" "description": ""
} }
} }

View File

@ -406,6 +406,18 @@
<img class="sheet-competence-img" src="{{equip.img}}" /> <img class="sheet-competence-img" src="{{equip.img}}" />
<span class="equipement-label">{{equip.name}}</span> <span class="equipement-label">{{equip.name}}</span>
<span class="equipement-label">{{upperFirst equip.data.type}}</span> <span class="equipement-label">{{upperFirst equip.data.type}}</span>
<span class="generic-label">Qty {{equip.data.quantity}}</span>
{{#if (count equip.data.effects)}}
{{#if equip.data.activated}}
<span class="stat-label"><a class="equip-deactivate">Deactivate</a></span>
{{else}}
<span class="stat-label"><a class="equip-activate">Activate</a></span>
{{/if}}
{{else}}
<span class="stat-label">&nbsp;</span>
{{/if}}
<span class="generic-label">Qty {{equip.data.quantity}}</span> <span class="generic-label">Qty {{equip.data.quantity}}</span>
<div class="item-controls"> <div class="item-controls">
<a class="item-control item-equip" title="Worn">{{#if equip.data.equipped}}<i <a class="item-control item-equip" title="Worn">{{#if equip.data.equipped}}<i
@ -426,6 +438,17 @@
<li class="item flexrow list-item" data-item-id="{{weapon._id}}"> <li class="item flexrow list-item" data-item-id="{{weapon._id}}">
<img class="sheet-competence-img" src="{{weapon.img}}" /> <img class="sheet-competence-img" src="{{weapon.img}}" />
<span class="equipement-label">{{weapon.name}}</span> <span class="equipement-label">{{weapon.name}}</span>
{{#if (count weapon.data.effects)}}
{{#if weapon.data.activated}}
<span class="stat-label"><a class="equip-deactivate">Deactivate</a></span>
{{else}}
<span class="stat-label"><a class="equip-activate">Activate</a></span>
{{/if}}
{{else}}
<span class="stat-label">&nbsp;</span>
{{/if}}
<div class="item-controls"> <div class="item-controls">
<a class="item-control item-equip" title="Worn">{{#if weapon.data.equipped}}<i <a class="item-control item-equip" title="Worn">{{#if weapon.data.equipped}}<i
class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a> class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
@ -445,6 +468,17 @@
<li class="item flexrow list-item" data-item-id="{{armor._id}}"> <li class="item flexrow list-item" data-item-id="{{armor._id}}">
<img class="sheet-competence-img" src="{{armor.img}}" /> <img class="sheet-competence-img" src="{{armor.img}}" />
<span class="equipement-label">{{armor.name}}</span> <span class="equipement-label">{{armor.name}}</span>
{{#if (count armor.data.effects)}}
{{#if armor.data.activated}}
<span class="stat-label"><a class="equip-deactivate">Deactivate</a></span>
{{else}}
<span class="stat-label"><a class="equip-activate">Activate</a></span>
{{/if}}
{{else}}
<span class="stat-label">&nbsp;</span>
{{/if}}
<div class="item-controls"> <div class="item-controls">
<a class="item-control item-equip" title="Worn">{{#if armor.data.equipped}}<i <a class="item-control item-equip" title="Worn">{{#if armor.data.equipped}}<i
class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a> class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
@ -457,6 +491,17 @@
<li class="item flexrow list-item" data-item-id="{{shield._id}}"> <li class="item flexrow list-item" data-item-id="{{shield._id}}">
<img class="sheet-competence-img" src="{{shield.img}}" /> <img class="sheet-competence-img" src="{{shield.img}}" />
<span class="equipement-label">{{shield.name}}</span> <span class="equipement-label">{{shield.name}}</span>
{{#if (count shield.data.effects)}}
{{#if shield.data.activated}}
<span class="stat-label"><a class="equip-deactivate">Deactivate</a></span>
{{else}}
<span class="stat-label"><a class="equip-activate">Activate</a></span>
{{/if}}
{{else}}
<span class="stat-label">&nbsp;</span>
{{/if}}
<div class="item-controls"> <div class="item-controls">
<a class="item-control item-equip" title="Worn">{{#if shield.data.equipped}}<i <a class="item-control item-equip" title="Worn">{{#if shield.data.equipped}}<i
class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a> class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>

View File

@ -0,0 +1,7 @@
<div class="post-item" data-transfer="{{transfer}}">
<h3><b>{{name}}</b></h3>
{{#if img}}
<img class="chat-img" src="{{img}}" title="{{name}}" />
{{/if}}
<div>{{name}} has Just Deactivated the Perk: {{perk.name}}, make sure to manually delete all Effects provided by this Perk from Targets.</div>
</div>

View File

@ -83,6 +83,7 @@
</li> </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"/>
</li> </li>
@ -99,6 +100,7 @@
{{/select}} {{/select}}
</select> </select>
</li> </li>
-->
<li class="flexrow"><label class="generic-label">Attacks Gained</label> <li class="flexrow"><label class="generic-label">Attacks Gained</label>
<li> <li>

View File

@ -30,6 +30,8 @@
<input type="text" class="" name="data.locationprotected" value="{{data.locationprotected}}" data-dtype="String"/> <input type="text" class="" name="data.locationprotected" value="{{data.locationprotected}}" data-dtype="String"/>
</li> </li>
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
<li class="flexrow"><label class="generic-label">Equipped ?</label> <li class="flexrow"><label class="generic-label">Equipped ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label> <label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label>
</li> </li>

View File

@ -43,6 +43,7 @@
<label class="attribute-value checkbox"><input type="checkbox" name="data.otherdice" {{checked data.otherdice}}/></label> <label class="attribute-value checkbox"><input type="checkbox" name="data.otherdice" {{checked data.otherdice}}/></label>
</li> </li>
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
<li class="flexrow"><label class="generic-label">Equipped ?</label> <li class="flexrow"><label class="generic-label">Equipped ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label> <label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label>

View File

@ -26,6 +26,9 @@
{{/select}} {{/select}}
</select> </select>
</li> </li>
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
<li class="flexrow"><label class="generic-label">Equipped ?</label> <li class="flexrow"><label class="generic-label">Equipped ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label> <label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label>
</li> </li>

View File

@ -88,6 +88,8 @@
</select> </select>
</li> </li>
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
<li class="flexrow"><label class="generic-label">Vehicle Damage Type Level</label> <li class="flexrow"><label class="generic-label">Vehicle Damage Type Level</label>
<input type="text" class="input-numeric-short padd-right" name="data.vehicledamagetypelevel" value="{{data.vehicledamagetypelevel}}" data-dtype="Number"/> <input type="text" class="input-numeric-short padd-right" name="data.vehicledamagetypelevel" value="{{data.vehicledamagetypelevel}}" data-dtype="Number"/>
</li> </li>

View File

@ -0,0 +1,16 @@
<li class="flexrow"><label class="generic-label">Effects</label>
</li>
<li>
<ul class="ul-level1">
<li class="flexrow"><div class="drop-equipment-effect"><label>Drop Effects here !</label></div>
</li>
{{#each data.effects as |effect idx|}}
<li class="flexrow">
<label name="data.effects[{{idx}}].name"><a class="view-subitem" data-type="effects" data-index="{{idx}}">{{effect.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="effects" data-index="{{idx}}" title="Delete Effect"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</li>