@@ -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 ,
0 commit comments