Skip to content

Commit

Permalink
fix: When casting spells privately should now show properly whether a…
Browse files Browse the repository at this point in the history
… save is basic or not.
  • Loading branch information
xdy committed Jul 12, 2024
1 parent 8638381 commit f78b8ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/module/feature/damageHandler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function autoRollDamage(message: ChatMessagePF2e) {
["all", "gm"].includes(settings.autoRollDamageAllow),
)
) {
const pf2eFlags = <ActorFlagsPF2e>message.flags.pf2e;
const pf2eFlags = message.flags.pf2e;
const originUuid = <string>pf2eFlags?.origin?.uuid;

if (originUuid) {
Expand Down Expand Up @@ -63,8 +63,7 @@ export async function autoRollDamage(message: ChatMessagePF2e) {
const degreeOfSuccess = degreeOfSuccessWithRerollHandling(message);
const isFailure = ["criticalFailure", "failure"].includes(degreeOfSuccess);
const isSuccess = ["criticalSuccess", "success"].includes(degreeOfSuccess);
const context: any = pf2eFlags.context;
const isBasicSave = context?.options?.includes("item:defense:basic");
const isBasicSave = pf2eFlags.context?.options?.includes("item:defense:basic");

const originMessage = await getLatestChatMessageWithOrigin(5, originUuid);
const flags = originMessage?.flags;
Expand Down
17 changes: 12 additions & 5 deletions src/module/feature/qolHandler/handlePrivateSpellcasting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ async function generateMessageData(message: ChatMessagePF2e, origin, spellUUID:

const type = message.flags?.pf2e.origin?.type ?? "spell";
const traditionString = message.flags?.pf2e.casting?.tradition ?? "";
const context = message.flags.pf2e.context;
const isBasicSave = context?.options?.includes("item:defense:basic");
const isBasicSave = message.flags.pf2e.context?.options?.includes("item:defense:basic");
const content = buildSpellMessage(origin, tokenName, type, traditionString, spellUUID, data, isBasicSave);

const flags = {
Expand Down Expand Up @@ -160,7 +159,15 @@ function isShiftModifierActive(): boolean {
return game?.keyboard?.isModifierActive(KeyboardManager.MODIFIER_KEYS.SHIFT);
}

function buildSpellMessage(origin, tokenName: string, type, traditionString: string, spellUUID: string, data, basic) {
function buildSpellMessage(
origin,
tokenName: string,
type,
traditionString: string,
spellUUID: string,
data,
isBasicSave,
) {
let content = "";
if (origin) {
content = game.i18n.localize(
Expand Down Expand Up @@ -212,12 +219,12 @@ function buildSpellMessage(origin, tokenName: string, type, traditionString: str
.map((trait: any) => game.pf2e.system.sluggify(trait.valueOf()))
.sort()
.join(","),
basic,
basic: isBasicSave ? "|basic:true" : "",
});
} else {
content += game.i18n.format(`${MODULENAME}.SETTINGS.castPrivateSpellWithPublicMessage.noButtonSavePart`, {
dataSave: dataSave,
basic: basic
basic: isBasicSave
? game.i18n.localize(`${MODULENAME}.SETTINGS.castPrivateSpellWithPublicMessage.basic`)
: "",
});
Expand Down
2 changes: 1 addition & 1 deletion static/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
"name": "Post public message that a spell has been cast.",
"basic": "Basic",
"noButtonSavePart": "<br><b>{basic} {dataSave} save</b>",
"savePart": "<br>Save for the unknown spell is: @Check[type:{dataSave}|dc:{dataDC}|traits:{traits}|basic:{basic}}]",
"savePart": "<br>Save for the unknown spell is: @Check[type:{dataSave}|dc:{dataDC}|traits:{traits}{basic}}]",
"secondPartNoRk": ".<br>You can try using one of @UUID[Compendium.pf2e.feats-srd.MjQyTcV8Jiv1Jtln] or @UUID[Compendium.pf2e.feats-srd.2rSyTfPgAmNAo01r] to recognize it. Or, on your turn, spend an action to try to identify it (ask your gm for details).",
"secondPartRK": ".<br>You can try using one of @UUID[Compendium.pf2e.feats-srd.MjQyTcV8Jiv1Jtln] or @UUID[Compendium.pf2e.feats-srd.2rSyTfPgAmNAo01r] to recognize it. Or, on your turn, spend an action to try to identify it with @Check[type:{skill}|dc:{dcRK}|traits:secret,action:recall-knowledge] @UUID[Compendium.pf2e.actionspf2e.Item.1OagaWtBpVXExToo] (or 10 minutes with @Check[type:{skill}|dc:{dcRK}|traits:secret,action:identify-magic] @UUID[Compendium.pf2e.actionspf2e.Item.eReSHVEPCsdkSL4G] )",
"spell": "Spell",
Expand Down

0 comments on commit f78b8ca

Please sign in to comment.