Skip to content

Commit b1713fe

Browse files
author
jolly[bot]
committed
jolly-bot: auto-format Lua files using Stylua
1 parent 6b75ce3 commit b1713fe

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

lib/overrides.lua

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,68 +1965,72 @@ end
19651965

19661966
function Cryptid.create_dummy_from_stone(rank)
19671967
rank = tonumber(rank) or ({
1968-
Ace=14,
1969-
King=13,
1970-
Queen=12,
1971-
Jack=11,
1968+
Ace = 14,
1969+
King = 13,
1970+
Queen = 12,
1971+
Jack = 11,
19721972
})[rank] or rank
19731973
return {
1974-
get_id = function() return rank end,
1974+
get_id = function()
1975+
return rank
1976+
end,
19751977
config = {
1976-
center = {}
1978+
center = {},
19771979
},
19781980
base = {
1979-
id = rank
1980-
}
1981+
id = rank,
1982+
},
19811983
}
19821984
end
19831985
function Cryptid.next_ranks(key, start, recurse)
19841986
key = ({
19851987
["14"] = "Ace",
19861988
["13"] = "King",
19871989
["12"] = "Queen",
1988-
["11"] = "Jack"
1990+
["11"] = "Jack",
19891991
})[tostring(key)] or key
19901992
local rank = SMODS.Ranks[tostring(key)]
19911993
local ret = {}
1992-
if not rank or (not start and not wrap and rank.straight_edge) then return ret end
1993-
for _,v in ipairs(rank.next) do
1994-
ret[#ret+1] = v
1994+
if not rank or (not start and not wrap and rank.straight_edge) then
1995+
return ret
1996+
end
1997+
for _, v in ipairs(rank.next) do
1998+
ret[#ret + 1] = v
19951999
local curr = #ret
19962000
if recurse and recurse > 0 then
19972001
for i, v in pairs(Cryptid.next_ranks(ret[#ret], start, recurse - 1)) do
1998-
ret[#ret+1] = v
2002+
ret[#ret + 1] = v
19992003
end
20002004
end
20012005
end
20022006
return ret
20032007
end
20042008

2005-
local function append (t, new)
2006-
local clone = {}
2007-
for _, item in ipairs (t) do
2008-
clone [#clone + 1] = item
2009-
end
2010-
clone [#clone + 1] = new
2011-
return clone
2009+
local function append(t, new)
2010+
local clone = {}
2011+
for _, item in ipairs(t) do
2012+
clone[#clone + 1] = item
2013+
end
2014+
clone[#clone + 1] = new
2015+
return clone
20122016
end
20132017

20142018
function Cryptid.unique_combinations(tbl, sub, min)
2015-
sub = sub or {}
2016-
min = min or 1
2019+
sub = sub or {}
2020+
min = min or 1
20172021
local wrap, yield = coroutine.wrap, coroutine.yield
2018-
return wrap (function ()
2019-
if #sub > 0 then
2020-
yield (sub) -- yield short combination.
2021-
end
2022-
if #sub < #tbl then
2023-
for i = min, #tbl do -- iterate over longer combinations.
2024-
for combo in Cryptid.unique_combinations (tbl, append (sub, tbl [i]), i + 1) do
2025-
yield (combo)
2026-
end
2027-
end
2028-
end
2029-
end)
2022+
return wrap(function()
2023+
if #sub > 0 then
2024+
yield(sub) -- yield short combination.
2025+
end
2026+
if #sub < #tbl then
2027+
for i = min, #tbl do -- iterate over longer combinations.
2028+
for combo in Cryptid.unique_combinations(tbl, append(sub, tbl[i]), i + 1) do
2029+
yield(combo)
2030+
end
2031+
end
2032+
end
2033+
end)
20302034
end
20312035

20322036
get_straight_ref = get_straight
@@ -2038,28 +2042,28 @@ function get_straight(hand, min_length, skip, wrap)
20382042
if stones > 0 then
20392043
for i, v in pairs(hand) do
20402044
if v.config.center.key ~= "m_stone" then
2041-
cards[#cards+1] = v
2045+
cards[#cards + 1] = v
20422046
for i, v in pairs(Cryptid.next_ranks(v:get_id(), nil, stones)) do --this means its inaccurate in some situations like K S S S S but its fine there isnt a better way
2043-
ranks[#ranks+1] = v
2047+
ranks[#ranks + 1] = v
20442048
end
20452049
end
20462050
end
20472051
for i, v in Cryptid.unique_combinations(ranks) do
20482052
if #i == stones then
2049-
permutations[#permutations+1] = i
2053+
permutations[#permutations + 1] = i
20502054
end
20512055
end
20522056
for i, v in ipairs(permutations) do
20532057
local actual = {}
20542058
local ranks = {}
2055-
for i, v in pairs(cards) do
2056-
actual[#actual+1] = v
2059+
for i, v in pairs(cards) do
2060+
actual[#actual + 1] = v
20572061
ranks[v:get_id()] = true
20582062
end
20592063
for i, p in pairs(v) do
2060-
local d = Cryptid.create_dummy_from_stone(p)
2064+
local d = Cryptid.create_dummy_from_stone(p)
20612065
if not ranks[d:get_id()] then
2062-
actual[#actual+1] = d
2066+
actual[#actual + 1] = d
20632067
end
20642068
end
20652069
local ret = get_straight_ref(actual, min_length + stones, skip, wrap)
@@ -2070,4 +2074,4 @@ function get_straight(hand, min_length, skip, wrap)
20702074
end
20712075

20722076
return get_straight_ref(hand, min_length + stones, skip, wrap)
2073-
end
2077+
end

0 commit comments

Comments
 (0)