-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.lua
More file actions
126 lines (109 loc) · 4.7 KB
/
Copy pathcore.lua
File metadata and controls
126 lines (109 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
_G.RandomContract = _G.RandomContract or {}
local RandomContract = _G.RandomContract
RandomContract.ModPath = RandomContract.ModPath or ModPath or "RandomContract/"
RandomContract.SavePath = RandomContract.SavePath or ((SavePath or "") .. "RandomContract.json")
RandomContract.VERSION = 1
RandomContract.LOBBY_ITEM_ID = "menu_roll_contract"
RandomContract.MENU_ID = "random_contract_options"
RandomContract.STEALTH_MENU_ID = "random_contract_stealth_options"
RandomContract.LOUD_MENU_ID = "random_contract_loud_options"
RandomContract.HEIST_POLICY_MENU_ID = "random_contract_heist_policy_options"
RandomContract.POLICY_GLOBAL_EXCLUDE_MENU_ID = "random_contract_policy_global_exclude_options"
RandomContract.POLICY_TACTIC_MENU_ID = "random_contract_policy_tactic_options"
RandomContract.POLICY_STEALTH_PRESET_MENU_ID = "random_contract_policy_stealth_preset_options"
RandomContract.POLICY_LOUD_PRESET_MENU_ID = "random_contract_policy_loud_preset_options"
RandomContract.DEFAULT_HISTORY_LIMIT = 5
RandomContract.MIN_HISTORY_LIMIT = 0
RandomContract.MAX_HISTORY_LIMIT = 30
RandomContract.HISTORY_LIMIT = RandomContract.DEFAULT_HISTORY_LIMIT
RandomContract.SESSION_HISTORY_KEY = "random_contract_recent_history"
RandomContract.DEFAULT_DIFFICULTY = "sm_wish"
RandomContract.SELECT_COOLDOWN_SECONDS = 0.15
RandomContract.LOBBY_SYNC_COALESCE_SECONDS = 0.35
RandomContract.STEALTH_SEARCH_INPUT_ID = "random_contract_stealth_search"
RandomContract.LOUD_SEARCH_INPUT_ID = "random_contract_loud_search"
RandomContract.POLICY_GLOBAL_EXCLUDE_SEARCH_INPUT_ID = "random_contract_policy_global_exclude_search"
RandomContract.POLICY_TACTIC_SEARCH_INPUT_ID = "random_contract_policy_tactic_search"
RandomContract.POLICY_STEALTH_PRESET_SEARCH_INPUT_ID = "random_contract_policy_stealth_preset_search"
RandomContract.POLICY_LOUD_PRESET_SEARCH_INPUT_ID = "random_contract_policy_loud_preset_search"
RandomContract.HEIST_VISIBLE_CALLBACK_PREFIX = "random_contract_heist_visible_"
RandomContract.recent_history = RandomContract.recent_history or {}
RandomContract.menu_search = RandomContract.menu_search or {}
RandomContract.DIFFICULTIES = {
{ id = "normal", text_id = "menu_difficulty_normal", label_text_id = "random_contract_label_difficulty_normal", fallback = "Normal" },
{ id = "hard", text_id = "menu_difficulty_hard", label_text_id = "random_contract_label_difficulty_hard", fallback = "Hard" },
{ id = "overkill", text_id = "menu_difficulty_very_hard", label_text_id = "random_contract_label_difficulty_very_hard", fallback = "Very Hard" },
{ id = "overkill_145", text_id = "menu_difficulty_overkill", label_text_id = "random_contract_label_difficulty_overkill", fallback = "Overkill" },
{ id = "easy_wish", text_id = "menu_difficulty_easy_wish", label_text_id = "random_contract_label_difficulty_mayhem", fallback = "Mayhem" },
{ id = "overkill_290", text_id = "menu_difficulty_apocalypse", label_text_id = "random_contract_label_difficulty_death_wish", fallback = "Death Wish" },
{ id = "sm_wish", text_id = "menu_difficulty_sm_wish", label_text_id = "random_contract_label_difficulty_death_sentence", fallback = "Death Sentence" }
}
local function merge_defaults(target, defaults)
for key, value in pairs(defaults) do
if type(value) == "table" then
target[key] = target[key] or {}
merge_defaults(target[key], value)
elseif target[key] == nil then
target[key] = value
end
end
end
local function read_json_file(path)
if not path or not json or type(json.decode) ~= "function" then
return nil
end
local file = io.open(path, "r")
if not file then
return nil
end
local data = file:read("*all")
file:close()
if not data then
return nil
end
local ok, decoded = pcall(json.decode, data)
if ok and type(decoded) == "table" then
return decoded
end
end
RandomContract.DEFAULT_JOB_POLICY = {
extra_candidates = {},
eligibility = {},
recommended_exclusions = {
stealth = {},
loud = {}
}
}
RandomContract.JobPolicyPath = RandomContract.JobPolicyPath or (RandomContract.ModPath .. "data/job_policy.json")
RandomContract.JobPolicy = RandomContract.JobPolicy or read_json_file(RandomContract.JobPolicyPath) or {}
merge_defaults(RandomContract.JobPolicy, RandomContract.DEFAULT_JOB_POLICY)
for _, module_name in ipairs({
"common/util",
"common/settings",
"contracts/policy",
"contracts/jobs",
"contracts/pool",
"common/runtime",
"network/authority",
"lobby/view",
"lobby/sync",
"contracts/selection",
"lobby/text",
"lobby/label",
"lobby/menu_items",
"lobby/marker",
"lobby/item",
"lobby/input",
"menu/search",
"menu/setup",
"menu/difficulty",
"menu/tactic",
"menu/settings",
"menu/localization",
"menu/populate",
"menu/build",
"menu/callbacks"
}) do
dofile(RandomContract.ModPath .. "modules/" .. module_name .. ".lua")
end
return RandomContract