Add worstfear/desires
This commit is contained in:
parent
d17afaf142
commit
ef8e737d1c
@ -105,6 +105,17 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
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 => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
@ -224,6 +235,13 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
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 => {
|
||||
const fieldName = $(ev.currentTarget).data("field-name");
|
||||
let value = Number(ev.currentTarget.value);
|
||||
|
@ -177,6 +177,35 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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() {
|
||||
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) {
|
||||
if ( item.data.type == 'race') {
|
||||
async preprocessItem(event, item, onDrop = false) {
|
||||
if (item.data.type == 'race') {
|
||||
this.applyRace(item.data)
|
||||
} else if ( item.data.type == 'ability') {
|
||||
} else if (item.data.type == 'ability') {
|
||||
this.applyAbility(item.data, [], true)
|
||||
if ( !onDrop) {
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
if (!onDrop) {
|
||||
await this.createEmbeddedDocuments('Item', [item.data])
|
||||
}
|
||||
} else {
|
||||
if ( !onDrop) {
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
if (!onDrop) {
|
||||
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') {
|
||||
this.rollMR(true, combatId, combatantId)
|
||||
}
|
||||
@ -334,7 +396,7 @@ export class PegasusActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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) {
|
||||
spec = duplicate(spec);
|
||||
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)
|
||||
if (effect) {
|
||||
PegasusUtility.createChatWithRollMode(effect.name, {
|
||||
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.data.data.status == status) return;// Ensure we are really changing the status
|
||||
|
||||
|
||||
let updateOK = true
|
||||
if ( status == "ready") {
|
||||
if (status == "ready") {
|
||||
let effects = []
|
||||
for( let item of this.data.items) {
|
||||
if ( item.type == "effect" && item.data.data.perkId == itemId) {
|
||||
effects.push( item.id)
|
||||
for (let item of this.data.items) {
|
||||
if (item.type == "effect" && item.data.data.perkId == itemId) {
|
||||
effects.push(item.id)
|
||||
}
|
||||
}
|
||||
if ( effects.length) {
|
||||
await this.deleteEmbeddedDocuments('Item', effects )
|
||||
if (effects.length) {
|
||||
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)
|
||||
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) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
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) {
|
||||
let delirium = duplicate(this.data.data.delirium.delirium)
|
||||
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) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
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
|
||||
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.isUsed = false // Flag to indicate removal when used in a roll window
|
||||
effects.push( effect )
|
||||
effects.push(effect)
|
||||
}
|
||||
if ( effects.length) {
|
||||
await this.createEmbeddedDocuments('Item', effects )
|
||||
if (effects.length) {
|
||||
await this.createEmbeddedDocuments('Item', effects)
|
||||
}
|
||||
// Manage additional flags
|
||||
if ( item.data.data.features.nrgcost.flag ) {
|
||||
if (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) {
|
||||
if (item.data.data.features.nrgcost.flag) {
|
||||
if (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.activated += 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 {
|
||||
updateOK = false
|
||||
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) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
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) {
|
||||
let delirium = duplicate(this.data.data.delirium.delirium)
|
||||
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) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.mod += item.data.data.features.bonusnrg.value
|
||||
this.update( {'data.nrg': nrg } )
|
||||
this.update({ 'data.nrg': nrg })
|
||||
}
|
||||
this.enableWeaverPerk(item)
|
||||
}
|
||||
if (updateOK) {
|
||||
this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'data.status': status }])
|
||||
@ -454,7 +570,7 @@ export class PegasusActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async computeNRGHealth() {
|
||||
if ( this.isToken ) return
|
||||
if (this.isToken) return
|
||||
if (this.isOwner || game.user.isGM) {
|
||||
let updates = {}
|
||||
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
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
this.data.data.combat.hindrancedice = hindrance
|
||||
@ -573,23 +689,23 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
// manage status bonus
|
||||
if (ability.data.statusaffected != "notapplicable") {
|
||||
if ( ability.data.statusaffected == 'nrg' ) {
|
||||
let nrg = duplicate( this.data.data.nrg)
|
||||
if (ability.data.statusaffected == 'nrg') {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.mod += Number(ability.data.statusmodifier)
|
||||
updates[`data.nrg`] = nrg
|
||||
}
|
||||
if ( ability.data.statusaffected == 'health' ) {
|
||||
let health = duplicate( this.data.data.secondary.health)
|
||||
if (ability.data.statusaffected == 'health') {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
health.bonus += Number(ability.data.statusmodifier)
|
||||
updates[`data.secondary.health`] = health
|
||||
}
|
||||
if ( ability.data.statusaffected == 'delirium' ) {
|
||||
let delirium = duplicate( this.data.data.secondary.delirium)
|
||||
if (ability.data.statusaffected == 'delirium') {
|
||||
let delirium = duplicate(this.data.data.secondary.delirium)
|
||||
delirium.bonus += Number(ability.data.statusmodifier)
|
||||
updates[`data.secondary.delirium`] = delirium
|
||||
}
|
||||
}
|
||||
if ( directUpdate ) {
|
||||
if (directUpdate) {
|
||||
await this.update(updates)
|
||||
}
|
||||
let newItems = []
|
||||
@ -617,7 +733,7 @@ export class PegasusActor extends Actor {
|
||||
for (let armor of ability.data.armorgained) {
|
||||
newItems.push(armor);
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
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' )
|
||||
for( let effect of effects) {
|
||||
let effects = this.data.items.filter(item => item.type == 'effect')
|
||||
for (let effect of effects) {
|
||||
effect = duplicate(effect)
|
||||
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) {
|
||||
let effects = this.data.items.filter( item => item.type == 'effect' )
|
||||
for( let effect of effects) {
|
||||
addEffects(rollData) {
|
||||
let effects = this.data.items.filter(item => item.type == 'effect')
|
||||
for (let effect of effects) {
|
||||
effect = duplicate(effect)
|
||||
if ( !effect.data.hindrance
|
||||
&& effect.data.stataffected != "notapplicable"
|
||||
&& effect.data.stataffected != "special") {
|
||||
rollData.effectsList.push( { label: effect.name, type: "effect", applied: false, effect: effect, value: effect.data.effectlevel } )
|
||||
if (!effect.data.hindrance
|
||||
&& effect.data.stataffected != "notapplicable"
|
||||
&& effect.data.stataffected != "special") {
|
||||
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') {
|
||||
let armors = this.getArmors()
|
||||
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)
|
||||
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) {
|
||||
let weapons = this.getWeapons()
|
||||
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 } )
|
||||
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) {
|
||||
rollData.weaponsList.push( {label: `Enhanced Attack ${weapon.name}`, type: "enhanced", applied: false, weapon: weapon, value: weapon.data.enhancedlevel } )
|
||||
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 })
|
||||
}
|
||||
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) {
|
||||
let equipments = this.getEquipmentsOnly()
|
||||
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 } )
|
||||
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.activePerks = duplicate(this.getActivePerks())
|
||||
|
||||
if ( statKey) {
|
||||
if (statKey) {
|
||||
rollData.statKey = statKey
|
||||
rollData.stat = this.getStat(statKey)
|
||||
rollData.statDicesLevel = rollData.stat.value
|
||||
rollData.statMod = rollData.stat.mod
|
||||
rollData.statMod = rollData.stat.mod
|
||||
rollData.specList = this.getRelevantSpec(statKey)
|
||||
rollData.selectedSpec = "0"
|
||||
}
|
||||
}
|
||||
|
||||
this.addEffects( rollData)
|
||||
this.addEffects(rollData)
|
||||
this.addArmorsShields(rollData, statKey, useShield)
|
||||
this.addWeapons(rollData, statKey, useShield)
|
||||
this.addEquipments(rollData, statKey)
|
||||
|
||||
|
||||
return rollData
|
||||
}
|
||||
|
||||
@ -828,7 +944,7 @@ export class PegasusActor extends Actor {
|
||||
let rollData = this.getCommonRollData(spec.data.statistic)
|
||||
rollData.mode = "spec"
|
||||
rollData.title = `Spec. : ${spec.name} `
|
||||
rollData.specList = [ spec ]
|
||||
rollData.specList = [spec]
|
||||
rollData.selectedSpec = spec._id
|
||||
rollData.specDicesLevel = spec.data.level
|
||||
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)
|
||||
if (mr) {
|
||||
mr.dice = PegasusUtility.getDiceFromLevel(mr.value);
|
||||
|
@ -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) {
|
||||
let newItem = duplicate(item.data);
|
||||
@ -365,7 +375,18 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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' ) {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
|
@ -20,7 +20,7 @@ export class PegasusUtility {
|
||||
Hooks.on("dropCanvasData", (canvas, data) => {
|
||||
PegasusUtility.dropItemOnToken(canvas, data)
|
||||
});
|
||||
|
||||
|
||||
this.rollDataStore = {}
|
||||
this.defenderStore = {}
|
||||
this.diceList = [];
|
||||
@ -64,18 +64,18 @@ export class PegasusUtility {
|
||||
if (data.type != "Item") {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const position = canvas.grid.getTopLeft(data.x, data.y)
|
||||
let x = position[0]
|
||||
let y = position[1]
|
||||
const tokensList = [...canvas.tokens.placeables]
|
||||
for(let token of tokensList) {
|
||||
if ( x >= token.x && x <= (token.x + token.width)
|
||||
&& y >= token.y && y <= (token.y + token.height) ) {
|
||||
let item = await this.searchItem(data)
|
||||
token.actor.preprocessItem("none", item, false )
|
||||
console.log("Dropped !!!", item, token)
|
||||
return
|
||||
for (let token of tokensList) {
|
||||
if (x >= token.x && x <= (token.x + token.width)
|
||||
&& y >= token.y && y <= (token.y + token.height)) {
|
||||
let item = await this.searchItem(data)
|
||||
token.actor.preprocessItem("none", item, false)
|
||||
console.log("Dropped !!!", item, token)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -186,6 +186,22 @@ export class PegasusUtility {
|
||||
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) {
|
||||
if (messageId) {
|
||||
@ -404,18 +420,18 @@ export class PegasusUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static removeUsedPerkEffects( rollData) {
|
||||
static removeUsedPerkEffects(rollData) {
|
||||
// De-actived used effects from perks
|
||||
let toRem = []
|
||||
for(let effect of rollData.effectsList) {
|
||||
for (let effect of rollData.effectsList) {
|
||||
if (effect.effect.data.perkId && effect.effect.data.isUsed) {
|
||||
toRem.push( effect.effect._id)
|
||||
toRem.push(effect.effect._id)
|
||||
}
|
||||
}
|
||||
if (toRem.length > 0) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.deleteEmbeddedDocuments('Item', toRem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -1163,6 +1163,8 @@ ul, li {
|
||||
.ul-level1 {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
|
||||
.drop-power-effect,
|
||||
.drop-perk-effect,
|
||||
.drop-ability-effect,
|
||||
.drop-effect-specaffected,
|
||||
|
@ -180,9 +180,9 @@
|
||||
"styles": [
|
||||
"styles/simple.css"
|
||||
],
|
||||
"templateVersion": 69,
|
||||
"templateVersion": 73,
|
||||
"title": "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"
|
||||
}
|
||||
|
@ -13,7 +13,9 @@
|
||||
"eyes": "",
|
||||
"description": "",
|
||||
"worstfear": "",
|
||||
"worstfearactive": false,
|
||||
"desires": "",
|
||||
"desiresactive": false,
|
||||
"preferredhand": "",
|
||||
"catchphrase": "",
|
||||
"catchphraseused": false,
|
||||
@ -251,6 +253,7 @@
|
||||
"level": 1,
|
||||
"ispowergroup": false,
|
||||
"powersource": "",
|
||||
"powersactivated": false,
|
||||
"powers": [],
|
||||
"description": ""
|
||||
},
|
||||
@ -258,6 +261,7 @@
|
||||
"level": 1,
|
||||
"active": false,
|
||||
"duration": "",
|
||||
"isweaver": false,
|
||||
"effectsgained": [],
|
||||
"features": {
|
||||
"nrgcost": {
|
||||
@ -312,6 +316,7 @@
|
||||
"effects": "",
|
||||
"activated": false,
|
||||
"purchasedeffects": "",
|
||||
"effectsgained": [],
|
||||
"description": ""
|
||||
},
|
||||
"armor": {
|
||||
|
@ -121,6 +121,15 @@
|
||||
<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">{{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"> </span>
|
||||
{{/if}}
|
||||
<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-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||
@ -493,14 +502,14 @@
|
||||
<ul>
|
||||
<li class="flexrow">
|
||||
<label class="short-label">Worst Fear </label>
|
||||
<input type="text" class="" name="data.biodata.worstfear" value="{{data.biodata.worstfear}}"
|
||||
data-dtype="String" />
|
||||
<input type="text" class="" name="data.biodata.worstfear" value="{{data.biodata.worstfear}}" 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 class="flexrow">
|
||||
<label class="short-label">Desires </label>
|
||||
<input type="text" class="" name="data.biodata.desires" value="{{data.biodata.desires}}"
|
||||
data-dtype="String" />
|
||||
</li>
|
||||
<input type="text" class="" name="data.biodata.desires" value="{{data.biodata.desires}}" 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>
|
||||
</ul>
|
||||
|
||||
<h3>Catchphrase : </h3>
|
||||
|
@ -11,12 +11,10 @@
|
||||
|
||||
<div class="tab" data-group="primary">
|
||||
<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>
|
||||
<input type="text" class="input-numeric-short padd-right" name="data.level" value="{{data.level}}" data-dtype="Number"/>
|
||||
</li>
|
||||
|
||||
<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 data.status}}
|
||||
@ -37,6 +35,9 @@
|
||||
{{/select}}
|
||||
</select>
|
||||
</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>
|
||||
|
@ -71,6 +71,24 @@
|
||||
<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"/>
|
||||
</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>
|
||||
<div class="small-editor item-text-long-line">
|
||||
{{editor content=data.effects target="data.effects" button=true owner=owner editable=editable}}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{{#if notapplicable}}
|
||||
<option value="notapplicable">Not applicable</option>
|
||||
{{/if}}
|
||||
<option value="touch">Touch</option>
|
||||
<option value="touch">Self Only</option>
|
||||
<option value="touchself">Touch/Self</option>
|
||||
<option value="tz">Threat Zone</option>
|
||||
<option value="close">Close</option>
|
||||
|
Loading…
Reference in New Issue
Block a user