-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableTop_7Wonders.lua
More file actions
276 lines (255 loc) · 7.13 KB
/
Copy pathTableTop_7Wonders.lua
File metadata and controls
276 lines (255 loc) · 7.13 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
-- GUIDs
local setup_button = '4f86c4'
local wonders_bag = '6d3f65'
local decks = {
players_2={ age_1='fc28eb', age_2='92afcb', age_3='0b315a'},
players_3={ age_1='fc28eb', age_2='92afcb', age_3='0b315a'},
players_4={ age_1='623991', age_2='f7e230', age_3='961889'},
players_5={ age_1='48b08b', age_2='5dc250', age_3='28a32a'},
players_6={ age_1='99626a', age_2='cca2df', age_3='436934'},
players_7={ age_1='54015e', age_2='47bf02', age_3='1110bb'}
}
local guilds = '646cfe'
local decks_zone = '181da9'
local age_1_button = '6c24eb'
local age_2_button = '5cddcf'
local age_3_button = '8b0ddb'
local rotate_button = 'd8e15b'
local decks_bag = '2c24a6'
local money_bag_3 = 'af90b4'
-- Positions
local age_1_deck = { -6, 1.5, 18 }
local age_2_deck = { -3, 1.5, 18 }
local age_3_deck = { 0, 1.5, 18 }
local dummy_board_position = { -2.5, 1.5, -13 }
local dummy_deck_position = { -2.5, 1.5, -17 }
local dummy_money_position = { -8.5, 1.5, -13 }
local board_positions = {
White={ 23, 1.5, -19 },
Brown={ 0, 1.5, -19 },
Red={ -23, 1.5, -19 },
Orange={ -40, 1.5, -11 },
Yellow={ -40, 1.5, 12 },
Purple={ 40, 1.5, 12 },
Pink={ 40, 1.5, -11 }
}
local money_positions = {
White={ 17, 1.5, -19 },
Brown={ -6, 1.5, -19 },
Red={ -29, 1.5, -19 },
Orange={ -40, 1.5, -5 },
Yellow={ -40, 1.5, 18 },
Purple={ 40, 1.5, 18 },
Pink={ 40, 1.5, -5 }
}
local board_rotations = {
White={0, 180, 0},
Brown={0, 180, 0},
Red={0, 180, 0},
Orange={0, -90, 0},
Yellow={0, -90, 0},
Purple={0, 90, 0},
Pink={0, 90, 0}
}
-- Variables
local number_of_players
local order = {
clockwise={
White=Player.Brown, Brown=Player.Red, Red=Player.Orange,
Orange=Player.Yellow, Yellow=Player.Purple, Purple=Player.Pink, Pink=Player.White
},
counterclockwise={
White=Player.Pink, Pink=Player.Purple, Purple=Player.Yellow,
Yellow=Player.Orange, Orange=Player.Red, Red=Player.Brown, Brown=Player.White
}
}
local direction = ''
function onload()
getObjectFromGUID(wonders_bag).shuffle()
create_setup_button()
end
function create_setup_button()
local button = getObjectFromGUID(setup_button)
local params = {}
params.click_function = "setup"
params.label = "Setup"
params.position = {0, 0.2, 0}
params.rotation = {0, 180, 0}
params.width = 1500
params.height = 1000
params.font_size = 160
button.createButton(params)
end
function setup()
startLuaCoroutine(Global, 'setup_game')
end
function setup_game()
number_of_players = #getSeatedPlayers()
if number_of_players > 1 then
deal_wonders()
move_play_decks()
waitFrames(10)
deal_guilds()
waitFrames(60)
remove_unneeded_decks()
create_age_1_button()
create_rotate_button()
getObjectFromGUID(setup_button).destruct()
else
printToAll("Minumum 2 players", {1,1,1})
end
return 1
end
function create_rotate_button()
local button = getObjectFromGUID(rotate_button)
local params = {}
params.click_function = "rotate"
params.label = "Rotate Hands"
params.position = {0, 0.2, 0}
params.rotation = {0, 180, 0}
params.width = 1500
params.height = 1000
params.font_size = 160
button.createButton(params)
end
function rotate()
if number_of_players > 1 then
for _, p in ipairs(getSeatedPlayers()) do
local cp = Player[p]
repeat
cp = order[direction][cp.color]
until cp.seated
local space = cp.getPlayerHand()
for _, v in ipairs(Player[p].getHandObjects()) do
v.setPosition({space.pos_x, space.pos_y, space.pos_z})
v.setRotation(board_rotations[cp.color])
end
end
else
printToAll("Unable to pass cards; nobody to pass to.", {1, 1, 1})
end
end
function create_age_1_button()
local button = getObjectFromGUID(age_1_button)
local params = {}
params.click_function = "start_age_1"
params.label = "Start Age 1"
params.position = {0, 0.2, 0}
params.rotation = {0, 180, 0}
params.width = 1500
params.height = 1000
params.font_size = 160
button.createButton(params)
end
function start_age_1()
direction = 'clockwise'
local deck = getObjectFromGUID(decks['players_' .. number_of_players].age_1)
deck.shuffle()
deck.dealToAll(7)
if number_of_players == 2 then
deck.setPosition(dummy_deck_position)
end
getObjectFromGUID(age_1_button).destruct()
create_age_2_button()
end
function create_age_2_button()
local button = getObjectFromGUID(age_2_button)
local params = {}
params.click_function = "start_age_2"
params.label = "Start Age 2"
params.position = {0, 0.2, 0}
params.rotation = {0, 180, 0}
params.width = 1500
params.height = 1000
params.font_size = 160
button.createButton(params)
end
function start_age_2()
direction = 'counterclockwise'
local deck = getObjectFromGUID(decks['players_' .. number_of_players].age_2)
deck.shuffle()
deck.dealToAll(7)
if number_of_players == 2 then
deck.setPosition(dummy_deck_position)
end
getObjectFromGUID(age_2_button).destruct()
create_age_3_button()
end
function create_age_3_button()
local button = getObjectFromGUID(age_3_button)
local params = {}
params.click_function = "start_age_3"
params.label = "Start Age 3"
params.position = {0, 0.2, 0}
params.rotation = {0, 180, 0}
params.width = 1500
params.height = 1000
params.font_size = 160
button.createButton(params)
end
function start_age_3()
direction = 'clockwise'
local deck = getObjectFromGUID(decks['players_' .. number_of_players].age_3)
deck.shuffle()
deck.dealToAll(7)
if number_of_players == 2 then
deck.setPosition(dummy_deck_position)
end
getObjectFromGUID(age_3_button).destruct()
end
function deal_wonders()
for _, p in ipairs(getSeatedPlayers()) do
local params = {}
local color = Player[p].color
params.position = board_positions[color]
params.rotation = board_rotations[color]
getObjectFromGUID(wonders_bag).takeObject(params)
params.position = money_positions[color]
getObjectFromGUID(money_bag_3).takeObject(params)
end
if number_of_players == 2 then
local params = {}
params.position = dummy_board_position
params.rotation = board_rotations.White
getObjectFromGUID(wonders_bag).takeObject(params)
params.position = dummy_money_position
getObjectFromGUID(money_bag_3).takeObject(params)
end
end
function deal_guilds()
local deck = getObjectFromGUID(guilds)
deck.shuffle()
local params = {}
params.position = age_3_deck
for i = 1, number_of_players+2, 1 do
deck.takeObject(params)
end
end
function move_play_decks()
local bag = getObjectFromGUID(decks_bag)
local params = {}
params.guid = decks['players_' .. number_of_players].age_1
params.position = age_1_deck
params.rotation = { 0, 180, 180 }
bag.takeObject(params)
params.guid = decks['players_' .. number_of_players].age_2
params.position = age_2_deck
bag.takeObject(params)
params.guid = decks['players_' .. number_of_players].age_3
params.position = age_3_deck
bag.takeObject(params)
end
function remove_unneeded_decks()
local objects = getObjectFromGUID(decks_zone).getObjects()
for _, o in ipairs(objects) do
o.destruct()
end
end
function update ()
end
function waitFrames(frames)
while frames > 0 do
coroutine.yield(0)
frames = frames - 1
end
end