Manage stuff
This commit is contained in:
parent
ef8e737d1c
commit
5e44a97686
@ -121,11 +121,23 @@ export class PegasusActorSheet extends ActorSheet {
|
|||||||
let itemId = li.data("item-id");
|
let itemId = li.data("item-id");
|
||||||
this.actor.perkEffectUsed( itemId)
|
this.actor.perkEffectUsed( itemId)
|
||||||
});
|
});
|
||||||
|
|
||||||
html.find('.perk-status').change(ev => {
|
html.find('.perk-status').change(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");
|
||||||
this.actor.updatePerkStatus( itemId, ev.currentTarget.value)
|
this.actor.updatePerkStatus( itemId, ev.currentTarget.value)
|
||||||
});
|
});
|
||||||
|
html.find('.power-cost-spent').change(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
let itemId = li.data("item-id");
|
||||||
|
this.actor.updatePowerSpentCost( itemId, ev.currentTarget.value)
|
||||||
|
});
|
||||||
|
html.find('.perk-used').change(ev => {
|
||||||
|
const li = $(ev.currentTarget).parents(".item")
|
||||||
|
let itemId = li.data("item-id")
|
||||||
|
let index = Number($(ev.currentTarget).data("use-index") )
|
||||||
|
this.actor.updatePerkUsed( itemId, index, ev.currentTarget.checked )
|
||||||
|
});
|
||||||
|
|
||||||
html.find('.subactor-edit').click(ev => {
|
html.find('.subactor-edit').click(ev => {
|
||||||
const li = $(ev.currentTarget).parents(".item");
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
|
@ -181,27 +181,26 @@ export class PegasusActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async manageWorstFear(flag) {
|
async manageWorstFear(flag) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
let effect = await PegasusUtility.getEffectFromCompendium( "Worst Fear" )
|
let effect = await PegasusUtility.getEffectFromCompendium("Worst Fear")
|
||||||
console.log("got effect", effect)
|
|
||||||
effect.data.worstfear = true
|
effect.data.worstfear = true
|
||||||
this.createEmbeddedDocuments( 'Item', [effect])
|
this.createEmbeddedDocuments('Item', [effect])
|
||||||
} else {
|
} else {
|
||||||
let effect = this.data.items.find( item => item.type == "effect" && item.data.data.worstfear )
|
let effect = this.data.items.find(item => item.type == "effect" && item.data.data.worstfear)
|
||||||
if (effect) {
|
if (effect) {
|
||||||
this.deleteEmbeddedDocuments( 'Item', [ effect.id ])
|
this.deleteEmbeddedDocuments('Item', [effect.id])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async manageDesires(flag) {
|
async manageDesires(flag) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
let effect = await PegasusUtility.getEffectFromCompendium( "Desires" )
|
let effect = await PegasusUtility.getEffectFromCompendium("Desires")
|
||||||
effect.data.desires = true
|
effect.data.desires = true
|
||||||
this.createEmbeddedDocuments( 'Item', [effect])
|
this.createEmbeddedDocuments('Item', [effect])
|
||||||
} else {
|
} else {
|
||||||
let effect = this.data.items.find( item => item.type == "effect" && item.data.data.desires )
|
let effect = this.data.items.find(item => item.type == "effect" && item.data.data.desires)
|
||||||
if (effect) {
|
if (effect) {
|
||||||
this.deleteEmbeddedDocuments( 'Item', [ effect.id ])
|
this.deleteEmbeddedDocuments('Item', [effect.id])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,13 +229,14 @@ export class PegasusActor extends Actor {
|
|||||||
if (item && item.data.data) {
|
if (item && item.data.data) {
|
||||||
|
|
||||||
let nrg = duplicate(this.data.data.nrg)
|
let nrg = duplicate(this.data.data.nrg)
|
||||||
if ( !item.data.data.activated) { // Current value
|
if (!item.data.data.activated) { // Current value
|
||||||
|
|
||||||
if ( item.data.data.cost > nrg.value) {
|
if (item.data.data.costspent > nrg.value || item.data.data.costspent > nrg.max) {
|
||||||
return ui.notifications.warn("Not enough NRG to activate the Power " + item.name )
|
return ui.notifications.warn("Not enough NRG to activate the Power " + item.name)
|
||||||
}
|
}
|
||||||
nrg.activated += item.data.data.cost
|
nrg.activated += item.data.data.costspent
|
||||||
nrg.value -= item.data.data.cost
|
nrg.value -= item.data.data.costspent
|
||||||
|
nrg.max -= item.data.data.costspent
|
||||||
this.update({ 'data.nrg': nrg })
|
this.update({ 'data.nrg': nrg })
|
||||||
|
|
||||||
let effects = []
|
let effects = []
|
||||||
@ -248,13 +248,14 @@ export class PegasusActor extends Actor {
|
|||||||
await this.createEmbeddedDocuments('Item', effects)
|
await this.createEmbeddedDocuments('Item', effects)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nrg.activated -= item.data.data.cost
|
nrg.activated -= item.data.data.costspent
|
||||||
|
nrg.max += item.data.data.costspent
|
||||||
this.update({ 'data.nrg': nrg })
|
this.update({ 'data.nrg': nrg })
|
||||||
|
|
||||||
let toRem = []
|
let toRem = []
|
||||||
for( let item of this.data.items) {
|
for (let item of this.data.items) {
|
||||||
if (item.type == 'effect' && item.data.data.powerId == itemId) {
|
if (item.type == 'effect' && item.data.data.powerId == itemId) {
|
||||||
toRem.push( item.id)
|
toRem.push(item.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toRem.length) {
|
if (toRem.length) {
|
||||||
@ -469,14 +470,7 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updatePerkStatus(itemId, status) {
|
async cleanPerkEffects(itemId) {
|
||||||
let item = this.items.get(itemId)
|
|
||||||
if (item) {
|
|
||||||
|
|
||||||
if (item.data.data.status == status) return;// Ensure we are really changing the status
|
|
||||||
|
|
||||||
let updateOK = true
|
|
||||||
if (status == "ready") {
|
|
||||||
let effects = []
|
let effects = []
|
||||||
for (let item of this.data.items) {
|
for (let item of this.data.items) {
|
||||||
if (item.type == "effect" && item.data.data.perkId == itemId) {
|
if (item.type == "effect" && item.data.data.perkId == itemId) {
|
||||||
@ -486,6 +480,46 @@ export class PegasusActor extends Actor {
|
|||||||
if (effects.length) {
|
if (effects.length) {
|
||||||
await this.deleteEmbeddedDocuments('Item', effects)
|
await this.deleteEmbeddedDocuments('Item', effects)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async updatePerkUsed(itemId, index, checked) {
|
||||||
|
let item = this.items.get(itemId)
|
||||||
|
if (item && index) {
|
||||||
|
let key = "data.used" + index
|
||||||
|
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, [`${key}`]: checked }] )
|
||||||
|
item = this.items.get(itemId) // Refresh
|
||||||
|
if (item.data.data.nbuse == "next1action" && item.data.data.used1) {
|
||||||
|
this.cleanPerkEffects(itemId)
|
||||||
|
}
|
||||||
|
if (item.data.data.nbuse == "next2action" && item.data.data.used1 && item.data.data.used2) {
|
||||||
|
this.cleanPerkEffects(itemId)
|
||||||
|
}
|
||||||
|
if (item.data.data.nbuse == "next3action" && item.data.data.used1 && item.data.data.used2 && item.data.data.used3) {
|
||||||
|
this.cleanPerkEffects(itemId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async updatePowerSpentCost(itemId, value) {
|
||||||
|
let item = this.items.get(itemId)
|
||||||
|
if (item && value) {
|
||||||
|
value = Number(value) || 0
|
||||||
|
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.costspent': value }])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async updatePerkStatus(itemId, status) {
|
||||||
|
let item = this.items.get(itemId)
|
||||||
|
if (item) {
|
||||||
|
|
||||||
|
if (item.data.data.status == status) return;// Ensure we are really changing the status
|
||||||
|
|
||||||
|
let updateOK = true
|
||||||
|
if (status == "ready") {
|
||||||
|
this.cleanPerkEffects(itemId)
|
||||||
if (item.data.data.features.nrgcost.flag) {
|
if (item.data.data.features.nrgcost.flag) {
|
||||||
let nrg = duplicate(this.data.data.nrg)
|
let nrg = duplicate(this.data.data.nrg)
|
||||||
nrg.activated -= item.data.data.features.nrgcost.value
|
nrg.activated -= item.data.data.features.nrgcost.value
|
||||||
|
@ -180,9 +180,9 @@
|
|||||||
"styles": [
|
"styles": [
|
||||||
"styles/simple.css"
|
"styles/simple.css"
|
||||||
],
|
],
|
||||||
"templateVersion": 73,
|
"templateVersion": 75,
|
||||||
"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.8",
|
"version": "0.4.10",
|
||||||
"background" : "./images/ui/pegasus_welcome_page.webp"
|
"background" : "./images/ui/pegasus_welcome_page.webp"
|
||||||
}
|
}
|
||||||
|
@ -302,13 +302,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"status": "",
|
"status": "",
|
||||||
"nbuse": ""
|
"nbuse": "",
|
||||||
|
"used1":false,
|
||||||
|
"used2":false,
|
||||||
|
"used3":false
|
||||||
},
|
},
|
||||||
"power": {
|
"power": {
|
||||||
"rollneeded": false,
|
"rollneeded": false,
|
||||||
"statistic": "",
|
"statistic": "",
|
||||||
"cost": 0,
|
"cost": 0,
|
||||||
"costtype": "",
|
"costspent": 0,
|
||||||
"range": "",
|
"range": "",
|
||||||
"action": "",
|
"action": "",
|
||||||
"type": "",
|
"type": "",
|
||||||
|
@ -83,7 +83,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li class="item flexrow list-item" data-key="nrg">
|
<li class="item flexrow list-item" data-key="nrg">
|
||||||
<span class="stat-label flexrow" name="nrg"> <h4>{{data.nrg.label}}</h4> </span>
|
<span class="stat-label flexrow" name="nrg"> <h4>{{data.nrg.label}}</h4> </span>
|
||||||
<span class="small-label padd-right packed-left">Act</span><input type="text" class="padd-right" name="data.nrg.activated" value="{{data.nrg.activated}}" data-dtype="Number"/>
|
<span class="small-label padd-right packed-left">Act</span>
|
||||||
|
<input type="text" class="padd-right" name="data.nrg.activated" value="{{data.nrg.activated}}" data-dtype="Number"/>
|
||||||
<span class="small-label padd-right packed-left"> Cur</span><input type="text" class="padd-right" name="data.nrg.value" value="{{data.nrg.value}}" data-dtype="Number"/>
|
<span class="small-label padd-right packed-left"> Cur</span><input type="text" class="padd-right" name="data.nrg.value" value="{{data.nrg.value}}" data-dtype="Number"/>
|
||||||
<span class="small-label padd-right packed-left"> Mod</span><input type="text" class="padd-right" name="data.nrg.mod" value="{{data.nrg.mod}}" data-dtype="Number"/>
|
<span class="small-label padd-right packed-left"> Mod</span><input type="text" class="padd-right" name="data.nrg.mod" value="{{data.nrg.mod}}" data-dtype="Number"/>
|
||||||
<span class="small-label padd-right packed-left"> Max</span><input type="text" class="padd-right" name="data.nrg.max" value="{{data.nrg.max}}" data-dtype="Number"/>
|
<span class="small-label padd-right packed-left"> Max</span><input type="text" class="padd-right" name="data.nrg.max" value="{{data.nrg.max}}" data-dtype="Number"/>
|
||||||
@ -231,11 +232,6 @@
|
|||||||
<span class="generic-label">{{upperFirst effect.data.genre}}</span>
|
<span class="generic-label">{{upperFirst effect.data.genre}}</span>
|
||||||
<span class="generic-label">Lvl:{{effect.data.effectlevel}}</span>
|
<span class="generic-label">Lvl:{{effect.data.effectlevel}}</span>
|
||||||
<span class="generic-label">{{upper effect.data.stataffected}}</span>
|
<span class="generic-label">{{upper effect.data.stataffected}}</span>
|
||||||
{{#if effect.data.perkId}}
|
|
||||||
<span class="generic-label"><a class="effect-used">Used?</a></span>
|
|
||||||
{{else}}
|
|
||||||
<span class="generic-label"> </span>
|
|
||||||
{{/if}}
|
|
||||||
<div class="item-controls">
|
<div class="item-controls">
|
||||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
@ -264,6 +260,29 @@
|
|||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
{{#if (ne perk.data.status "ready")}}
|
||||||
|
{{#if (eq perk.data.nbuse "next1action")}}
|
||||||
|
<label class="attribute-value checkbox"><input type="checkbox" class="perk-used" data-use-index="1" name="perk.data.used1" {{checked perk.data.used1}}/></label>
|
||||||
|
<span class="stat-label"> </span>
|
||||||
|
<span class="stat-label"> </span>
|
||||||
|
{{/if}}
|
||||||
|
{{#if (eq perk.data.nbuse "next2action")}}
|
||||||
|
<label class="attribute-value checkbox"></label><input type="checkbox" class="perk-used" data-use-index="1" name="perk.data.used1" {{checked perk.data.used1}}/></label>
|
||||||
|
<label class="attribute-value checkbox"></label><input type="checkbox" class="perk-used" data-use-index="2" name="perk.data.used2" {{checked perk.data.used2}}/></label>
|
||||||
|
<span class="stat-label"> </span>
|
||||||
|
{{/if}}
|
||||||
|
{{#if (eq perk.data.nbuse "next3action")}}
|
||||||
|
<label class="attribute-value checkbox"></label><input type="checkbox" class="perk-used" data-use-index="1" name="perk.data.used1" {{checked perk.data.used1}}/></label>
|
||||||
|
<label class="attribute-value checkbox"></label><input type="checkbox" class="perk-used" data-use-index="2" name="perk.data.used2" {{checked perk.data.used2}}/></label>
|
||||||
|
<label class="attribute-value checkbox"></label><input type="checkbox" class="perk-used" data-use-index="3" name="perk.data.used3" {{checked perk.data.used3}}/></label>
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
<span class="stat-label"> </span>
|
||||||
|
<span class="stat-label"> </span>
|
||||||
|
<span class="stat-label"> </span>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<div class="item-controls">
|
<div class="item-controls">
|
||||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
@ -307,9 +326,17 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
<span class="stat-label outfit-label">{{power.data.type}}</span>
|
<span class="stat-label outfit-label">{{power.data.type}}</span>
|
||||||
<span class="stat-label outfit-label">{{#if power.data.activated}}Activated{{/if}}</span>
|
{{#if power.data.activated}}
|
||||||
|
<span class="stat-label outfit-label">Activated</span>
|
||||||
|
{{else}}
|
||||||
|
<span class="stat-label outfit-label"> </span>
|
||||||
|
{{/if}}
|
||||||
|
<span class="stat-label outfit-label">{{power.data.cost}}</span>
|
||||||
|
<span class="stat-label outfit-label">Spent:
|
||||||
|
<input type="text" class="padd-right power-cost-spent" value="{{power.data.costspent}}" data-dtype="Number"/>
|
||||||
|
</span>
|
||||||
<div class="item-controls">
|
<div class="item-controls">
|
||||||
<a class="item-control power-activate" title="Worn">{{#if power.data.activated}}<i
|
<a class="item-control power-activate" title="Activated">{{#if power.data.activated}}<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>
|
||||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
<li class="flexrow"><label class="generic-label">Number of use during activation</label>
|
<li class="flexrow"><label class="generic-label">Number of use during activation</label>
|
||||||
<select class="competence-base flexrow" type="text" name="data.nbuse" value="{{data.nbuse}}" data-dtype="Number">
|
<select class="competence-base flexrow" type="text" name="data.nbuse" value="{{data.nbuse}}" data-dtype="String">
|
||||||
{{#select data.nbuse}}
|
{{#select data.nbuse}}
|
||||||
<option value="perkduration">For Duration of Perk</option>
|
<option value="perkduration">For Duration of Perk</option>
|
||||||
<option value="next1action">Next 1 Stated Action</option>
|
<option value="next1action">Next 1 Stated Action</option>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<input type="text" class="input-numeric-short padd-right" name="data.cost" value="{{data.cost}}" data-dtype="Number"/>
|
<input type="text" class="input-numeric-short padd-right" name="data.cost" value="{{data.cost}}" data-dtype="Number"/>
|
||||||
</li>
|
</li>
|
||||||
<li class="flexrow"><label class="generic-label">NRG Spent</label>
|
<li class="flexrow"><label class="generic-label">NRG Spent</label>
|
||||||
<input type="text" class="input-numeric-short padd-right" name="data.costtype" value="{{data.costtype}}" data-dtype="Number"/>
|
<input type="text" class="input-numeric-short padd-right" name="data.costspent" value="{{data.costspent}}" data-dtype="Number"/>
|
||||||
</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">
|
||||||
|
Loading…
Reference in New Issue
Block a user