mirror of
https://github.com/Nighthawk42/roll20-character-sheets.git
synced 2026-08-30 03:40:32 +00:00
revert attributes quaries
This commit is contained in:
@@ -33,16 +33,14 @@ const setTranslatedDefaults = () => {
|
||||
const handleAttributeQueries = () => {
|
||||
// Attribute query magic to set the global query variables according to
|
||||
// translations and the state of the setting_skill_query attribute.
|
||||
const getAttributeTranslation = (attr: string) =>
|
||||
translate(attr.toUpperCase());
|
||||
|
||||
const attrQueries = attributes.map((attr) => {
|
||||
const translated = getAttributeTranslation(attr);
|
||||
return `${translated},+ @{${attr}_mod}[${translated}]]]}} {{attribute= + ${translated})}}}`;
|
||||
const translated = translate(attr.toUpperCase());
|
||||
return (
|
||||
`${translated},+ @{${attr}_mod}[${translated}]]]}} ` +
|
||||
`{{attribute= + ${translate(`${attr.toUpperCase()}_SHORT`)}}}`
|
||||
);
|
||||
});
|
||||
|
||||
const queryPrefix = `?{${translate("ATTRIBUTE")}|`;
|
||||
|
||||
getAttrs(
|
||||
[
|
||||
"attribute_query",
|
||||
@@ -50,66 +48,69 @@ const handleAttributeQueries = () => {
|
||||
...attributes.map((a) => `attribute_query_${a.slice(0, 3)}`),
|
||||
],
|
||||
(v) => {
|
||||
const translatedString = (attr: string) => {
|
||||
const translated = getAttributeTranslation(attr);
|
||||
const abbr = translated && translate(translated.slice(0, 3));
|
||||
|
||||
return `+ @{${attr}_mod}[${`${translated}`}]]]}} {{attribute= + ${abbr}}}`;
|
||||
};
|
||||
|
||||
const attributeObject: { [key: string]: string } = {};
|
||||
attributes.forEach((a) => {
|
||||
attributeObject[
|
||||
`attribute_query_${a.slice(0, 3)}` as keyof typeof attributeObject
|
||||
] = translatedString(a);
|
||||
});
|
||||
|
||||
if (
|
||||
v.setting_skill_query === "hover" ||
|
||||
v.setting_skill_query === "hide"
|
||||
) {
|
||||
mySetAttrs(
|
||||
{
|
||||
attribute_query: `${queryPrefix}${[
|
||||
attribute_query: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[0],
|
||||
...attrQueries.slice(1),
|
||||
].join("|")}}`,
|
||||
...attributeObject,
|
||||
attribute_query_str: `+ @{strength_mod}[${translate(
|
||||
"STRENGTH"
|
||||
)}]]]}} {{attribute= + ${translate("STRENGTH_SHORT")}}}`,
|
||||
attribute_query_dex: `+ @{dexterity_mod}[${translate(
|
||||
"DEXTERITY"
|
||||
)}]]]}} {{attribute= + ${translate("DEXTERITY_SHORT")}}}`,
|
||||
attribute_query_con: `+ @{constitution_mod}[${translate(
|
||||
"CONSTITUTION"
|
||||
)}]]]}} {{attribute= + ${translate("CONSTITUTION_SHORT")}}}`,
|
||||
attribute_query_int: `+ @{intelligence_mod}[${translate(
|
||||
"INTELLIGENCE"
|
||||
)}]]]}} {{attribute= + ${translate("INTELLIGENCE_SHORT")}}}`,
|
||||
attribute_query_wis: `+ @{wisdom_mod}[${translate(
|
||||
"WISDOM"
|
||||
)}]]]}} {{attribute= + ${translate("WISDOM_SHORT")}}}`,
|
||||
attribute_query_cha: `+ @{charisma_mod}[${translate(
|
||||
"CHARISMA"
|
||||
)}]]]}} {{attribute= + ${translate("CHARISMA_SHORT")}}}`,
|
||||
},
|
||||
v
|
||||
);
|
||||
} else if (v.setting_skill_query === "query") {
|
||||
mySetAttrs(
|
||||
{
|
||||
attribute_query: `${queryPrefix}${[
|
||||
attribute_query: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[0],
|
||||
...attrQueries.slice(1),
|
||||
].join("|")}}`,
|
||||
attribute_query_str: `${queryPrefix}${[
|
||||
attribute_query_str: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[0],
|
||||
...attrQueries.slice(1),
|
||||
].join("|")}}`,
|
||||
attribute_query_dex: `${queryPrefix}${[
|
||||
attribute_query_dex: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[1],
|
||||
attrQueries[0],
|
||||
...attrQueries.slice(2),
|
||||
].join("|")}}`,
|
||||
attribute_query_con: `${queryPrefix}${[
|
||||
attribute_query_con: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[2],
|
||||
...attrQueries.slice(0, 2),
|
||||
...attrQueries.slice(3),
|
||||
].join("|")}}`,
|
||||
attribute_query_int: `${queryPrefix}${[
|
||||
attribute_query_int: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[3],
|
||||
...attrQueries.slice(0, 3),
|
||||
...attrQueries.slice(4),
|
||||
].join("|")}}`,
|
||||
attribute_query_wis: `${queryPrefix}${[
|
||||
attribute_query_wis: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[4],
|
||||
...attrQueries.slice(0, 4),
|
||||
...attrQueries.slice(5),
|
||||
].join("|")}}`,
|
||||
attribute_query_cha: `${queryPrefix}${[
|
||||
attribute_query_cha: `?{${translate("ATTRIBUTE")}|${[
|
||||
attrQueries[5],
|
||||
...attrQueries.slice(0, 5),
|
||||
].join("|")}}`,
|
||||
@@ -120,6 +121,7 @@ const handleAttributeQueries = () => {
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleModifierQuery = () => {
|
||||
getAttrs(["modifier_query", "setting_modifier_query"], (v) => {
|
||||
if (`${v.setting_modifier_query}` === "1") {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user