-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton_verify_deal.ttslua
49 lines (45 loc) · 1.2 KB
/
button_verify_deal.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
status_block_GUID = "167ce3"
VALID = color(0, 255, 0, 100)
INVALID = color(255, 0, 0, 100)
function onload(save_state)
status_block = getObjectFromGUID(status_block_GUID)
self.setName("Button - Verify Deal")
self.createButton(
{
click_function = "pressed",
label = "verify deal",
function_owner = self,
position = {0, 1, 1},
rotation = {0, 180, 0},
width = 2300,
height = 600,
font_size = 500
}
)
end
function pressed(clicked_object, player)
players = Player.getPlayers()
valid_hands = verify_player_hands(players)
if valid_hands then
status_block.setColorTint(VALID)
else
status_block.setColorTint(INVALID)
end
end
function verify_player_hands(players)
result = true
for _, player in pairs(players) do
if player.color ~= "Black" then
result = result and verify_player_hand(player)
end
end
return result
end
function verify_player_hand(player)
handcount = player.getHandCount()
if handcount == 0 then
return false
end
hand_contents = player.getHandObjects(1)
return #hand_contents == 4
end