working zombie needs powerpoints

This commit is contained in:
Mike Bloy 2024-06-08 10:45:20 -05:00
parent 929cdda415
commit 5965b89b66
2 changed files with 83 additions and 12 deletions

View File

@ -56,7 +56,7 @@ import { SmiteEffect } from './smite.js';
import { SoundSilenceEffect } from './soundSilence.js';
import { SpeakLanguageEffect } from './speakLanguage.js';
import { StunEffect } from './stun.js';
import { SummonAllyEffect } from './summon.js';
import { SummonAllyEffect, ZombieEffect } from './summon.js';
import { TelekinesisEffect } from './telekinesis.js';
import { TeleportEffect } from './teleport.js';
import { TimeStopEffect } from './timeStop.js';
@ -146,6 +146,7 @@ const PowerClasses = {
'wall-walker': WallWalkerEffect,
'warriors-gift': WarriorsGiftEffect,
wish: WishEffect,
zombie: ZombieEffect,
};
/* ---------------------------------------------------------------- */

View File

@ -232,14 +232,6 @@ class BaseAllyEffect extends BaseSummonEffect {
async createSecondaryEffects(maintId) {
const effects = await super.createSecondaryEffects(maintId);
// if (this.data.mindRider) {
// const doc = this.enhanceSecondaryEffect(
// maintId,
// this.createEffectDocument('icons/magic/control/hypnosis-mesmerism-eye.webp', 'Mind Rider', []),
// );
// doc.description = `The caster can communicate and sense through the ally`;
// effects.push(doc);
// }
if ((this.data?.increasedTraitChanges?.length ?? 0) > 0) {
const doc = this.enhanceSecondaryEffect(
maintId,
@ -501,7 +493,7 @@ export class ZombieEffect extends BaseSummonEffect {
},
{
type: 'checkbox',
name: 'Skeletal',
name: 'Skeletal (+1 per zombie)',
value: 0,
id: 'skeletal',
epic: false,
@ -583,9 +575,87 @@ export class ZombieEffect extends BaseSummonEffect {
return 3 + size;
}
async parseValuesRaise() {
const attrList = ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor'];
const skillSet = new Set();
for (const skill of this.targetActor.items.filter((i) => i.type === 'skill')) {
skillSet.add(skill.name);
}
const skillList = Array.from(skillSet);
skillList.sort();
const html = `<form><h2>Raise Effect - raise one trait a die type</h2>
<p>All raised zombies will have the chosen trait raised one die type.</p>
<div class="form-group">
<label>Trait: <select name="trait">
<optgroup label="Attributes">
${attrList.map((attr) => `<option value="system.attributes.${attr.toLowerCase()}.die.sides">${attr}</option>`).join('')}
</optgroup>
<optgroup label="Skills">
${skillList.map((skill) => `<option value="@Skill{${skill}}[system.die.sides]">${skill}</option>`).join('')}
</optgroup>
</select>
</label>
</div>
</form>
`;
const formData = await Dialog.wait({
title: 'Select trait for raise increase',
content: html,
buttons: {
submit: {
label: 'Submit',
callback: (html) => {
const formElement = html[0].querySelector('form');
const formData = new FormDataExtended(formElement);
return formData.object;
},
},
cancel: { label: 'cancel' },
},
});
const key = formData.trait;
this.data.primaryEffectChanges.push({
mode: CONST.ACTIVE_EFFECT_MODES.ADD,
value: 2,
key,
priority: 0,
});
}
async parseValuesPre() {
await super.parseValuesPre();
this.data.actorUpdates.name = `${this.source.acor.name}'s raised ${this.targetActor.name}`;
this.data.tokenUpdates.name = `${this.source.name}'s raised ${this.targetActor.name}`;
this.data.primaryEffectChanges = [];
this.data.actorUpdates = { name: `${this.source.actor.name}'s raised ${this.targetActor.name}` };
this.data.tokenUpdates = { name: `${this.source.name}'s raised ${this.targetActor.name}` };
this.data.embeddedUpdates = {
ActiveEffect: {},
Item: {},
};
if (this.data.armed && this.data.actors['armed_template']) {
const armedTemplate = this.data.actors.armed_template;
for (const item of armedTemplate.items) {
const armedItemDoc = armedTemplate.getEmbeddedDocument('Item', item.id);
this.data.embeddedUpdates.Item[item.name] = armedItemDoc;
}
}
if (this.data.raise) {
await this.parseValuesRaise();
}
}
get summonCount() {
return 1 + this.data.additionalAllies;
}
getPrimaryEffectChanges() {
return [...super.getPrimaryEffectChanges(), ...this.data.primaryEffectChanges];
}
get spawnUpdates() {
const updates = super.spawnUpdates;
mergeObject(updates.actor, this.data.actorUpdates);
mergeObject(updates.token, this.data.tokenUpdates);
mergeObject(updates.embedded, this.data.embeddedUpdates);
return updates;
}
}