Skip to content

Commit

Permalink
Fix lag, increase suit/rank limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelius7309 authored Mar 30, 2024
1 parent 55401ec commit 4bc363d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 53 deletions.
2 changes: 1 addition & 1 deletion core/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SMODS.BUFFERS = {
Vouchers = {},
}

MODDED_VERSION = "0.9.2-STEAMODDED"
MODDED_VERSION = "0.9.3-STEAMODDED"

function STR_UNPACK(str)
local chunk, err = loadstring(str)
Expand Down
45 changes: 40 additions & 5 deletions core/suit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,26 @@ SMODS.Card.RANKS = {
SMODS.Card.RANK_LIST = { '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A' }
SMODS.Card.MAX_ID = 14
function SMODS.Card.generate_prefix()
local permutations
permutations = function(list, len)
len = len or 2
if len <= 1 then return list end
local t = permutations(list, len-1)
local o = {}
for _,a in ipairs(list) do
for _,b in ipairs(t) do
table.insert(o, a..b)
end
end
return o
end
local possible_prefixes = { 'A', 'B', 'E', 'F', 'G', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9' }
local perm = permutations(possible_prefixes, 2)
for _,a in ipairs(perm) do
table.insert(possible_prefixes, a)
end
for _, v in pairs(SMODS.Card.SUITS) do
for i, vv in ipairs(possible_prefixes) do
if v.prefix == vv then
Expand All @@ -61,9 +78,25 @@ function SMODS.Card.generate_prefix()
end

function SMODS.Card.generate_suffix()
local permutations
permutations = function(list, len)
len = len or 2
if len <= 1 then return list end
local t = permutations(list, len-1)
local o = {}
for _,a in ipairs(list) do
for _,b in ipairs(t) do
table.insert(o, a..b)
end
end
return o
end
local possible_suffixes = { 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z' }
't', 'u', 'v', 'w', 'x', 'y', 'z' }
for _,a in permutations(possible_suffixes, 2) do
table.insert(possible_suffixes, a)
end
for _, v in pairs(SMODS.Card.RANKS) do
for i, vv in ipairs(possible_suffixes) do
if v.suffix == vv then
Expand Down Expand Up @@ -201,8 +234,8 @@ function SMODS.Card:new(suit, value, name, pos, atlas_low_contrast, atlas_high_c
suit = suit,
value = value,
pos = pos or { x = rank_data.pos.x, y = suit_data.card_pos.y },
atlas_low_contrast = atlas_low_contrast or rank_data.atlas_low_contrast or suit_data.atlas_low_contrast,
atlas_high_contrast = atlas_high_contrast or rank_data.atlas_high_contrast or suit_data.atlas_high_contrast
card_atlas_low_contrast = atlas_low_contrast or rank_data.atlas_low_contrast or suit_data.atlas_low_contrast,
card_atlas_high_contrast = atlas_high_contrast or rank_data.atlas_high_contrast or suit_data.atlas_high_contrast
}
return G.P_CARDS[suit_data.prefix .. '_' .. (rank_data.suffix or rank_data.value)]
end
Expand Down Expand Up @@ -683,8 +716,10 @@ function SMODS.Card:_extend()

if not card_protos then
card_protos = {}
for k, v in pairs(G.P_CARDS) do
local _r, _s = string.sub(k, 3, 3), string.sub(k, 1, 1)
for k, v in pairs(G.P_CARDS) do
local rank_data = SMODS.Card.RANKS[v.value]
local suit_data = SMODS.Card.SUITS[v.suit]
local _r, _s = (rank_data.suffix or rank_data.value), suit_data.prefix
local keep, _e, _d, _g = true, nil, nil, nil
if _de then
if _de.yes_ranks and not _de.yes_ranks[_r] then keep = false end
Expand Down
84 changes: 37 additions & 47 deletions core/tarot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,40 +153,28 @@ end

local generate_card_ui_ref = generate_card_ui
function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, hide_desc, main_start, main_end)
local original_full_UI_table = full_UI_table
local original_main_end = main_end
local first_pass = nil
if not full_UI_table then
first_pass = true
full_UI_table = {
main = {},
info = {},
type = {},
name = nil,
badges = badges or {}
}
end
local original_full_UI_table = full_UI_table
local original_main_end = main_end
local first_pass = nil
if not full_UI_table then
first_pass = true
full_UI_table = {
main = {},
info = {},
type = {},
name = nil,
badges = badges or {}
}
end

local desc_nodes = (not full_UI_table.name and full_UI_table.main) or full_UI_table.info
local name_override = nil
local info_queue = {}
local loc_vars = {}
local desc_nodes = (not full_UI_table.name and full_UI_table.main) or full_UI_table.info
local name_override = nil
local info_queue = {}
local loc_vars = {}
if main_start then
desc_nodes[#desc_nodes + 1] = main_start
end

if not full_UI_table.name then
if specific_vars and specific_vars.no_name then
elseif card_type == 'Locked' then
elseif card_type == 'Undiscovered' then
elseif specific_vars and (card_type == 'Default' or card_type == 'Enhanced') then
elseif card_type == 'Booster' then
else
full_UI_table.name = localize{type = 'name', set = _c.set, key = _c.key, nodes = full_UI_table.name}
end
full_UI_table.card_type = card_type or _c.set
end


if not (card_type == 'Locked') and not hide_desc then
if _c.set == 'Tarot' then
for _k, v in pairs(SMODS.Tarots) do
Expand Down Expand Up @@ -217,29 +205,31 @@ function generate_card_ui(_c, full_UI_table, specific_vars, card_type, badges, h
end
end

if first_pass and not (_c.set == 'Edition') and badges and next(badges) then
for _, v in ipairs(badges) do
for k, _ in pairs(SMODS.Seals) do
if k == v then info_queue[#info_queue + 1] = { key = v, set = 'Other' } end
end
end
end
if first_pass and not (_c.set == 'Edition') and badges and next(badges) then
for _, v in ipairs(badges) do
for k, _ in pairs(SMODS.Seals) do
if k == v then info_queue[#info_queue + 1] = { key = v, set = 'Other' } end
end
end
end

if next(loc_vars) then
full_UI_table.name = localize { type = 'name', set = _c.set, key = _c.key, nodes = full_UI_table.name }
full_UI_table.card_type = card_type or _c.set
localize { type = 'descriptions', key = _c.key, set = _c.set, nodes = desc_nodes, vars = loc_vars }
end

if main_end then
desc_nodes[#desc_nodes + 1] = main_end
end

if main_end then
desc_nodes[#desc_nodes + 1] = main_end
for _, v in ipairs(info_queue) do
sendDebugMessage(inspect(v))
generate_card_ui(v, full_UI_table)
end

for _, v in ipairs(info_queue) do
sendDebugMessage(inspect(v))
generate_card_ui(v, full_UI_table)
end
if next(loc_vars) or next(info_queue) then return full_UI_table end
return generate_card_ui_ref(_c, original_full_UI_table, specific_vars, card_type, badges, hide_desc, main_start,
original_main_end)
if next(loc_vars) or next(info_queue) then return full_UI_table end
return generate_card_ui_ref(_c, original_full_UI_table, specific_vars, card_type, badges, hide_desc, main_start,
original_main_end)
end

local card_use_consumeable_ref = Card.use_consumeable
Expand Down

0 comments on commit 4bc363d

Please # to comment.