Add worstfear/desires

This commit is contained in:
sladecraven 2022-02-10 21:58:19 +01:00
parent d17afaf142
commit ef8e737d1c
11 changed files with 311 additions and 105 deletions

View File

@ -105,6 +105,17 @@ export class PegasusActorSheet extends ActorSheet {
PegasusUtility.confirmDelete(this, li); PegasusUtility.confirmDelete(this, li);
}); });
html.find('.spec-group-activate').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let itemId = li.data("item-id");
this.actor.specPowerActivate( itemId)
});
html.find('.spec-group-deactivate').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let itemId = li.data("item-id");
this.actor.specPowerDeactivate( itemId)
});
html.find('.effect-used').click(ev => { html.find('.effect-used').click(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");
@ -224,6 +235,13 @@ export class PegasusActorSheet extends ActorSheet {
this.render(true); this.render(true);
}); });
html.find('.change-worstfear').change(ev => {
this.actor.manageWorstFear( ev.currentTarget.checked )
});
html.find('.change-desires').change(ev => {
this.actor.manageDesires( ev.currentTarget.checked )
});
html.find('.update-field').change(ev => { html.find('.update-field').change(ev => {
const fieldName = $(ev.currentTarget).data("field-name"); const fieldName = $(ev.currentTarget).data("field-name");
let value = Number(ev.currentTarget.value); let value = Number(ev.currentTarget.value);

View File

@ -177,6 +177,35 @@ export class PegasusActor extends Actor {
} }
return comp; return comp;
} }
/* -------------------------------------------- */
async manageWorstFear(flag) {
if (flag) {
let effect = await PegasusUtility.getEffectFromCompendium( "Worst Fear" )
console.log("got effect", effect)
effect.data.worstfear = true
this.createEmbeddedDocuments( 'Item', [effect])
} else {
let effect = this.data.items.find( item => item.type == "effect" && item.data.data.worstfear )
if (effect) {
this.deleteEmbeddedDocuments( 'Item', [ effect.id ])
}
}
}
/* -------------------------------------------- */
async manageDesires(flag) {
if (flag) {
let effect = await PegasusUtility.getEffectFromCompendium( "Desires" )
effect.data.desires = true
this.createEmbeddedDocuments( 'Item', [effect])
} else {
let effect = this.data.items.find( item => item.type == "effect" && item.data.data.desires )
if (effect) {
this.deleteEmbeddedDocuments( 'Item', [ effect.id ])
}
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getRelevantSpec(statKey) { getRelevantSpec(statKey) {
let comp = duplicate(this.data.items.filter(item => item.type == 'specialisation' && item.data.data.statistic == statKey) || []); let comp = duplicate(this.data.items.filter(item => item.type == 'specialisation' && item.data.data.statistic == statKey) || []);
@ -197,10 +226,43 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async activatePower(itemId) { async activatePower(itemId) {
let item = this.data.items.find(item => item.id == itemId); let item = this.data.items.find(item => item.id == itemId)
if (item && item.data.data) { if (item && item.data.data) {
let update = { _id: item.id, "data.activated": !item.data.data.activated };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity let nrg = duplicate(this.data.data.nrg)
if ( !item.data.data.activated) { // Current value
if ( item.data.data.cost > nrg.value) {
return ui.notifications.warn("Not enough NRG to activate the Power " + item.name )
}
nrg.activated += item.data.data.cost
nrg.value -= item.data.data.cost
this.update({ 'data.nrg': nrg })
let effects = []
for (let effect of item.data.data.effectsgained) {
effect.data.powerId = itemId // Link to the perk, in order to dynamically remove them
effects.push(effect)
}
if (effects.length) {
await this.createEmbeddedDocuments('Item', effects)
}
} else {
nrg.activated -= item.data.data.cost
this.update({ 'data.nrg': nrg })
let toRem = []
for( let item of this.data.items) {
if (item.type == 'effect' && item.data.data.powerId == itemId) {
toRem.push( item.id)
}
}
if (toRem.length) {
await this.deleteEmbeddedDocuments('Item', toRem)
}
}
let update = { _id: item.id, "data.activated": !item.data.data.activated }
await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity
} }
} }
@ -230,7 +292,7 @@ export class PegasusActor extends Actor {
} }
/* ------------------------------------------- */ /* ------------------------------------------- */
getEquipmentsOnly() { getEquipmentsOnly() {
return duplicate( this.data.items.filter(item => item.type == "equipment") || [] ) return duplicate(this.data.items.filter(item => item.type == "equipment") || [])
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -253,17 +315,17 @@ export class PegasusActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async preprocessItem( event, item, onDrop = false) { async preprocessItem(event, item, onDrop = false) {
if ( item.data.type == 'race') { if (item.data.type == 'race') {
this.applyRace(item.data) this.applyRace(item.data)
} else if ( item.data.type == 'ability') { } else if (item.data.type == 'ability') {
this.applyAbility(item.data, [], true) this.applyAbility(item.data, [], true)
if ( !onDrop) { if (!onDrop) {
await this.createEmbeddedDocuments('Item', [item.data] ) await this.createEmbeddedDocuments('Item', [item.data])
} }
} else { } else {
if ( !onDrop) { if (!onDrop) {
await this.createEmbeddedDocuments('Item', [item.data] ) await this.createEmbeddedDocuments('Item', [item.data])
} }
} }
} }
@ -277,7 +339,7 @@ export class PegasusActor extends Actor {
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getInitiativeScore( combatId, combatantId) { getInitiativeScore(combatId, combatantId) {
if (this.type == 'character') { if (this.type == 'character') {
this.rollMR(true, combatId, combatantId) this.rollMR(true, combatId, combatantId)
} }
@ -334,7 +396,7 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getOneSpec(specId) { getOneSpec(specId) {
let spec = this.data.items.find(item => item.type == 'specialisation' && item.id == specId); let spec = this.data.items.find(item => item.type == 'specialisation' && item.id == specId)
if (spec) { if (spec) {
spec = duplicate(spec); spec = duplicate(spec);
spec.data.dice = PegasusUtility.getDiceFromLevel(spec.data.level); spec.data.dice = PegasusUtility.getDiceFromLevel(spec.data.level);
@ -343,14 +405,66 @@ export class PegasusActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async perkEffectUsed( itemId) { specPowerActivate(specId) {
let spec = this.getOneSpec(specId)
if (spec) {
let powers = []
for (let power of spec.data.powers) {
power.data.specId = specId
powers.push(power)
}
if (powers.length > 0) {
this.createEmbeddedDocuments('Item', powers)
}
this.updateEmbeddedDocuments('Item', [{ _id: specId, 'data.powersactivated': true }])
}
}
/* -------------------------------------------- */
specPowerDeactivate(specId) {
let toRem = []
for (let power of this.data.items) {
if (power.type == "power" && power.data.data.specId && power.data.data.specId == specId) {
toRem.push(power.id)
}
}
if (toRem.length > 0) {
this.deleteEmbeddedDocuments('Item', toRem)
}
this.updateEmbeddedDocuments('Item', [{ _id: specId, 'data.powersactivated': false }])
}
/* -------------------------------------------- */
async perkEffectUsed(itemId) {
let effect = this.items.get(itemId) let effect = this.items.get(itemId)
if (effect) { if (effect) {
PegasusUtility.createChatWithRollMode(effect.name, { PegasusUtility.createChatWithRollMode(effect.name, {
content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-effect-used.html`, effect.data) content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-effect-used.html`, effect.data)
}); });
this.deleteEmbeddedDocuments('Item', [ effect.id] ) this.deleteEmbeddedDocuments('Item', [effect.id])
}
}
/* -------------------------------------------- */
disableWeaverPerk(perk) {
if (perk.data.data.isweaver) {
for (let spec of this.data.items) {
if (spec.type == 'specialisation' && spec.data.data.ispowergroup) {
this.specPowerDeactivate(spec.id)
}
}
}
}
/* -------------------------------------------- */
enableWeaverPerk(perk) {
if (perk.data.data.isweaver) {
for (let spec of this.data.items) {
if (spec.type == 'specialisation' && spec.data.data.ispowergroup) {
this.specPowerActivate(spec.id)
}
}
} }
} }
@ -360,57 +474,58 @@ export class PegasusActor extends Actor {
if (item) { if (item) {
if (item.data.data.status == status) return;// Ensure we are really changing the status if (item.data.data.status == status) return;// Ensure we are really changing the status
let updateOK = true let updateOK = true
if ( status == "ready") { 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) {
effects.push( item.id) effects.push(item.id)
} }
} }
if ( effects.length) { if (effects.length) {
await this.deleteEmbeddedDocuments('Item', effects ) await this.deleteEmbeddedDocuments('Item', effects)
} }
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
this.update( {'data.nrg': nrg } ) this.update({ 'data.nrg': nrg })
} }
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 -= item.data.data.features.bonushealth.value health.bonus -= item.data.data.features.bonushealth.value
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.delirium.delirium) let delirium = duplicate(this.data.data.delirium.delirium)
delirium.bonus -= item.data.data.features.bonusdelirium.value delirium.bonus -= item.data.data.features.bonusdelirium.value
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 -= item.data.data.features.bonusnrg.value nrg.mod -= item.data.data.features.bonusnrg.value
this.update( {'data.nrg': nrg } ) this.update({ 'data.nrg': nrg })
} }
this.disableWeaverPerk(item)
} }
if ( status == "activated") { if (status == "activated") {
// Add effects linked to the perk // Add effects linked to the perk
let effects = [] let effects = []
for( let effect of item.data.data.effectsgained) { for (let effect of item.data.data.effectsgained) {
effect.data.perkId = itemId // Link to the perk, in order to dynamically remove them effect.data.perkId = itemId // Link to the perk, in order to dynamically remove them
effect.data.isUsed = false // Flag to indicate removal when used in a roll window effect.data.isUsed = false // Flag to indicate removal when used in a roll window
effects.push( effect ) effects.push(effect)
} }
if ( effects.length) { if (effects.length) {
await this.createEmbeddedDocuments('Item', effects ) await this.createEmbeddedDocuments('Item', effects)
} }
// Manage additional flags // Manage additional flags
if ( item.data.data.features.nrgcost.flag ) { if (item.data.data.features.nrgcost.flag) {
if (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) { if (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) {
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
nrg.value -= item.data.data.features.nrgcost.value nrg.value -= item.data.data.features.nrgcost.value
this.update( {'data.nrg': nrg } ) this.update({ 'data.nrg': nrg })
} else { } else {
updateOK = false updateOK = false
ui.notifications.warn("Not enough NRG to activate the Perk " + item.name) ui.notifications.warn("Not enough NRG to activate the Perk " + item.name)
@ -419,18 +534,19 @@ 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 += item.data.data.features.bonushealth.value health.bonus += item.data.data.features.bonushealth.value
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.delirium.delirium) let delirium = duplicate(this.data.data.delirium.delirium)
delirium.bonus += item.data.data.features.bonusdelirium.value delirium.bonus += item.data.data.features.bonusdelirium.value
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 += item.data.data.features.bonusnrg.value nrg.mod += item.data.data.features.bonusnrg.value
this.update( {'data.nrg': nrg } ) this.update({ 'data.nrg': nrg })
} }
this.enableWeaverPerk(item)
} }
if (updateOK) { if (updateOK) {
this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'data.status': status }]) this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'data.status': status }])
@ -454,7 +570,7 @@ 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;
@ -515,10 +631,10 @@ export class PegasusActor extends Actor {
// Update current hindrance level // Update current hindrance level
let hindrance = this.data.data.combat.hindrancedice let hindrance = this.data.data.combat.hindrancedice
if ( this.data.data.secondary.health.value < 0) { if (this.data.data.secondary.health.value < 0) {
hindrance += Math.abs(this.data.data.secondary.health.value) hindrance += Math.abs(this.data.data.secondary.health.value)
} }
if ( this.data.data.secondary.delirium.value < 0) { if (this.data.data.secondary.delirium.value < 0) {
hindrance += Math.abs(this.data.data.secondary.delirium.value) hindrance += Math.abs(this.data.data.secondary.delirium.value)
} }
this.data.data.combat.hindrancedice = hindrance this.data.data.combat.hindrancedice = hindrance
@ -573,23 +689,23 @@ export class PegasusActor extends Actor {
} }
// manage status bonus // manage status bonus
if (ability.data.statusaffected != "notapplicable") { if (ability.data.statusaffected != "notapplicable") {
if ( ability.data.statusaffected == 'nrg' ) { if (ability.data.statusaffected == 'nrg') {
let nrg = duplicate( this.data.data.nrg) let nrg = duplicate(this.data.data.nrg)
nrg.mod += Number(ability.data.statusmodifier) nrg.mod += Number(ability.data.statusmodifier)
updates[`data.nrg`] = nrg updates[`data.nrg`] = nrg
} }
if ( ability.data.statusaffected == 'health' ) { if (ability.data.statusaffected == 'health') {
let health = duplicate( this.data.data.secondary.health) let health = duplicate(this.data.data.secondary.health)
health.bonus += Number(ability.data.statusmodifier) health.bonus += Number(ability.data.statusmodifier)
updates[`data.secondary.health`] = health updates[`data.secondary.health`] = health
} }
if ( ability.data.statusaffected == 'delirium' ) { if (ability.data.statusaffected == 'delirium') {
let delirium = duplicate( this.data.data.secondary.delirium) let delirium = duplicate(this.data.data.secondary.delirium)
delirium.bonus += Number(ability.data.statusmodifier) delirium.bonus += Number(ability.data.statusmodifier)
updates[`data.secondary.delirium`] = delirium updates[`data.secondary.delirium`] = delirium
} }
} }
if ( directUpdate ) { if (directUpdate) {
await this.update(updates) await this.update(updates)
} }
let newItems = [] let newItems = []
@ -617,7 +733,7 @@ export class PegasusActor extends Actor {
for (let armor of ability.data.armorgained) { for (let armor of ability.data.armorgained) {
newItems.push(armor); newItems.push(armor);
} }
} }
await this.createEmbeddedDocuments('Item', newItems) await this.createEmbeddedDocuments('Item', newItems)
} }
@ -672,18 +788,18 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
addHindrancesList( effectsList ) { addHindrancesList(effectsList) {
if (this.data.data.combat.stunlevel > 0) { if (this.data.data.combat.stunlevel > 0) {
effectsList.push( { label: "Stun Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.stunlevel } ) effectsList.push({ label: "Stun Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.stunlevel })
} }
if (this.data.data.combat.hindrancedice > 0) { if (this.data.data.combat.hindrancedice > 0) {
effectsList.push( { label: "Health/Delirium Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.hindrancedice } ) effectsList.push({ label: "Health/Delirium Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.hindrancedice })
} }
let effects = this.data.items.filter( item => item.type == 'effect' ) let effects = this.data.items.filter(item => item.type == 'effect')
for( let effect of effects) { for (let effect of effects) {
effect = duplicate(effect) effect = duplicate(effect)
if (effect.data.hindrance) { if (effect.data.hindrance) {
effectsList.push( { label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel } ) effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel })
} }
} }
} }
@ -693,52 +809,52 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
/* -------------------------------------------- */ /* -------------------------------------------- */
addEffects( rollData) { addEffects(rollData) {
let effects = this.data.items.filter( item => item.type == 'effect' ) let effects = this.data.items.filter(item => item.type == 'effect')
for( let effect of effects) { for (let effect of effects) {
effect = duplicate(effect) effect = duplicate(effect)
if ( !effect.data.hindrance if (!effect.data.hindrance
&& effect.data.stataffected != "notapplicable" && effect.data.stataffected != "notapplicable"
&& effect.data.stataffected != "special") { && effect.data.stataffected != "special") {
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 })
} }
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
addArmorsShields( rollData, statKey = "none", useShield = false) { addArmorsShields(rollData, statKey = "none", useShield = false) {
if (statKey == 'phy') { if (statKey == 'phy') {
let armors = this.getArmors() let armors = this.getArmors()
for (let armor of armors) { for (let armor of armors) {
rollData.armorsList.push( {label: `Armor ${armor.name}`, type: "other", applied: false, value: armor.data.resistance } ) rollData.armorsList.push({ label: `Armor ${armor.name}`, type: "other", applied: false, value: armor.data.resistance })
} }
} }
if (useShield ) { if (useShield) {
let shields = this.data.items.filter(item => item.type == "shield" && item.data.data.equipped) let shields = this.data.items.filter(item => item.type == "shield" && item.data.data.equipped)
for (let sh of shields) { for (let sh of shields) {
rollData.armorsList.push( {label: `Shield ${sh.name}`, type: "other", applied: false, value: sh.data.data.level } ) rollData.armorsList.push({ label: `Shield ${sh.name}`, type: "other", applied: false, value: sh.data.data.level })
} }
} }
} }
addWeapons(rollData, statKey) { addWeapons(rollData, statKey) {
let weapons = this.getWeapons() let weapons = this.getWeapons()
for (let weapon of weapons) { for (let weapon of weapons) {
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 } ) rollData.weaponsList.push({ label: `Attack ${weapon.name}`, type: "attack", applied: false, weapon: weapon, value: 0 })
} }
if (weapon.data.equipped && weapon.data.enhanced && weapon.data.enhancedstat == statKey) { if (weapon.data.equipped && weapon.data.enhanced && weapon.data.enhancedstat == statKey) {
rollData.weaponsList.push( {label: `Enhanced Attack ${weapon.name}`, type: "enhanced", applied: false, weapon: weapon, value: weapon.data.enhancedlevel } ) rollData.weaponsList.push({ label: `Enhanced Attack ${weapon.name}`, type: "enhanced", applied: false, weapon: weapon, value: weapon.data.enhancedlevel })
} }
if (weapon.data.equipped && weapon.data.damagestatistic == statKey) { 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 } ) rollData.weaponsList.push({ label: `Damage ${weapon.name}`, type: "damage", applied: false, weapon: weapon, value: weapon.data.damage })
} }
} }
} }
addEquipments(rollData, statKey) { addEquipments(rollData, statKey) {
let equipments = this.getEquipmentsOnly() let equipments = this.getEquipmentsOnly()
for (let equip of equipments) { for (let equip of equipments) {
if (equip.data.equipped && equip.data.stataffected == statKey) { 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 } ) rollData.equipmentsList.push({ label: `Item ${equip.name}`, type: "item", applied: false, equip: equip, value: equip.data.level })
} }
} }
} }
@ -752,20 +868,20 @@ export class PegasusActor extends Actor {
rollData.img = this.img rollData.img = this.img
rollData.activePerks = duplicate(this.getActivePerks()) rollData.activePerks = duplicate(this.getActivePerks())
if ( statKey) { if (statKey) {
rollData.statKey = statKey rollData.statKey = statKey
rollData.stat = this.getStat(statKey) rollData.stat = this.getStat(statKey)
rollData.statDicesLevel = rollData.stat.value rollData.statDicesLevel = rollData.stat.value
rollData.statMod = rollData.stat.mod rollData.statMod = rollData.stat.mod
rollData.specList = this.getRelevantSpec(statKey) rollData.specList = this.getRelevantSpec(statKey)
rollData.selectedSpec = "0" rollData.selectedSpec = "0"
} }
this.addEffects( rollData) this.addEffects(rollData)
this.addArmorsShields(rollData, statKey, useShield) this.addArmorsShields(rollData, statKey, useShield)
this.addWeapons(rollData, statKey, useShield) this.addWeapons(rollData, statKey, useShield)
this.addEquipments(rollData, statKey) this.addEquipments(rollData, statKey)
return rollData return rollData
} }
@ -828,7 +944,7 @@ export class PegasusActor extends Actor {
let rollData = this.getCommonRollData(spec.data.statistic) let rollData = this.getCommonRollData(spec.data.statistic)
rollData.mode = "spec" rollData.mode = "spec"
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.specDicesLevel = spec.data.level rollData.specDicesLevel = spec.data.level
this.startRoll(rollData) this.startRoll(rollData)
@ -838,7 +954,7 @@ export class PegasusActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollMR( isInit = false, combatId = 0, combatantId = 0) { async rollMR(isInit = false, combatId = 0, combatantId = 0) {
let mr = duplicate(this.data.data.mr) let mr = duplicate(this.data.data.mr)
if (mr) { if (mr) {
mr.dice = PegasusUtility.getDiceFromLevel(mr.value); mr.dice = PegasusUtility.getDiceFromLevel(mr.value);

View File

@ -348,6 +348,16 @@ export class PegasusItemSheet extends ItemSheet {
} }
} }
/* -------------------------------------------- */
async addEffectPower( event, item, dataItem) {
let newItem = duplicate(item.data)
if ( event.toElement.className == 'drop-power-effect') {
let effectArray = duplicate(this.object.data.data.effectsgained)
effectArray.push( newItem );
await this.object.update( { 'data.effectsgained': effectArray} )
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async addEffectSpec( event, item, dataItem) { async addEffectSpec( event, item, dataItem) {
let newItem = duplicate(item.data); let newItem = duplicate(item.data);
@ -365,7 +375,18 @@ export class PegasusItemSheet extends ItemSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDrop(event) { async _onDrop(event) {
//console.log(event);
if (this.object.type == 'power' ) {
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.addEffectPower( event, item, dataItem);
}
}
}
if (this.object.type == 'effect' ) { if (this.object.type == 'effect' ) {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {

View File

@ -20,7 +20,7 @@ export class PegasusUtility {
Hooks.on("dropCanvasData", (canvas, data) => { Hooks.on("dropCanvasData", (canvas, data) => {
PegasusUtility.dropItemOnToken(canvas, data) PegasusUtility.dropItemOnToken(canvas, data)
}); });
this.rollDataStore = {} this.rollDataStore = {}
this.defenderStore = {} this.defenderStore = {}
this.diceList = []; this.diceList = [];
@ -64,18 +64,18 @@ export class PegasusUtility {
if (data.type != "Item") { if (data.type != "Item") {
return return
} }
const position = canvas.grid.getTopLeft(data.x, data.y) const position = canvas.grid.getTopLeft(data.x, data.y)
let x = position[0] let x = position[0]
let y = position[1] let y = position[1]
const tokensList = [...canvas.tokens.placeables] const tokensList = [...canvas.tokens.placeables]
for(let token of tokensList) { for (let token of tokensList) {
if ( x >= token.x && x <= (token.x + token.width) if (x >= token.x && x <= (token.x + token.width)
&& y >= token.y && y <= (token.y + token.height) ) { && y >= token.y && y <= (token.y + token.height)) {
let item = await this.searchItem(data) let item = await this.searchItem(data)
token.actor.preprocessItem("none", item, false ) token.actor.preprocessItem("none", item, false)
console.log("Dropped !!!", item, token) console.log("Dropped !!!", item, token)
return return
} }
} }
} }
@ -186,6 +186,22 @@ export class PegasusUtility {
return loadTemplates(templatePaths); return loadTemplates(templatePaths);
} }
/* -------------------------------------------- */
static async getEffectFromCompendium(effectName) {
effectName = effectName.toLowerCase()
let effect = game.items.find(item => item.data.type == 'effect' && item.name.toLowerCase() == effectName)
if (!effect) {
let effects = await this.loadCompendium('fvtt-pegasus.effect', item => item.name.toLowerCase() == effectName)
let objs = effects.map(i => i.toObject())
effect = objs[0]
} else {
effect = duplicate(effect);
}
console.log("Effect", effect)
return effect
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static removeChatMessageId(messageId) { static removeChatMessageId(messageId) {
if (messageId) { if (messageId) {
@ -404,18 +420,18 @@ export class PegasusUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static removeUsedPerkEffects( rollData) { static removeUsedPerkEffects(rollData) {
// De-actived used effects from perks // De-actived used effects from perks
let toRem = [] let toRem = []
for(let effect of rollData.effectsList) { for (let effect of rollData.effectsList) {
if (effect.effect.data.perkId && effect.effect.data.isUsed) { if (effect.effect.data.perkId && effect.effect.data.isUsed) {
toRem.push( effect.effect._id) toRem.push(effect.effect._id)
} }
} }
if (toRem.length > 0) { if (toRem.length > 0) {
let actor = game.actors.get(rollData.actorId) let actor = game.actors.get(rollData.actorId)
actor.deleteEmbeddedDocuments('Item', toRem) actor.deleteEmbeddedDocuments('Item', toRem)
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -1163,6 +1163,8 @@ ul, li {
.ul-level1 { .ul-level1 {
padding-left: 2rem; padding-left: 2rem;
} }
.drop-power-effect,
.drop-perk-effect, .drop-perk-effect,
.drop-ability-effect, .drop-ability-effect,
.drop-effect-specaffected, .drop-effect-specaffected,

View File

@ -180,9 +180,9 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 69, "templateVersion": 73,
"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.2", "version": "0.4.8",
"background" : "./images/ui/pegasus_welcome_page.webp" "background" : "./images/ui/pegasus_welcome_page.webp"
} }

View File

@ -13,7 +13,9 @@
"eyes": "", "eyes": "",
"description": "", "description": "",
"worstfear": "", "worstfear": "",
"worstfearactive": false,
"desires": "", "desires": "",
"desiresactive": false,
"preferredhand": "", "preferredhand": "",
"catchphrase": "", "catchphrase": "",
"catchphraseused": false, "catchphraseused": false,
@ -251,6 +253,7 @@
"level": 1, "level": 1,
"ispowergroup": false, "ispowergroup": false,
"powersource": "", "powersource": "",
"powersactivated": false,
"powers": [], "powers": [],
"description": "" "description": ""
}, },
@ -258,6 +261,7 @@
"level": 1, "level": 1,
"active": false, "active": false,
"duration": "", "duration": "",
"isweaver": false,
"effectsgained": [], "effectsgained": [],
"features": { "features": {
"nrgcost": { "nrgcost": {
@ -312,6 +316,7 @@
"effects": "", "effects": "",
"activated": false, "activated": false,
"purchasedeffects": "", "purchasedeffects": "",
"effectsgained": [],
"description": "" "description": ""
}, },
"armor": { "armor": {

View File

@ -121,6 +121,15 @@
<span class="stat-label"><a class="roll-spec">{{spec.name}}</a></span> <span class="stat-label"><a class="roll-spec">{{spec.name}}</a></span>
<span class="stat-label">{{upper spec.data.statistic}}</span> <span class="stat-label">{{upper spec.data.statistic}}</span>
<span class="stat-label">{{spec.data.dice}}</span> <span class="stat-label">{{spec.data.dice}}</span>
{{#if spec.data.ispowergroup}}
{{#if spec.data.powersactivated}}
<span class="stat-label"><a class="spec-group-deactivate">Deactivate</a></span>
{{else}}
<span class="stat-label"><a class="spec-group-activate">Activate</a></span>
{{/if}}
{{else}}
<span class="stat-label">&nbsp;</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>
@ -493,14 +502,14 @@
<ul> <ul>
<li class="flexrow"> <li class="flexrow">
<label class="short-label">Worst Fear </label> <label class="short-label">Worst Fear </label>
<input type="text" class="" name="data.biodata.worstfear" value="{{data.biodata.worstfear}}" <input type="text" class="" name="data.biodata.worstfear" value="{{data.biodata.worstfear}}" data-dtype="String" />
data-dtype="String" /> <label class="attribute-value checkbox"><input type="checkbox" class="change-worstfear" name="data.biodata.worstfearactive" {{checked data.biodata.worstfearactive}}/> Active ?</label>
</li> </li>
<li class="flexrow"> <li class="flexrow">
<label class="short-label">Desires </label> <label class="short-label">Desires </label>
<input type="text" class="" name="data.biodata.desires" value="{{data.biodata.desires}}" <input type="text" class="" name="data.biodata.desires" value="{{data.biodata.desires}}" data-dtype="String" />
data-dtype="String" /> <label class="attribute-value checkbox"><input type="checkbox" class="change-desires" name="data.biodata.desiresactive" {{checked data.biodata.desiresactive}}/> Active ?</label>
</li> </li>
</ul> </ul>
<h3>Catchphrase : </h3> <h3>Catchphrase : </h3>

View File

@ -11,12 +11,10 @@
<div class="tab" data-group="primary"> <div class="tab" data-group="primary">
<ul> <ul>
<li class="flexrow"><label class="generic-label">Active ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.active" {{checked data.active}}/></label>
</li>
<li class="flexrow"><label class="generic-label">Level</label> <li class="flexrow"><label class="generic-label">Level</label>
<input type="text" class="input-numeric-short padd-right" name="data.level" value="{{data.level}}" data-dtype="Number"/> <input type="text" class="input-numeric-short padd-right" name="data.level" value="{{data.level}}" data-dtype="Number"/>
</li> </li>
<li class="flexrow"><label class="generic-label">Perk Status</label> <li class="flexrow"><label class="generic-label">Perk Status</label>
<select class="competence-base flexrow" type="text" name="data.status" value="{{data.status}}" data-dtype="String"> <select class="competence-base flexrow" type="text" name="data.status" value="{{data.status}}" data-dtype="String">
{{#select data.status}} {{#select data.status}}
@ -37,6 +35,9 @@
{{/select}} {{/select}}
</select> </select>
</li> </li>
<li class="flexrow"><label class="generic-label">Is Weaver Perk?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.isweaver" {{checked data.isweaver}}/></label>
</li>
<li class="flexrow"><label class="generic-label">Effects Gained</label> <li class="flexrow"><label class="generic-label">Effects Gained</label>
</li> </li>

View File

@ -71,6 +71,24 @@
<li class="flexrow"><label class="generic-label">Power Source</label> <li class="flexrow"><label class="generic-label">Power Source</label>
<input type="text" class="padd-right" name="data.powersource" value="{{data.powersource}}" data-dtype="String"/> <input type="text" class="padd-right" name="data.powersource" value="{{data.powersource}}" data-dtype="String"/>
</li> </li>
<li class="flexrow"><label class="generic-label">Effects Gained</label>
</li>
<li>
<ul class="ul-level1">
<li class="flexrow"><div class="drop-power-effect"><label>Drop Effects here !</label></div>
</li>
{{#each data.effectsgained as |effect idx|}}
<li class="flexrow">
<label name="data.effectsgained[{{idx}}].name"><a class="view-subitem" data-type="effectsgained" data-index="{{idx}}">{{effect.name}}</a></label>
<div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="effectsgained" data-index="{{idx}}" title="Delete Effect"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</li>
<li class="flexrow"><label class="generic-label">Available Effects</label> <li class="flexrow"><label class="generic-label">Available Effects</label>
<div class="small-editor item-text-long-line"> <div class="small-editor item-text-long-line">
{{editor content=data.effects target="data.effects" button=true owner=owner editable=editable}} {{editor content=data.effects target="data.effects" button=true owner=owner editable=editable}}

View File

@ -1,7 +1,7 @@
{{#if notapplicable}} {{#if notapplicable}}
<option value="notapplicable">Not applicable</option> <option value="notapplicable">Not applicable</option>
{{/if}} {{/if}}
<option value="touch">Touch</option> <option value="touch">Self Only</option>
<option value="touchself">Touch/Self</option> <option value="touchself">Touch/Self</option>
<option value="tz">Threat Zone</option> <option value="tz">Threat Zone</option>
<option value="close">Close</option> <option value="close">Close</option>