forked from jordanmchavez/kdm-tts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Deck.ttslua
82 lines (69 loc) · 2.55 KB
/
Deck.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
local Archive = require("Kdm/Archive")
local Location = require("Kdm/Location")
local log = require("Kdm/Log").ForModule("Deck")
local NamedObject = require("Kdm/NamedObject")
local Ui = require("Kdm/Ui")
local Util = require("Kdm/Util/Util")
---------------------------------------------------------------------------------------------------
local Deck = {}
Deck.NEEDS_SHUFFLE = {
["Fighting Arts"] = true,
["Disorders"] = true,
["Tactics"] = true,
["Vermin"] = true,
["Basic Resources"] = true,
["Monster Resources"] = true,
["Terrain"] = true,
["Patterns"] = true,
}
---------------------------------------------------------------------------------------------------
function Deck.Init()
local ui = Ui.Create3d("Deck", NamedObject.Get("Showdown Board"), 10.74)
local deckGrid = {
{ "Patterns" },
{ "Abilities", "Fighting Arts", "Secret Fighting Arts" },
{ "Disorders", "Severe Injuries", "Tactics" },
{ "Weapon Proficiencies", "Armor Sets", "Vermin" },
{ "Strange Resources", "Basic Resources" },
}
local x1 = 9.575500
local x1End = 9.375386
local width = x1End - x1
local x3 = 7.538684
local dx = (x3 - x1) / 2
local y1 = -1.193880
local y1End = -0.042474
local height = y1End - y1
local y4 = 3.030348
local dy = (y4 - y1) / 3
for row, decks in ipairs(deckGrid) do
for col, deck in ipairs(decks) do
local x = x1 + (col - 1) * dx
local y = y1 + (row - 2) * dy
ui:Button({ id = deck, topLeft = { x = x, y = y }, bottomRight = { x = x + width, y = y + height }, onClick = function()
Deck.ResetDeck(deck)
end })
end
end
--ui:ApplyToObject()
end
---------------------------------------------------------------------------------------------------
function Deck.ResetDeck(deck)
log:Debugf("Resetting deck %s", deck)
location = Location.Get(deck)
local blocking = location:BoxClean({ types = { deck } })
if #blocking > 0 then
log:Broadcastf("Something is blocking the deck. Please move the highlighted objects out of the way and try again.")
Util.HighlightAll(blocking)
return
end
local deckObject = Archive.Take({ name = deck, type = deck, location = location, rotation = { x = 0, y = 180, z = 180 } })
if Deck.NEEDS_SHUFFLE[deck] then
deckObject.shuffle()
end
Archive.Clean()
end
---------------------------------------------------------------------------------------------------
return {
Init = Deck.Init
}