363 lines
24 KiB
Luau
363 lines
24 KiB
Luau
-- GeneratorWindow: "Генератор" — shards in a 4x4 pattern + optional booster -> a random toy (frame, tabs, buttons: ShopKit).
|
|
-- Tabs: Создать / Шансы / Как это работает.
|
|
-- Создать : 4x4 grid (click a cell = put / take a shard, hover shows "+"), booster slot + booster rows,
|
|
-- luck, buttons Автоузор / Очистить (alt; off when useless) and Создать (ready "Создать · N";
|
|
-- off "Добавь ещё N" / "Мало осколков"; busy while the machine works). Right: what can drop (toy chances,
|
|
-- the toy that matches the pattern is highlighted, locked toys are dimmed).
|
|
-- Шансы : rarity chances with bars for the current luck + pity progress.
|
|
-- RemoteEvent CraftAction: Slot i / Fill / Clear / Booster id|nil. ctx.submit(machine) starts the generation.
|
|
local K = require(script.Parent:WaitForChild("ShopKit"))
|
|
|
|
local G = {}
|
|
|
|
local WHITE, GOLD, SOFT, OK, WARN, BODY, NAVY = K.WHITE, K.GOLD, K.SOFT, K.OK, K.WARN, K.BODY, K.NAVY
|
|
local new, corner, art, label, maxText, pill, tween = K.new, K.corner, K.art, K.label, K.maxText, K.pill, K.tween
|
|
local MUTED = Color3.fromRGB(170, 190, 185)
|
|
local ICE = Color3.fromRGB(190, 225, 255)
|
|
|
|
function G.install(ctx)
|
|
local Config, player, remote = ctx.Config, ctx.player, ctx.remote
|
|
local fmt, pct = ctx.fmtNum, ctx.fmtPct
|
|
local function attr(n, d) local v = player:GetAttribute(n); if v == nil then return d end return v end
|
|
local win = ctx.win
|
|
local refresh
|
|
local pendingUntil = 0
|
|
local TABS = {
|
|
{ id = "Create", text = "Create", icon = "🎄", tip = "If your shard pattern looks like an ornament, you're more likely to get that one." },
|
|
{ id = "Chances", text = "Odds", icon = "🎲", tip = "More shards and a booster mean more luck and better odds for rare ornaments." },
|
|
{ id = "Help", text = "How It Works", icon = "📖", tip = "Pity: a rare ornament is guaranteed within the shown number of tries." },
|
|
}
|
|
local ch = K.chrome({ win = win, title = "GENERATOR", subtitle = "Make ornaments\nfrom shards", tabs = TABS,
|
|
closeWindow = ctx.closeWindow, fmtNum = fmt, onTab = function() if win.overlay.Visible then refresh() end end })
|
|
|
|
local function darkPanel(parent, pos, size, z)
|
|
return new("Frame", { Position = pos, Size = size, BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 0.5, ZIndex = z or 4, Parent = parent }, {
|
|
corner(UDim.new(0, 22)), new("UIStroke", { Color = GOLD, Thickness = 2, Transparency = 0.4 }),
|
|
})
|
|
end
|
|
local function getSlots()
|
|
local s = player:GetAttribute("CraftSlots")
|
|
if typeof(s) ~= "string" or #s ~= Config.SLOT_COUNT then s = string.rep("0", Config.SLOT_COUNT) end
|
|
return s
|
|
end
|
|
local function busy()
|
|
local m = ctx.machine()
|
|
return os.clock() < pendingUntil or (m ~= nil and m:GetAttribute("GeneratorBusy") == true)
|
|
end
|
|
|
|
---------------------------------------------------------------- create page
|
|
local cg = ch.makePage("Create")
|
|
-- left: the shard grid
|
|
local gridPanel = darkPanel(cg, UDim2.fromOffset(0, 0), UDim2.fromOffset(520, 566))
|
|
maxText(label({ Position = UDim2.fromOffset(20, 10), Size = UDim2.fromOffset(260, 36), Text = "Shard pattern", TextScaled = true, ZIndex = 5, Parent = gridPanel }, 2), 30)
|
|
local counter = maxText(label({ Position = UDim2.fromOffset(290, 14), Size = UDim2.fromOffset(210, 30), Text = "", TextScaled = true, FontFace = BODY,
|
|
TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 5, Parent = gridPanel }, 1.5), 24)
|
|
local CELL, GAP = 108, 10
|
|
local slots = {}
|
|
for i = 1, Config.SLOT_COUNT do
|
|
local cx, cy = 29 + ((i - 1) % 4) * (CELL + GAP), 56 + ((i - 1) // 4) * (CELL + GAP)
|
|
local b = new("TextButton", { Name = "ShardSlot" .. i, Text = "", AutoButtonColor = false, AnchorPoint = Vector2.new(0.5, 0.5),
|
|
Position = UDim2.fromOffset(cx + CELL / 2, cy + CELL / 2), Size = UDim2.fromOffset(CELL, CELL), BackgroundColor3 = Color3.fromRGB(12, 40, 52), ZIndex = 5, Parent = gridPanel }, {
|
|
corner(UDim.new(0, 20)),
|
|
})
|
|
local st = new("UIStroke", { Color = Color3.fromRGB(120, 190, 200), Thickness = 2, Transparency = 0.5, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = b })
|
|
local sc = new("UIScale", { Parent = b })
|
|
local icon = art("crystal", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.fromOffset(84, 86), Visible = false, ZIndex = 6, Parent = b })
|
|
local plus = label({ Size = UDim2.fromScale(1, 1), Text = "+", TextSize = 44, TextColor3 = Color3.fromRGB(166, 236, 230), TextTransparency = 1, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = b }, 0)
|
|
local s = { button = b, stroke = st, icon = icon, scale = sc, on = false, hover = false }
|
|
b.MouseEnter:Connect(function() s.hover = true; tween(sc, 0.12, { Scale = 1.06 }, Enum.EasingStyle.Back); if not s.on then tween(plus, 0.12, { TextTransparency = 0.2 }) end end)
|
|
b.MouseLeave:Connect(function() s.hover = false; tween(sc, 0.12, { Scale = 1 }); tween(plus, 0.12, { TextTransparency = 1 }) end)
|
|
b.InputBegan:Connect(function(input) if K.isPress(input) then tween(sc, 0.06, { Scale = 0.92 }) end end)
|
|
b.InputEnded:Connect(function(input) if K.isPress(input) then tween(sc, 0.12, { Scale = s.hover and 1.06 or 1 }, Enum.EasingStyle.Back) end end)
|
|
b.Activated:Connect(function()
|
|
if busy() then return end
|
|
if not s.on and attr("Shards", 0) <= 0 then ctx.toast("No shards — they build up over time", WARN) return end
|
|
remote:FireServer("Slot", i)
|
|
end)
|
|
s.plus = plus
|
|
slots[i] = s
|
|
end
|
|
maxText(label({ Position = UDim2.fromOffset(20, 528), Size = UDim2.fromOffset(480, 28), Text = "Click a cell to add or remove a shard", TextScaled = true, FontFace = BODY,
|
|
TextColor3 = SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = gridPanel }, 1.5), 20)
|
|
|
|
-- middle: booster + luck + buttons
|
|
local boPanel = darkPanel(cg, UDim2.fromOffset(540, 0), UDim2.fromOffset(350, 300))
|
|
maxText(label({ Position = UDim2.fromOffset(16, 8), Size = UDim2.fromOffset(200, 34), Text = "Booster", TextScaled = true, ZIndex = 5, Parent = boPanel }, 2), 30)
|
|
local boSlot = new("TextButton", { Name = "BoosterSlot", Text = "", AutoButtonColor = false, Position = UDim2.fromOffset(18, 48), Size = UDim2.fromOffset(120, 120),
|
|
BackgroundColor3 = Color3.fromRGB(12, 40, 52), ZIndex = 5, Parent = boPanel }, { corner(UDim.new(0.5, 0)) })
|
|
local boSlotStroke = new("UIStroke", { Color = GOLD, Thickness = 3, Transparency = 0.4, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = boSlot })
|
|
local boSlotScale = new("UIScale", { Parent = boSlot })
|
|
local boSlotText = maxText(label({ Position = UDim2.fromScale(0.15, 0.2), Size = UDim2.fromScale(0.7, 0.6), Text = "+", TextScaled = true, TextColor3 = MUTED,
|
|
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = boSlot }, 2.5), 56)
|
|
local boInfo = maxText(label({ Position = UDim2.fromOffset(150, 52), Size = UDim2.fromOffset(188, 112), Text = "", TextScaled = true, TextWrapped = true, FontFace = BODY,
|
|
TextColor3 = SOFT, TextYAlignment = Enum.TextYAlignment.Center, ZIndex = 5, Parent = boPanel }, 1.5), 21)
|
|
boSlot.MouseEnter:Connect(function() tween(boSlotScale, 0.12, { Scale = 1.05 }, Enum.EasingStyle.Back) end)
|
|
boSlot.MouseLeave:Connect(function() tween(boSlotScale, 0.12, { Scale = 1 }) end)
|
|
boSlot.Activated:Connect(function() if player:GetAttribute("CraftBooster") then remote:FireServer("Booster", nil) end end)
|
|
local boRows = {}
|
|
local order = {}
|
|
for id, b in Config.BOOSTERS do table.insert(order, { id = id, b = b }) end
|
|
table.sort(order, function(x, y) return (x.b.Order or 0) < (y.b.Order or 0) end)
|
|
for k, e in order do
|
|
local row = new("TextButton", { Name = "Booster" .. e.id, Text = "", AutoButtonColor = false, AnchorPoint = Vector2.new(0.5, 0.5),
|
|
Position = UDim2.fromOffset(175, 205 + (k - 1) * 58), Size = UDim2.fromOffset(318, 50), BackgroundColor3 = Color3.fromRGB(12, 40, 52), ZIndex = 5, Parent = boPanel }, {
|
|
corner(UDim.new(0.5, 0)),
|
|
})
|
|
local st = new("UIStroke", { Color = e.b.Color, Thickness = 2, Transparency = 0.3, ApplyStrokeMode = Enum.ApplyStrokeMode.Border, Parent = row })
|
|
local sc = new("UIScale", { Parent = row })
|
|
local orb = new("Frame", { AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(0, 6, 0.5, 0), Size = UDim2.fromOffset(40, 40), BackgroundColor3 = e.b.Color, ZIndex = 6, Parent = row }, { corner(UDim.new(0.5, 0)) })
|
|
maxText(label({ Position = UDim2.fromScale(0.1, 0.18), Size = UDim2.fromScale(0.8, 0.64), Text = "x" .. e.b.Luck, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 7, Parent = orb }, 1.5), 20)
|
|
maxText(label({ Position = UDim2.fromOffset(56, 8), Size = UDim2.fromOffset(180, 34), Text = e.b.Name, TextScaled = true, ZIndex = 6, Parent = row }, 2), 24)
|
|
local cnt = maxText(label({ Position = UDim2.fromOffset(236, 8), Size = UDim2.fromOffset(70, 34), Text = "", TextScaled = true, TextColor3 = GOLD,
|
|
TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 6, Parent = row }, 2), 26)
|
|
local r = { row = row, stroke = st, count = cnt, scale = sc, hover = false, b = e.b }
|
|
row.MouseEnter:Connect(function() r.hover = true; tween(sc, 0.12, { Scale = 1.04 }, Enum.EasingStyle.Back) end)
|
|
row.MouseLeave:Connect(function() r.hover = false; tween(sc, 0.12, { Scale = 1 }) end)
|
|
row.InputBegan:Connect(function(input) if K.isPress(input) then tween(sc, 0.06, { Scale = 0.95 }) end end)
|
|
row.InputEnded:Connect(function(input) if K.isPress(input) then tween(sc, 0.12, { Scale = r.hover and 1.04 or 1 }, Enum.EasingStyle.Back) end end)
|
|
row.Activated:Connect(function()
|
|
if player:GetAttribute("CraftBooster") == e.id then remote:FireServer("Booster", nil) return end
|
|
if attr("Booster_" .. e.id, 0) <= 0 then
|
|
ctx.toast("No “" .. e.b.Name .. "” boosters — craft them in the Workshop", WARN)
|
|
tween(row, 0.05, { Rotation = -3 }).Completed:Wait()
|
|
tween(row, 0.07, { Rotation = 3 }).Completed:Wait()
|
|
tween(row, 0.06, { Rotation = 0 })
|
|
return
|
|
end
|
|
remote:FireServer("Booster", e.id)
|
|
end)
|
|
boRows[e.id] = r
|
|
end
|
|
local luckText = maxText(label({ Position = UDim2.fromOffset(540, 308), Size = UDim2.fromOffset(350, 44), Text = "", TextScaled = true, TextColor3 = GOLD,
|
|
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = cg }, 2.5), 36)
|
|
local luckSub = maxText(label({ Position = UDim2.fromOffset(540, 352), Size = UDim2.fromOffset(350, 28), Text = "", TextScaled = true, FontFace = BODY, TextColor3 = SOFT,
|
|
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = cg }, 1.5), 20)
|
|
local fillBtn = pill(cg, { Name = "Autofill", Position = UDim2.fromOffset(540, 392), Size = UDim2.fromOffset(170, 66), ZIndex = 5, TextMax = 26 }, function() remote:FireServer("Fill") end)
|
|
local clearBtn = pill(cg, { Name = "Clear", Position = UDim2.fromOffset(720, 392), Size = UDim2.fromOffset(170, 66), ZIndex = 5, TextMax = 26 }, function() remote:FireServer("Clear") end)
|
|
local genBtn
|
|
genBtn = pill(cg, { Name = "GenerateButton", Position = UDim2.fromOffset(540, 468), Size = UDim2.fromOffset(350, 96), ZIndex = 5, TextMax = 34 }, function()
|
|
local m = ctx.machine()
|
|
if not m then ctx.toast("Go to your generator", WARN) return end
|
|
pendingUntil = os.clock() + 1.5
|
|
genBtn.set("busy")
|
|
ctx.submit(m)
|
|
end)
|
|
|
|
-- right: what can drop
|
|
local poolPanel = darkPanel(cg, UDim2.fromOffset(910, 0), UDim2.fromOffset(350, 566))
|
|
maxText(label({ Position = UDim2.fromOffset(16, 8), Size = UDim2.fromOffset(320, 34), Text = "Possible drops", TextScaled = true, ZIndex = 5, Parent = poolPanel }, 2), 30)
|
|
local pool = {}
|
|
for i, toy in Config.TOYS do
|
|
local row = new("Frame", { Position = UDim2.fromOffset(10, 48 + (i - 1) * 85), Size = UDim2.fromOffset(330, 78), BackgroundColor3 = Color3.fromRGB(12, 40, 52), ZIndex = 5, Parent = poolPanel }, {
|
|
corner(UDim.new(0, 18)),
|
|
})
|
|
local st = new("UIStroke", { Color = GOLD, Thickness = 0, Parent = row })
|
|
local mini = ctx.miniPattern(toy.Mask, ICE, 54, row)
|
|
mini.Position = UDim2.fromOffset(12, 12)
|
|
mini.ZIndex = 6
|
|
for _, x in mini:GetDescendants() do if x:IsA("GuiObject") then x.ZIndex = 6 end end
|
|
maxText(label({ Position = UDim2.fromOffset(78, 6), Size = UDim2.fromOffset(150, 34), Text = toy.Name, TextScaled = true, ZIndex = 6, Parent = row }, 2), 26)
|
|
local sub = maxText(label({ Position = UDim2.fromOffset(79, 42), Size = UDim2.fromOffset(170, 26), Text = "", TextScaled = true, FontFace = BODY, TextColor3 = MUTED, ZIndex = 6, Parent = row }, 1.5), 18)
|
|
local p = maxText(label({ Position = UDim2.fromOffset(226, 8), Size = UDim2.fromOffset(92, 36), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 6, Parent = row }, 2), 28)
|
|
maxText(label({ Position = UDim2.fromOffset(246, 44), Size = UDim2.fromOffset(72, 24), Text = "x" .. toy.Mult, TextScaled = true, FontFace = BODY, TextColor3 = Color3.fromRGB(255, 205, 90),
|
|
TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 6, Parent = row }, 1.5), 18)
|
|
local dim = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.new(0, 0, 0), BackgroundTransparency = 0.45, Visible = false, ZIndex = 8, Parent = row }, { corner(UDim.new(0, 18)) })
|
|
local lockT = maxText(label({ Position = UDim2.fromOffset(160, 20), Size = UDim2.fromOffset(160, 38), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 9, Parent = dim }, 2), 24)
|
|
pool[i] = { row = row, stroke = st, sub = sub, pct = p, toy = toy, dim = dim, lockT = lockT }
|
|
end
|
|
|
|
---------------------------------------------------------------- chances page
|
|
local chg = ch.makePage("Chances")
|
|
local raPanel = darkPanel(chg, UDim2.fromOffset(0, 0), UDim2.fromOffset(620, 566))
|
|
maxText(label({ Position = UDim2.fromOffset(20, 10), Size = UDim2.fromOffset(300, 38), Text = "Rarity odds", TextScaled = true, ZIndex = 5, Parent = raPanel }, 2), 32)
|
|
local chLuck = maxText(label({ Position = UDim2.fromOffset(320, 14), Size = UDim2.fromOffset(280, 32), Text = "", TextScaled = true, TextColor3 = GOLD,
|
|
TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 5, Parent = raPanel }, 2), 26)
|
|
local raRows = {}
|
|
for i, r in Config.RARITIES do
|
|
local y = 62 + (i - 1) * 78
|
|
maxText(label({ Position = UDim2.fromOffset(20, y), Size = UDim2.fromOffset(240, 32), Text = r.Name, TextScaled = true, TextColor3 = r.Color, ZIndex = 5, Parent = raPanel }, 2), 26)
|
|
local val = maxText(label({ Position = UDim2.fromOffset(400, y), Size = UDim2.fromOffset(200, 32), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 5, Parent = raPanel }, 2), 26)
|
|
local bg = new("Frame", { Position = UDim2.fromOffset(20, y + 38), Size = UDim2.fromOffset(580, 18), BackgroundColor3 = Color3.fromRGB(10, 20, 26), ZIndex = 5, Parent = raPanel }, { corner(UDim.new(0.5, 0)) })
|
|
local bar = new("Frame", { Size = UDim2.fromScale(0, 1), BackgroundColor3 = r.Color, ZIndex = 6, Parent = bg }, { corner(UDim.new(0.5, 0)) })
|
|
raRows[i] = { val = val, bar = bar }
|
|
end
|
|
local piPanel = darkPanel(chg, UDim2.fromOffset(640, 0), UDim2.fromOffset(620, 566))
|
|
maxText(label({ Position = UDim2.fromOffset(20, 10), Size = UDim2.fromOffset(580, 38), Text = "Pity — protection from bad luck", TextScaled = true, ZIndex = 5, Parent = piPanel }, 2), 32)
|
|
maxText(label({ Position = UDim2.fromOffset(20, 54), Size = UDim2.fromOffset(580, 56), Text = "Every generation without the rarity fills the pity bar. When it's full, a rare ornament is guaranteed.",
|
|
TextScaled = true, TextWrapped = true, FontFace = BODY, TextColor3 = SOFT, ZIndex = 5, Parent = piPanel }, 1.5), 20)
|
|
local piRows = {}
|
|
for i, pc in Config.PITY do
|
|
local r = Config.RarityById[pc.Rarity]
|
|
local y = 130 + (i - 1) * 104
|
|
maxText(label({ Position = UDim2.fromOffset(20, y), Size = UDim2.fromOffset(380, 34), Text = r.Name .. " or better", TextScaled = true, TextColor3 = r.Color, ZIndex = 5, Parent = piPanel }, 2), 28)
|
|
local val = maxText(label({ Position = UDim2.fromOffset(330, y + 2), Size = UDim2.fromOffset(270, 30), Text = "", TextScaled = true, FontFace = BODY,
|
|
TextXAlignment = Enum.TextXAlignment.Right, ZIndex = 5, Parent = piPanel }, 1.5), 22)
|
|
local bg = new("Frame", { Position = UDim2.fromOffset(20, y + 42), Size = UDim2.fromOffset(580, 26), BackgroundColor3 = Color3.fromRGB(10, 20, 26), ZIndex = 5, Parent = piPanel }, { corner(UDim.new(0.5, 0)) })
|
|
local bar = new("Frame", { Size = UDim2.fromScale(0, 1), BackgroundColor3 = r.Color, ZIndex = 6, Parent = bg }, { corner(UDim.new(0.5, 0)) })
|
|
local num = maxText(label({ Size = UDim2.fromScale(1, 1), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 7, Parent = bg }, 1.5), 18)
|
|
piRows[i] = { pc = pc, val = val, bar = bar, num = num }
|
|
end
|
|
|
|
---------------------------------------------------------------- help page
|
|
local _, heScroll = ch.makePage("Help", true)
|
|
new("UIGridLayout", { CellSize = UDim2.fromOffset(404, 540), CellPadding = UDim2.fromOffset(20, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = heScroll })
|
|
new("UIPadding", { PaddingLeft = UDim.new(0, 4), PaddingTop = UDim.new(0, 4), Parent = heScroll })
|
|
local HELP = {
|
|
{ card = "cardCyan", icon = "💎", title = "1. Pattern", btn = "To Grid", go = function() ch.showTab("Create") end,
|
|
text = "Put " .. Config.MIN_SHARDS .. " to " .. Config.SLOT_COUNT .. " shards in the grid. More shards mean more luck. A pattern that looks like an ornament raises the odds for that one." },
|
|
{ card = "cardViolet", icon = "🍀", title = "2. Booster", btn = "Workshop", go = function() K.go("Workshop", "Boosters") end,
|
|
text = "A booster in the slot multiplies the luck of one generation. Boosters are crafted in the Workshop or bought in Premium." },
|
|
{ card = "cardOrange", icon = "🎁", title = "3. Create", btn = "Odds", go = function() ch.showTab("Chances") end,
|
|
text = "Press “Create” — the shards go into the machine, and an ornament appears a couple of seconds later. Pity makes sure you won't go long without rares." },
|
|
}
|
|
for i, h in HELP do
|
|
local card = art(h.card, { LayoutOrder = i, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = heScroll })
|
|
label({ AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 44), Size = UDim2.fromOffset(120, 110), Text = h.icon, TextSize = 84, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 0)
|
|
maxText(label({ Position = UDim2.fromOffset(24, 160), Size = UDim2.new(1, -48, 0, 50), Text = h.title, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 42)
|
|
maxText(label({ Position = UDim2.fromOffset(30, 218), Size = UDim2.new(1, -60, 0, 190), Text = h.text, TextScaled = true, TextWrapped = true, FontFace = BODY,
|
|
TextColor3 = WHITE, TextXAlignment = Enum.TextXAlignment.Center, TextYAlignment = Enum.TextYAlignment.Top, ZIndex = 5, Parent = card }, 1.5), 24)
|
|
local go = pill(card, { Position = UDim2.fromOffset(62, 420), Size = UDim2.fromOffset(280, 70), ZIndex = 5, TextMax = 30 }, h.go)
|
|
go.set("alt", h.btn)
|
|
end
|
|
|
|
---------------------------------------------------------------- refresh
|
|
local lastOn = {}
|
|
refresh = function()
|
|
local shards, level = attr("Shards", 0), attr("Level", 1)
|
|
ch.setBalance(shards)
|
|
local s = getSlots()
|
|
local placed = 0
|
|
for i, sl in slots do
|
|
local on = s:sub(i, i) == "1"
|
|
if on then placed += 1 end
|
|
sl.on = on
|
|
sl.icon.Visible = on
|
|
sl.stroke.Color = on and Color3.fromRGB(150, 230, 255) or Color3.fromRGB(120, 190, 200)
|
|
sl.stroke.Thickness = on and 4 or 2
|
|
sl.stroke.Transparency = on and 0 or 0.5
|
|
sl.button.BackgroundColor3 = on and Color3.fromRGB(24, 74, 96) or Color3.fromRGB(12, 40, 52)
|
|
if on then sl.plus.TextTransparency = 1 end
|
|
if on and not lastOn[i] then
|
|
sl.icon.Size = UDim2.fromOffset(44, 46)
|
|
sl.icon.Rotation = -14
|
|
tween(sl.icon, 0.23, { Size = UDim2.fromOffset(84, 86), Rotation = 0 }, Enum.EasingStyle.Back)
|
|
end
|
|
lastOn[i] = on
|
|
end
|
|
counter.Text = "Shards in: " .. placed .. " / " .. Config.SLOT_COUNT
|
|
counter.TextColor3 = placed >= Config.MIN_SHARDS and OK or SOFT
|
|
|
|
local booster = player:GetAttribute("CraftBooster")
|
|
local b = booster and Config.BOOSTERS[booster]
|
|
if b then
|
|
boSlot.BackgroundColor3 = b.Color
|
|
boSlotStroke.Color, boSlotStroke.Thickness, boSlotStroke.Transparency = WHITE, 4, 0
|
|
boSlotText.Text, boSlotText.TextColor3 = "x" .. b.Luck, WHITE
|
|
boInfo.Text = b.Name .. " in the slot.\nClick the circle to remove it."
|
|
else
|
|
boSlot.BackgroundColor3 = Color3.fromRGB(12, 40, 52)
|
|
boSlotStroke.Color, boSlotStroke.Thickness, boSlotStroke.Transparency = GOLD, 3, 0.4
|
|
boSlotText.Text, boSlotText.TextColor3 = "+", MUTED
|
|
boInfo.Text = "Pick a booster below — it boosts one generation."
|
|
end
|
|
for id, r in boRows do
|
|
local n = attr("Booster_" .. id, 0)
|
|
r.count.Text = "x" .. n
|
|
r.count.TextColor3 = n > 0 and GOLD or MUTED
|
|
local sel = id == booster
|
|
r.stroke.Color = sel and GOLD or r.b.Color
|
|
r.stroke.Thickness = sel and 4 or 2
|
|
r.row.BackgroundColor3 = sel and Color3.fromRGB(70, 56, 20) or Color3.fromRGB(12, 40, 52)
|
|
end
|
|
|
|
local luck = Config.Luck(placed, booster, attr("Upg_Luck", 0))
|
|
local chances = Config.Chances(luck > 0 and luck or 1)
|
|
if placed == 0 then
|
|
luckText.Text, luckText.TextColor3 = "Put shards in the grid", SOFT
|
|
luckSub.Text = "min " .. Config.MIN_SHARDS .. ", max " .. Config.SLOT_COUNT
|
|
elseif luck == 0 then
|
|
luckText.Text, luckText.TextColor3 = "Need " .. (Config.MIN_SHARDS - placed), WARN
|
|
luckSub.Text = "min " .. Config.MIN_SHARDS .. " shards"
|
|
else
|
|
luckText.Text, luckText.TextColor3 = string.format("Luck x%.2f", luck), GOLD
|
|
local rare = 0
|
|
for i, r in Config.RARITIES do if r.Index >= 5 then rare += chances[i] end end
|
|
luckSub.Text = "legendary or better: " .. pct(rare)
|
|
end
|
|
|
|
-- buttons
|
|
local isBusy = busy()
|
|
if isBusy then genBtn.set("busy")
|
|
elseif placed > shards then genBtn.set("off", "Not enough shards")
|
|
elseif placed < Config.MIN_SHARDS then genBtn.set("off", "Add " .. (Config.MIN_SHARDS - placed))
|
|
else genBtn.set("ready", "Create · " .. placed) end
|
|
if isBusy or shards < Config.MIN_SHARDS then fillBtn.set("off", "Auto Pattern") else fillBtn.set("alt", "Auto Pattern") end
|
|
if isBusy or placed == 0 then clearBtn.set("off", "Clear") else clearBtn.set("alt", "Clear") end
|
|
|
|
-- drop pool
|
|
local toyChances, best, sim, bonus = Config.ToyChances(s, level)
|
|
for i, pr in pool do
|
|
local locked = pr.toy.Unlock > level
|
|
local isBest = (not locked) and i == best and bonus > 0
|
|
pr.dim.Visible = locked
|
|
pr.lockT.Text = "🔒 lvl " .. pr.toy.Unlock
|
|
pr.pct.Text = locked and "" or pct(toyChances[i])
|
|
pr.pct.TextColor3 = isBest and OK or WHITE
|
|
if isBest then
|
|
pr.sub.Text = (sim >= 0.999 and "exact pattern" or string.format("pattern %d%%", math.floor(sim * 100 + 0.5))) .. string.format(" +%.1f%%", bonus)
|
|
pr.sub.TextColor3 = OK
|
|
else
|
|
pr.sub.Text = pr.toy.Count .. " shards"
|
|
pr.sub.TextColor3 = MUTED
|
|
end
|
|
pr.stroke.Thickness = isBest and 4 or 0
|
|
pr.row.BackgroundColor3 = isBest and Color3.fromRGB(24, 74, 50) or Color3.fromRGB(12, 40, 52)
|
|
end
|
|
|
|
-- chances page
|
|
chLuck.Text = luck > 0 and string.format("luck x%.2f", luck) or "luck x1 (no shards)"
|
|
local maxC = 0
|
|
for i in Config.RARITIES do maxC = math.max(maxC, chances[i]) end
|
|
for i, rr in raRows do
|
|
rr.val.Text = pct(chances[i])
|
|
tween(rr.bar, 0.25, { Size = UDim2.fromScale(math.clamp(chances[i] / math.max(maxC, 1e-9), 0.01, 1), 1) })
|
|
end
|
|
for _, pr in piRows do
|
|
local done = attr("Pity_" .. pr.pc.Rarity, 0)
|
|
local left = math.max(1, pr.pc.Rolls - done)
|
|
pr.val.Text = "at most in " .. left
|
|
pr.num.Text = math.min(done, pr.pc.Rolls) .. " / " .. pr.pc.Rolls
|
|
tween(pr.bar, 0.25, { Size = UDim2.fromScale(math.clamp(done / pr.pc.Rolls, 0, 1), 1) })
|
|
end
|
|
end
|
|
|
|
local watched = { "Shards", "Level", "CraftSlots", "CraftBooster", "Upg_Luck" }
|
|
for id in Config.BOOSTERS do table.insert(watched, "Booster_" .. id) end
|
|
for _, pc in Config.PITY do table.insert(watched, "Pity_" .. pc.Rarity) end
|
|
for _, n in watched do player:GetAttributeChangedSignal(n):Connect(function() if win.overlay.Visible then refresh() end end) end
|
|
-- the machine's busy flag and the short "pending" window after a click
|
|
local wasBusy = false
|
|
task.spawn(function()
|
|
while win.panel.Parent do
|
|
task.wait(0.2)
|
|
if win.overlay.Visible then
|
|
local b = busy()
|
|
if b ~= wasBusy then wasBusy = b; refresh() end
|
|
end
|
|
end
|
|
end)
|
|
|
|
ch.showTab("Create")
|
|
return {
|
|
open = function(tab)
|
|
ch.setBalance(attr("Shards", 0), true)
|
|
if tab then ch.showTab(tab) end
|
|
refresh()
|
|
end,
|
|
refresh = refresh,
|
|
showTab = ch.showTab,
|
|
}
|
|
end
|
|
|
|
return G
|