Initial import

This commit is contained in:
2021-12-03 18:31:43 +01:00
parent b3f0af8c12
commit 742f96fcbe
14 changed files with 199 additions and 116 deletions

View File

@ -84,7 +84,11 @@ export class PegasusActor extends Actor {
super._preUpdate(changed, options, user);
}
/* -------------------------------------------- */
getActivePerks() {
let perks = this.data.items.filter( item => item.type == 'perk' && item.data.data.active);
return perks;
}
/* -------------------------------------------- */
getPerks() {
let comp = this.data.items.filter( item => item.type == 'perk');
@ -139,6 +143,15 @@ export class PegasusActor extends Actor {
return comp;
}
/* -------------------------------------------- */
async activatePerk(perkId ) {
let item = this.data.items.find( item => item.id == perkId );
if (item && item.data.data) {
let update = { _id: item.id, "data.active": !item.data.data.active };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
async equipItem(itemId ) {
let item = this.data.items.find( item => item.id == itemId );
@ -392,6 +405,7 @@ export class PegasusActor extends Actor {
rollMode: game.settings.get("core", "rollMode"),
title: `Stat ${stat.label} `,
stat: stat,
activePerks: duplicate(this.getActivePerks()),
optionsDiceList: PegasusUtility.getOptionsDiceList(),
bonusDicesLevel: 0,
hindranceDicesLevel: 0,
@ -420,10 +434,11 @@ export class PegasusActor extends Actor {
actorId: this.id,
img: spec.img,
rollMode: game.settings.get("core", "rollMode"),
title: `Specialisation Roll : ${spec.name} `,
spec : spec ,
optionsDiceList: PegasusUtility.getOptionsDiceList(),
title: `Spec. : ${spec.name} `,
stat: this.getStat( spec.data.statistic ),
spec : spec ,
activePerks: duplicate(this.getActivePerks()),
optionsDiceList: PegasusUtility.getOptionsDiceList(),
bonusDicesLevel: 0,
hindranceDicesLevel: 0,
otherDicesLevel: 0,
@ -439,17 +454,6 @@ export class PegasusActor extends Actor {
}
}
/* -------------------------------------------- */
applyTechniqueCost( techId) {
let tech = duplicate(this.data.items.find( item => item.id == techId));
if (tech ) {
let attr = this.getAttributeFromChiName( tech.data.chicolor);
let chiscore = attr.chiscore - tech.data.chicost;
chiscore = (chiscore < 0) ? 0 : chiscore;
this.update( { [`data.attributes.${attr.key}.chiscore`]: chiscore } );
}
}
/* -------------------------------------------- */
updateWithTarget( rollData) {
let objectDefender
@ -469,48 +473,30 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
async rollTechnique( techId ) {
let technique = this.data.items.find( item => item.type == 'technique' && item.id == techId);
if (technique) {
let usedChi = this.getAttributeFromChiName( technique.data.data.chicolor);
if ( usedChi.chiscore < 0 || technique.data.data.chicost > usedChi.chiscore) {
ui.notifications.warn(`Not enough ${usedChi.chi} to use Technique ${technique.name}`);
return;
}
let chi = undefined;
let skill = this.data.items.find( item => item.type == 'skill' && item.name == technique.data.data.skillchi);
if ( !skill) {
chi = this.getAttributeFromChiName( technique.data.data.skillchi);
}
async rollPower( powId ) {
let power = this.data.items.find( item => item.type == 'power' && item.id == powId);
if (power) {
let rollData = {
mode: "technique",
mode: "power",
alias: this.name,
armorModifier: this.getArmorModifier(),
actorImg: this.img,
actorId: this.id,
img: technique.img,
img: power.img,
rollMode: game.settings.get("core", "rollMode"),
title: `Technique ${technique.name} `,
technique: duplicate(technique),
optionsNegative: WotGUtility.getNegativeModifiers(),
optionsPositive: WotGUtility.getPositiveModifiers(),
negativeModifier: 0,
positiveModifier: 0,
specialtiesBonus: 0
}
if ( skill) {
rollData.skill = duplicate(skill);
rollData.attr = this.getAttribute( skill.data.data.attribute );
} else {
rollData.attr = chi;
title: `Power ${power.name} `,
power: duplicate(power),
activePerks: duplicate(this.getActivePerks()),
optionsDiceList: PegasusUtility.getOptionsDiceList(),
bonusDicesLevel: 0,
hindranceDicesLevel: 0,
otherDicesLevel: 0,
}
this.updateWithTarget(rollData);
this.syncRoll( rollData);
let rollDialog = await WotGRollDialog.create( this, rollData);
let rollDialog = await PegasusRollDialog.create( this, rollData);
console.log(rollDialog);
rollDialog.render( true );
} else {
@ -534,22 +520,20 @@ export class PegasusActor extends Actor {
actorId: this.id,
img: weapon.img,
rollMode: game.settings.get("core", "rollMode"),
armorModifier: this.getArmorModifier(),
title: "Attack : " + weapon.name,
weapon: weapon,
skillKey : 0,
optionsNegative: WotGUtility.getNegativeModifiers(),
optionsPositive: WotGUtility.getPositiveModifiers(),
negativeModifier: 0,
positiveModifier: 0,
specialtiesBonus: 0,
}
activePerks: duplicate(this.getActivePerks()),
optionsDiceList: PegasusUtility.getOptionsDiceList(),
bonusDicesLevel: 0,
hindranceDicesLevel: 0,
otherDicesLevel: 0,
}
this.updateWithTarget(rollData);
this.syncRoll( rollData);
let rollDialog = await WotGRollDialog.create( this, rollData);
let rollDialog = await PegasusRollDialog.create( this, rollData);
console.log("WEAPON ROLL", rollData);
rollDialog.render( true );
} else {