Skip to content

Commit e927858

Browse files
authored
embrace steamodded, compat for Four Fingers, Shortcut
1 parent 69fcd4f commit e927858

File tree

5 files changed

+183
-25
lines changed

5 files changed

+183
-25
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Adds compatibility for the following jokers:
1111
- Delayed Gratification
1212
- Drunkard
1313
- Egg
14+
- Four Fingers
1415
- Gift Card
1516
- Golden Joker
1617
- Invisible Joker
@@ -21,6 +22,7 @@ Adds compatibility for the following jokers:
2122
- Oops! All 6s
2223
- Rocket
2324
- Satellite
25+
- Shortcut
2426
- Showman
2527
- Sixth Sense
2628
- To the Moon

assets/1x/exb_icon.png

795 Bytes
Loading

assets/2x/exb_icon.png

1.06 KB
Loading

lovely.toml

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ function Card:soft_add_to_deck()
143143
if self.ability.name == 'Showman' then
144144
G.GAME.showman_count = (G.GAME.showman_count and G.GAME.showman_count + 1) or 1
145145
end
146+
if self.ability.name == 'Four Fingers' then
147+
G.GAME.exb_fingers = (G.GAME.exb_fingers and G.GAME.exb_fingers + 1) or 1
148+
exb_parse()
149+
end
150+
if self.ability.name == 'Shortcut' then
151+
G.GAME.exb_shortcuts = (G.GAME.exb_shortcuts and G.GAME.exb_shortcuts + 1) or 1
152+
exb_parse()
153+
end
146154
if self.ability.name == 'Credit Card' then
147155
G.GAME.bankrupt_at = G.GAME.bankrupt_at - self.ability.extra
148156
end
@@ -199,6 +207,14 @@ function Card:soft_remove_from_deck()
199207
if self.ability.name == 'Showman' then
200208
G.GAME.showman_count = G.GAME.showman_count - 1
201209
end
210+
if self.ability.name == 'Four Fingers' then
211+
G.GAME.exb_fingers = G.GAME.exb_fingers - 1
212+
exb_parse()
213+
end
214+
if self.ability.name == 'Shortcut' then
215+
G.GAME.exb_shortcuts = G.GAME.exb_shortcuts - 1
216+
exb_parse()
217+
end
202218
if self.ability.name == 'Credit Card' then
203219
G.GAME.bankrupt_at = G.GAME.bankrupt_at + self.ability.extra
204220
end
@@ -543,7 +559,10 @@ end
543559
'''
544560
match_indent = true
545561

546-
# showman add to deck
562+
563+
564+
565+
# add to deck
547566
[[patches]]
548567
[patches.pattern]
549568
target = "card.lua"
@@ -553,10 +572,18 @@ payload = '''
553572
if self.ability.name == 'Showman' then
554573
G.GAME.showman_count = (G.GAME.showman_count and G.GAME.showman_count + 1) or 1
555574
end
575+
if self.ability.name == 'Four Fingers' then
576+
G.GAME.exb_fingers = (G.GAME.exb_fingers and G.GAME.exb_fingers + 1) or 1
577+
exb_parse()
578+
end
579+
if self.ability.name == 'Shortcut' then
580+
G.GAME.exb_shortcuts = (G.GAME.exb_shortcuts and G.GAME.exb_shortcuts + 1) or 1
581+
exb_parse()
582+
end
556583
'''
557584
match_indent = true
558585

559-
# showman remove from deck
586+
# remove from deck
560587
[[patches]]
561588
[patches.pattern]
562589
target = "card.lua"
@@ -566,6 +593,14 @@ payload = '''
566593
if self.ability.name == 'Showman' then
567594
G.GAME.showman_count = G.GAME.showman_count - 1
568595
end
596+
if self.ability.name == 'Four Fingers' then
597+
G.GAME.exb_fingers = G.GAME.exb_fingers - 1
598+
exb_parse()
599+
end
600+
if self.ability.name == 'Shortcut' then
601+
G.GAME.exb_shortcuts = G.GAME.exb_shortcuts - 1
602+
exb_parse()
603+
end
569604
'''
570605
match_indent = true
571606

@@ -605,28 +640,9 @@ target = "game.lua"
605640
pattern = '''self.P_CENTER_POOLS = {'''
606641
position = "before"
607642
payload = '''
608-
self.P_CENTERS.j_credit_card.blueprint_compat = true
609-
self.P_CENTERS.j_chaos.blueprint_compat = true
610-
self.P_CENTERS.j_delayed_grat.blueprint_compat = true
611-
self.P_CENTERS.j_egg.blueprint_compat = true
612-
self.P_CENTERS.j_sixth_sense.blueprint_compat = true
613-
self.P_CENTERS.j_cloud_9.blueprint_compat = true
614-
self.P_CENTERS.j_rocket.blueprint_compat = true
615-
self.P_CENTERS.j_midas_mask.blueprint_compat = true
616-
self.P_CENTERS.j_gift.blueprint_compat = true
617-
self.P_CENTERS.j_turtle_bean.blueprint_compat = true
618-
self.P_CENTERS.j_to_the_moon.blueprint_compat = true
619-
self.P_CENTERS.j_juggler.blueprint_compat = true
620-
self.P_CENTERS.j_drunkard.blueprint_compat = true
621-
self.P_CENTERS.j_golden.blueprint_compat = true
622-
self.P_CENTERS.j_trading.blueprint_compat = true
623-
self.P_CENTERS.j_mr_bones.blueprint_compat = true
624-
self.P_CENTERS.j_troubadour.blueprint_compat = true
625-
self.P_CENTERS.j_ring_master.blueprint_compat = true
626-
self.P_CENTERS.j_merry_andy.blueprint_compat = true
627-
self.P_CENTERS.j_oops.blueprint_compat = true
628-
self.P_CENTERS.j_invisible.blueprint_compat = true
629-
self.P_CENTERS.j_satellite.blueprint_compat = true
630-
self.P_CENTERS.j_chicot.blueprint_compat = true
643+
local exb_overrides = {'j_four_fingers', 'j_credit_card', 'j_chaos', 'j_delayed_grat', 'j_egg', 'j_sixth_sense', 'j_shortcut', 'j_cloud_9', 'j_rocket', 'j_midas_mask', 'j_gift', 'j_turtle_bean', 'j_to_the_moon', 'j_juggler', 'j_drunkard', 'j_golden', 'j_trading', 'j_mr_bones', 'j_troubadour', 'j_ring_master', 'j_merry_andy', 'j_oops', 'j_invisible', 'j_satellite', 'j_chicot'}
644+
for i = 1, #exb_overrides do
645+
self.P_CENTERS[exb_overrides[i]].blueprint_compat = true
646+
end
631647
'''
632648
match_indent = true

main.lua

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
--- STEAMODDED HEADER
2+
--- MOD_NAME: Extended Blueprint
3+
--- MOD_ID: ExtendedBlueprint
4+
--- PREFIX: exb
5+
--- MOD_AUTHOR: [toneblock]
6+
--- MOD_DESCRIPTION: Increases blueprint compatibility
7+
--- BADGE_COLOUR: 4b68ce
8+
--- DEPENDENCIES: [Steamodded>=1.0.0~ALPHA-1216c]
9+
--- VERSION: 0.2.0
10+
11+
----------------------------------------------
12+
------------MOD CODE -------------------------
13+
14+
-- gotta go for smods to do four fingers/shortcut stuff
15+
16+
SMODS.PokerHandPart:take_ownership('_straight', {
17+
func = function(hand) return exb_get_straight(hand) end
18+
})
19+
SMODS.PokerHandPart:take_ownership('_flush', {
20+
func = function(hand) return exb_get_flush(hand) end
21+
})
22+
23+
24+
function exb_parse()
25+
if G.hand and G.STATE == G.STATES.SELECTING_HAND then
26+
G.hand:parse_highlighted()
27+
end
28+
end
29+
30+
31+
-- me when i copy the entire functions just to edit a couple lines
32+
function exb_get_flush(hand)
33+
local ret = {}
34+
local four_fingers = math.min(4, G.GAME and G.GAME.exb_fingers or 0)
35+
local suits = SMODS.Suit.obj_buffer
36+
if #hand < (5 - (four_fingers)) then return ret else
37+
for j = 1, #suits do
38+
local t = {}
39+
local suit = suits[j]
40+
local flush_count = 0
41+
for i=1, #hand do
42+
if hand[i]:is_suit(suit, nil, true) then flush_count = flush_count + 1; t[#t+1] = hand[i] end
43+
end
44+
if flush_count >= (5 - (four_fingers)) then
45+
table.insert(ret, t)
46+
return ret
47+
end
48+
end
49+
return {}
50+
end
51+
end
52+
53+
function exb_get_straight(hand)
54+
local ret = {}
55+
local four_fingers = math.min(4, G.GAME and G.GAME.exb_fingers or 0)
56+
local can_skip = math.min(4, G.GAME and G.GAME.exb_shortcuts or 0)
57+
if #hand < (5 - (four_fingers)) then return ret end
58+
local t = {}
59+
local RANKS = {}
60+
for i = 1, #hand do
61+
if hand[i]:get_id() > 0 then
62+
local rank = hand[i].base.value
63+
RANKS[rank] = RANKS[rank] or {}
64+
RANKS[rank][#RANKS[rank] + 1] = hand[i]
65+
end
66+
end
67+
local straight_length = 0
68+
local straight = false
69+
local skipped_rank = can_skip
70+
local vals = {}
71+
for k, v in pairs(SMODS.Ranks) do
72+
if v.straight_edge then
73+
table.insert(vals, k)
74+
end
75+
end
76+
local init_vals = {}
77+
for _, v in ipairs(vals) do
78+
init_vals[v] = true
79+
end
80+
if not next(vals) then table.insert(vals, 'Ace') end
81+
local initial = true
82+
local br = false
83+
local end_iter = false
84+
local i = 0
85+
while 1 do
86+
end_iter = false
87+
if straight_length >= (5 - (four_fingers)) then
88+
straight = true
89+
end
90+
i = i + 1
91+
if br or (i > #SMODS.Rank.obj_buffer + 1) then break end
92+
if not next(vals) then break end
93+
for _, val in ipairs(vals) do
94+
if init_vals[val] and not initial then br = true end
95+
if RANKS[val] then
96+
straight_length = straight_length + 1
97+
skipped_rank = can_skip
98+
for _, vv in ipairs(RANKS[val]) do
99+
t[#t + 1] = vv
100+
end
101+
vals = SMODS.Ranks[val].next
102+
initial = false
103+
end_iter = true
104+
break
105+
end
106+
end
107+
if not end_iter then
108+
local new_vals = {}
109+
for _, val in ipairs(vals) do
110+
for _, r in ipairs(SMODS.Ranks[val].next) do
111+
table.insert(new_vals, r)
112+
end
113+
end
114+
vals = new_vals
115+
if can_skip and skipped_rank > 0 then
116+
skipped_rank = skipped_rank - 1
117+
else
118+
straight_length = 0
119+
skipped_rank = can_skip
120+
if not straight then t = {} end
121+
if straight then break end
122+
end
123+
end
124+
end
125+
if not straight then return ret end
126+
table.insert(ret, t)
127+
return ret
128+
end
129+
130+
131+
132+
SMODS.Atlas({
133+
key = "modicon",
134+
path = "exb_icon.png",
135+
px = 34,
136+
py = 34
137+
}):register()
138+
139+
----------------------------------------------
140+
------------MOD CODE END----------------------

0 commit comments

Comments
 (0)