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