Allow items
This commit is contained in:
parent
7da8f7d9f1
commit
04afb7a424
@ -116,6 +116,17 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
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 => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
|
@ -435,6 +435,36 @@ export class PegasusActor extends Actor {
|
||||
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) {
|
||||
let effect = this.items.get(itemId)
|
||||
@ -547,6 +577,10 @@ export class PegasusActor extends Actor {
|
||||
await this.update({ 'data.nrg': nrg })
|
||||
}
|
||||
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") {
|
||||
// Add effects linked to the perk
|
||||
|
@ -373,9 +373,30 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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) {
|
||||
|
||||
if (this.object.type == 'weapon' || this.object.type == 'shield' || this.object.type == 'armor' || this.object.type == 'shield') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'effect') {
|
||||
return this.addEffectItem(event, item, dataItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'power') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
|
@ -187,7 +187,8 @@ export class PegasusUtility {
|
||||
'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-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);
|
||||
}
|
||||
|
@ -1164,6 +1164,7 @@ ul, li {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
|
||||
.drop-equipment-effect,
|
||||
.drop-power-effect,
|
||||
.drop-perk-effect,
|
||||
.drop-ability-effect,
|
||||
|
@ -180,9 +180,9 @@
|
||||
"styles": [
|
||||
"styles/simple.css"
|
||||
],
|
||||
"templateVersion": 78,
|
||||
"templateVersion": 80,
|
||||
"title": "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"
|
||||
}
|
||||
|
@ -339,6 +339,8 @@
|
||||
"idr": "",
|
||||
"equipped": false,
|
||||
"locationprotected": "",
|
||||
"effects": [],
|
||||
"activated": false,
|
||||
"description":""
|
||||
},
|
||||
"shield": {
|
||||
@ -348,6 +350,8 @@
|
||||
"cost": 0,
|
||||
"idr": "",
|
||||
"equipped": false,
|
||||
"effects": [],
|
||||
"activated": false,
|
||||
"description":""
|
||||
},
|
||||
"equipment": {
|
||||
@ -362,6 +366,8 @@
|
||||
"statdice": false,
|
||||
"bonusdice": false,
|
||||
"otherdice": false,
|
||||
"effects": [],
|
||||
"activated": false,
|
||||
"description":""
|
||||
},
|
||||
"money" : {
|
||||
@ -390,6 +396,8 @@
|
||||
"ammocurrent": 0,
|
||||
"ammomax": 0,
|
||||
"equipped": false,
|
||||
"effects": [],
|
||||
"activated": false,
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
@ -406,6 +406,18 @@
|
||||
<img class="sheet-competence-img" src="{{equip.img}}" />
|
||||
<span class="equipement-label">{{equip.name}}</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"> </span>
|
||||
{{/if}}
|
||||
|
||||
<span class="generic-label">Qty {{equip.data.quantity}}</span>
|
||||
<div class="item-controls">
|
||||
<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}}">
|
||||
<img class="sheet-competence-img" src="{{weapon.img}}" />
|
||||
<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"> </span>
|
||||
{{/if}}
|
||||
|
||||
<div class="item-controls">
|
||||
<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>
|
||||
@ -445,6 +468,17 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{armor._id}}">
|
||||
<img class="sheet-competence-img" src="{{armor.img}}" />
|
||||
<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"> </span>
|
||||
{{/if}}
|
||||
|
||||
<div class="item-controls">
|
||||
<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>
|
||||
@ -457,6 +491,17 @@
|
||||
<li class="item flexrow list-item" data-item-id="{{shield._id}}">
|
||||
<img class="sheet-competence-img" src="{{shield.img}}" />
|
||||
<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"> </span>
|
||||
{{/if}}
|
||||
|
||||
<div class="item-controls">
|
||||
<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>
|
||||
|
7
templates/chat-perk-ready.html
Normal file
7
templates/chat-perk-ready.html
Normal 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>
|
@ -83,6 +83,7 @@
|
||||
</li>
|
||||
</li>
|
||||
|
||||
<!--
|
||||
<li class="flexrow"><label class="generic-label">AoE</label>
|
||||
<input type="text" class="padd-right" name="data.aoe" value="{{data.aoe}}" data-dtype="String"/>
|
||||
</li>
|
||||
@ -99,6 +100,7 @@
|
||||
{{/select}}
|
||||
</select>
|
||||
</li>
|
||||
-->
|
||||
|
||||
<li class="flexrow"><label class="generic-label">Attacks Gained</label>
|
||||
<li>
|
||||
|
@ -30,6 +30,8 @@
|
||||
<input type="text" class="" name="data.locationprotected" value="{{data.locationprotected}}" data-dtype="String"/>
|
||||
</li>
|
||||
|
||||
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
|
||||
|
||||
<li class="flexrow"><label class="generic-label">Equipped ?</label>
|
||||
<label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label>
|
||||
</li>
|
||||
|
@ -43,6 +43,7 @@
|
||||
<label class="attribute-value checkbox"><input type="checkbox" name="data.otherdice" {{checked data.otherdice}}/></label>
|
||||
</li>
|
||||
|
||||
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
|
||||
|
||||
<li class="flexrow"><label class="generic-label">Equipped ?</label>
|
||||
<label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label>
|
||||
|
@ -26,6 +26,9 @@
|
||||
{{/select}}
|
||||
</select>
|
||||
</li>
|
||||
|
||||
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
|
||||
|
||||
<li class="flexrow"><label class="generic-label">Equipped ?</label>
|
||||
<label class="attribute-value checkbox"><input type="checkbox" name="data.equipped" {{checked data.equipped}}/></label>
|
||||
</li>
|
||||
|
@ -88,6 +88,8 @@
|
||||
</select>
|
||||
</li>
|
||||
|
||||
{{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
|
||||
|
||||
<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"/>
|
||||
</li>
|
||||
|
16
templates/partial-equipment-effects.html
Normal file
16
templates/partial-equipment-effects.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user