-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRulebook.ttslua
330 lines (287 loc) · 15.8 KB
/
Rulebook.ttslua
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
--[[
--SH Expansion Rulebook
--Made by Sionar
--]]
------------------Constants
RULES = {
'*Expansion Rules',
'R1. Setup: Deal three abilities to each player at the start of the game. Keep two and place one back in the deck.',
'R2. [0000FF]Liberals can only use one ability per game.',
'[FFFFFF]R3. Abilities are one time use only unless stated otherwise. Keep them concealed until you use them. Announce when you are using an ability. Text in brackets restricts when they can be used.',
'R4. Abilities resolve in the order that they are revealed. All parts of the ability must resolve before the next ability can begin to resolve. The exceptions to this are Saboteur, Hacker and Puppeteer, which are played in response to other abilities.',
'R5. Unless stated otherwise, abilities cannot be used while there are policy tiles in play. After a government passes, abilities can be played before a player draws policy tiles and after a policy is placed on a tracker.',
'*Hard Mode Rules',
'H1. Any ability that is revealed must be played.',
'H2. When playing an ability, make sure it is face down when coming out of your hidden zone. Announce to the table \'I am playing an ability\'. If nobody else is contesting you for playing an ability, then you may flip it over and reveal the ability.',
'H3. You can contest someone for playing an ability if you do it within half a second of the other person. The person who goes first is chosen randomly. After the first person finishes resolving their ability, the second person has priority to play an ability before anyone else.',
'H4. If an ability is played before it is legal (i.e playing a card that can only be done after Hitler Territory before Hitler Territory), the card fizzles, meaning that it has no effect. It counts as playing an ability and remains revealed on the table.',
'H5. All of these rules also apply for revealing artifacts.',
'*Terminology',
'T1. Round: A "round" starts when the presidency placard moves and ends after the presidential power gets used or a play gets downvoted. If the government is interrupted without a vote going through, it does not count as a round.',
'T2. Negate: Every part of the ability does not resolve.',
'T3. Right after: This timing window refers to the time before anything else occurs. This includes a player using an ability or a presidential power, or a president choosing a chancellor.',
'T4. Reveal this ability before voting: The ability can only be played while you are still voting on a government. It cannot be played after the vote passes and before the start of a new voting session.',
'T5. Free: The player with a free ability can play it without it counting towards their one ability per game limit. It is kept concealed in front of that player.',
'*Etiquette and Timing',
'E1. Saboteur, Hacker and Interceptor cannot be used once the player has already started performing the actions of the ability. When you announce an ability, wait at least five seconds to give other players a chance to respond before you play your ability.',
'E2. If a player wants you to wait before you use your ability, give them at least thirty seconds to decide whether or not they want to respond to your ability.',
'E3. After a government passes, wait at least five seconds before you draw cards in case someone wants to play an ability.',
'E4. After a player dies, wait five seconds before asking if they are Hitler in case someone decides to save them with an ability.',
'E5. If a government fails and a topdeck occurs, the topdeck happens at the end of the round. Abilities may be played right before a topdeck.',
'*Clarifications',
'C1. Dead players cannot use abilities or reveal artifacts.',
'C2. A player with Aegis cannot be targeted by any abilities. Their abilities also cannot be interacted with in any manner.',
'C3. Players with the Silenced effect may reveal artifacts.',
'C4. Abilities that can be Hacked: Any ability with the green lock symbol.',
'C5. Abilities that can be Puppeteered: Any ability with the yellow puppet symbol.',
'C6. Cards may not be traded while an ability is being played.'
}
CREDITS = 'Made by: \nPiggy\nSionar\n\nSpecial thanks to the entire\nSecret Hitler community!\n\nCome join us on Discord at:\ncFuFmmm'
NOTEBOOK_TITLE = 'Expansion'
LINE_WIDTH = 58
LINES_PER_PAGE = 27
START_POS = {x = 100, y = 1.1, z = -22}
START_ROT = {x = 0, y = 180, z = 0}
COLOR_TABLE = {'White', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Teal', 'Blue', 'Purple', 'Pink'}
------------------Variables
rulebook = {}
title = {}
page = 1
function format()
local lineLen, pNumLines, rNumLines = 0,0,0
local pageText = ''
local currentTitle
local ruleText = ''
for n, rule in pairs(RULES) do
rNumLines = 2
ruleText = ''
lineLen = 0
for word in string.gmatch(rule, '%g+') do
if string.match(word, '*') then
if pageText ~= '' then
while pNumLines < LINES_PER_PAGE do
pageText = pageText .. '\n'
pNumLines = pNumLines + 1
end
table.insert(rulebook, pageText)
table.insert(title, currentTitle)
pNumLines = 0
pageText = ''
end
currentTitle = string.sub(rule,2,-1)
break
else
if lineLen + string.len(word) > LINE_WIDTH then
while lineLen < LINE_WIDTH do
ruleText = ruleText .. ' '
lineLen = lineLen + 1
end
ruleText = ruleText .. '\n' .. word .. ' '
lineLen = string.len(word) + 1
rNumLines = rNumLines + 1
else
ruleText = ruleText .. word .. ' '
lineLen = lineLen + string.len(word) + 1
end
end
end
ruleText = ruleText .. '\n\n'
if pNumLines + rNumLines < LINES_PER_PAGE then
pageText = pageText .. ruleText
pNumLines = pNumLines + rNumLines
else
while pNumLines < LINES_PER_PAGE do
pageText = pageText .. '\n'
pNumLines = pNumLines + 1
end
table.insert(rulebook, pageText)
table.insert(title, currentTitle)
pNumLines = rNumLines
pageText = ruleText
end
end
while pNumLines < LINES_PER_PAGE - 4 do
pageText = pageText .. '\n'
pNumLines = pNumLines + 1
end
table.insert(rulebook, pageText)
table.insert(title, currentTitle)
end
format()
last = #rulebook
------------------Main Functions
function onLoad()
page = 1
refreshText()
moveBoard()
addEditNotebookTab()
self.setDescription('v ' .. VERSION .. '\nMade by Sionar')
end
function addEditNotebookTab()
local params = {}
local index = nil
params.title = NOTEBOOK_TITLE
params.body = ''
for _, rule in pairs(RULES) do
if string.match(rule, '^*') then
params.body = params.body .. string.gsub(rule, '^*', '[u][b]') .. '[/b][/u]\n\n'
else
params.body = params.body .. rule .. '\n\n'
end
end
params.body = params.body .. CREDITS
for _, tab in ipairs(getNotebookTabs()) do
if tab.title == NOTEBOOK_TITLE then
index = tab.index
break
end
end
if index then
removeNotebookTab(index)
addNotebookTab(params)
else
addNotebookTab(params)
end
end
function moveBoard()
local global_name = Global.getVar('MOD_NAME')
if global_name == 'Secret Hitler: CE' then
self.setPositionSmooth(START_POS)
self.setRotationSmooth(START_ROT)
self.setLock(true)
end
refreshText()
end
function refreshText()
self.clearButtons()
self.clearInputs()
local buttonParam = {click_function = 'nullFunc', function_owner = self, label = title[page], color = {0,0,0,1}, font_color = stringColorToRGB('Red'),
position = {0,0.2,-1.35}, width = 0, height = 0, font_size = 320, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'nullFunc', function_owner = self, label = rulebook[page], color = {0,0,0,1}, font_color = stringColorToRGB('White'),
position = {0,0.2,0}, width = 0, height = 0, font_size = 200, alignment = 2, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'firstPage', function_owner = self, label = '[b]⇤[/b]', color = {0,0,0,0.8}, font_color = stringColorToRGB('Red'),
position = {-0.9,0.2,1.1}, width = 1000, height = 600, font_size = 480, tooltip = 'First Page [Numpad 8]', scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'prevPage', function_owner = self, label = '[b]←[/b]', color = {0,0,0,0.8}, font_color = stringColorToRGB('Red'),
position = {-0.3,0.2,1.1}, width = 1000, height = 600, font_size = 400, tooltip = 'Previous Page [Numpad 4]', scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'nextPage', function_owner = self, label = '[b]→[/b]', color = {0,0,0,0.8}, font_color = stringColorToRGB('Red'),
position = {0.3,0.2,1.1}, width = 1000, height = 600, font_size = 400, tooltip = 'Next Page [Numpad 6]', scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'lastPage', function_owner = self, label = '[b]⇥[/b]', color = {0,0,0,0.8}, font_color = stringColorToRGB('Red'),
position = {0.9,0.2,1.1}, width = 1000, height = 600, font_size = 480, tooltip = 'Last Page [Numpad 2]', scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'givetMenu', function_owner = self, label = '☆', color = {0,0,0,0.8}, font_color = stringColorToRGB('Red'),
position = {1.5,0.2,-1.5}, width = 400, height = 400, font_size = 320, tooltip = 'Give Rulebook to:', scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'nullFunc', function_owner = self, label = CREDITS, color = {0,0,0,1}, font_color = stringColorToRGB('White'),
position = {0,-0.1,-0.15}, rotation = {180, 180, 0}, width = 0, height = 0, font_size = 400, alignment = 3, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
end
function nullFunc()
end
function firstPage()
page = 1
refreshText()
end
function prevPage()
if page ~= 1 then
page = page - 1
end
refreshText()
end
function nextPage()
if page ~= last then
page = page + 1
end
refreshText()
end
function lastPage()
page = last
refreshText()
end
function onScriptingButtonDown(index, playerColor)
if index == 8 then
firstPage()
elseif index == 2 then
lastPage()
elseif index == 4 then
prevPage()
elseif index == 6 then
nextPage()
end
end
function giveTool(clickedButton, playerColor, index)
local pos = {forward = -17, right = 0, up = 1}
local rot = {x = 0, y = 180, z = 0}
if COLOR_TABLE[index] == 'Purple' or COLOR_TABLE[index] == 'Orange' then
pos['right'] = 5
elseif COLOR_TABLE[index] == 'Pink' or COLOR_TABLE[index] == 'Yellow' then
pos['right'] = -5
end
giveObjectToPlayer(self, COLOR_TABLE[index], pos, rot)
refreshText()
end
for k = 1,10 do
_G['giveTool' .. k] = function(obj, col)
giveTool(obj, col, k)
end
end
function givetMenu()
self.clearButtons()
state = 11
local buttonParam = {click_function = 'giveTool6', label = "Green", color = stringColorToRGB('Green'), function_owner = self,
position = {-1,0.2,-0.9}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool7', label = "Teal", color = stringColorToRGB('Teal'), function_owner = self,
position = {0,0.2,-0.9}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool8', label = "Blue", color = stringColorToRGB('Blue'), function_owner = self,
position = {1,0.2,-0.9}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool3', label = "Red", color = stringColorToRGB('Red'), function_owner = self,
position = {-1,0.2,0.9}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool2', label = "Brown", color = stringColorToRGB('Brown'), function_owner = self,
position = {0,0.2,0.9}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool1', label = "White", color = stringColorToRGB('White'), function_owner = self,
position = {1,0.2,0.9}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool5', label = "Yellow", color = stringColorToRGB('Yellow'), function_owner = self,
position = {-1.2,0.2,-0.3}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool4', label = "Orange", color = stringColorToRGB('Orange'), function_owner = self,
position = {-1.2,0.2,0.3}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool9', label = "Purple", color = stringColorToRGB('Purple'), function_owner = self,
position = {1.2,0.2,-0.3}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool10', label = "Pink", color = stringColorToRGB('Pink'), function_owner = self,
position = {1.2,0.2,0.3}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
local buttonParam = {click_function = 'moveBoard', label = "Cancel", color = {1,1,1,0.8}, function_owner = self,
position = {0,0.2,0}, rotation = {0,0,0}, width = 1800, height = 1000, font_size = 400, scale = {0.25,0.25,0.25}}
self.createButton(buttonParam)
end
function giveObjectToPlayer(object, playerColor, posAdd, rotAdd, ...)
local ph = Player[playerColor].getPlayerHand()
if ph then
if rotAdd['exactRot'] then
object.setRotationSmooth({rotAdd['x'], rotAdd['y'], rotAdd['z']}, ...)
else
object.setRotationSmooth({ph['rot_x'] + rotAdd['x'], ph['rot_y'] + rotAdd['y'], ph['rot_z'] + rotAdd['z']}, ...)
end
if posAdd['forceHeight'] then
object.setPositionSmooth({ph['pos_x'] + ph['trigger_forward_x'] * posAdd['forward'] + ph['trigger_right_x'] * posAdd['right'] + ph['trigger_up_x'] * posAdd['up'],
posAdd['forceHeight'],
ph['pos_z'] + ph['trigger_forward_z'] * posAdd['forward'] + ph['trigger_right_z'] * posAdd['right'] + ph['trigger_up_z'] * posAdd['up']}, ...)
else
object.setPositionSmooth({ph['pos_x'] + ph['trigger_forward_x'] * posAdd['forward'] + ph['trigger_right_x'] * posAdd['right'] + ph['trigger_up_x'] * posAdd['up'],
ph['pos_y'] + ph['trigger_forward_y'] * posAdd['forward'] + ph['trigger_right_y'] * posAdd['right'] + ph['trigger_up_y'] * posAdd['up'],
ph['pos_z'] + ph['trigger_forward_z'] * posAdd['forward'] + ph['trigger_right_z'] * posAdd['right'] + ph['trigger_up_z'] * posAdd['up']}, ...)
end
end
end