Skip to content

Commit 99bb5e2

Browse files
committed
* Fix: Fall back to tab for sleep when deactivating magic/karma and the corresponding regeneration types
1 parent 9623ebd commit 99bb5e2

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

Das_Schwarze_Auge_4-1/dev/js/regeneration.js

+62
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,66 @@
11
/* regeneration begin */
2+
/* Handle active regeneration tabs when deactivating magic/karma */
3+
const attrsUIReg = [
4+
'ui_tab_reg',
5+
'MagieTab',
6+
'LiturgienTab',
7+
];
8+
Object.freeze(attrsUIReg);
9+
10+
on(attrsUIReg.map(attr => "change:" + attr).join(" ").toLowerCase(),
11+
function(eventInfo) {
12+
// Boilerplate
13+
const caller = "Action Listener for Showing/Hiding Regeneration Tabs";
14+
debugLog(caller, "eventInfo", eventInfo);
15+
16+
// Preparation
17+
const sourceType = eventInfo["sourceType"];
18+
const sourceAttr = eventInfo["sourceAttribute"];
19+
const newValue = eventInfo["newValue"];
20+
21+
// Quick decision
22+
if (sourceType === "player")
23+
{
24+
safeGetAttrs(attrsUIReg, function(values) {
25+
// Preparation
26+
const currentTab = values["ui_tab_reg"];
27+
/// Regeneration type always available
28+
const fallback = "sleep";
29+
let attrsToChange = {};
30+
31+
// Handling changes to showing/hiding regeneration tabs
32+
/// The user must always see a non-hidden regeneration tab
33+
/// When hiding e. g. the magic tab, astral meditation gets hidden.
34+
/// If the user goes back to the regeneration tab it would appear empty
35+
/// if not set to a non-hidden regeneration type.
36+
if (
37+
(newValue === "1")
38+
&&
39+
(
40+
(
41+
(sourceAttr === "magietab")
42+
&&
43+
(currentTab === "astralmeditation")
44+
)
45+
||
46+
(
47+
(sourceAttr === "liturgientab")
48+
&&
49+
(currentTab === "karmicmeditation")
50+
)
51+
)
52+
)
53+
{
54+
attrsToChange["ui_tab_reg"] = fallback;
55+
}
56+
57+
// Finish
58+
debugLog(caller, "attrsToChange", attrsToChange);
59+
safeSetAttrs(attrsToChange);
60+
});
61+
}
62+
});
63+
264
/* handle activation/deactivation of advantages/disadvantages */
365
on(
466
"change:nachteil_schlechte_regeneration " +

0 commit comments

Comments
 (0)