Skip to content

Commit

Permalink
enhance blind and playing card APIs, fix various bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelius7309 committed Apr 4, 2024
1 parent ae8d2d2 commit 8b74786
Show file tree
Hide file tree
Showing 12 changed files with 446 additions and 235 deletions.
20 changes: 0 additions & 20 deletions core/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SMODS.BUFFERS = {
Vouchers = {},
}


MODDED_VERSION = "0.9.5-STEAMODDED"

function STR_UNPACK(str)
Expand Down Expand Up @@ -978,24 +977,5 @@ function SMODS.LOAD_LOC()
end
end

-- retain added objects on profile reload
local init_item_prototypes_ref = Game.init_item_prototypes
function Game:init_item_prototypes()
local P_CENTERS = self.P_CENTERS
local P_CENTER_POOLS = self.P_CENTER_POOLS
local P_JOKER_RARITY_POOLS = self.P_JOKER_RARITY_POOLS
local P_BLINDS = self.P_BLINDS
local P_SEALS = self.P_SEALS
local P_CARDS = self.P_CARDS
init_item_prototypes_ref(self)
if P_CENTERS then self.P_CENTERS = P_CENTERS end
if P_CENTER_POOLS then self.P_CENTER_POOLS = P_CENTER_POOLS end
if P_JOKER_RARITY_POOLS then self.P_JOKER_RARITY_POOLS = P_JOKER_RARITY_POOLS end
if P_BLINDS then self.P_BLINDS = P_BLINDS end
if P_SEALS then self.P_SEALS = P_SEALS end
if P_CARDS then self.P_CARDS = P_CARDS end
SMODS.SAVE_UNLOCKS()
end

----------------------------------------------
------------MOD CORE END----------------------
4 changes: 2 additions & 2 deletions core/deck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ local back_initref = Back.init;
function Back:init(selected_back)
back_initref(self, selected_back)
self.atlas = "centers"
if selected_back.config.atlas then
self.atlas = selected_back.config.atlas
if self.effect.center.config.atlas then
self.atlas = self.effect.center.config.atlas
end
end

Expand Down
31 changes: 13 additions & 18 deletions core/joker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,33 +100,28 @@ function SMODS.injectJokers()
sendDebugMessage("The Joker named " .. joker.name .. " with the slug " .. joker.slug ..
" have been registered at the id " .. id .. ".")
end
SMODS.BUFFERS.Jokers = {}
end

local cardset_abilityRef = Card.set_ability
function Card.set_ability(self, center, initial, delay_sprites)
cardset_abilityRef(self, center, initial, delay_sprites)

-- Iterate over each object in SMODS.JKR_EFFECT
for _k, obj in pairs(SMODS.Jokers) do
--! CHANGED from effect due to overlap
if obj.set_ability and type(obj.set_ability) == "function" and _k == self.config.center.key then
obj.set_ability(self, center, initial, delay_sprites)
end
local key = self.config.center.key
local joker_obj = SMODS.Jokers[key]
if joker_obj and joker_obj.set_ability and type(joker_obj.set_ability) == 'function' then
joker_obj.set_ability(self, center, initial, delay_sprites)
end
end

local calculate_jokerref = Card.calculate_joker;
function Card:calculate_joker(context)
local ret_val = calculate_jokerref(self, context);

if self.ability.set == "Joker" and not self.debuff then
local ret_val = calculate_jokerref(self, context)
if not self.debuff then
local key = self.config.center.key
local joker_obj = SMODS.Jokers[key]
if joker_obj and joker_obj.calculate and type(joker_obj.calculate) == "function" then
local o = joker_obj.calculate(self, context)
if o then return o end
end
local center_obj = SMODS.Jokers[key] or SMODS.Tarots[key] or SMODS.Planets[key] or SMODS.Spectrals[key]
if center_obj and center_obj.calculate and type(center_obj.calculate) == "function" then
local o = center_obj.calculate(self, context)
if o then return o end
end
end

return ret_val;
Expand Down Expand Up @@ -154,8 +149,8 @@ function Card:generate_UIBox_ability_table()
local joker_obj = SMODS.Jokers[key]
if joker_obj and joker_obj.loc_def and type(joker_obj.loc_def) == 'function' then
local o, m = joker_obj.loc_def(self)
if o and next(o) then loc_vars = o end
if m and next(m) then main_end = m end
if o then loc_vars = o end
if m then main_end = m end
end
end
if loc_vars then
Expand Down
1 change: 0 additions & 1 deletion core/planet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ function SMODS.injectPlanets()
sendDebugMessage("The Planet named " .. planet.name .. " with the slug " .. planet.slug ..
" have been registered at the id " .. id .. ".")
end
SMODS.BUFFERS.Planets = {}
end

function create_UIBox_your_collection_planets()
Expand Down
122 changes: 109 additions & 13 deletions core/r_blind.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function SMODS.injectBlinds()
sendDebugMessage("The Blind named " ..
blind.name .. " with the slug " .. blind.slug .. " have been registered at the id " .. id .. ".")
end
SMODS.BUFFERS.Blinds = {}
end

local set_blindref = Blind.set_blind;
Expand All @@ -94,10 +93,10 @@ function Blind:set_blind(blind, reset, silent)
self.children.animatedSprite.states = prev_anim.states
self.children.animatedSprite.states.visible = prev_anim.states.visible
self.children.animatedSprite.states.drag.can = prev_anim.states.drag.can
for _k, v in pairs(SMODS.Blinds) do
if v.set and type(v.set) == 'function' and self.config.blind.key == _k then
v.set(self, blind, reset, silent)
end
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.set_blind and type(blind_obj.set_blind) == 'function' then
blind_obj.set_blind(self, blind, reset, silent)
end
end
for _, v in ipairs(G.playing_cards) do
Expand All @@ -110,24 +109,121 @@ end

local blind_disable_ref = Blind.disable
function Blind:disable()
for _k,v in pairs(SMODS.Blinds) do
if v.disable and type(v.disable) == 'function' and self.config.blind.key == _k then
v.disable(self)
end
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.disable and type(blind_obj.disable) == 'function' then
blind_obj.disable(self)
end
blind_disable_ref(self)
end

local blind_defeat_ref = Blind.defeat
function Blind:defeat(silent)
for _k,v in pairs(SMODS.Blinds) do
if v.defeat and type(v.defeat) == 'function' and self.config.blind.key == _k then
v.defeat(self, silent)
end
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.defeat and type(blind_obj.defeat) == 'function' then
blind_obj.set_blind(self, silent)
end
blind_defeat_ref(self, silent)
end

local blind_debuff_card_ref = Blind.debuff_card
function Blind:debuff_card(card, from_blind)
blind_debuff_card_ref(self, card, from_blind)
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.debuff_card and type(blind_obj.debuff_card) == 'function' and not self.disabled then
blind_obj.debuff_card(self, card, from_blind)
end
end

local blind_stay_flipped_ref = Blind.stay_flipped
function Blind:stay_flipped(area, card)
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.stay_flipped and type(blind_obj.stay_flipped) == 'function' and not self.disabled and area == G.hand then
return blind_obj.stay_flipped(self, area, card)
end
return blind_stay_flipped_ref(self, area, card)
end

local blind_drawn_to_hand_ref = Blind.drawn_to_hand
function Blind:drawn_to_hand()
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.drawn_to_hand and type(blind_obj.drawn_to_hand) == 'function' and not self.disabled then
blind_obj.drawn_to_hand(self)
end
blind_drawn_to_hand_ref(self)
end

local blind_debuff_hand_ref = Blind.debuff_hand
function Blind:debuff_hand(cards, hand, handname, check)
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.debuff_hand and type(blind_obj.debuff_hand) == 'function' and not self.disabled then
return blind_obj.debuff_hand(self, cards, hand, handname, check)
end
return blind_debuff_hand_ref(self, cards, hand, handname, check)
end

local blind_modify_hand_ref = Blind.modify_hand
function Blind:modify_hand(cards, poker_hands, text, mult, hand_chips)
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.modify_hand and type(blind_obj.modify_hand) == 'function' and not self.debuff then
return blind_obj.modify_hand(cards, poker_hands, text, mult, hand_chips)
end
return blind_modify_hand_ref(cards, poker_hands, text, mult, hand_chips)
end

local blind_press_play_ref = Blind.press_play
function Blind:press_play()
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.press_play and type(blind_obj.press_play) == 'function' and not self.disabled then
return blind_obj.press_play(self)
end
return blind_press_play_ref(self)
end

local blind_get_loc_debuff_text_ref = Blind.get_loc_debuff_text
function Blind:get_loc_debuff_text()
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
if blind_obj and blind_obj.get_loc_debuff_text and type(blind_obj.get_loc_debuff_text) == 'function' then
return blind_obj.get_loc_debuff_text(self)
end
return blind_get_loc_debuff_text_ref(self)
end

local blind_set_text = Blind.set_text
function Blind:set_text()
local key = self.config.blind.key
local blind_obj = SMODS.Blinds[key]
local loc_vars = nil
if blind_obj and blind_obj.loc_def and type(blind_obj.loc_def) == 'function' and not self.disabled then
loc_vars = blind_obj.loc_def(self)
local loc_target = localize { type = 'raw_descriptions', key = self.config.blind.key, set = 'Blind', vars = loc_vars or self.config.blind.vars }
if loc_target then
self.loc_name = self.name == '' and self.name or
localize { type = 'name_text', key = self.config.blind.key, set = 'Blind' }
self.loc_debuff_text = ''
for k, v in ipairs(loc_target) do
self.loc_debuff_text = self.loc_debuff_text .. v .. (k <= #loc_target and ' ' or '')
end
self.loc_debuff_lines[1] = loc_target[1] or ''
self.loc_debuff_lines[2] = loc_target[2] or ''
else
self.loc_name = ''; self.loc_debuff_text = ''
self.loc_debuff_lines[1] = ''
self.loc_debuff_lines[2] = ''
end
return
end
blind_set_text(self)
end

function create_UIBox_blind_choice(type, run_info)
if not G.GAME.blind_on_deck then
G.GAME.blind_on_deck = 'Small'
Expand Down
1 change: 0 additions & 1 deletion core/seal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function SMODS.injectSeals()
sendDebugMessage("The Seal named " ..
seal.name .. " have been registered at the id " .. #G.P_CENTER_POOLS.Seal .. ".")
end
SMODS.BUFFERS.Seals = {}
end

local get_badge_colourref = get_badge_colour
Expand Down
1 change: 0 additions & 1 deletion core/spectral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function SMODS.injectSpectrals()
sendDebugMessage("The Spectral named " .. spectral.name .. " with the slug " .. spectral.slug ..
" have been registered at the id " .. id .. ".")
end
SMODS.BUFFERS.Spectrals = {}
end

function create_UIBox_your_collection_spectrals()
Expand Down
Loading

0 comments on commit 8b74786

Please sign in to comment.