Minor fixes on powers

This commit is contained in:
sladecraven 2022-08-28 18:51:52 +02:00
parent f92d8552bc
commit 92cea77239
4 changed files with 37 additions and 5 deletions

View File

@ -47,6 +47,7 @@ export class PegasusActor extends Actor {
if (data.type == 'npc') { if (data.type == 'npc') {
} }
return super.create(data, options); return super.create(data, options);
} }
@ -61,6 +62,9 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
prepareDerivedData() { prepareDerivedData() {
if (!this.traumaState) {
this.traumaState = "none"
}
if (this.type == 'character') { if (this.type == 'character') {
this.computeNRGHealth(); this.computeNRGHealth();
@ -277,6 +281,7 @@ export class PegasusActor extends Actor {
if (item.data.data.costspent > nrg.value || item.data.data.costspent > nrg.max) { 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.costspent nrg.activated += item.data.data.costspent
nrg.value -= item.data.data.costspent nrg.value -= item.data.data.costspent
nrg.max -= item.data.data.costspent nrg.max -= item.data.data.costspent
@ -290,6 +295,9 @@ export class PegasusActor extends Actor {
if (effects.length) { if (effects.length) {
await this.createEmbeddedDocuments('Item', effects) await this.createEmbeddedDocuments('Item', effects)
} }
if (item.data.data.activatedtext.length > 0) {
ChatMessage.create({ content: `Power ${item.name} activated : ${item.data.data.activatedtext}` })
}
} else { } else {
nrg.activated -= item.data.data.costspent nrg.activated -= item.data.data.costspent
nrg.max += item.data.data.costspent nrg.max += item.data.data.costspent
@ -304,6 +312,9 @@ export class PegasusActor extends Actor {
if (toRem.length) { if (toRem.length) {
await this.deleteEmbeddedDocuments('Item', toRem) await this.deleteEmbeddedDocuments('Item', toRem)
} }
if (item.data.data.deactivatedtext.length > 0) {
ChatMessage.create({ content: `Power ${item.name} deactivated : ${item.data.data.deactivatedtext}` })
}
} }
let update = { _id: item.id, "data.activated": !item.data.data.activated } let update = { _id: item.id, "data.activated": !item.data.data.activated }
await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity
@ -612,7 +623,9 @@ export class PegasusActor extends Actor {
return false return false
} }
} }
if (item.data.type == "power" && item.data.data.purchasedtext.length > 0 ) {
ChatMessage.create({ content: `Power ${item.name} puchased : ${item.data.data.purchasedtext}` })
}
let dropID = $(event.target).parents(".item").attr("data-item-id") // Only relevant if container drop let dropID = $(event.target).parents(".item").attr("data-item-id") // Only relevant if container drop
let objectID = item.id || item._id let objectID = item.id || item._id
this.addObjectToContainer(objectID, dropID) this.addObjectToContainer(objectID, dropID)
@ -1408,7 +1421,7 @@ export class PegasusActor extends Actor {
if (isPowerDmg && effect.data.stataffected == "powerdmgroll") { if (isPowerDmg && effect.data.stataffected == "powerdmgroll") {
this.pushEffect(rollData, effect) this.pushEffect(rollData, effect)
} }
} }
} }
@ -1433,7 +1446,7 @@ export class PegasusActor extends Actor {
if (weapon.data.equipped && weapon.data.statistic == statKey) { if (weapon.data.equipped && weapon.data.statistic == statKey) {
rollData.weaponsList.push({ label: `Attack ${weapon.name}`, type: "attack", applied: false, weapon: weapon, value: 0, damageDice: PegasusUtility.getDiceFromLevel(0) }) rollData.weaponsList.push({ label: `Attack ${weapon.name}`, type: "attack", applied: false, weapon: weapon, value: 0, damageDice: PegasusUtility.getDiceFromLevel(0) })
} }
if (weapon.data.equipped && weapon.data.canbethrown && statKey == "agi" ) { if (weapon.data.equipped && weapon.data.canbethrown && statKey == "agi") {
rollData.weaponsList.push({ label: `Attack ${weapon.name}`, type: "attack", applied: false, weapon: weapon, value: 0, damageDice: PegasusUtility.getDiceFromLevel(0) }) rollData.weaponsList.push({ label: `Attack ${weapon.name}`, type: "attack", applied: false, weapon: weapon, value: 0, damageDice: PegasusUtility.getDiceFromLevel(0) })
} }
if (weapon.data.equipped && weapon.data.enhanced && weapon.data.enhancedstat == statKey) { if (weapon.data.equipped && weapon.data.enhanced && weapon.data.enhancedstat == statKey) {

View File

@ -270,9 +270,9 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 108, "templateVersion": 109,
"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.6.25", "version": "0.6.26",
"background" : "./images/ui/pegasus_welcome_page.webp" "background" : "./images/ui/pegasus_welcome_page.webp"
} }

View File

@ -517,6 +517,10 @@
"activated": false, "activated": false,
"purchasedeffects": "", "purchasedeffects": "",
"effectsgained": [], "effectsgained": [],
"purchasedtext": "",
"activatedtext": "",
"deactivatedtext": "",
"powerlevelcost": "",
"dmgroll": false, "dmgroll": false,
"dmgstatistic": "", "dmgstatistic": "",
"description": "" "description": ""

View File

@ -114,6 +114,21 @@
</li> </li>
{{/if}} {{/if}}
<li class="flexrow"><label class="generic-label">When purchased display text</label>
<input type="text" class="padd-right" name="data.purchasedtext" value="{{data.purchasedtext}}" data-dtype="String"/>
</li>
<li class="flexrow"><label class="generic-label">When activated display text</label>
<input type="text" class="padd-right" name="data.activatedtext" value="{{data.activatedtext}}" data-dtype="String"/>
</li>
<li class="flexrow"><label class="generic-label">When deactivated display text</label>
<input type="text" class="padd-right" name="data.deactivatedtext" value="{{data.deactivatedtext}}" data-dtype="String"/>
</li>
<li class="flexrow"><label class="generic-label">Power Level Cost</label>
<input type="text" class="input-numeric-short padd-right" name="data.powerlevelcost" value="{{data.powerlevelcost}}"
data-dtype="Number" />
</li>
<li class="flexrow"><label class="generic-label">Effects Gained</label> <li class="flexrow"><label class="generic-label">Effects Gained</label>
</li> </li>
<li> <li>