Skip to content

Commit

Permalink
Merge pull request dmdorman#1422 from phBalance/phBalance/v12-warning…
Browse files Browse the repository at this point in the history
…-cleanup

Ph balance/v12 warning cleanup - temporary Documents should be newed
  • Loading branch information
phBalance authored Nov 9, 2024
2 parents 521c24f + 9dbf1dd commit acd6b5d
Show file tree
Hide file tree
Showing 8 changed files with 382 additions and 460 deletions.
18 changes: 9 additions & 9 deletions module/actor/actor-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class HeroSystemActorSheet extends ActorSheet {
name: "Defense Calculation Actor",
type: "pc",
},
{ temporary: true },
{},
);
defenseCalculationActor.system.is5e = this.actor.system.is5e;

Expand All @@ -263,9 +263,9 @@ export class HeroSystemActorSheet extends ActorSheet {
<POWER XMLID="ENERGYBLAST" ID="1695402954902" BASECOST="0.0" LEVELS="1" ALIAS="Blast" POSITION="0" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" INPUT="PD" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
</POWER>
`;
const pdAttack = await new HeroSystem6eItem(
const pdAttack = new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(pdContentsAttack, defenseCalculationActor),
{ temporary: true, parent: defenseCalculationActor },
{ parent: defenseCalculationActor },
);
await pdAttack._postUpload();

Expand Down Expand Up @@ -313,9 +313,9 @@ export class HeroSystemActorSheet extends ActorSheet {
<POWER XMLID="ENERGYBLAST" ID="1695402954902" BASECOST="0.0" LEVELS="1" ALIAS="Blast" POSITION="0" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" INPUT="ED" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
</POWER>
`;
const edAttack = await new HeroSystem6eItem(
const edAttack = new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(edContentsAttack, defenseCalculationActor),
{ temporary: true, parent: defenseCalculationActor },
{ parent: defenseCalculationActor },
);
await edAttack._postUpload();

Expand Down Expand Up @@ -364,9 +364,9 @@ export class HeroSystemActorSheet extends ActorSheet {
<NOTES />
</POWER>
`;
const mdAttack = await new HeroSystem6eItem(
const mdAttack = new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(mdContentsAttack, defenseCalculationActor),
{ temporary: true, parent: defenseCalculationActor },
{ parent: defenseCalculationActor },
);
await mdAttack._postUpload();

Expand Down Expand Up @@ -412,9 +412,9 @@ export class HeroSystemActorSheet extends ActorSheet {
<NOTES />
</POWER>
`;
const drainAttack = await new HeroSystem6eItem(
const drainAttack = new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(drainContentsAttack, defenseCalculationActor),
{ temporary: true, parent: defenseCalculationActor },
{ parent: defenseCalculationActor },
);
await drainAttack._postUpload();

Expand Down
29 changes: 12 additions & 17 deletions module/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -871,19 +871,14 @@ export class HeroSystem6eActor extends Actor {
},
],
origin: this.uuid,
// duration: {
// seconds: 3.154e7 * 100, // 100 years should be close to infinity
// },
flags: {
dcvDex: dcvDex,
// temporary: true,
encumbrance: true,
},
};

if (prevActiveEffect) {
await prevActiveEffect.delete();
//prevActiveEffect = null;
}

await this.createEmbeddedDocuments("ActiveEffect", [activeEffect]);
Expand Down Expand Up @@ -1335,12 +1330,12 @@ export class HeroSystem6eActor extends Actor {

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Reset system properties to defaults
const _actor = await HeroSystem6eActor.create(
const _actor = new HeroSystem6eActor(
{
name: "Test Actor",
type: this.type,
},
{ temporary: true },
{},
);
const _system = _actor.system;

Expand Down Expand Up @@ -1414,8 +1409,7 @@ export class HeroSystem6eActor extends Actor {

if (this.system.is5e && this.id) {
// We can't delay this with the changes array because any items based on this actor needs this value.
// Speifically compound power is a problem if we don't set is5e properly for a 5e actor.
// changes[`system.is5e`] = this.system.is5e;
// Specifically compound power is a problem if we don't set is5e properly for a 5e actor.
await this.update({ "system.is5e": this.system.is5e });
}

Expand Down Expand Up @@ -1532,8 +1526,7 @@ export class HeroSystem6eActor extends Actor {
}
}
} else {
const item = await HeroSystem6eItem.create(itemData, {
temporary: true,
const item = new HeroSystem6eItem(itemData, {
parent: this,
});
this.items.set(item.system.XMLID + item.system.POSITION, item);
Expand Down Expand Up @@ -1580,8 +1573,7 @@ export class HeroSystem6eActor extends Actor {
POSITION: parseInt(system2.POSITION),
},
};
const item = await HeroSystem6eItem.create(itemData2, {
temporary: true,
const item = new HeroSystem6eItem(itemData2, {
parent: this,
});
this.items.set(item.system.XMLID + item.system.POSITION, item);
Expand Down Expand Up @@ -1829,10 +1821,13 @@ export class HeroSystem6eActor extends Actor {
levels: "0",
},
};
const perceptionItem = await HeroSystem6eItem.create(itemDataPerception, {
temporary: this.id ? false : true,
parent: this,
});
const perceptionItem = this.id
? await HeroSystem6eItem.create(itemDataPerception, {
parent: this,
})
: new HeroSystem6eItem(itemDataPerception, {
parent: this,
});
if (!this.id) {
this.items.set(perceptionItem.system.XMLID, perceptionItem);
}
Expand Down
14 changes: 5 additions & 9 deletions module/item/item-attack.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export async function AttackToHit(item, options) {
const effectiveItemData = item.toObject();
effectiveItemData._id = null;
effectiveItemData.system.LEVELS = options.effectiveLevels;
effectiveItem = await HeroSystem6eItem.create(effectiveItemData, { parent: item.actor, temporary: true });
effectiveItem = new HeroSystem6eItem(effectiveItemData, { parent: item.actor });
await effectiveItem._postUpload();
}
}
Expand Down Expand Up @@ -1220,9 +1220,7 @@ async function _rollApplyKnockback(token, knockbackDice) {
</MODIFIER>
</POWER>
`;
const pdAttack = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(pdContentsAttack, actor), {
temporary: true,
});
const pdAttack = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(pdContentsAttack, actor), {});
await pdAttack._postUpload();
pdAttack.name ??= "KNOCKBACK";

Expand Down Expand Up @@ -1402,7 +1400,7 @@ export async function _onRollDamage(event) {
const effectiveItemData = item.toObject();
effectiveItemData._id = null;
effectiveItemData.system.LEVELS = toHitData.effectiveLevels;
effectiveItem = await HeroSystem6eItem.create(effectiveItemData, { parent: item.actor, temporary: true });
effectiveItem = new HeroSystem6eItem(effectiveItemData, { parent: item.actor });
await effectiveItem._postUpload();
}
}
Expand Down Expand Up @@ -1662,7 +1660,7 @@ export async function _onRollMindScanEffectRoll(event) {
const effectiveItemData = item.toObject();
effectiveItemData._id = null;
effectiveItemData.system.LEVELS = toHitData.effectiveLevels;
effectiveItem = await HeroSystem6eItem.create(effectiveItemData, { parent: item.actor, temporary: true });
effectiveItem = new HeroSystem6eItem(effectiveItemData, { parent: item.actor });
await effectiveItem._postUpload();
}
}
Expand Down Expand Up @@ -3198,9 +3196,7 @@ async function _calcKnockback(body, item, options, knockbackMultiplier) {
<POWER XMLID="KNOCKBACK" ID="1695402954902" BASECOST="0.0" LEVELS="1" ALIAS="Knockback" POSITION="0" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
</POWER>
`;
const kbAttack = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(kbContentsAttack, actor), {
temporary: true,
});
const kbAttack = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(kbContentsAttack, actor), {});
//await pdAttack._postUpload();
let { defenseValue, defenseTags } = getActorDefensesVsAttack(actor, kbAttack);
knockbackTags = [...knockbackTags, ...defenseTags];
Expand Down
23 changes: 11 additions & 12 deletions module/testing/testing-damage-functions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ export function registerDamageFunctionTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);
actor.system.is5e = false;
await actor._postUpload();

item = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
item = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await item._postUpload();
Expand Down Expand Up @@ -197,13 +197,12 @@ export function registerDamageFunctionTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);
actor.system.is5e = true;
await actor._postUpload();

item = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
item = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await item._postUpload();
Expand Down Expand Up @@ -237,12 +236,12 @@ export function registerDamageFunctionTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);
actor.system.is5e = false;
await actor._postUpload();

item = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
item = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await item._postUpload();
Expand Down Expand Up @@ -276,12 +275,12 @@ export function registerDamageFunctionTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);
actor.system.is5e = false;
await actor._postUpload();

item = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
item = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await item._postUpload();
Expand Down
48 changes: 20 additions & 28 deletions module/testing/testing-defense.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,22 @@ export function registerDefenseTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);

const contentsAttack = `
<POWER XMLID="ENERGYBLAST" ID="1695402954902" BASECOST="0.0" LEVELS="1" ALIAS="Blast" POSITION="0" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" INPUT="PD" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
</POWER>
`;
const itemDefense = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
const itemDefense = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await itemDefense._postUpload();
actor.items.set(itemDefense.system.XMLID, itemDefense);

const itemAttack = await new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(contentsAttack, actor),
{ temporary: true, parent: actor },
);
const itemAttack = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contentsAttack, actor), {
parent: actor,
});
await itemAttack._postUpload();

const defense = determineDefense(actor, itemAttack);
Expand All @@ -55,24 +53,22 @@ export function registerDefenseTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);

const contentsAttack = `
<POWER XMLID="ENERGYBLAST" ID="1695402954902" BASECOST="0.0" LEVELS="1" ALIAS="Blast" POSITION="0" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" INPUT="ED" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
</POWER>
`;
const itemDefense = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
const itemDefense = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await itemDefense._postUpload();
actor.items.set(itemDefense.system.XMLID, itemDefense);

const itemAttack = await new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(contentsAttack, actor),
{ temporary: true, parent: actor },
);
const itemAttack = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contentsAttack, actor), {
parent: actor,
});
await itemAttack._postUpload();

const defense = determineDefense(actor, itemAttack);
Expand All @@ -90,25 +86,23 @@ export function registerDefenseTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);

const contentsAttack = `
<POWER XMLID="EGOATTACK" ID="1695575160315" BASECOST="0.0" LEVELS="1" ALIAS="Mental Blast" POSITION="1" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" NAME="" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
<NOTES />
</POWER>
`;
const itemDefense = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
const itemDefense = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await itemDefense._postUpload();
actor.items.set(itemDefense.system.XMLID, itemDefense);

const itemAttack = await new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(contentsAttack, actor),
{ temporary: true, parent: actor },
);
const itemAttack = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contentsAttack, actor), {
parent: actor,
});
await itemAttack._postUpload();

const defense = determineDefense(actor, itemAttack);
Expand All @@ -126,25 +120,23 @@ export function registerDefenseTests(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);

const contentsAttack = `
<POWER XMLID="DRAIN" ID="1695576093210" BASECOST="0.0" LEVELS="1" ALIAS="Drain" POSITION="2" MULTIPLIER="1.0" GRAPHIC="Burst" COLOR="255 255 255" SFX="Default" SHOW_ACTIVE_COST="Yes" INCLUDE_NOTES_IN_PRINTOUT="Yes" NAME="" INPUT="BODY" USESTANDARDEFFECT="No" QUANTITY="1" AFFECTS_PRIMARY="No" AFFECTS_TOTAL="Yes">
<NOTES />
</POWER>
`;
const itemDefense = await new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
temporary: true,
const itemDefense = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contents, actor), {
parent: actor,
});
await itemDefense._postUpload();
actor.items.set(itemDefense.system.XMLID, itemDefense);

const itemAttack = await new HeroSystem6eItem(
HeroSystem6eItem.itemDataFromXml(contentsAttack, actor),
{ temporary: true, parent: actor },
);
const itemAttack = new HeroSystem6eItem(HeroSystem6eItem.itemDataFromXml(contentsAttack, actor), {
parent: actor,
});

await itemAttack._postUpload();

Expand Down
4 changes: 2 additions & 2 deletions module/testing/testing-everything-lad-lass.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ export function registerEverythingLadLass(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);

await actor.uploadFromXml(contents);
Expand Down Expand Up @@ -1938,7 +1938,7 @@ export function registerEverythingLadLass(quench) {
name: "Quench Actor",
type: "pc",
},
{ temporary: true },
{},
);

await actor.uploadFromXml(contents);
Expand Down
Loading

0 comments on commit acd6b5d

Please sign in to comment.