more linting and power conversion

This commit is contained in:
2024-05-13 23:25:16 -05:00
parent 8f015bc05c
commit 6ec4d9019e
13 changed files with 2142 additions and 349 deletions
+107
View File
@@ -0,0 +1,107 @@
import { PowerEffect } from './basePowers.js';
export class BarrierEffect extends PowerEffect {
get name() {
return 'Barrier';
}
get duration() {
return 5;
}
get icon() {
return 'icons/environment/settlement/fence-stone-brick.webp';
}
get isTargeted() {
return false;
}
get isDamaging() {
return true;
}
get basePowerPoints() {
return 2;
}
get usePrimaryEffect() {
return false;
}
get modifiers() {
const mods = super.modifiers;
mods.push({
type: 'select',
name: 'Damage',
id: 'damage',
epic: false,
choices: {
none: 'None',
damage: 'Damage',
immaterial: 'Damage (immaterial)',
deadly: '⭐ Deadly',
},
effects: { none: null, damage: null, immaterial: null, deadly: null },
values: { none: 0, damage: 1, immaterial: 0, deadly: 2 },
});
mods.push({
type: 'checkbox',
name: 'Hardened',
id: 'hardened',
value: 1,
epic: false,
effect: false,
});
mods.push({
type: 'checkbox',
name: 'Shaped',
id: 'shaped',
value: 1,
epic: false,
effect: false,
});
mods.push({
type: 'checkbox',
name: 'Size',
id: 'size',
value: 1,
epic: false,
effect: false,
});
return mods;
}
get _length() {
let height = 10;
if (this.data.raise) {
height *= 2;
}
if (this.data.size) {
height *= 2;
}
return `${height}" (${height * 2} yards)`;
}
get _height() {
return `${this.data.size ? '2" (4' : '1" (2'} yards)`;
}
get _hardness() {
return (this.data.raise ? 12 : 10) + (this.data.hardened ? 2 : 0);
}
get description() {
let text = super.description;
text += `<p>A barrier ${this._height} tall and ${this._length} long, of hardness ${this._hardness}. `;
if (this.data.damage === 'deadly') {
text += 'It does 2d6 damage to anyone who contacts it. ';
} else if (this.data.damage != 'none') {
text += 'It does 2d4 damage to anyone who contacts it. ';
}
if (this.data.shaped) {
text += 'It was shaped into a circle, square, or rectangle. ';
}
text += '</p>';
return text;
}
}
+2 -3
View File
@@ -371,7 +371,7 @@ export class PowerEffect {
}
render() {
let app = new PowerFormApplication(this).render(true);
new PowerFormApplication(this).render(true);
}
async applyEffect() {
@@ -457,7 +457,6 @@ export class PowerEffect {
return deepClone(docs);
}
// eslint-disable-next-line no-unused-vars
async primaryDocForTarget(doc, target) {
const newDoc = deepClone(doc);
newDoc.flags[moduleName].maintainingId = doc.flags[moduleName].maintId;
@@ -559,7 +558,7 @@ export class PowerEffect {
text += '</p>';
const desc = this.description;
if (desc) {
text += `<details><summary>Description</summary>${desc}</details>`;
text += `<details open><summary>Description</summary>${desc}</details>`;
}
const effects = this.chatMessageEffects;
if (effects.length > 0) {
+90
View File
@@ -0,0 +1,90 @@
import { PowerEffect } from './basePowers.js';
export class BeastFriendEffect extends PowerEffect {
get name() {
return 'Beast Friend';
}
get duration() {
return (this.data.duration ? 30 : 10) * 6 * 60;
}
get icon() {
return 'icons/magic/nature/wolf-paw-glow-large-green.webp';
}
get isTargeted() {
return true;
}
get usePrimaryEffect() {
return true;
}
get modifiers() {
const mods = super.modifiers;
const ppDefault = Math.max(
this.targets.map((t) => Math.max(t.actor.system.stats.size, 1)).reduce((a, b) => a + b, 0),
1,
);
mods.push(
{
name: 'Bestiarium',
type: 'checkbox',
value: 2,
id: 'bestiarium',
epic: true,
effect: false,
},
{
name: 'Duration',
type: 'checkbox',
value: 1,
id: 'duration',
epic: false,
effect: false,
},
{
name: 'Mind Rider',
type: 'checkbox',
value: 1,
id: 'mindrider',
epic: false,
effect: false,
},
{
name: 'Base power points',
type: 'number',
value: 0,
default: ppDefault,
id: 'basePP',
epic: false,
effect: false,
},
);
return mods;
}
get basePowerPoints() {
return (
this.data.basePP ??
Math.max(
this.targets.map((t) => Math.max(t.actor.system.stats.size, 1)).reduce((a, b) => a + b, 0),
1,
)
);
}
get description() {
let text = super.description;
if (this.data.raise) {
text += '<p>Creatures will overcome instincts to follow orders.';
} else {
text += '<p>Creatures obey simple commands, subject to their insticts.';
}
if (this.data.bestiarium) {
text += ' The caster may even effect magical beasts.';
}
return text;
}
}
+70
View File
@@ -0,0 +1,70 @@
import { PowerEffect } from './basePowers.js';
export class BlastEffect extends PowerEffect {
get name() {
return 'Blast';
}
get icon() {
return 'icons/magic/fire/explosion-fireball-large-red-orange.webp';
}
get duration() {
return 0;
}
get isTargeted() {
return true;
}
get usePrimaryEffect() {
return false;
}
get isDamaging() {
return true;
}
get basePowerPoints() {
return 3;
}
get hasAoe() {
return true;
}
get modifiers() {
const mods = super.modifiers;
mods.push(
{
name: 'Area of Effect',
id: 'aoe',
type: 'select',
default: 'mbt',
choices: {
sbt: 'Small Blast Template',
mbt: 'Medium Blast Template',
lbt: 'Large Blast Template',
},
effects: { sbt: null, mbt: null, lbt: null },
values: { sbt: 0, mbt: 0, lbt: 1 },
epic: false,
},
{ name: 'Damage', value: 2, id: 'damage', epic: false, effect: false },
{
name: 'Greater Blast',
value: 4,
id: 'greater',
epic: true,
effect: false,
},
);
return mods;
}
get description() {
const dmgDie = (this.data.greater ? 4 : this.data.damage ? 3 : 2) + (this.data.raise ? 1 : 0);
const size = this.data.aoe.toUpperCase();
return super.description + `<p>The blast covers a ${size} and does ${dmgDie}d6 damage</p>`;
}
}
+4 -279
View File
@@ -3,284 +3,9 @@ import { moduleName } from '../globals.js';
import { PowerEffect } from './basePowers.js';
import { ArcaneProtectionEffect } from './arcaneProtection.js';
import { BanishEffect } from './banish.js';
class BarrierEffect extends PowerEffect {
get name() {
return 'Barrier';
}
get duration() {
return 5;
}
get icon() {
return 'icons/environment/settlement/fence-stone-brick.webp';
}
get isTargeted() {
return false;
}
get isDamaging() {
return true;
}
get basePowerPoints() {
return 2;
}
get usePrimaryEffect() {
return false;
}
get modifiers() {
const mods = super.modifiers;
mods.push({
name: 'Damage',
id: 'damage',
value: 1,
epic: false,
effect: false,
});
mods.push({
name: 'Damage (immaterial trapping)',
id: 'damage',
value: 0,
epic: false,
effect: false,
});
mods.push({
name: 'Deadly',
id: 'deadly',
value: 2,
epic: true,
effect: false,
});
mods.push({
name: 'Hardened',
id: 'hardened',
value: 1,
epic: false,
effect: false,
});
mods.push({
name: 'Shaped',
id: 'shaped',
value: 1,
epic: false,
effect: false,
});
mods.push({
name: 'Size',
id: 'size',
value: 1,
epic: false,
effect: false,
});
return mods;
}
get _length() {
let height = 10;
if (this.data.raise) {
height *= 2;
}
if (this.data.mods.has('size')) {
height *= 2;
}
return `${height}" (${height * 2} yards)`;
}
get _height() {
return `${this.data.mods.has('size') ? '2" (4' : '1" (2'} yards`;
}
get _hardness() {
return (this.data.raise ? 12 : 10) + (this.data.mods.has('hardened') ? 2 : 0);
}
get description() {
let text = super.description;
text += `<p>A barrier ${this._height} tall and ${this._length} long, of hardness ${this._hardness}. `;
if (this.data.mods.has('deadly')) {
text += 'It does 2d6 damage to anyone who contacts it. ';
} else if (this.data.mods.has('damage')) {
text += 'It does 2d4 damage to anyone who contacts it. ';
}
if (this.data.mods.has('shaped')) {
text += 'It was shaped into a circle, square, or rectangle. ';
}
text += '</p>';
return text;
}
}
class BeastFriendEffect extends PowerEffect {
get name() {
return 'Beast Friend';
}
get duration() {
return (this.data.mods.has('duration') ? 30 : 10) * 6 * 60;
}
get icon() {
return 'icons/magic/nature/wolf-paw-glow-large-green.webp';
}
get isTargeted() {
return true;
}
get usePrimaryEffect() {
return true;
}
get modifiers() {
const mods = super.modifiers;
mods.push(
{
name: 'Bestiarium',
value: 2,
id: 'bestiarium',
epic: true,
effect: false,
},
{
name: 'Duration',
value: 1,
id: 'duration',
epic: false,
effect: false,
},
{
name: 'Mind Rider',
value: 1,
id: 'mindrider',
epic: false,
effect: false,
},
);
return mods;
}
get menuInputs() {
const inputs = super.menuInputs;
const pp = Math.max(
this.targets.map((t) => Math.max(t.actor.system.stats.size, 1)).reduce((a, b) => a + b, 0),
1,
);
inputs.push({ type: 'number', label: 'Base power points', options: pp });
return inputs;
}
async parseValues() {
await super.parseValues();
this.data.basePP = this.data.values.shift();
}
get basePowerPoints() {
return this?.data?.basePP || 2;
}
get description() {
let text = super.description;
if (this.data.raise) {
text += '<p>Creatures will overcome instincts to follow orders.';
} else {
text += '<p>Creatures obey simple commands, subject to their insticts.';
}
if (this.data.mods.has('bestiarium')) {
text += ' The caster may even effect magical beasts.';
}
return text;
}
}
class BlastEffect extends PowerEffect {
get name() {
return 'Blast';
}
get icon() {
return 'icons/magic/fire/explosion-fireball-large-red-orange.webp';
}
get duration() {
return 0;
}
get isTargeted() {
return true;
}
get usePrimaryEffect() {
return false;
}
get isDamaging() {
return true;
}
get basePowerPoints() {
return 3;
}
get hasAoe() {
return true;
}
get menuInputs() {
const inputs = super.menuInputs;
inputs.push({
type: 'select',
label: 'Area of Effect',
options: [
{ html: 'Small Blast Template (0)', value: 's', selected: false },
{ html: 'Medium Blast Template (0)', value: 'm', selected: true },
{ html: 'Large Blast Template (+1)', value: 'l', selected: false },
],
});
return inputs;
}
get modifiers() {
const mods = super.modifiers;
mods.push(
{ name: 'Damage', value: 2, id: 'damage', epic: false, effect: false },
{
name: 'Greater Blast',
value: 4,
id: 'greater',
epic: true,
effect: false,
},
);
return mods;
}
get powerPoints() {
let total = super.powerPoints;
total += this.data.aoe === 'l' ? 1 : 0;
return total;
}
async parseValues() {
await super.parseValues();
this.data.aoe = this.data.values.shift();
}
get description() {
const dmgDie =
(this.data.mods.has('greater') ? 4 : this.data.mods.has('damage') ? 3 : 2) + (this.data.raise ? 1 : 0);
const size = this.data.aoe === 'l' ? 'LBT' : this.data.aoe === 's' ? 'SBT' : 'MBT';
return (
super.description +
`
<p>The blast covers a ${size} and does ${dmgDie}d6 damage</p>`
);
}
}
import { BarrierEffect } from './barrier.js';
import { BeastFriendEffect } from './beastFriend.js';
import { BlastEffect } from './blast.js';
class BlindEffect extends PowerEffect {
get name() {
@@ -1448,5 +1173,5 @@ export async function powers(options = {}) {
runner.render();
return;
}
ui.notifications.error(`No power effect found for ${name}`);
ui.notifications.error(`No power effect found for ${swid}`);
}
+1 -7
View File
@@ -56,16 +56,10 @@ export async function preTraitRollModifiers(actor, trait, roll, modifiers, optio
}
}
// eslint-disable-next-line no-unused-vars
export async function preDamageRollModifiers(actor, item, roll, modifiers, options) {
const targets = Array.from(game.user.targets);
const token = game.canvas.tokens.controlled.length > 0 ? game.canvas.tokens.controlled[0] : null;
// log('ACTOR', actor)
// log('TOKEN', token)
// log('ITEM', item)
// log('ROLL', roll)
// log('MODIFIERS', modifiers)
// log('OPTIONS', options)
// log('TARGET', targets)
if (targets.length === 1 && token) {
const target = targets[0];
_addArcaneModifiers(target, modifiers);
-3
View File
@@ -1,7 +1,4 @@
/* globals ColorAdjustmentsSamplerShader */
/* globals socketlib */
/* globals VisionMode */
/* globals warpgate */
// Import JavaScript modules
import { registerSettings } from './settings.js';
import { preloadTemplates } from './preloadTemplates.js';
+25 -23
View File
@@ -1,72 +1,74 @@
export function initVisionModes () {
log('INIT VISION')
/* globals ColorAdjustmentsSamplerShader, VisionMode */
import { log } from './globals.js';
export function initVisionModes() {
log('INIT VISION');
CONFIG.Canvas.visionModes.basic = new VisionMode({
id: 'basic',
label: 'VISION.ModeBasicVision',
canvas: {
shader: ColorAdjustmentsSamplerShader,
uniforms: { contrast: 0, saturation: -0.85, brightness: -1.0 }
uniforms: { contrast: 0, saturation: -0.85, brightness: -1.0 },
},
lighting: {
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED }
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED },
},
vision: {
darkness: { adaptive: false },
defaults: { attenuation: 0, contrast: 0, saturation: -0.85, brightness: -1.0 },
preferred: true
}
})
preferred: true,
},
});
CONFIG.Canvas.visionModes.darkvision = new VisionMode({
id: 'darkvision',
label: 'VISION.ModeDarkvision',
canvas: {
shader: ColorAdjustmentsSamplerShader,
uniforms: { contrast: 0, saturation: 0, brightness: 0.75, tint: [0.8, 0.8, 1.0] }
uniforms: { contrast: 0, saturation: 0, brightness: 0.75, tint: [0.8, 0.8, 1.0] },
},
lighting: {
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED },
levels: {
[VisionMode.LIGHTING_LEVELS.DIM]: VisionMode.LIGHTING_LEVELS.BRIGHT
}
[VisionMode.LIGHTING_LEVELS.DIM]: VisionMode.LIGHTING_LEVELS.BRIGHT,
},
},
vision: {
darkness: { adaptive: false },
defaults: { attenuation: 0.1, contrast: 0, saturation: 0, brightness: 0.75 },
preferred: false
}
})
preferred: false,
},
});
CONFIG.Canvas.visionModes.lowlight = new VisionMode({
id: 'lowlight',
label: 'Low Light Vision',
canvas: {
shader: ColorAdjustmentsSamplerShader,
uniforms: { contrast: 0, saturation: -0.5, brightness: -0.2 }
uniforms: { contrast: 0, saturation: -0.5, brightness: -0.2 },
},
lighting: {
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED }
background: { visibility: VisionMode.LIGHTING_VISIBILITY.REQUIRED },
},
vision: {
darkness: { adaptive: false },
defaults: { attenuation: 0.1, contrast: 0, saturation: -0.5, brightness: -0.2 },
preferred: false
}
})
preferred: false,
},
});
CONFIG.Canvas.visionModes.blindsense = new VisionMode({
id: 'blindsense',
label: 'Blindsense',
canvas: {
shader: ColorAdjustmentsSamplerShader,
uniforms: { contrast: 0, saturation: -0.5, brightness: -0.2 }
uniforms: { contrast: 0, saturation: -0.5, brightness: -0.2 },
},
lighting: {
background: { visibility: VisionMode.LIGHTING_VISIBILITY.DISABLED },
coloration: { visibility: VisionMode.LIGHTING_VISIBILITY.DISABLED },
illumination: { visibility: VisionMode.LIGHTING_VISIBILITY.DISABLED }
illumination: { visibility: VisionMode.LIGHTING_VISIBILITY.DISABLED },
},
vision: {
darkness: { adaptive: false },
defaults: { attenuation: 0.3, contrast: -0.5, saturation: 0.75, brightness: 0.5 },
preferred: false
}
})
preferred: false,
},
});
}