Skip to content

Commit

Permalink
Merge pull request dmdorman#1635 from aeauseth/main
Browse files Browse the repository at this point in the history
RAR. Effects Panel Setting. ProseMirror. AdjustmentPowers.
  • Loading branch information
aeauseth authored Dec 20, 2024
2 parents f5a5d7b + 55ee98a commit d50ff6a
Show file tree
Hide file tree
Showing 15 changed files with 365 additions and 45 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
- SIGHTGROUP visions now respect the BLIND status. [#1590](https://github.com/dmdorman/hero6e-foundryvtt/issues/1590)
- Fixed issue with some enhanced visions not showing map in the dark.
- Adjustment powers now work with POWERDEFENSE.
- Inobivous powers do not show for Actor Description.
- Inobivous powers no longer show for Actor Description.
- Fixed the chat card name of Adjustment powers that targeted POWERs. Was showing attack item, not target power. [#1608](https://github.com/dmdorman/hero6e-foundryvtt/issues/1608)
- Fixed formatting issues with prosemirror editor caused by us overriding some css that we shouldn't have. [#1629](https://github.com/dmdorman/hero6e-foundryvtt/issues/1629)

## Version 4.0.12 [Hero System 6e (Unofficial) v2](https://github.com/dmdorman/hero6e-foundryvtt)

Expand Down
9 changes: 8 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@
"StatusTargeted": "Targeted",
"StatusTunneling": "Tunneling",
"StatusUnconscious": "Unconscious",
"Underwater": "Underwater"
"Underwater": "Underwater",
"Seconds": "Sec",
"AP": "AP",
"Source": "Source"
},

"Settings": {
Expand Down Expand Up @@ -204,6 +207,10 @@
"Name": "Combat Movement Only On Actors Phase",
"Hint": "This prevents players from moving their tokens when it isn't their turn."
},
"effectsPanel" :{
"Name": "Effects Panel",
"Hint": "Show the effects panel when a token is controlled."
},
"ShowAllConditionalDefenses": {
"Name": "Show all Conditional Defenses",
"Hint": "Conditional Defenses that provide no obvious defense are hidden by default. There may be some edge cases where these defenses should be applied. Enabling this setting will give the GM an opportunity to apply a conditional defense, even when the automation thinks it does not apply."
Expand Down
47 changes: 38 additions & 9 deletions module/actor/active-effect-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class HeroSystemActiveEffectConfig extends ActiveEffectConfig {
const defaultOptions = super.defaultOptions;
return foundry.utils.mergeObject(defaultOptions, {
//classes: ["herosystem6e", "sheet", "item"],
// width: 520,
width: 700,
// height: 660,
// scrollY: [".sheet-body"],
classes: ["sheet", "herosystem-active-effect-config", "active-effect-sheet"],
Expand All @@ -16,21 +16,50 @@ export class HeroSystemActiveEffectConfig extends ActiveEffectConfig {
async getData() {
const context = await super.getData();
for (let i = 0; i < context.data.changes.length; i++) {
context.data.changes[i] = { ...context.data.changes[i], ...context.data.flags.changes?.[i] };
context.data.changes[i] = { ...context.data.changes[i], ...context.data.system.changes?.[i] };
}
const originItem = fromUuidSync(context.data.origin);
const token = fromUuidSync(context.data.origin.match(/(.*).Actor/)?.[1]);
const token = fromUuidSync(context.data.origin?.match(/(.*).Actor/)?.[1]);
context.originText = originItem
? `${token?.name || originItem.actor?.name}: ${originItem.name}`
: context.data.origin;

//sourceText
for (const change of context.data.changes) {
if (change.source) {
const sourceItem = fromUuidSync(change.source);
const token = fromUuidSync(change.source.match(/(.*).Actor/)?.[1]);
change.sourceText = `${token?.name || sourceItem.actor?.name}: ${sourceItem.name}`;
}
}
return context;
}

// async _updateObject(event, formData) {
// await super._updateObject(event, formData);
_onEffectControl(event) {
event.preventDefault();
const button = event.currentTarget;
switch (button.dataset.action) {
case "add":
return this._addEffectChange();
case "delete":
button.closest(".effect-change").remove();
return this.submit({ preventClose: true }).then(() => this.render());
}
}

async _updateObject(event, formData) {
await super._updateObject(event, formData);
}

_getSubmitData(updateData = {}) {
const fd = new FormDataExtended(this.form, { editors: this.editors, disabled: true });
let data = foundry.utils.expandObject(fd.object);
if (updateData) foundry.utils.mergeObject(data, updateData);
data.changes = Array.from(Object.values(data.changes || {}));
data.statuses ??= [];

// // if (formData.changes) {
// // await this.object.update({ changes: formData.changes });
// // }
// }
// Need to collapse the array (get rid of any sparse indexes that can occur when deleting middle indexes)
data.system.changes = Array.from(Object.values(data.system.changes || {}));
return data;
}
}
17 changes: 17 additions & 0 deletions module/actor/actor-active-effects.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import { HEROSYS } from "../herosystem6e.mjs";
import { RoundFavorPlayerUp } from "../utility/round.mjs";

export class HeroSystem6eActorActiveEffectsSystemData extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
// Make sure active-effect-config.hbs has all these fields so they don't get lost during editing
changes: new fields.ArrayField(
new fields.SchemaField({
seconds: new fields.NumberField({ integer: true }),
activePoints: new fields.NumberField({ integer: false }),
source: new fields.StringField(),
startTime: new fields.NumberField({ integer: true }),
}),
),
};
}
}

export class HeroSystem6eActorActiveEffects extends ActiveEffect {
// static defineSchema() {
// const schema2 = this.schema; // foundry.deepClone(super.defineSchema());
Expand Down
1 change: 1 addition & 0 deletions module/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { RoundFavorPlayerDown, RoundFavorPlayerUp } from "../utility/round.mjs";
* @extends {Actor}
*/
export class HeroSystem6eActor extends Actor {

/** @inheritdoc */
async _preCreate(data, options, user) {
await super._preCreate(data, options, user);
Expand Down
21 changes: 15 additions & 6 deletions module/herosystem6e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { HeroSystem6eItem, initializeItemHandlebarsHelpers } from "./item/item.m
import { HeroSystem6eItemSheet } from "./item/item-sheet.mjs";
import * as chat from "./chat.mjs";
import { HeroSystem6eCardHelpers } from "./card/card-helpers.mjs";
import { HeroSystem6eActorActiveEffects } from "./actor/actor-active-effects.mjs";
import {
HeroSystem6eActorActiveEffects,
HeroSystem6eActorActiveEffectsSystemData,
} from "./actor/actor-active-effects.mjs";
import HeroSystem6eMeasuredTemplate from "./measuretemplate.mjs";
import { HeroSystem6eCombat } from "./combat.mjs";
import { HeroSystem6eCombatTracker } from "./combatTracker.mjs";
Expand Down Expand Up @@ -84,10 +87,14 @@ Hooks.once("init", async function () {
CONFIG.Token.objectClass = HeroSystem6eToken;
CONFIG.MeasuredTemplate.objectClass = HeroSystem6eMeasuredTemplate;
CONFIG.ActiveEffect.documentClass = HeroSystem6eActorActiveEffects;
// CONFIG.ActiveEffect.dataModels.base = HeroSystem6eActorActiveEffects.defineSchema();
CONFIG.Canvas.rulerClass = HeroRuler;
CONFIG.Canvas.visionSourceClass = HeroPointVisionSource;

Object.assign(CONFIG.ActiveEffect.dataModels, {
// REF: https://foundryvtt.wiki/en/development/api/DataModel
base: HeroSystem6eActorActiveEffectsSystemData,
});

HeroRuler.initialize();

SettingsHelpers.initLevelSettings();
Expand Down Expand Up @@ -165,10 +172,12 @@ Hooks.once("i18nInit", () => {
});

Hooks.on("canvasReady", () => {
// Effect Panel singleton application
game[HEROSYS.module].effectPanel.render(true);
if (!canvas.scene) return;
if (game.ready) canvas.scene.reset();
if (game.settings.get(game.system.id, "effectsPanel")) {
// Effect Panel singleton application
game[HEROSYS.module].effectPanel.render(true);
if (!canvas.scene) return;
if (game.ready) canvas.scene.reset();
}
});

Hooks.once("ready", async function () {
Expand Down
13 changes: 7 additions & 6 deletions module/item/item-attack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@ async function _onApplyAdjustmentToSpecificToken(adjustmentItem, token, damageDe

// DRAIN
const reductionChatMessages = [];
const reductionTargetActor = token.actor;
//const reductionTargetActor = token.actor;
for (const reduce of reducesArray) {
reductionChatMessages.push(
await performAdjustment(
Expand All @@ -2710,7 +2710,7 @@ async function _onApplyAdjustmentToSpecificToken(adjustmentItem, token, damageDe
defense,
damageDetail.effects,
false,
reductionTargetActor,
token,
action,
),
);
Expand All @@ -2721,7 +2721,7 @@ async function _onApplyAdjustmentToSpecificToken(adjustmentItem, token, damageDe

// AID
const enhancementChatMessages = [];
const enhancementTargetActor = adjustmentItem.system.XMLID === "TRANSFER" ? adjustmentItem.actor : token.actor;
//const enhancementTargetActor = adjustmentItem.system.XMLID === "TRANSFER" ? adjustmentItem.actor : token.actor;
for (const enhance of enhancesArray) {
const simplifiedHealing = adjustmentItem.system.XMLID === "HEALING" && enhance.match(/simplified/i);

Expand All @@ -2735,7 +2735,7 @@ async function _onApplyAdjustmentToSpecificToken(adjustmentItem, token, damageDe
"None - Beneficial",
"",
false,
enhancementTargetActor,
token,
),
);
// BODY
Expand All @@ -2747,7 +2747,7 @@ async function _onApplyAdjustmentToSpecificToken(adjustmentItem, token, damageDe
"None - Beneficial",
"",
false,
enhancementTargetActor,
token,
),
);
adjustmentItemTags.push({
Expand All @@ -2767,7 +2767,8 @@ async function _onApplyAdjustmentToSpecificToken(adjustmentItem, token, damageDe
"None - Beneficial",
"",
false,
enhancementTargetActor,
token,
action,
),
);
adjustmentItemTags.push({ name: enhance });
Expand Down
6 changes: 3 additions & 3 deletions module/item/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,13 @@ export class HeroSystem6eItem extends Item {

// recurse part
for (const mod of this.modifiers || this.MODIFIER || []) {
return recursiveFindByXmlid.call(mod, xmlid);
if (recursiveFindByXmlid.call(mod, xmlid)) return mod;
}
for (const adder of this.adders || this.ADDER || []) {
return recursiveFindByXmlid.call(adder, xmlid);
if (recursiveFindByXmlid.call(adder, xmlid)) return adder;
}
for (const power of this.powers || this.POWER || []) {
return recursiveFindByXmlid.call(power, xmlid);
if (recursiveFindByXmlid.call(power, xmlid)) return power;
}
}

Expand Down
11 changes: 11 additions & 0 deletions module/settings/settings-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ export default class SettingsHelpers {
requiresReload: false,
});

game.settings.register(module, "effectsPanel", {
name: game.i18n.localize("Settings.effectsPanel.Name"),
hint: game.i18n.localize("Settings.effectsPanel.Hint"),
scope: "client",
config: true,
type: Boolean,
default: true,
//onChange: () => ui.chat.render(), // doesn't seem to work
requiresReload: true,
});

game.settings.register(module, "ShowOnlyVisibleCombatants", {
name: game.i18n.localize("Settings.ShowOnlyVisibleCombatants.Name"),
hint: game.i18n.localize("Settings.ShowOnlyVisibleCombatants.Hint"),
Expand Down
Loading

0 comments on commit d50ff6a

Please sign in to comment.