forked from Azurency/Civ6-UIFiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameEffectsText.lua
66 lines (59 loc) · 1.73 KB
/
GameEffectsText.lua
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
------------------------------------------------------------------------------
-- Basic text provider for GameEffects classes
--
-- LIMITATIONS:
-- This logic does not route through GameCore and thus cannot use
-- implementation-specific arguments or functions.
------------------------------------------------------------------------------
function GetModifierText(modifierId, context)
if(GameEffects) then
local key = GameEffects.GetModifierTextKey(modifierId, context);
if(key) then
return GameEffects.GetModifierText(modifierId, key);
end
else
local key;
for row in GameInfo.ModifierStrings() do
if(row.ModifierId == modifierId and row.Context == context) then
key = row.Text;
break;
end
end
if(key) then
local args = {};
for row in GameInfo.ModifierArguments() do
if(row.ModifierId == modifierId) then
local nValue = tonumber(row.Value);
table.insert(args, {Name = row.Name, Value = nValue or row.Value});
end
end
return Locale.Lookup(key, unpack(args));
end
end
end
function GetRequirementText(requirementId, context)
if(GameEffects) then
local key = GameEffects.GetRequirementTextKey(modifierId, context);
if(key) then
return GameEffects.GetRequirementText(modifierId, key);
end
else
local key;
for row in GameInfo.RequirementStrings() do
if(row.RequirementId == requirementId and row.Context == context) then
key = row.Text;
break;
end
end
if(key) then
local args = {};
for row in GameInfo.RequirementArguments() do
if(row.RequirementId == requirementId) then
local nValue = tonumber(row.Value);
table.insert(args, {Name = row.Name, Value = nValue or row.Value});
end
end
return Locale.Lookup(key, unpack(args));
end
end
end