Skip to content

Commit 90ce302

Browse files
committed
Core quantify stuff
1 parent edcf00b commit 90ce302

File tree

4 files changed

+172
-3
lines changed

4 files changed

+172
-3
lines changed

items/code.lua

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,7 +3830,7 @@ local quantify = {
38303830
"?",
38313831
},
38323832
code = {
3833-
"Unimplemented (but will be Nova probably)",
3833+
"lord.ruby",
38343834
},
38353835
},
38363836
dependencies = {
@@ -3847,8 +3847,124 @@ local quantify = {
38473847
atlas = "atlasnotjokers",
38483848
order = 425,
38493849
can_use = function(self, card)
3850-
return false
3850+
return true
3851+
end,
3852+
use = function(self, card)
3853+
G.GAME.USING_CODE = true
3854+
G.GAME.cry_quantify = true
38513855
end,
3856+
init = function()
3857+
3858+
local love_mousepressedref = love.mousepressed
3859+
function love.mousepressed(x,y,button,istouch)
3860+
love_mousepressedref(x,y,button,istouch)
3861+
if G.GAME.cry_quantify and G.CONTROLLER.hovering.target.config then
3862+
if Cryptid.handle_quantify(G.CONTROLLER.hovering.target) then
3863+
G.GAME.USING_CODE = nil
3864+
G.GAME.cry_quantify = nil
3865+
else
3866+
play_sound("tarot1")
3867+
attention_text({
3868+
text = localize("k_nope_ex"),
3869+
backdrop_colour = G.C.SECONDARY_SET.Code,
3870+
scale = 0.8,
3871+
hold = 2,
3872+
align = "cm",
3873+
offset = { x = 0, y = 0},
3874+
major = G.play
3875+
})
3876+
end
3877+
end
3878+
end
3879+
3880+
local calculate_ref = Card.calculate_joker
3881+
function Card:calculate_joker(context)
3882+
local ret, post = calculate_ref(self, context)
3883+
if not ret and not post then
3884+
if context.joker_main or context.forcetrigger then
3885+
if self.config.center.key == "c_base" or self.config.center.set == "Enhanced" then
3886+
local enhancement = eval_card(self, {cardarea=G.play, main_scoring=true, scoring_hand={}})
3887+
local ret2 = {}
3888+
local ret3 = {}
3889+
if enhancement then
3890+
ret2 = enhancement
3891+
end
3892+
local hand_enhancement = eval_card(self, {cardarea=G.hand, main_scoring=true, scoring_hand={}})
3893+
if hand_enhancement then
3894+
ret3 = hand_enhancement
3895+
end
3896+
for _, tbl in pairs(ret2) do for i, v in pairs(tbl) do
3897+
SMODS.calculate_individual_effect({[i]=v}, self, i, v, false)
3898+
end end
3899+
for _, tbl in pairs(ret3) do for i, v in pairs(tbl) do
3900+
SMODS.calculate_individual_effect({[i]=v}, self, i, v, false)
3901+
end end
3902+
end
3903+
if self.config.center.set == "Booster" then
3904+
local limit = self.ability.extra
3905+
local choose = self.ability.choose
3906+
local kind = self.config.center.kind
3907+
local kindmap = {
3908+
["Standard"] = "Enhanced",
3909+
["Buffoon"] = "Joker",
3910+
["Arcana"] = "Tarot"
3911+
}
3912+
kind = kindmap[kind] or kind
3913+
if not G.P_CENTER_POOLS[kind] then
3914+
kind = "Tarot"
3915+
end
3916+
for i = 1, G.jokers.config.card_limit - #G.jokers.cards do
3917+
if to_big(self.ability.choose ) > to_big(0) then
3918+
self.ability.choose = self.ability.choose - 1
3919+
local card = self.config.center.create_card and self.config.center:create_card(self) or
3920+
create_card(kind, G.Jokers, nil, nil, nil, nil, nil, "cry_quantify_booster")
3921+
--G.jokers:emplace(card)
3922+
if to_big(self.ability.choose) <= to_big(0) then
3923+
self:start_dissolve()
3924+
end
3925+
end
3926+
end
3927+
end
3928+
end
3929+
end
3930+
return ret, post
3931+
end
3932+
local debuff_handref = Blind.debuff_hand
3933+
function Blind:debuff_hand(cards, hand, handname, check)
3934+
local tbl = {}
3935+
for i, v in pairs(G.jokers.cards) do
3936+
if v.base.nominal and v.base.suit then
3937+
tbl[#tbl+1] = v
3938+
end
3939+
end
3940+
return debuff_handref(self, Cryptid.table_merge(cards, tbl), hand, handname, check)
3941+
end
3942+
function Cryptid.handle_quantify(target)
3943+
if type(target) == "table" and target.calculate_joker then
3944+
local highlighted = target
3945+
--removing from jokers just to readd to jokers is pointless
3946+
if highlighted and highlighted.area ~= G.consumeables or not G.GAME.modifiers.cry_beta then
3947+
if highlighted.children.price then
3948+
if to_big(G.GAME.dollars - G.GAME.bankrupt_at) < to_big(highlighted.cost) then
3949+
return
3950+
end
3951+
ease_dollars(-highlighted.cost)
3952+
highlighted.children.price:remove()
3953+
end
3954+
highlighted.area:remove_card(highlighted)
3955+
highlighted.children.price = nil
3956+
if highlighted.children.buy_button then highlighted.children.buy_button:remove() end
3957+
highlighted.children.buy_button = nil
3958+
remove_nils(highlighted.children)
3959+
G.E_MANAGER:add_event(Event{
3960+
func = function() highlighted:highlight(); return true end
3961+
})
3962+
G.jokers:emplace(highlighted)
3963+
return true
3964+
end
3965+
end
3966+
end
3967+
end
38523968
-- use = function(self, card, area, copier)
38533969

38543970
-- end,
@@ -5194,7 +5310,7 @@ local code_cards = {
51945310
global_sticker,
51955311
variable,
51965312
-- crylog, -- this and quantify will be implemented later on
5197-
-- quantify,
5313+
quantify,
51985314
divide,
51995315
multiply,
52005316
delete,

lib/misc.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,3 +830,9 @@ function Cryptid.reset_to_none()
830830
handname = localize("cry_None", "poker_hands"),
831831
})
832832
end
833+
function Cryptid.table_merge(t1, t2)
834+
local tbl = {}
835+
for i, v in pairs(t1) do tbl[#tbl+1] = v end
836+
for i, v in pairs(t2) do tbl[#tbl+1] = v end
837+
return tbl
838+
end

lovely/code.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,40 @@ for i = 1, #G.play.cards do
533533
end
534534
'''
535535
match_indent = true
536+
537+
[[patches]]
538+
[patches.pattern]
539+
target = "cardarea.lua"
540+
pattern = "local text,disp_text,poker_hands = G.FUNCS.get_poker_hand_info(self.highlighted)"
541+
position = "after"
542+
payload = '''
543+
local text,disp_text,poker_hands
544+
if self == G.hand then
545+
local tbl = {}
546+
for i, v in pairs(G.jokers.cards) do
547+
if v.base.nominal and v.base.suit then
548+
tbl[#tbl+1] = v
549+
end
550+
end
551+
text,disp_text,poker_hands = G.FUNCS.get_poker_hand_info(Cryptid.table_merge(self.highlighted, tbl))
552+
else
553+
text,disp_text,poker_hands = G.FUNCS.get_poker_hand_info(self.highlighted)
554+
end
555+
'''
556+
match_indent = true
557+
558+
[[patches]]
559+
[patches.pattern]
560+
target = "functions/state_events.lua"
561+
pattern = "local text,disp_text,poker_hands,scoring_hand,non_loc_disp_text = G.FUNCS.get_poker_hand_info(G.play.cards)"
562+
position = "after"
563+
payload = '''
564+
local tbl = {}
565+
for i, v in pairs(G.jokers.cards) do
566+
if v.base.nominal and v.base.suit then
567+
tbl[#tbl+1] = v
568+
end
569+
end
570+
local text,disp_text,poker_hands,scoring_hand,non_loc_disp_text = G.FUNCS.get_poker_hand_info(Cryptid.table_merge(G.play.cards, tbl))
571+
'''
572+
match_indent = true

lovely/misprint.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,3 +535,13 @@ Cryptid.misprintize_tbl(
535535
)
536536
'''
537537
match_indent = true
538+
#fix for bignum playing cards
539+
[[patches]]
540+
[patches.pattern]
541+
target = "card.lua"
542+
pattern = "nominal_chips = self.base.nominal > 0 and self.base.nominal or nil,"
543+
position = "at"
544+
payload = '''
545+
nominal_chips = to_big(self.base.nominal) > to_big(0) and self.base.nominal or nil,
546+
'''
547+
match_indent = true

0 commit comments

Comments
 (0)