forked from LostSavage/SecretHitlerCE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.ttslua
More file actions
696 lines (642 loc) · 20.9 KB
/
UI.ttslua
File metadata and controls
696 lines (642 loc) · 20.9 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
UIActionTable = {}
UITargetColorTable = {}
UIPlayerNameTable = {}
UIInputTable = {}
function refreshUI()
if options.zoneType == 6 then
local abilitiesDeck = getDeckFromZoneByGUID(ABILITIESPILE_ZONE_GUID)
if abilitiesDeck then
UI.setAttribute("greyCommandsExp", "visibility", "Grey")
UI.setAttribute("greyCommands", "visibility", " ")
else
UI.setAttribute("greyCommands", "visibility", "Grey")
UI.setAttribute("greyCommandsExp", "visibility", " ")
end
UI.setAttribute("greyPolicy", "visibility", "Grey")
UI.setAttribute("greyVote", "visibility", "Grey")
UI.setAttribute("adminButton", "visibility", "Admin")
UI.setAttribute("admin", "visibility", "Admin")
UI.setAttribute("adminButton", "active", "true")
end
if started then
local youHitler = " "
local youFas = " "
local youLib = " "
local youNotPlaying = "Grey"
local hitWhite = ""
local hitBrown = ""
local hitRed = ""
local hitOrange = ""
local hitYellow = ""
local hitGreen = ""
local hitTeal = ""
local hitBlue = ""
local hitPurple = ""
local hitPink = ""
local hitTan = ""
local hitMaroon = ""
local fasWhite = ""
local fasBrown = ""
local fasRed = ""
local fasOrange = ""
local fasYellow = ""
local fasGreen = ""
local fasTeal = ""
local fasBlue = ""
local fasPurple = ""
local fasPink = ""
local fasTan = ""
local fasMaroon = ""
if options.zoneType == 6 then
youNotPlaying = " "
for _, playerColor in pairs(GREY_PLAYABLE_COLORS) do
if roles[playerColor] == "hitler" then
UI.setValue("hit" .. playerColor, playerColor .. " is " .. text.hitler .. "!")
elseif roles[playerColor] == "fascist" then
UI.setValue("fas" .. playerColor, playerColor .. " is " .. text.fascistArticle .. " " .. text.fascist .. "!")
end
end
end
for _, playerColor in pairs(MAIN_PLAYABLE_COLORS) do
UI.setAttribute("player" .. playerColor, "visibility", playerColor)
if roles[playerColor] == "hitler" then
UI.setValue("hit" .. playerColor, playerColor .. " is " .. text.hitler .. "!")
if youHitler == " " then
youHitler = playerColor
else
youHitler = youHitler .. "|" .. playerColor
end
elseif roles[playerColor] == "fascist" then
UI.setValue("fas" .. playerColor, playerColor .. " is " .. text.fascistArticle .. " " .. text.fascist .. "!")
if youFas == " " then
youFas = playerColor
else
youFas = youFas .. "|" .. playerColor
end
elseif roles[playerColor] == "liberal" then
if youLib == " " then
youLib = playerColor
else
youLib = youLib .. "|" .. playerColor
end
else
if youNotPlaying == " " then
youNotPlaying = playerColor
else
youNotPlaying = youNotPlaying .. "|" .. playerColor
end
end
end
hitWhite = hitVisibility("White")
hitBrown = hitVisibility("Brown")
hitRed = hitVisibility("Red")
hitOrange = hitVisibility("Orange")
hitYellow = hitVisibility("Yellow")
hitGreen = hitVisibility("Green")
hitTeal = hitVisibility("Teal")
hitBlue = hitVisibility("Blue")
hitPurple = hitVisibility("Purple")
hitPink = hitVisibility("Pink")
hitTan = hitVisibility("Tan")
hitMaroon = hitVisibility("Maroon")
fasWhite = fasVisibility("White")
fasBrown = fasVisibility("Brown")
fasRed = fasVisibility("Red")
fasOrange = fasVisibility("Orange")
fasYellow = fasVisibility("Yellow")
fasGreen = fasVisibility("Green")
fasTeal = fasVisibility("Teal")
fasBlue = fasVisibility("Blue")
fasPurple = fasVisibility("Purple")
fasPink = fasVisibility("Pink")
fasTan = fasVisibility("Tan")
fasMaroon = fasVisibility("Maroon")
UI.setValue("youLib", "You are " .. text.liberalArticle .. " " .. text.liberal .. "!")
UI.setValue("youFas", "You are " .. text.fascistArticle .. " " .. text.fascist .. "!")
UI.setValue("youHitler", "You are " .. text.hitler .. "!")
UI.setAttribute("youLib", "visibility", youLib)
UI.setAttribute("youFas", "visibility", youFas)
UI.setAttribute("youHitler", "visibility", youHitler)
UI.setAttribute("youNotPlaying", "visibility", youNotPlaying)
UI.setAttribute("hitWhite", "visibility", hitWhite)
UI.setAttribute("hitBrown", "visibility", hitBrown)
UI.setAttribute("hitRed", "visibility", hitRed)
UI.setAttribute("hitOrange", "visibility", hitOrange)
UI.setAttribute("hitYellow", "visibility", hitYellow)
UI.setAttribute("hitGreen", "visibility", hitGreen)
UI.setAttribute("hitTeal", "visibility", hitTeal)
UI.setAttribute("hitBlue", "visibility", hitBlue)
UI.setAttribute("hitPurple", "visibility", hitPurple)
UI.setAttribute("hitPink", "visibility", hitPink)
UI.setAttribute("hitTan", "visibility", hitTan)
UI.setAttribute("hitMaroon", "visibility", hitMaroon)
UI.setAttribute("fasWhite", "visibility", fasWhite)
UI.setAttribute("fasBrown", "visibility", fasBrown)
UI.setAttribute("fasRed", "visibility", fasRed)
UI.setAttribute("fasOrange", "visibility", fasOrange)
UI.setAttribute("fasYellow", "visibility", fasYellow)
UI.setAttribute("fasGreen", "visibility", fasGreen)
UI.setAttribute("fasTeal", "visibility", fasTeal)
UI.setAttribute("fasBlue", "visibility", fasBlue)
UI.setAttribute("fasPurple", "visibility", fasPurple)
UI.setAttribute("fasPink", "visibility", fasPink)
UI.setAttribute("fasTan", "visibility", fasTan)
UI.setAttribute("fasMaroon", "visibility", fasMaroon)
end
end
function hitVisibility(colorIn)
local visList = ""
if inTable(hitler, colorIn) then
visList = "Black"
for _, playerColor in pairs(fascists) do
if playerColor ~= colorIn and not inTable(GREY_PLAYABLE_COLORS, playerColor) then
visList = visList .. "|" .. playerColor
end
end
if #players < 7 then
for _, playerColor in pairs(hitler) do
if playerColor ~= colorIn and not inTable(GREY_PLAYABLE_COLORS, playerColor) then
visList = visList .. "|" .. playerColor
end
end
end
end
if visList == "" then
visList = " "
end
return visList
end
function fasVisibility(colorIn)
local visList = ""
if inTable(fascists, colorIn) then
visList = "Black"
for _, playerColor in pairs(fascists) do
if playerColor ~= colorIn and not inTable(GREY_PLAYABLE_COLORS, playerColor) then
visList = visList .. "|" .. playerColor
end
end
if #players < 7 then
for _, playerColor in pairs(hitler) do
if playerColor ~= colorIn and not inTable(GREY_PLAYABLE_COLORS, playerColor) then
visList = visList .. "|" .. playerColor
end
end
end
end
if visList == "" then
visList = " "
end
return visList
end
function chooseChan12P(targetColor, playerColor)
local player = getPlayerObj(playerColor)
local currPres = getPres()
if currPres == playerColor then
local tmpChan = getObjectFromGUID(CHANCELOR_GUID)
if tmpChan then giveObjectToPlayer(tmpChan, targetColor, {forward = 11, right = 0, up = 0, forceHeight = 2.8}, NO_ROT, false, false) end
else
player.print("You are not the current president.", {1,0,0})
end
end
function deal12P(amount, playerColor)
function deal12PCoroutine()
local drawDeck = getDeckFromZoneByGUID(DRAW_ZONE_GUID)
local takeParam = {}
for i = 1, amount do
local card = drawDeck.takeObject(takeParam)
local cardRot = {x = 0, y = 180, z = 180, exactRot = true}
giveObjectToPlayer(card, playerColor, {forward = GREY_FORWARD, right = GREY_POLICY_RIGHT, up = GREY_UP}, cardRot, false, true)
sleep(0.1)
end
sleep(2)
printPolicyCards12P("Draw", playerColor)
return 1
end
startLuaCoroutine(Global, "deal12PCoroutine")
end
function discard12P(policy, playerColor)
local discardZone = getObjectFromGUID(DISCARD_ZONE_GUID)
if discardZone then
local pos = discardZone.getPosition()
pos = {pos['x'], 2.5, pos['z']}
local result = moveCard12P(nil, policy, pos, FACE_DOWN_ROT, playerColor)
if result ~= -1 then
smartBroadcastToColor("You discarded a " .. policy .. " card.", playerColor, {1, 1, 1})
end
else
broadcastToAll("ERROR: Discard zone not found", {1, 0, 0})
end
end
function givePres12P(targetColor, playerColor)
local player = getPlayerObj(playerColor)
local currPres = getPres()
if currPres == playerColor then
movePlacards(targetColor, true)
else
player.print("You are not the current president.",{1,0,0})
end
end
function moveCard12P(name, description, pos, rot, playerColor)
local foundIndex = nil
local zoneObjs = getObjsFromZone(GREY_HAND_ZONE_GUIDS[playerColor])
if #zoneObjs == nil then
smartBroadcastToColor("ERROR: No cards found in your hand.", playerColor, {1, 0, 0})
return -1
end
if name == nil then
for i = 1, #zoneObjs do
if string.match(zoneObjs[i].description, description) then
foundIndex = i
break
end
end
else
for i = 1, #zoneObjs do
if string.match(string.lower(zoneObjs[i].name), string.lower(name)) then
foundIndex = i
break
end
end
end
if foundIndex == nil then
smartBroadcastToColor("ERROR: Card not found.", playerColor, {1, 0, 0})
return -1
end
if zoneObjs[foundIndex].deck_guid == nil then
local card = getObjectFromGUID(zoneObjs[foundIndex].guid)
card.setPositionSmooth(pos)
card.setRotationSmooth(rot)
else
local deck = getObjectFromGUID(zoneObjs[foundIndex].deck_guid)
takeParam =
{
position = pos,
rotation = rot,
index = zoneObjs[foundIndex].index
}
deck.takeObject(takeParam)
end
return zoneObjs[foundIndex]
end
function printPolicyCards12P(mode, playerColor)
local player = getPlayerObj(playerColor)
local zoneObjs = {}
local policyCardStr = ""
local expansionCardStr = "Your other cards are:"
local outStr = ""
if player then
zoneObjs = getObjsFromZone(GREY_HAND_ZONE_GUIDS[playerColor])
for k, v in pairs(zoneObjs) do
if v.description == "Liberal Policy" then
policyCardStr = policyCardStr .. "[0000FF]L[-]"
elseif v.description == "Fascist Policy" then
policyCardStr = policyCardStr .. "[FF0000]F[-]"
elseif not (string.match(v.description, "Ja Card") or string.match(v.description, "Nein Card")) then
expansionCardStr = expansionCardStr .. "\n" .. v.name
end
end
if mode == "Draw" then
outStr = "You drew " .. policyCardStr .. ".\n"
elseif mode == "Check" then
if policyCardStr == "" then
outStr = "You have no policy cards.\n"
else
outStr = "Your policy cards are:" .. policyCardStr .. "\n"
end
end
if expansionCardStr == "Your other cards are:" or mode == "Draw" then
bigBroadcast(outStr, player)
else
bigBroadcast(outStr .. expansionCardStr, player)
end
end
end
function vote12P(playerColor, voteName)
function vote12PCoroutine()
local jaCard = getObjectFromGUID(jaCardGuids[playerColor])
local neinCard = getObjectFromGUID(neinCardGuids[playerColor])
-- move found cards back
if jaCard then
local jaCardRot = {x = 0, y = 180, z = 180, exactRot = true}
giveObjectToPlayer(jaCard, playerColor, {forward = GREY_FORWARD, right = GREY_RIGHT, up = GREY_UP}, jaCardRot, false, true)
end
if neinCard then
local neinCardRot = {x = 0, y = 180, z = 180, exactRot = true}
giveObjectToPlayer(neinCard, playerColor, {forward = GREY_FORWARD, right = GREY_RIGHT, up = GREY_UP}, neinCardRot, false, true)
end
sleep(0.1)
-- move vote out
moveCard12P(nil, voteName, GREY_VOTE_POS[playerColor], FACE_DOWN_ROT, playerColor)
return 1
end
startLuaCoroutine(Global, "vote12PCoroutine")
end
function playerNameUIIF(player, value, id)
UIPlayerNameTable[player.steam_id] = value
end
function sitMaroonUIB(player, value, id)
sitColorGrey(player, "Maroon")
end
function sitTanUIB(player, value, id)
sitColorGrey(player, "Tan")
end
function sitColorGrey(player, color)
if player.admin then
if UIPlayerNameTable[player.steam_id] then
local sitPlayer = getPlayerByNameSteamID(UIPlayerNameTable[player.steam_id], Player.getSpectators())
if not sitPlayer then
player.broadcast(UIPlayerNameTable[player.steam_id] .. " not found or is not grey.", {1, 0, 0})
return
end
if inTable(greyPlayerSteamIds, sitPlayer.steam_id) then
player.broadcast(sitPlayer.steam_name .. " is already seated.", {1, 0, 0})
return
end
printToAll(sitPlayer.steam_name .. " is color " .. color .. ".", GREY_PLAYABLE_COLORS_RGB[color])
local textObj = getObjectFromGUID(GREY_TEXT_GUIDS[color])
textObj.TextTool.setValue(sitPlayer.steam_name)
greyPlayerSteamIds[color] = sitPlayer.steam_id
local objParam = {
type = "Custom_Model",
position = GREY_AVATAR_POS[color],
rotation = {0, 0, 0},
scale = {2.5, 2.5, 1},
callback = "greyAvatarCallback",
sound = false
}
if greyAvatarGuids[color] then
destroyObjectByGUID(greyAvatarGuids[color])
end
local avatar = spawnObject(objParam)
avatar.setLock(true)
avatar.setDescription(color .. " Avatar")
avatar.interactable = false
local customParam = {
diffuse = generateAvatarImageUrl(sitPlayer.steam_id),
mesh = "http://cloud-3.steamusercontent.com/ugc/933813375177509684/900B7683E01C43C394C408BC38E034B305F1B3AA/",
collider = "http://cloud-3.steamusercontent.com/ugc/487893695356616224/E3E39A827C062914E4185D8757A81D4D14892B8B/",
type = 0,
material = 3
}
avatar.setCustomObject(customParam)
end
end
end
function greyAvatarCallback(objIn, paramsIn)
local color = string.gsub(objIn.getDescription(), " Avatar", "")
greyAvatarGuids[color] = objIn.getGUID()
end
function removeColorGreyUIB(player, value, id)
if player.admin then
local sitPlayer = getPlayerByNameSteamID(UIPlayerNameTable[player.steam_id], Player.getSpectators())
if not sitPlayer then
player.broadcast(UIPlayerNameTable[player.steam_id] .. " not found or is not grey.", {1, 0, 0})
return
end
local colorFound = getGreyColor(sitPlayer.steam_id)
if colorFound then
greyPlayerSteamIds[colorFound] = nil
destroyObjectByGUID(greyAvatarGuids[colorFound])
local textObj = getObjectFromGUID(GREY_TEXT_GUIDS[colorFound])
if textObj then
textObj.TextTool.setValue(" ")
end
else
player.print(sitPlayer.steam_name .. " is not seated.")
end
end
end
function tellRoleButtonUIB(player, value, id)
local colorFound = getGreyColor(player.steam_id)
if colorFound then
bigBroadcast(tellRole(colorFound), player)
else
bigBroadcast(tellRole(player.color), player)
end
end
function voteJaUIB(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
vote12P(colorFound, "Ja Card")
else
player.print("You are not seated.")
end
end
function voteNeinUIB(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
vote12P(colorFound, "Nein Card")
else
player.print("You are not seated.")
end
end
function voteRemoveUIB(player, value, id)
if not started then
player.print('Game has not started.')
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
local jaCard = getObjectFromGUID(jaCardGuids[colorFound])
local neinCard = getObjectFromGUID(neinCardGuids[colorFound])
if jaCard then
local jaCardRot = {x = 0, y = 180, z = 180, exactRot = true}
giveObjectToPlayer(jaCard, colorFound, {forward = GREY_FORWARD, right = GREY_RIGHT, up = GREY_UP}, jaCardRot, false, true)
end
if neinCard then
local neinCardRot = {x = 0, y = 180, z = 180, exactRot = true}
giveObjectToPlayer(neinCard, colorFound, {forward = GREY_FORWARD, right = GREY_RIGHT, up = GREY_UP}, neinCardRot, false, true)
end
else
player.print('You are not seated.')
end
end
function UIDrawCards(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
drawThree(nil, colorFound)
else
player.print("You are not seated.")
end
end
function discardFUIB(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
discard12P("Fascist Policy", colorFound)
else
player.print("You are not seated.")
end
end
function discardLUIB(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
discard12P("Liberal Policy", colorFound)
else
player.print("You are not seated.")
end
end
function checkCardsUIB(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
printPolicyCards12P("Check", colorFound)
else
player.print("You are not seated.")
end
end
function actionUID(player, value, id)
UIActionTable[player.steam_id] = value
end
function colorUID(player, value, id)
UITargetColorTable[player.steam_id] = value
end
function inputUIIF(player, value, id)
UIInputTable[player.steam_id] = value
end
function startUIB(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
if UIActionTable[player.steam_id] == "Choose Chancellor" then
chooseChan12P(UITargetColorTable[player.steam_id], colorFound)
elseif UIActionTable[player.steam_id] == "Inspect Player" then
playerInspected(nil, colorFound, UITargetColorTable[player.steam_id])
elseif UIActionTable[player.steam_id] == "Give Presidency To" then
givePres12P(UITargetColorTable[player.steam_id], colorFound)
elseif UIActionTable[player.steam_id] == "Discard Ability" then
discardAbility(UIInputTable[player.steam_id], colorFound)
elseif UIActionTable[player.steam_id] == "Reveal Ability" then
revealAbility(UIInputTable[player.steam_id], colorFound)
elseif UIActionTable[player.steam_id] == "Examine Ability Deck" then
examineAbilityDeck(colorFound)
elseif UIActionTable[player.steam_id] == "Take from Ability Deck" then
takeAbility(UIInputTable[player.steam_id], colorFound)
elseif UIActionTable[player.steam_id] == "Give Card to" then
giveCardExp(UIInputTable[player.steam_id], UITargetColorTable[player.steam_id], colorFound)
end
else
player.print("You are not seated.")
end
end
function discardAbility(cardName, playerColor)
local abilityDeck = getDeckFromZoneByGUID(ABILITIESPILE_ZONE_GUID)
local pos = abilityDeck.getPosition()
local result = {}
result = moveCard12P(cardName, nil, pos, FACE_DOWN_ROT, playerColor)
if result ~= -1 then
smartBroadcastToColor("You discarded " .. result.name, playerColor, {1, 1, 1})
end
end
function revealAbility(cardName, playerColor)
local pos = GREY_ABILITY_POS[playerColor]
local result = {}
result = moveCard12P(cardName, nil, pos, FACE_UP_ROT, playerColor)
if result ~= -1 then
broadcastToAll(playerColor .. " has played " .. result.name, {1, 1, 1})
end
end
function examineAbilityDeck(playerColor)
local player = getPlayerObj(playerColor)
local abilityDeck = getDeckFromZoneByGUID(ABILITIESPILE_ZONE_GUID)
local deckString = ""
if abilityDeck == nil then
player.broadcast("ERROR: Ability deck not found.", {1, 1, 1})
return
end
local deckTable = abilityDeck.getObjects()
player.print("Cards in the ability deck:")
for k, v in pairs(deckTable) do
deckString = deckString .. v.nickname .. " "
end
player.print(deckString)
broadcastToAll(playerColor .. " examines the Ability deck.", {1, 1, 1})
end
function takeAbility(cardName, playerColor)
local player = getPlayerObj(playerColor)
local foundIndex = nil
local abilityDeck = getDeckFromZoneByGUID(ABILITIESPILE_ZONE_GUID)
if abilityDeck == nil then
player.broadcast("ERROR: Ability deck not found.", {1, 0, 0})
return
end
local deckTable = abilityDeck.getObjects()
for k,v in pairs(deckTable) do
if string.match(string.lower(v.nickname), string.lower(cardName)) then
foundIndex = v.index
end
end
if foundIndex == nil then
player.broadcast("ERROR: Ability not found in deck.", {1, 0, 0})
else
local info = getPlayerPosRotVectors(playerColor)
if info.pos then
local takeParams = {
index = foundIndex,
position = info.pos
}
abilityDeck.takeObject(takeParams)
player.broadcast("You drew " .. deckTable[foundIndex + 1].nickname .. " [FFFFFF]from the Ability deck.", {1, 1, 1})
broadcastToAll(playerColor .. " takes an ability from the Ability deck", {1, 1, 1})
end
end
end
function giveCardExp(cardName, targetColor, playerColor)
local info = getPlayerPosRotVectors(targetColor)
local result = {}
if info.pos then
result = moveCard12P(cardName, nil, info.pos, FACE_DOWN_ROT, playerColor)
end
if result ~= -1 then
smartBroadcastToColor("You gave " .. targetColor .. " the " .. result.name .. " card.", playerColor, {1, 1, 1})
end
end
function closeAdminUIB(player, value, id)
if player.admin then
UI.setAttribute("admin", "active", false)
UI.setAttribute("adminButton", "active", true)
end
end
function showAdminUIB(player, value, id)
if player.admin then
UI.setAttribute("admin", "active", true)
UI.setAttribute("adminButton", "active", false)
end
end
function drawCardsUIB(player, value, id)
if not started then
player.print("Game has not started.")
return
end
local colorFound = getGreyColor(player.steam_id)
if colorFound then
drawThree(player, colorFound)
else
player.print("You are not seated.")
end
end