-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlackboardAPI.lua
155 lines (137 loc) · 5.03 KB
/
BlackboardAPI.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
--- STEAMODDED HEADER
--- MOD_NAME: BlackboardAPI
--- MOD_ID: BlackboardAPI
--- MOD_AUTHOR: [Emihead]
--- MOD_DESCRIPTION: Lets modded suits be considered "light" or "dark"
--- PRIORITY: -10000
----------------------------------------------
------------MOD CODE -------------------------
function format_localization()
local key = ""
local suits = ""
for k, v in ipairs(G.suitcolors.colorlist) do
key = G.suitcolors.colorlist[k].."suits"
G.localization.descriptions.Other[key] = {}
G.localization.descriptions.Other[key].name = firstToUpper(G.suitcolors.colorlist[k]).." suits"
G.localization.descriptions.Other[key].text = {}
for i, w in ipairs(G.suitcolors.colors[v]) do
if ((i-1) % 2 +1) == 1 then
suits = w
else
suits = suits..", "..w
table.insert(G.localization.descriptions.Other[key].text, suits)
end
end
end
end
function SMODS.INIT.BlackboardAPI()
G.suitcolors = {}
G.suitcolors.colors = {}
G.suitcolors.colors.light = {"Hearts", "Diamonds"}
G.suitcolors.colors.dark = {"Spades", "Clubs"}
G.suitcolors.blackboard_liked = {"dark"}
G.suitcolors.colorlist = {"light", "dark"}
G.localization.descriptions.Joker.j_blackboard.text = {
"{X:red,C:white} X#1# {} Mult if all",
"cards held in hand",
"have #2# suits"
}
G.localization.descriptions.Other["lightsuits"] = {
name = "Light suits",
text = {
"Hearts",
"Diamonds"
}
}
G.localization.descriptions.Other["darksuits"] = {
name = "Dark suits",
text = {
"Spades",
"Clubs"
}
}
if SMODS.findModByID('SixSuits') then
table.insert(G.suitcolors.colors.light, "Stars")
table.insert(G.suitcolors.colors.dark, "Moons")
table.insert(G.localization.descriptions.Other["lightsuits"].text, "Stars")
table.insert(G.localization.descriptions.Other["darksuits"].text, "Moons")
end
if SMODS.findModByID('Bunco') then
table.insert(G.suitcolors.colors.light, "Fleurons")
table.insert(G.suitcolors.colors.dark, "Halberds")
table.insert(G.localization.descriptions.Other["lightsuits"].text, "Fleurons")
table.insert(G.localization.descriptions.Other["darksuits"].text, "Halberds")
end
SMODS.Joker:take_ownership('blackboard'):register()
format_localization()
function SMODS.Jokers.j_blackboard.loc_def(card)
local goodsuits = ""
local i = 0
for k,v in ipairs(G.suitcolors.blackboard_liked) do
if i == 0 then
goodsuits = v
elseif i == 1 then
goodsuits = goodsuits.." or "..v
else
goodsuits = v..", "..goodsuits
end
i = i + 1
end
return {card.ability.extra, goodsuits}
end
function SMODS.Jokers.j_blackboard.tooltip(card, info_queue)
local key = ""
for k,v in ipairs(G.suitcolors.blackboard_liked) do
key = v..'suits'
info_queue[#info_queue+1]= {key = key, set = 'Other'}
end
end
SMODS.Jokers.j_blackboard.calculate = function(self, context)
if context.cardarea == G.jokers and not context.after and not context.before then
local black_suits, all_cards = 0, 0
local goodsuits = {}
for k,v in ipairs(G.suitcolors.blackboard_liked) do
for l,w in ipairs(G.suitcolors.colors[v]) do
table.insert(goodsuits, w)
end
end
for k, v in ipairs(G.hand.cards) do
all_cards = all_cards + 1
local done = false
for i,w in ipairs(goodsuits) do
if v:is_suit(w, nil, true) and not done then
done = true
black_suits = black_suits + 1
end
end
end
if black_suits == all_cards then
return {
message = localize{type='variable',key='a_xmult',vars={self.ability.extra}},
Xmult_mod = self.ability.extra
}
end
end
end
end
function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
function new_suit_color(color, blackboard_liked)
G.suitcolors.colors[color] = {}
if blackboard_liked then table.insert(G.suitcolors.blackboard_liked, color) end
table.insert(G.suitcolors.colorlist, color)
local key = color.."suits"
G.localization.descriptions.Other[key] = {
name = firstToUpper(color).." suits",
text = {}
}
end
function define_suit_color(suitname, color)
table.insert(G.suitcolors.colors[color], suitname)
local key = color.."suits"
table.insert(G.localization.descriptions.Other[key].text, suitname)
format_localization()
end
----------------------------------------------
------------MOD CODE END----------------------