Sync effetcts + initiative

This commit is contained in:
2022-01-28 17:27:01 +01:00
parent a4ead72808
commit 44131734bd
10 changed files with 193 additions and 31 deletions

View File

@@ -232,6 +232,10 @@ export class PegasusActor extends Actor {
getEquipments() {
return this.data.items.filter(item => item.type == 'shield' || item.type == 'armor' || item.type == "weapon" || item.type == "equipment");
}
/* ------------------------------------------- */
getEquipmentsOnly() {
return duplicate( this.data.items.filter(item => item.type == "equipment") || [] )
}
/* -------------------------------------------- */
getActiveEffects(matching = it => true) {
@@ -568,6 +572,25 @@ export class PegasusActor extends Actor {
}
}
}
addWeapons(rollData, statKey) {
let weapons = this.getWeapons()
for (let weapon of weapons) {
if (weapon.data.equipped && weapon.data.statistic == statKey) {
rollData.weaponsList.push( {label: `Attack ${weapon.name}`, type: "attack", applied: false, weapon: weapon, value: 0 } )
}
if (weapon.data.equipped && weapon.data.damagestatistic == statKey) {
rollData.weaponsList.push( {label: `Damage ${weapon.name}`, type: "damage", applied: false, weapon: weapon, value: weapon.data.damage } )
}
}
}
addEquipments(rollData, statKey) {
let equipments = this.getEquipmentsOnly()
for (let equip of equipments) {
if (equip.data.equipped && equip.data.stataffected == statKey) {
rollData.equipmentsList.push( {label: `Item ${equip.name}`, type: "item", applied: false, equip: equip, value: equip.data.level } )
}
}
}
/* -------------------------------------------- */
getCommonRollData(statKey = undefined, useShield = false) {
@@ -589,6 +612,8 @@ export class PegasusActor extends Actor {
this.addEffects( rollData)
this.addArmorsShields(rollData, statKey, useShield)
this.addWeapons(rollData, statKey, useShield)
this.addEquipments(rollData, statKey)
return rollData
}

View File

@@ -81,8 +81,8 @@ function welcomeMessage() {
<p>The Pegasus Engine is a available for free on our website. It is also available as a PDF and in Print format at an affordable price.</p>
<p>This project has been made possible thanks to all the Official GMD Members and Patreon Members that have supported me and as a result made it possible to supply this interface for free.</p>
<p>In return I have made available a fully detailed Compendium for FREE for all members, which can be obtained from the Members page on my website.</p>
<p>You too can become a supporter for future projects and enjoy amazing rewards.
<br>Sign up Here: https://www.gmdonline.co.uk/gmdmemberspage/</p>
<P>You too can become a supporter for future projects and enjoy amazing rewards.
<BR>Sign up Here : https://www.gmdonline.co.uk/gmdmemberspage/</p>
<p>GMD Online, GMD CORE RPG logo are © 2018 CORE Worlds and Game Rules © 2001. Interface © 2021 All rights reserved.</p>
<p>Enjoy and become the hero you were born to be!</p>
` });

View File

@@ -60,7 +60,7 @@ export class PegasusRollDialog extends Dialog {
if (effectData.data.bonusdice) {
idVal = "#bonusDicesLevel"
}
if (effectData.data.reducedicevalue) {
if (effectData.data.reducedicevalue || effectData.data.statdice) {
idVal = "#statDicesLevel"
}
if (effectData.data.otherdice) {
@@ -116,6 +116,56 @@ export class PegasusRollDialog extends Dialog {
console.log("Armor", armorIdx, toggled)
}
/* -------------------------------------------- */
manageWeapons( weaponIdx, toggled) {
let weapon = this.rollData.weaponsList[weaponIdx]
if (weapon) {
weapon.applied = toggled
if (weapon.type == 'damage' ) {
if (toggled) {
this.rollData.otherDicesLevel += Number(weapon.value)
} else {
this.rollData.otherDicesLevel -= Number(weapon.value)
this.rollData.otherDicesLevel = (this.rollData.otherDicesLevel<0) ? 0 : this.rollData.otherDicesLevel
}
$("#otherDicesLevel").val(this.rollData.otherDicesLevel)
}
}
console.log("Weapon", weaponIdx, toggled, this.rollData.otherDicesLevel, weapon)
}
/* -------------------------------------------- */
manageEquip( equipIdx, toggled) {
let equip = this.rollData.equipmentsList[equipIdx]
if (equip) {
equip.applied = toggled
let idVal = "#otherDicesLevel" // Default
if (equip.equip.data.bonusdice) {
idVal = "#bonusDicesLevel"
}
if (equip.equip.data.statdice) {
idVal = "#statDicesLevel"
}
if (equip.equip.data.otherdice) {
idVal = "#otherDicesLevel"
}
let newLevel = Number($(idVal).val())
if (toggled) {
newLevel += Number(equip.value)
} else {
newLevel -= Number(equip.value)
}
newLevel = (newLevel <0) ? 0 : newLevel
$(idVal).val(newLevel)
// Then refresh
this.rollData.statDicesLevel = $('#statDicesLevel').val()
this.rollData.specDicesLevel = $('#specDicesLevel').val()
this.rollData.bonusDicesLevel = $('#bonusDicesLevel').val()
this.rollData.hindranceDicesLevel = $('#hindranceDicesLevel').val()
this.rollData.otherDicesLevel = $('#otherDicesLevel').val()
}
}
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
@@ -160,6 +210,16 @@ export class PegasusRollDialog extends Dialog {
let armorIdx = $(event.currentTarget).data("armor-idx")
this.manageArmors( armorIdx, toggled)
});
html.find('.weapon-clicked').change((event) => {
let toggled = event.currentTarget.checked
let weaponIdx = $(event.currentTarget).data("weapon-idx")
this.manageWeapons( weaponIdx, toggled)
});
html.find('.equip-clicked').change((event) => {
let toggled = event.currentTarget.checked
let equipIdx = $(event.currentTarget).data("equip-idx")
this.manageEquip( equipIdx, toggled)
});
}

View File

@@ -32,6 +32,9 @@ export class PegasusUtility {
if (typeof text !== 'string') return text
return text.charAt(0).toUpperCase() + text.slice(1)
});
Handlebars.registerHelper('notEmpty', function (list) {
return list.length > 0;
});
}
@@ -587,6 +590,8 @@ export class PegasusUtility {
specDicesLevel: 0,
effectsList: [],
armorsList: [],
weaponsList: [],
equipmentsList: [],
optionsDiceList: PegasusUtility.getOptionsDiceList()
}
PegasusUtility.updateWithTarget(rollData)