-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRulebook.ttslua
More file actions
323 lines (281 loc) · 14.5 KB
/
Rulebook.ttslua
File metadata and controls
323 lines (281 loc) · 14.5 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
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
--[[
--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. Liberals can only use one ability per game.',
'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.',
'*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. Reshuffle: Place the policy tiles from the discard pile into the policy deck and shuffle the deck. Reshuffling when the discard pile is empty results in a deck shuffle.',
'T3. Negate: Every part of the ability does not resolve.',
'T4. 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.',
'T5. Concealed: Placed face down on the table.',
'*Etiquette and Timing',
'E1. Saboteur and Hacker 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: Martyr, Collector, Harbinger, Jester, Surgeon, Gambler, Senator, Trickster, Usurper, Rebel, Fisherman, Dictator, Decider, Scout, Spelunker.',
'C5. Abilities that can be Puppeteered: Spy (one target), Assassin, Poisoner (one target), Collector, Harbinger, Soulmate, Avenger, Guardian-Angel, Bandit, Librarian, Spiritualist, Silencer, Denouncer and Big-Brother.',
'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.1,-1.3}, width = 0, height = 0, font_size = 100}
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.1,0}, width = 0, height = 0, font_size = 50, alignment = 2}
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.1,1.1}, width = 250, height = 200, font_size = 120, tooltip = 'First Page [Numpad 8]'}
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.1,1.1}, width = 250, height = 200, font_size = 100, tooltip = 'Previous Page [Numpad 4]'}
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.1,1.1}, width = 250, height = 200, font_size = 100, tooltip = 'Next Page [Numpad 6]'}
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.1,1.1}, width = 250, height = 200, font_size = 120, tooltip = 'Last Page [Numpad 2]'}
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.1,-1.5}, width = 100, height = 100, font_size = 80, tooltip = 'Give Rulebook to:'}
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 = 100, alignment = 3}
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.1,-0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool7', label = "Teal", color = stringColorToRGB('Teal'), function_owner = self,
position = {0,0.1,-0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool8', label = "Blue", color = stringColorToRGB('Blue'), function_owner = self,
position = {1,0.1,-0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool3', label = "Red", color = stringColorToRGB('Red'), function_owner = self,
position = {-1,0.1,0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool2', label = "Brown", color = stringColorToRGB('Brown'), function_owner = self,
position = {0,0.1,0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool1', label = "White", color = stringColorToRGB('White'), function_owner = self,
position = {1,0.1,0.9}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool5', label = "Yellow", color = stringColorToRGB('Yellow'), function_owner = self,
position = {-1.2,0.1,-0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool4', label = "Orange", color = stringColorToRGB('Orange'), function_owner = self,
position = {-1.2,0.1,0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool9', label = "Purple", color = stringColorToRGB('Purple'), function_owner = self,
position = {1.2,0.1,-0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'giveTool10', label = "Pink", color = stringColorToRGB('Pink'), function_owner = self,
position = {1.2,0.1,0.3}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
self.createButton(buttonParam)
local buttonParam = {click_function = 'moveBoard', label = "Cancel", color = {1,1,1,0.8}, function_owner = self,
position = {0,0.1,0}, rotation = {0,0,0}, width = 500, height = 300, font_size = 100}
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