Skip to content

Commit 62b67d7

Browse files
committed
add declare
1 parent 2352430 commit 62b67d7

File tree

7 files changed

+416
-9
lines changed

7 files changed

+416
-9
lines changed

assets/1x/atlasnotjokers.png

42 Bytes
Loading

items/challenge.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,14 @@ 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 d0 = true end
491+
end
492+
if not d0 then
493+
table.insert(G.handlist, 1, "cry_Declare0")
494+
table.insert(G.handlist, 1, "cry_Declare1")
495+
table.insert(G.handlist, 1, "cry_Declare2")
496+
end
489497
end
490498
local challenges = {
491499
sticker_sheet,

items/code.lua

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

lib/ascended.lua

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,24 +134,30 @@ 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 and G.GAME.hands.cry_Declare0.declare_cards and #G.GAME.hands.cry_Declare0.declare_cards,
138+
["cry_Declare1"] = G.GAME.hands.cry_Declare1 and G.GAME.hands.cry_Declare1.declare_cards and #G.GAME.hands.cry_Declare1.declare_cards,
139+
["cry_Declare2"] = G.GAME.hands.cry_Declare2 and G.GAME.hands.cry_Declare2.declare_cards and #G.GAME.hands.cry_Declare2.declare_cards
137140
}
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
146141
-- 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
147142
if hand_table[text] and Cryptid.enabled("set_cry_poker_hand_stuff") == true then
148143
G.GAME.current_round.current_hand.cry_asc_num = G.GAME.used_vouchers.v_cry_hyperspacetether
149144
and #_cards - hand_table[text]
150145
or #scoring_hand - hand_table[text]
146+
147+
if G.GAME.hands[text] and G.GAME.hands[text].declare_cards then
148+
G.GAME.current_round.current_hand.cry_asc_num = G.GAME.current_round.current_hand.cry_asc_num + (Cryptid.declare_hand_ascended_counter(_cards, G.GAME.hands[text]) - #scoring_hand)
149+
end
151150
else
152151
G.GAME.current_round.current_hand.cry_asc_num = 0
153152
end
154-
153+
-- Change mult and chips colors if hand is ascended
154+
if G.GAME.current_round.current_hand.cry_asc_num > 0 and not hidden then
155+
ease_colour(G.C.UI_CHIPS, copy_table(G.C.GOLD), 0.3)
156+
ease_colour(G.C.UI_MULT, copy_table(G.C.GOLD), 0.3)
157+
else
158+
ease_colour(G.C.UI_CHIPS, G.C.BLUE, 0.3)
159+
ease_colour(G.C.UI_MULT, G.C.RED, 0.3)
160+
end
155161
G.GAME.current_round.current_hand.cry_asc_num = math.max(0, G.GAME.current_round.current_hand.cry_asc_num)
156162
if G.GAME.cry_exploit_override then
157163
G.GAME.current_round.current_hand.cry_asc_num = G.GAME.current_round.current_hand.cry_asc_num + 1

lib/misc.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,3 +1392,32 @@ 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 rank = true end
1405+
if v2:is_suit(v.suit) or (v.suit == "suitless" and SMODS.has_no_suit(v2)) or not v.suit then suit = true end
1406+
if not (suit and rank) then
1407+
suit = false
1408+
rank = false
1409+
end
1410+
if suit and rank then
1411+
how_many_fit = how_many_fit + 1
1412+
v2.marked = true
1413+
end
1414+
end
1415+
end
1416+
if not rank or not suit then how_many_fit = 0 end
1417+
total = total + how_many_fit
1418+
end
1419+
for i2, v2 in pairs(hand) do
1420+
v2.marked = nil
1421+
end
1422+
return total
1423+
end

localization/en-us.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,15 @@ return {
755755
"{C:cry_code}without{} cashing out",
756756
},
757757
},
758+
c_cry_declare = {
759+
name = "://DECLARE",
760+
text = {
761+
"Your {C:attention}currently{} selected cards",
762+
"become a {C:cry_code}new{} Poker hand which is",
763+
"considered to contain a {C:attention}#1#{}",
764+
"You may create up to {C:attention}3{} {C:inactive}[#2#]{} Hands"
765+
},
766+
},
758767
},
759768
["Content Set"] = {
760769
set_cry_blind = {
@@ -4862,6 +4871,10 @@ return {
48624871
"Are you insane?",
48634872
},
48644873
["cry_None"] = { "A hand containing 0 cards" },
4874+
4875+
["cry_Declare0"] = { "Always counts as a Straight" },
4876+
["cry_Declare1"] = { "Always counts as a Flush" },
4877+
["cry_Declare2"] = { "Always counts as a Full House" },
48654878
},
48664879
achievement_names = {
48674880
ach_cry_ace_in_crash = "Pocket ACE",
@@ -5027,6 +5040,10 @@ return {
50275040
cry_code_create_previous = "CREATE PREVIOUS",
50285041
cry_code_execute = "EXECUTE",
50295042
cry_code_cancel = "CANCEL",
5043+
cry_code_enter_hand = "ENTER POKER HAND NAME",
5044+
cry_code_with_suits = "INCLUDE SUITS",
5045+
cry_code_without_suits = "IGNORE SUITS",
5046+
cry_code_suitless = "Hand does not require specific suits",
50305047

50315048
b_flip = "FLIP",
50325049
b_merge = "MERGE",

0 commit comments

Comments
 (0)