Add spells and alchemy

This commit is contained in:
2022-01-23 09:25:09 +01:00
parent 5eb059a2fa
commit aeb7739879
28 changed files with 696 additions and 71 deletions

View File

@@ -38,6 +38,11 @@ export class BoLActorSheet extends ActorSheet {
// Equip/Unequip item
html.find('.item-equip').click(this._onToggleEquip.bind(this));
html.find(".inc-dec-btns-alchemy").click((ev) => {
const li = $(ev.currentTarget).parents(".item");
this.actor.spendAlchemyPoint( li.data("itemId"), 1)
})
// Incr./Decr. career ranks
html.find(".inc-dec-btns").click((ev) => {
const li = $(ev.currentTarget).parents(".item");
@@ -65,10 +70,6 @@ export class BoLActorSheet extends ActorSheet {
item.update(update);
}
}
// const input = html.find("#" + type);
// let value = parseInt(input.val(), 10) || 0;
// value += operator === "plus" ? 1 : -1;
// input.val(value > 0 ? value : 0);
});
@@ -110,26 +111,36 @@ export class BoLActorSheet extends ActorSheet {
const data = super.getData(options);
const actorData = duplicate(data.data);
let formData = duplicate(data)
formData.config = game.bol.config;
formData.data = actorData.data;
formData.details = this.actor.details;
formData.attributes = this.actor.attributes;
formData.aptitudes = this.actor.aptitudes;
formData.resources = this.actor.getResourcesFromType();
formData.equipment = this.actor.equipment;
formData.weapons = this.actor.weapons;
formData.protections = this.actor.protections;
formData.containers = this.actor.containers;
formData.treasure = this.actor.treasure;
formData.config = game.bol.config
formData.data = actorData.data
formData.details = this.actor.details
formData.attributes = this.actor.attributes
formData.aptitudes = this.actor.aptitudes
formData.resources = this.actor.getResourcesFromType()
formData.equipment = this.actor.equipment
formData.weapons = this.actor.weapons
formData.protections = this.actor.protections
formData.spells = this.actor.spells
formData.alchemy = this.actor.alchemy
formData.containers = this.actor.containers
formData.treasure = this.actor.treasure
formData.treasure = this.actor.treasure
formData.treasure = this.actor.alchemyrecipe
formData.vehicles = this.actor.vehicles;
formData.ammos = this.actor.ammos;
formData.misc = this.actor.misc;
formData.combat = this.actor.buildCombat();
formData.features = this.actor.buildFeatures();
formData.isGM = game.user.isGM;
formData.options= this.options,
formData.owner= this.document.isOwner,
formData.editScore= this.options.editScore,
formData.features = this.actor.buildFeatures()
formData.isGM = game.user.isGM
formData.options= this.options
formData.owner= this.document.isOwner
formData.editScore= this.options.editScore
formData.isSorcerer = this.actor.isSorcerer()
formData.isAlchemist = this.actor.isAlchemist()
formData.isPriest = this.actor.isPriest()
formData.isGM= game.user.isGM
console.log("ACTORDATA", formData);
@@ -193,6 +204,12 @@ export class BoLActorSheet extends ActorSheet {
case "weapon":
BoLRoll.weaponCheck(this.actor, actorData, dataset, event);
break;
case "spell":
BoLRoll.spellCheck(this.actor, actorData, dataset, event);
break;
case "alchemy":
BoLRoll.alchemyCheck(this.actor, actorData, dataset, event);
break;
case "protection":
this.actor.rollProtection(li.data("item-id"))
break;

View File

@@ -109,6 +109,12 @@ export class BoLActor extends Actor {
get protections() {
return this.armors.concat(this.helms).concat(this.shields)
}
get spells() {
return this.itemData.filter(i => i.type === "item" && i.data.category === "spell");
}
get alchemy() {
return this.itemData.filter(i => i.type === "item" && i.data.category === "alchemy");
}
get melee() {
return this.weapons.filter(i => i.data.properties.melee === true);
}
@@ -136,6 +142,66 @@ export class BoLActor extends Actor {
return this.itemData.filter(i => i.type === "item" && i.data.category === "equipment" && (i.data.subtype === "other" ||i.data.subtype === "container" ||i.data.subtype === "scroll" || i.data.subtype === "jewel"));
}
isSorcerer( ) {
if ( this.careers.find( item => item.data.properties.sorcerer == true) )
return true
return false
}
isAlchemist( ) {
if ( this.careers.find( item => item.data.properties.alchemist == true) )
return true
return false
}
isPriest( ) {
if ( this.careers.find( item => item.data.properties.priest == true) )
return true
return false
}
spendPowerPoint( ppCost ) {
let newPP = this.data.data.resources.power.value - ppCost
newPP = (newPP<0) ? 0 : newPP
this.update( {'data.resources.power.value': newPP})
}
resetAlchemyStatus( alchemyId ) {
let alchemy = this.data.items.get( alchemyId)
if (alchemy) {
this.updateEmbeddedDocuments('Item', [{_id: alchemy.id, 'data.properties.pccurrent': 0}] )
}
}
async spendAlchemyPoint( alchemyId, pcCost) {
let alchemy = this.data.items.get( alchemyId)
if (alchemy) {
pcCost = Number(pcCost)?? 0
if ( this.data.data.resources.alchemypoints.value >= pcCost) {
let newPC = this.data.data.resources.alchemypoints.value - pcCost
newPC = (newPC<0) ? 0 : newPC
this.update( {'data.resources.alchemypoints.value': newPC} )
newPC = alchemy.data.data.properties.pccurrent + pcCost
await this.updateEmbeddedDocuments('Item', [{_id: alchemy.id, 'data.properties.pccurrent': newPC}] )
} else {
ui.notifications.warn("Plus assez de Points de Création !")
}
}
}
getAlchemistBonus() {
let sorcerer = this.careers.find( item => item.data.properties.alchemist == true)
if (sorcerer) {
return sorcerer.data.rank
}
return 0;
}
getSorcererBonus() {
let sorcerer = this.careers.find( item => item.data.properties.sorcerer == true)
if (sorcerer) {
return sorcerer.data.rank
}
return 0;
}
heroReroll( ) {
if (this.type == 'character') {
return this.data.data.resources.hero.value > 0;