Various fixes

This commit is contained in:
sladecraven 2022-02-16 12:14:34 +01:00
parent 6e8e1ec5a3
commit 8dd7217e69
9 changed files with 124 additions and 55 deletions

View File

@ -477,7 +477,7 @@ export class PegasusActor extends Actor {
effects.push(item.id) effects.push(item.id)
} }
} }
if (effects.length) { if (effects.length > 0) {
await this.deleteEmbeddedDocuments('Item', effects) await this.deleteEmbeddedDocuments('Item', effects)
} }
} }
@ -491,12 +491,18 @@ export class PegasusActor extends Actor {
item = this.items.get(itemId) // Refresh item = this.items.get(itemId) // Refresh
if (item.data.data.nbuse == "next1action" && item.data.data.used1) { if (item.data.data.nbuse == "next1action" && item.data.data.used1) {
this.cleanPerkEffects(itemId) this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
} }
if (item.data.data.nbuse == "next2action" && item.data.data.used1 && item.data.data.used2) { if (item.data.data.nbuse == "next2action" && item.data.data.used1 && item.data.data.used2) {
this.cleanPerkEffects(itemId) this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
} }
if (item.data.data.nbuse == "next3action" && item.data.data.used1 && item.data.data.used2 && item.data.data.used3) { if (item.data.data.nbuse == "next3action" && item.data.data.used1 && item.data.data.used2 && item.data.data.used3) {
this.cleanPerkEffects(itemId) this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
} }
} }
} }
@ -519,8 +525,10 @@ export class PegasusActor extends Actor {
let updateOK = true let updateOK = true
if (status == "ready") { if (status == "ready") {
console.log("Cleaning effects")
this.cleanPerkEffects(itemId) this.cleanPerkEffects(itemId)
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.used1': false, 'data.used3': false, 'data.used3': false }] ) // Reset on Ready await this.updateEmbeddedDocuments('Item', [ { _id: itemId, 'data.status': "ready", 'data.used1': false },
{ _id: itemId, 'data.used2': false}, { _id: itemId,'data.used3': false } ] ) // Reset on Ready
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
@ -529,17 +537,20 @@ export class PegasusActor extends Actor {
} }
if (item.data.data.features.bonushealth.flag) { if (item.data.data.features.bonushealth.flag) {
let health = duplicate(this.data.data.secondary.health) let health = duplicate(this.data.data.secondary.health)
health.bonus -= Number(item.data.data.features.bonushealth.value) || 0 health.value -= Number(item.data.data.features.bonushealth.value) || 0
health.max -= Number(item.data.data.features.bonushealth.value) || 0
this.update({ 'data.secondary.health': health }) this.update({ 'data.secondary.health': health })
} }
if (item.data.data.features.bonusdelirium.flag) { if (item.data.data.features.bonusdelirium.flag) {
let delirium = duplicate(this.data.data.secondary.delirium) let delirium = duplicate(this.data.data.secondary.delirium)
delirium.bonus -= Number(item.data.data.features.bonusdelirium.value) || 0 delirium.value -= Number(item.data.data.features.bonusdelirium.value) || 0
delirium.max -= Number(item.data.data.features.bonusdelirium.value) || 0
this.update({ 'data.secondary.delirium': delirium }) this.update({ 'data.secondary.delirium': delirium })
} }
if (item.data.data.features.bonusnrg.flag) { if (item.data.data.features.bonusnrg.flag) {
let nrg = duplicate(this.data.data.nrg) let nrg = duplicate(this.data.data.nrg)
nrg.mod -= Number(item.data.data.features.bonusnrg.value) || 0 nrg.value -= Number(item.data.data.features.bonusnrg.value) || 0
nrg.max -= Number(item.data.data.features.bonusnrg.value) || 0
this.update({ 'data.nrg': nrg }) this.update({ 'data.nrg': nrg })
} }
this.disableWeaverPerk(item) this.disableWeaverPerk(item)
@ -570,17 +581,20 @@ export class PegasusActor extends Actor {
} }
if (item.data.data.features.bonushealth.flag) { if (item.data.data.features.bonushealth.flag) {
let health = duplicate(this.data.data.secondary.health) let health = duplicate(this.data.data.secondary.health)
health.bonus += Number(item.data.data.features.bonushealth.value) || 0 health.value += Number(item.data.data.features.bonushealth.value) || 0
health.max += Number(item.data.data.features.bonushealth.value) || 0
this.update({ 'data.secondary.health': health }) this.update({ 'data.secondary.health': health })
} }
if (item.data.data.features.bonusdelirium.flag) { if (item.data.data.features.bonusdelirium.flag) {
let delirium = duplicate(this.data.data.secondary.delirium) let delirium = duplicate(this.data.data.secondary.delirium)
delirium.bonus += Number(item.data.data.features.bonusdelirium.value) || 0 delirium.value += Number(item.data.data.features.bonusdelirium.value) || 0
delirium.max += Number(item.data.data.features.bonusdelirium.value) || 0
this.update({ 'data.secondary.delirium': delirium }) this.update({ 'data.secondary.delirium': delirium })
} }
if (item.data.data.features.bonusnrg.flag) { if (item.data.data.features.bonusnrg.flag) {
let nrg = duplicate(this.data.data.nrg) let nrg = duplicate(this.data.data.nrg)
nrg.mod += Number(item.data.data.features.bonusnrg.value) || 0 nrg.value += Number(item.data.data.features.bonusnrg.value) || 0
nrg.max += Number(item.data.data.features.bonusnrg.value) || 0
this.update({ 'data.nrg': nrg }) this.update({ 'data.nrg': nrg })
} }
this.enableWeaverPerk(item) this.enableWeaverPerk(item)
@ -606,35 +620,47 @@ export class PegasusActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async computeNRGHealth() { async computeNRGHealth( ) {
if (this.isToken) return if (this.isToken) return
if (this.isOwner || game.user.isGM) { if (this.isOwner || game.user.isGM) {
let updates = {} let updates = {}
let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod; let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod;
if (phyDiceValue != this.data.data.secondary.health.max) { if (phyDiceValue != this.data.data.secondary.health.max) {
updates['data.secondary.health.max'] = phyDiceValue updates['data.secondary.health.max'] = phyDiceValue
//updates['data.secondary.health.value'] = phyDiceValue if (this.computeValue) {
updates['data.secondary.health.value'] = phyDiceValue
}
} }
let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.secondary.delirium.bonus + this.data.data.statistics.mnd.mod; let mndDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.mnd.value) + this.data.data.secondary.delirium.bonus + this.data.data.statistics.mnd.mod;
if (mndDiceValue != this.data.data.secondary.delirium.max) { if (mndDiceValue != this.data.data.secondary.delirium.max) {
updates['data.secondary.delirium.max'] = mndDiceValue updates['data.secondary.delirium.max'] = mndDiceValue
//updates['data.secondary.delirium.value'] = mndDiceValue if (this.computeValue) {
updates['data.secondary.delirium.value'] = mndDiceValue
}
} }
let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value) + this.data.data.secondary.stealthhealth.bonus + this.data.data.statistics.stl.mod; let stlDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.stl.value) + this.data.data.secondary.stealthhealth.bonus + this.data.data.statistics.stl.mod;
if (stlDiceValue != this.data.data.secondary.stealthhealth.max) { if (stlDiceValue != this.data.data.secondary.stealthhealth.max) {
updates['data.secondary.stealthhealth.max'] = stlDiceValue updates['data.secondary.stealthhealth.max'] = stlDiceValue
//updates['data.secondary.stealthhealth.value'] = stlDiceValue if (this.computeValue) {
updates['data.secondary.stealthhealth.value'] = stlDiceValue
}
} }
let socDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.soc.value) + this.data.data.secondary.socialhealth.bonus + this.data.data.statistics.soc.mod; let socDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.soc.value) + this.data.data.secondary.socialhealth.bonus + this.data.data.statistics.soc.mod;
if (socDiceValue != this.data.data.secondary.socialhealth.max) { if (socDiceValue != this.data.data.secondary.socialhealth.max) {
updates['data.secondary.socialhealth.max'] = socDiceValue updates['data.secondary.socialhealth.max'] = socDiceValue
//updates['data.secondary.socialhealth.value'] = socDiceValue if (this.computeValue) {
updates['data.secondary.socialhealth.value'] = socDiceValue
}
} }
let nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.nrg.mod + this.data.data.statistics.foc.mod; let nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.nrg.mod + this.data.data.statistics.foc.mod;
if (nrgValue != this.data.data.nrg.absolutemax) { if (nrgValue != this.data.data.nrg.absolutemax) {
updates['data.nrg.absolutemax'] = nrgValue updates['data.nrg.absolutemax'] = nrgValue
if (this.computeValue) {
updates['data.nrg.max'] = nrgValue
updates['data.nrg.value'] = nrgValue
}
} }
nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.statistics.foc.mod; nrgValue = PegasusUtility.getDiceValue(this.data.data.statistics.foc.value) + this.data.data.statistics.foc.mod;
if (nrgValue != this.data.data.combat.stunthreshold) { if (nrgValue != this.data.data.combat.stunthreshold) {
@ -852,6 +878,9 @@ export class PegasusActor extends Actor {
if (!effect.data.hindrance if (!effect.data.hindrance
&& effect.data.stataffected != "notapplicable" && effect.data.stataffected != "notapplicable"
&& effect.data.stataffected != "special") { && effect.data.stataffected != "special") {
if ( effect.data.effectstatlevel && effect.data.effectstat == rollData.statKey) {
effect.data.effectlevel = rollData.statDicesLevel
}
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel }) rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
} }
} }
@ -982,6 +1011,7 @@ export class PegasusActor extends Actor {
rollData.title = `Spec. : ${spec.name} ` rollData.title = `Spec. : ${spec.name} `
rollData.specList = [spec] rollData.specList = [spec]
rollData.selectedSpec = spec._id rollData.selectedSpec = spec._id
rollData.specName = spec.name
rollData.specDicesLevel = spec.data.level rollData.specDicesLevel = spec.data.level
this.startRoll(rollData) this.startRoll(rollData)
} else { } else {

View File

@ -11,14 +11,16 @@ export class PegasusActorCreate {
name: "New Actor", name: "New Actor",
type: "character" type: "character"
}); });
this.actor.sheet.render(true); this.actor.sheet.render(true)
const racesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.race"); this.actor.computeValue = true // To force value computation
this.races = racesPack.map(i => i.toObject());
const rolesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.role"); const racesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.race")
this.roles = rolesPack.map(i => i.toObject()); this.races = racesPack.map(i => i.toObject())
const perksPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.perk"); const rolesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.role")
this.perks = perksPack.map(i => i.toObject()); this.roles = rolesPack.map(i => i.toObject())
const perksPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.perk")
this.perks = perksPack.map(i => i.toObject())
this.showRaces() this.showRaces()
} }
@ -239,12 +241,10 @@ export class PegasusActorCreate {
/* --------------- -------------------- --------- */ /* --------------- -------------------- --------- */
manageRacePerks(race) { manageRacePerks(race) {
console.log("MANAG RACE PERKsS", this.currentRace)
if ( !this.currentRace.data.perksgained ) { if ( !this.currentRace.data.perksgained ) {
this.showRoles() this.showRoles()
return; return;
} }
console.log("MANAG RACE PERKsS 2", this.currentRace)
if ( !this.racePerks) { // First init if ( !this.racePerks) { // First init
if ( this.currentRace.data.perksall) { if ( this.currentRace.data.perksall) {
this.racePerks = duplicate(this.perks) this.racePerks = duplicate(this.perks)
@ -337,7 +337,7 @@ export class PegasusActorCreate {
formData.rolestats.push( duplicate(this.actor.data.data.statistics[stat.name.toLowerCase()]) ) formData.rolestats.push( duplicate(this.actor.data.data.statistics[stat.name.toLowerCase()]) )
} }
} }
console.log("STAT", this.roleStats, formData) //console.log("STAT", this.roleStats, formData)
this.renderChatMessage( formData) this.renderChatMessage( formData)
} }
@ -362,7 +362,8 @@ export class PegasusActorCreate {
/* -------------------------------------------- */ /* -------------------------------------------- */
async showCharacterEnd() { async showCharacterEnd() {
this.actor.computeNRGHealth() await this.actor.computeNRGHealth()
this.actor.computeValue = false // To force value computation
let formData = this.createFormData("character-end") let formData = this.createFormData("character-end")
this.renderChatMessage( formData) this.renderChatMessage( formData)
} }

View File

@ -41,6 +41,7 @@ export class PegasusRollDialog extends Dialog {
PegasusUtility.rollPegasus( this.rollData ) PegasusUtility.rollPegasus( this.rollData )
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
manageEffects( effectIdx, toggled) { manageEffects( effectIdx, toggled) {
let effect = this.rollData.effectsList[effectIdx] let effect = this.rollData.effectsList[effectIdx]
@ -182,15 +183,20 @@ export class PegasusRollDialog extends Dialog {
} }
$(function () { onLoad(); }); $(function () { onLoad(); });
html.find('#specList').change((event) => { html.find('#specList').change(async (event) => {
this.rollData.selectedSpec = event.currentTarget.value this.rollData.selectedSpec = event.currentTarget.value
let spec = this.rollData.specList.find(item => item._id == this.rollData.selectedSpec) let spec = this.rollData.specList.find(item => item._id == this.rollData.selectedSpec)
if ( spec) { if ( spec) {
this.rollData.specDiceLevel = spec.data.level this.rollData.specDiceLevel = spec.data.level
this.rollData.specName = spec.name
$('#specDicesLevel').val(this.rollData.specDiceLevel) $('#specDicesLevel').val(this.rollData.specDiceLevel)
} else { } else {
this.rollData.specName = undefined
$('#specDicesLevel').val(0) $('#specDicesLevel').val(0)
} }
const content = await renderTemplate("systems/fvtt-pegasus-rpg/templates/roll-dialog-generic.html", this.rollData)
this.data.content = content
this.render(true)
}); });
html.find('#statDicesLevel').change((event) => { html.find('#statDicesLevel').change((event) => {
this.rollData.statDicesLevel = Number(event.currentTarget.value) this.rollData.statDicesLevel = Number(event.currentTarget.value)

View File

@ -29,6 +29,12 @@ export class PegasusUtility {
this.buildDiceLists(); this.buildDiceLists();
PegasusCommands.init(); PegasusCommands.init();
Handlebars.registerHelper('count', function (list) {
return list.length;
});
Handlebars.registerHelper('includes', function (array, val) {
return array.includes(val);
});
Handlebars.registerHelper('upper', function (text) { Handlebars.registerHelper('upper', function (text) {
return text.toUpperCase(); return text.toUpperCase();
}); });

View File

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

View File

@ -200,6 +200,8 @@
"recoveryroll": false, "recoveryroll": false,
"recoveryrollstat": "", "recoveryrollstat": "",
"recoveryrollspec": [], "recoveryrollspec": [],
"effectstatlevel": false,
"effectstat": "",
"description": "" "description": ""
}, },
"race": { "race": {

View File

@ -110,8 +110,6 @@
{{!-- Other Tab --}} {{!-- Other Tab --}}
<div class="tab items" data-group="primary" data-tab="specs"> <div class="tab items" data-group="primary" data-tab="specs">
<div class="grid grid-2col">
<div> <div>
<span class="generic-label"> <span class="generic-label">
<h3>Specialisations</h3> <h3>Specialisations</h3>
@ -142,7 +140,6 @@
</div> </div>
</div> </div>
</div>
</div> </div>
@ -187,8 +184,6 @@
<span class="stat-label flexrow" name="momentum"><h4>{{data.momentum.label}}:</h4></span> <span class="stat-label flexrow" name="momentum"><h4>{{data.momentum.label}}:</h4></span>
<span class="small-label padd-right packed-left">Cur</span><input type="text" class="padd-right update-field input-numeric-short" data-field-name="data.momentum.value" value="{{data.momentum.value}}" data-dtype="Number"/> <span class="small-label padd-right packed-left">Cur</span><input type="text" class="padd-right update-field input-numeric-short" data-field-name="data.momentum.value" value="{{data.momentum.value}}" data-dtype="Number"/>
<span class="small-label padd-right packed-left">&nbsp;Max</span><input type="text" class="padd-right update-field input-numeric-short" data-field-name="data.momentum.max" value="{{data.momentum.max}}" data-dtype="Number"/> <span class="small-label padd-right packed-left">&nbsp;Max</span><input type="text" class="padd-right update-field input-numeric-short" data-field-name="data.momentum.max" value="{{data.momentum.max}}" data-dtype="Number"/>
<span class="stat-label flexrow" name="momentum"><h4>Current Hindrance level:</h4></span>
<input type="text" class="padd-right update-field input-numeric-short" data-field-name="data.combat.hindrancedice" value="{{data.combat.hindrancedice}}" data-dtype="Number"/>
</li> </li>
</ul> </ul>

View File

@ -37,9 +37,23 @@
</select> </select>
</li> </li>
<li class="flexrow"><label class="generic-label">'Effect Level is a Stat?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.effectstatlevel" {{checked data.effectstatlevel}}/></label>
</li>
{{#if data.effectstatlevel}}
<li class="flexrow"><label class="generic-label">Stat to use for Effect Level</label>
<select class="competence-base flexrow" type="text" name="data.effectstat" value="{{data.effectstat}}" data-dtype="String">
{{#select data.effectstat}}
{{> systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html notapplicable=false mr=true all=false}}
{{/select}}
</select>
</li>
{{else}}
<li class="flexrow"><label class="generic-label">Effect Level</label> <li class="flexrow"><label class="generic-label">Effect Level</label>
<input type="text" class="input-numeric-short padd-right" name="data.effectlevel" value="{{data.effectlevel}}" data-dtype="Number"/> <input type="text" class="input-numeric-short padd-right" name="data.effectlevel" value="{{data.effectlevel}}" data-dtype="Number"/>
</li> </li>
{{/if}}
<li class="flexrow"> <label class="generic-label">Affected Specialisations </label></li> <li class="flexrow"> <label class="generic-label">Affected Specialisations </label></li>
<li class="flexrow"> <li class="flexrow">

View File

@ -15,6 +15,20 @@
<label class="attribute-value checkbox"><input type="checkbox" class="effect-clicked" id="effect-{{idx}}" data-effect-idx="{{idx}}" {{checked effect.applied}}/></label> <label class="attribute-value checkbox"><input type="checkbox" class="effect-clicked" id="effect-{{idx}}" data-effect-idx="{{idx}}" {{checked effect.applied}}/></label>
<label class="generic-label">Target Hindrance : {{effect.label}} ({{effect.value}})</label> <label class="generic-label">Target Hindrance : {{effect.label}} ({{effect.value}})</label>
</li> </li>
{{else}}
{{#if (count effect.effect.data.specaffected)}}
{{#each effect.effect.data.specaffected as |spec idx|}}
{{#if (eq @root.specName spec.name)}}
<li class="flex-group-left">
<label class="attribute-value checkbox"><input type="checkbox" class="effect-clicked" id="effect-{{idx}}" data-effect-idx="{{idx}}" {{checked effect.applied}}/></label>
{{#if effect.effect}}
<label class="generic-label">{{effect.label}} ({{upperFirst effect.effect.data.type}}, {{upperFirst effect.effect.data.genre}}, {{effect.value}})</label>
{{else}}
<label class="generic-label">{{effect.label}} ({{effect.value}})</label>
{{/if}}
</li>
{{/if}}
{{/each}}
{{else}} {{else}}
{{#if (eq @root.statKey effect.effect.data.stataffected)}} {{#if (eq @root.statKey effect.effect.data.stataffected)}}
<li class="flex-group-left"> <li class="flex-group-left">
@ -39,6 +53,7 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/if}}
{{/each}} {{/each}}
</ul> </ul>