Skip to content

Commit fe1a384

Browse files
authored
Merge branch 'SpectralPack:main' into main
2 parents 85af2b8 + 1465618 commit fe1a384

File tree

7 files changed

+436
-9
lines changed

7 files changed

+436
-9
lines changed

assets/1x/atlasnotjokers.png

42 Bytes
Loading

items/challenge.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,16 @@ function Game:start_run(args)
486486
if G.GAME.modifiers.cry_no_consumables then
487487
G.GAME.joker_rate = 1e300
488488
end
489+
for i, v in pairs(G.handlist) do
490+
if v == "cry_Declare0" then
491+
d0 = true
492+
end
493+
end
494+
if not d0 then
495+
table.insert(G.handlist, 1, "cry_Declare0")
496+
table.insert(G.handlist, 1, "cry_Declare1")
497+
table.insert(G.handlist, 1, "cry_Declare2")
498+
end
489499
end
490500
local challenges = {
491501
sticker_sheet,

items/code.lua

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,6 +2820,258 @@ local run = {
28202820
self:use(card, area)
28212821
end,
28222822
}
2823+
2824+
-- ://Declare
2825+
-- Create a new Poker hand from selected cards
2826+
local declare = {
2827+
cry_credits = {
2828+
idea = {
2829+
"Ronnec",
2830+
},
2831+
art = {
2832+
"lord.ruby",
2833+
},
2834+
code = {
2835+
"lord.ruby",
2836+
},
2837+
},
2838+
dependencies = {
2839+
items = {
2840+
"set_cry_code",
2841+
},
2842+
},
2843+
object_type = "Consumable",
2844+
set = "Code",
2845+
name = "cry-Declare",
2846+
key = "declare",
2847+
pos = { x = 6, y = 4 },
2848+
cost = 4,
2849+
atlas = "atlasnotjokers",
2850+
order = 420.5,
2851+
loc_vars = function(self, q, card)
2852+
return {
2853+
vars = {
2854+
localize(
2855+
({
2856+
"Straight",
2857+
"Flush",
2858+
"Full House",
2859+
"Full House",
2860+
})[(G.GAME.DECLARE_USED or 0) + 1],
2861+
"poker_hands"
2862+
),
2863+
number_format(-G.GAME.DECLARE_USED),
2864+
},
2865+
}
2866+
end,
2867+
can_use = function(self, card)
2868+
return (G.GAME.DECLARE_USED or 0) < 3
2869+
end,
2870+
use = function(self, card, area, copier)
2871+
G.GAME.USING_CODE = true
2872+
G.GAME.USING_DECLARE = true
2873+
G.ENTERED_CARD = ""
2874+
G.CHOOSE_CARD = UIBox({
2875+
definition = create_UIBox_declare(card),
2876+
config = {
2877+
align = "cm",
2878+
offset = { x = 0, y = 10 },
2879+
major = G.ROOM_ATTACH,
2880+
bond = "Weak",
2881+
instance_type = "POPUP",
2882+
},
2883+
})
2884+
G.CHOOSE_CARD.alignment.offset.y = 0
2885+
G.ROOM.jiggle = G.ROOM.jiggle + 1
2886+
G.CHOOSE_CARD:align_to_major()
2887+
end,
2888+
init = function()
2889+
function create_UIBox_declare(card)
2890+
G.E_MANAGER:add_event(Event({
2891+
blockable = false,
2892+
func = function()
2893+
G.REFRESH_ALERTS = true
2894+
return true
2895+
end,
2896+
}))
2897+
local t = create_UIBox_generic_options({
2898+
no_back = true,
2899+
colour = HEX("04200c"),
2900+
outline_colour = G.C.SECONDARY_SET.Code,
2901+
contents = {
2902+
{
2903+
n = G.UIT.R,
2904+
nodes = {
2905+
create_text_input({
2906+
colour = G.C.SET.Code,
2907+
hooked_colour = darken(copy_table(G.C.SET.Code), 0.3),
2908+
w = 4.5,
2909+
h = 1,
2910+
max_length = 100,
2911+
extended_corpus = true,
2912+
prompt_text = localize("cry_code_enter_hand"),
2913+
ref_table = G,
2914+
ref_value = "ENTERED_CARD",
2915+
keyboard_offset = 1,
2916+
}),
2917+
},
2918+
},
2919+
{
2920+
n = G.UIT.R,
2921+
config = { align = "cm" },
2922+
nodes = {
2923+
UIBox_button({
2924+
colour = G.C.SET.Code,
2925+
button = "declare_apply",
2926+
label = { localize("cry_code_with_suits") },
2927+
minw = 4.5,
2928+
focus_args = { snap_to = true },
2929+
}),
2930+
},
2931+
},
2932+
{
2933+
n = G.UIT.R,
2934+
config = { align = "cm" },
2935+
nodes = {
2936+
UIBox_button({
2937+
colour = G.C.SET.Code,
2938+
button = "declare_apply_suitless",
2939+
label = { localize("cry_code_without_suits") },
2940+
minw = 4.5,
2941+
focus_args = { snap_to = true },
2942+
}),
2943+
},
2944+
},
2945+
{
2946+
n = G.UIT.R,
2947+
config = { align = "cm" },
2948+
nodes = {
2949+
UIBox_button({
2950+
colour = G.C.RED,
2951+
button = "declare_cancel",
2952+
label = { localize("cry_code_cancel") },
2953+
minw = 4.5,
2954+
focus_args = { snap_to = true },
2955+
}),
2956+
},
2957+
},
2958+
},
2959+
})
2960+
return t
2961+
end
2962+
G.FUNCS.declare_cancel = function()
2963+
if G.CHOOSE_CARD then
2964+
G.CHOOSE_CARD:remove()
2965+
end
2966+
G.GAME.USING_CODE = false
2967+
G.GAME.USING_DECLARE = false
2968+
end
2969+
G.FUNCS.declare_apply = function()
2970+
G.GAME.hands["cry_Declare" .. tostring(G.GAME.DECLARE_USED or 0)] =
2971+
Cryptid.create_declare_hand(G.hand.highlighted, G.ENTERED_CARD)
2972+
G.GAME.DECLARE_USED = (G.GAME.DECLARE_USED or 0) + 1
2973+
G.FUNCS.declare_cancel()
2974+
end
2975+
G.FUNCS.declare_apply_suitless = function()
2976+
G.GAME.hands["cry_Declare" .. tostring(G.GAME.DECLARE_USED or 0)] =
2977+
Cryptid.create_declare_hand(G.hand.highlighted, G.ENTERED_CARD, true)
2978+
G.GAME.DECLARE_USED = (G.GAME.DECLARE_USED or 0) + 1
2979+
G.FUNCS.declare_cancel()
2980+
end
2981+
Cryptid.create_declare_hand = function(cards, name, suitless)
2982+
if G.ENTERED_CARD == "" then
2983+
G.ENTERED_CARD = "cry_Declare" .. tostring(G.GAME.DECLARE_USED or 0)
2984+
end
2985+
local complexity = #cards
2986+
local ranks = {}
2987+
local suits = {}
2988+
for i, v in pairs(cards) do
2989+
if not ranks[v:get_id()] then
2990+
ranks[v:get_id()] = true
2991+
complexity = complexity + 0.85
2992+
end
2993+
if not suitless then
2994+
if (SMODS.has_no_suit(v) and not suits["suitless"]) or not suits[v.base.suit] then
2995+
suits[SMODS.has_no_suit(v) and "suitless" or v.base.suit] = true
2996+
complexity = complexity + 0.45
2997+
end
2998+
end
2999+
end
3000+
if #cards > 5 then
3001+
complexity = complexity * 1.25 ^ (#cards - 5)
3002+
end
3003+
complexity = complexity * 0.75
3004+
local mult = complexity
3005+
local chips = complexity * 8.45 --arbitrary just shake it up a little
3006+
local l_mult = complexity * 0.1
3007+
local l_chips = complexity
3008+
local declare_cards = {}
3009+
for i, v in pairs(cards) do
3010+
local card = {
3011+
rank = v:get_id() > 0 and v:get_id() or "rankless",
3012+
suit = not suitless and (SMODS.has_no_suit(v) and "suitless" or v.base.suit),
3013+
}
3014+
declare_cards[#declare_cards + 1] = card
3015+
end
3016+
for i, v in pairs(G.GAME.hands) do
3017+
v.order = (v.order or 0) + 1
3018+
end
3019+
local desc = localize("cry_Declare" .. tostring(G.GAME.DECLARE_USED or 0), "poker_hand_descriptions")
3020+
desc[#desc + 1] = localize("cry_code_suitless")
3021+
return {
3022+
order = 1,
3023+
l_mult = l_mult,
3024+
l_chips = l_chips,
3025+
mult = mult,
3026+
chips = chips,
3027+
example = Cryptid.create_declare_example(cards, suitless),
3028+
visible = true,
3029+
played = 0,
3030+
_saved_d_v = true,
3031+
played_this_round = 0,
3032+
s_mult = mult,
3033+
s_chips = chips,
3034+
from_declare = true,
3035+
declare_cards = declare_cards,
3036+
declare_name = G.ENTERED_CARD,
3037+
level = 1,
3038+
index = G.GAME.DECLARE_USED or 0,
3039+
desc_text = suitless and desc or nil,
3040+
}
3041+
end
3042+
local localize_ref = localize
3043+
function localize(first, second, ...)
3044+
if second == "poker_hands" then
3045+
if G and G.GAME and G.GAME.hands[first] and G.GAME.hands[first].declare_name then
3046+
return G.GAME.hands[first].declare_name
3047+
end
3048+
end
3049+
if second == "poker_hand_descriptions" then
3050+
if G and G.GAME and G.GAME.hands[first] and G.GAME.hands[first].desc_text then
3051+
return G.GAME.hands[first].desc_text
3052+
end
3053+
end
3054+
return localize_ref(first, second, ...)
3055+
end
3056+
local is_visibleref = SMODS.is_poker_hand_visible
3057+
function SMODS.is_poker_hand_visible(handname)
3058+
if not SMODS.PokerHands[handname] then
3059+
return G.GAME.hands[handname].visible
3060+
end
3061+
return is_visibleref(handname)
3062+
end
3063+
function Cryptid.create_declare_example(cards, suitless)
3064+
local c = {}
3065+
for i, v in pairs(cards) do
3066+
local key = SMODS.Suits[v.base.suit].card_key .. "_" .. SMODS.Ranks[v.base.value].card_key
3067+
local enhancement = (SMODS.has_no_suit(v) and "m_stone") or (suitless and "m_wild") or nil
3068+
c[#c + 1] = { key, true, enhancement = enhancement }
3069+
end
3070+
return c
3071+
end
3072+
end,
3073+
}
3074+
28233075
-- ://Class
28243076
-- Change a selected card's enhancement to one of your choosing (or nil)
28253077

@@ -4719,6 +4971,7 @@ local code_cards = {
47194971
cryfunction,
47204972
function_sticker,
47214973
run,
4974+
declare,
47224975
class,
47234976
global,
47244977
global_sticker,

lib/ascended.lua

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,24 +134,37 @@ function G.FUNCS.get_poker_hand_info(_cards)
134134
["cry_Clusterfuck"] = 8,
135135
["cry_UltPair"] = 8,
136136
["cry_WholeDeck"] = 52,
137+
["cry_Declare0"] = G.GAME.hands.cry_Declare0
138+
and G.GAME.hands.cry_Declare0.declare_cards
139+
and #G.GAME.hands.cry_Declare0.declare_cards,
140+
["cry_Declare1"] = G.GAME.hands.cry_Declare1
141+
and G.GAME.hands.cry_Declare1.declare_cards
142+
and #G.GAME.hands.cry_Declare1.declare_cards,
143+
["cry_Declare2"] = G.GAME.hands.cry_Declare2
144+
and G.GAME.hands.cry_Declare2.declare_cards
145+
and #G.GAME.hands.cry_Declare2.declare_cards,
137146
}
138-
-- Change mult and chips colors if hand is ascended
139-
if hand_table[text] and next(scoring_hand) and #scoring_hand > hand_table[text] and not hidden then
140-
ease_colour(G.C.UI_CHIPS, copy_table(G.C.GOLD), 0.3)
141-
ease_colour(G.C.UI_MULT, copy_table(G.C.GOLD), 0.3)
142-
else
143-
ease_colour(G.C.UI_CHIPS, G.C.BLUE, 0.3)
144-
ease_colour(G.C.UI_MULT, G.C.RED, 0.3)
145-
end
146147
-- this is where all the logic for asc hands is. currently it's very simple but if you want more complex logic, here's the place to do it
147148
if hand_table[text] and Cryptid.enabled("set_cry_poker_hand_stuff") == true then
148149
G.GAME.current_round.current_hand.cry_asc_num = G.GAME.used_vouchers.v_cry_hyperspacetether
149150
and #_cards - hand_table[text]
150151
or #scoring_hand - hand_table[text]
152+
153+
if G.GAME.hands[text] and G.GAME.hands[text].declare_cards then
154+
G.GAME.current_round.current_hand.cry_asc_num = G.GAME.current_round.current_hand.cry_asc_num
155+
+ (Cryptid.declare_hand_ascended_counter(_cards, G.GAME.hands[text]) - #scoring_hand)
156+
end
151157
else
152158
G.GAME.current_round.current_hand.cry_asc_num = 0
153159
end
154-
160+
-- Change mult and chips colors if hand is ascended
161+
if G.GAME.current_round.current_hand.cry_asc_num > 0 and not hidden then
162+
ease_colour(G.C.UI_CHIPS, copy_table(G.C.GOLD), 0.3)
163+
ease_colour(G.C.UI_MULT, copy_table(G.C.GOLD), 0.3)
164+
else
165+
ease_colour(G.C.UI_CHIPS, G.C.BLUE, 0.3)
166+
ease_colour(G.C.UI_MULT, G.C.RED, 0.3)
167+
end
155168
G.GAME.current_round.current_hand.cry_asc_num = math.max(0, G.GAME.current_round.current_hand.cry_asc_num)
156169
if G.GAME.cry_exploit_override then
157170
G.GAME.current_round.current_hand.cry_asc_num = G.GAME.current_round.current_hand.cry_asc_num + 1

lib/misc.lua

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,3 +1392,38 @@ create_UIBox_your_collection_seals_pointer = function()
13921392
end,
13931393
})
13941394
end
1395+
1396+
function Cryptid.declare_hand_ascended_counter(hand, declarehand)
1397+
local total = 0
1398+
for i, v in pairs(declarehand.declare_cards or {}) do
1399+
local how_many_fit = 0
1400+
local suit
1401+
local rank
1402+
for i2, v2 in pairs(hand) do
1403+
if not v2.marked then
1404+
if SMODS.has_no_rank(v2) and v.rank == "rankless" or v2:get_id() == v.rank then
1405+
rank = true
1406+
end
1407+
if v2:is_suit(v.suit) or (v.suit == "suitless" and SMODS.has_no_suit(v2)) or not v.suit then
1408+
suit = true
1409+
end
1410+
if not (suit and rank) then
1411+
suit = false
1412+
rank = false
1413+
end
1414+
if suit and rank then
1415+
how_many_fit = how_many_fit + 1
1416+
v2.marked = true
1417+
end
1418+
end
1419+
end
1420+
if not rank or not suit then
1421+
how_many_fit = 0
1422+
end
1423+
total = total + how_many_fit
1424+
end
1425+
for i2, v2 in pairs(hand) do
1426+
v2.marked = nil
1427+
end
1428+
return total
1429+
end

0 commit comments

Comments
 (0)