forked from the-Astra/Maximus
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
1648 lines (1438 loc) · 47.8 KB
/
main.lua
File metadata and controls
1648 lines (1438 loc) · 47.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- CONFIG
--#region Config --------------------------------------------------------------------------------------------
Maximus = SMODS.current_mod
Maximus_path = SMODS.current_mod.path
Maximus_config = SMODS.current_mod.config
-- Config Menu
Maximus.config_tab = function()
return {
n = G.UIT.ROOT,
config = { align = "m", r = 0.1, padding = 0.1, colour = G.C.BLACK, minw = 8, minh = 6 },
nodes = {
{ n = G.UIT.R, config = { align = "cl", padding = 0, minh = 0.1 }, nodes = {} },
-- 4D Ticking Toggle
{
n = G.UIT.R,
config = { align = "cl", padding = 0 },
nodes = {
{
n = G.UIT.C,
config = { align = "cl", padding = 0.05 },
nodes = {
create_toggle { col = true, label = "", scale = 1, w = 0, shadow = true, ref_table = Maximus_config, ref_value = "four_d_ticks" },
}
},
{
n = G.UIT.C,
config = { align = "c", padding = 0 },
nodes = {
{ n = G.UIT.T, config = { text = localize('b_mxms_4d_ticking'), scale = 0.45, colour = G.C.UI.TEXT_LIGHT } },
}
},
}
},
-- Maximus Jokers Only toggle
{
n = G.UIT.R,
config = { align = "cl", padding = 0 },
nodes = {
{
n = G.UIT.C,
config = { align = "cl", padding = 0.05 },
nodes = {
create_toggle { col = true, label = "", scale = 1, w = 0, shadow = true, ref_table = Maximus_config, ref_value = "only_maximus_jokers" },
}
},
{
n = G.UIT.C,
config = { align = "c", padding = 0 },
nodes = {
{ n = G.UIT.T, config = { text = localize('b_mxms_only_maximus_jokers'), scale = 0.45, colour = G.C.UI.TEXT_LIGHT } },
}
},
}
},
{ n = G.UIT.R, config = { minh = 0.04, minw = 4, colour = G.C.L_BLACK } },
-- Custom Menu Toggle
{
n = G.UIT.R,
config = { align = "cl", padding = 0 },
nodes = {
{
n = G.UIT.C,
config = { align = "cl", padding = 0.05 },
nodes = {
create_toggle { col = true, label = "", scale = 1, w = 0, shadow = true, ref_table = Maximus_config, ref_value = "menu" },
}
},
{
n = G.UIT.C,
config = { align = "c", padding = 0 },
nodes = {
{ n = G.UIT.T, config = { text = localize('b_mxms_custom_menu'), scale = 0.45, colour = G.C.UI.TEXT_LIGHT } },
}
},
}
},
-- Horoscopes Toggle
{
n = G.UIT.R,
config = { align = "cl", padding = 0 },
nodes = {
{
n = G.UIT.C,
config = { align = "cl", padding = 0.05 },
nodes = {
create_toggle { col = true, label = "", scale = 1, w = 0, shadow = true, ref_table = Maximus_config, ref_value = "horoscopes" },
}
},
{
n = G.UIT.C,
config = { align = "c", padding = 0 },
nodes = {
{ n = G.UIT.T, config = { text = localize('b_mxms_enable_horoscopes'), scale = 0.45, colour = G.C.UI.TEXT_LIGHT } },
}
},
}
},
-- New Handtypes Toggle
{
n = G.UIT.R,
config = { align = "cl", padding = 0 },
nodes = {
{
n = G.UIT.C,
config = { align = "cl", padding = 0.05 },
nodes = {
create_toggle { col = true, label = "", scale = 1, w = 0, shadow = true, ref_table = Maximus_config, ref_value = "new_handtypes" },
}
},
{
n = G.UIT.C,
config = { align = "c", padding = 0 },
nodes = {
{ n = G.UIT.T, config = { text = localize('b_mxms_enable_handtypes'), scale = 0.45, colour = G.C.UI.TEXT_LIGHT } },
}
},
}
},
{
n = G.UIT.R,
config = { align = "cm", padding = 0.5 },
nodes = {
{ n = G.UIT.T, config = { text = localize('b_mxms_restart_settings'), scale = 0.40, colour = G.C.UI.TEXT_LIGHT } },
}
},
}
}
end
-- Credits Tab - Derived from Joyous Spring credits tab
SMODS.current_mod.extra_tabs = function()
return {
{
label = localize('b_mxms_credits'),
tab_definition_function = function()
local modNodes = {}
modNodes[#modNodes + 1] = {}
local loc_vars = { background_colour = G.C.CLEAR, text_colour = G.C.WHITE, scale = 1.4 }
localize { type = 'descriptions', key = 'mxms_credits', set = 'Other', nodes = modNodes[#modNodes], vars = loc_vars.vars, scale = loc_vars.scale, text_colour = loc_vars.text_colour, shadow = loc_vars.shadow }
modNodes[#modNodes] = desc_from_rows(modNodes[#modNodes])
modNodes[#modNodes].config.colour = loc_vars.background_colour or modNodes[#modNodes].config.colour
return {
n = G.UIT.ROOT,
config = {
emboss = 0.05,
minh = 6,
r = 0.1,
minw = 6,
align = "tm",
padding = 0.2,
colour = G.C.BLACK
},
nodes = modNodes
}
end
}
}
end
-- load update.lua
assert(SMODS.load_file("update.lua"))()
--#endregion
--#region SMODS Optional Features ---------------------------------------------------------------------------
SMODS.current_mod.optional_features = { retrigger_joker = true, post_trigger = true, cardareas = { unscored = true } }
--#endregion
--#region Menu stuff ----------------------------------------------------------------------------------------
local oldfunc = Game.main_menu
Game.main_menu = function(change_context)
local ret = oldfunc(change_context)
if Maximus_config.menu then
-- Creates Maximus Logo Sprite
local SC_scale = 1.1 * (G.debug_splash_size_toggle and 0.8 or 1)
G.SPLASH_MAXIMUS_LOGO = Sprite(0, 0,
6 * SC_scale,
6 * SC_scale * (G.ASSET_ATLAS["mxms_logo"].py / G.ASSET_ATLAS["mxms_logo"].px),
G.ASSET_ATLAS["mxms_logo"], { x = 0, y = 0 }
)
G.SPLASH_MAXIMUS_LOGO:set_alignment({
major = G.title_top,
type = 'cm',
bond = 'Strong',
offset = { x = 0, y = 3 }
})
G.SPLASH_MAXIMUS_LOGO:define_draw_steps({ {
shader = 'dissolve',
} })
-- Define logo properties
G.SPLASH_MAXIMUS_LOGO.tilt_var = { mx = 0, my = 0, dx = 0, dy = 0, amt = 0 }
G.SPLASH_MAXIMUS_LOGO.dissolve_colours = { Maximus.C.MXMS_PRIMARY, Maximus.C.MXMS_SECONDARY }
G.SPLASH_MAXIMUS_LOGO.dissolve = 1
G.SPLASH_MAXIMUS_LOGO.states.collide.can = true
-- Define node functions for Maximus Logo
function G.SPLASH_MAXIMUS_LOGO:click()
play_sound('button', 1, 0.3)
G.FUNCS['openModUI_Maximus']()
end
function G.SPLASH_MAXIMUS_LOGO:hover()
G.SPLASH_MAXIMUS_LOGO:juice_up(0.05, 0.03)
play_sound('paper1', math.random() * 0.2 + 0.9, 0.35)
Node.hover(self)
end
function G.SPLASH_MAXIMUS_LOGO:stop_hover() Node.stop_hover(self) end
--Logo animation
G.E_MANAGER:add_event(Event({
trigger = 'after',
delay = change_context == 'splash' and 3.6 or change_context == 'game' and 4 or 1,
blockable = false,
blocking = false,
func = (function()
play_sound('magic_crumple' .. (change_context == 'splash' and 2 or 3),
(change_context == 'splash' and 1 or 1.3), 0.9)
play_sound('whoosh1', 0.2, 0.8)
ease_value(G.SPLASH_MAXIMUS_LOGO, 'dissolve', -1, nil, nil, nil,
change_context == 'splash' and 2.3 or 0.9)
G.VIBRATION = G.VIBRATION + 1.5
return true
end)
}))
-- adds a James to the main menu
local newcard = create_card('Joker', G.title_top, nil, nil, nil, nil, 'j_mxms_normal', 'astra')
-- recenter the title
G.title_top.T.w = G.title_top.T.w * 1.7675
G.title_top.T.x = G.title_top.T.x - 0.8
G.title_top:emplace(newcard)
-- make the card look the same way as the title screen Ace of Spades
newcard.T.w = newcard.T.w * 1.1 * 1.2
newcard.T.h = newcard.T.h * 1.1 * 1.2
newcard.no_ui = true
newcard.states.visible = false
-- make the title screen use different background colors
G.SPLASH_BACK:define_draw_steps({ {
shader = 'splash',
send = {
{ name = 'time', ref_table = G.TIMERS, ref_value = 'REAL_SHADER' },
{ name = 'vort_speed', val = 0.4 },
{ name = 'colour_1', ref_table = Maximus.C, ref_value = 'MXMS_PRIMARY' },
{ name = 'colour_2', ref_table = Maximus.C, ref_value = 'MXMS_SECONDARY' },
}
} })
-- materialize James
G.E_MANAGER:add_event(Event({
trigger = "after",
delay = 0,
blockable = false,
blocking = false,
func = function()
if change_context == "splash" then
newcard.states.visible = true
newcard:start_materialize({ G.C.WHITE, Maximus.C.MXMS_SECONDARY }, true, 2.5)
else
newcard.states.visible = true
newcard:start_materialize({ G.C.WHITE, Maximus.C.MXMS_SECONDARY }, nil, 1.2)
end
return true
end,
}))
end
Maximus.update_check()
return ret
end
--#endregion
-- ASSETS
--#region Colors --------------------------------------------------------------------------------------------
Maximus.C = {
MXMS_PRIMARY = HEX('7855fc'),
MXMS_SECONDARY = HEX('901b7f'),
HOROSCOPE = HEX('e86fa5'),
SET = {
Horoscope = HEX('d9629c')
},
SECONDARY_SET = {
Horoscope = HEX('a64d79')
}
}
--#endregion
--#region Misc Atlases --------------------------------------------------------------------------------------
SMODS.Atlas { -- Placeholder Atlas
key = 'Placeholder',
path = "placeholders.png",
px = 71,
py = 95
}
SMODS.Atlas { -- Main Modifiers/Backs Atlas
key = 'Modifiers',
path = "Modifiers.png",
px = 71,
py = 95
}
SMODS.Atlas { -- Mod Icon
key = "modicon",
path = "modicon.png",
px = 32,
py = 32
}
SMODS.Atlas { -- Maximus Menu Logo
key = 'logo',
path = 'Maximus_Logo.png',
px = 173,
py = 61
}
if next(SMODS.find_mod("AntePreview")) then -- Ante Preview compat
SMODS.Atlas {
key = 'poker_hands',
path = "Poker Hands.png",
px = 53,
py = 13
}
end
--#endregion
--#region Sounds --------------------------------------------------------------------------------------------
SMODS.Sound({
key = 'perfect',
path = 'perfect.ogg'
})
SMODS.Sound({
key = 'eggsplosion',
path = 'eggsplosion.ogg'
})
SMODS.Sound({
key = 'hey',
path = 'hey.ogg'
})
SMODS.Sound({
key = 'joker',
path = 'i\'m a joker.ogg'
})
SMODS.Sound({
key = 'spirit_beh',
path = 'spirit beh.ogg',
pitch = 0.8
})
SMODS.Sound({
key = 'spirit_miss',
path = 'spirit miss.ogg'
})
SMODS.Sound({
key = 'spirit_ough',
path = 'spirit ough.ogg'
})
SMODS.Sound({
key = 'spirit_pow',
path = 'spirit pow.ogg'
})
SMODS.Sound({
key = 'clown_horn',
path = 'clown horn.ogg'
})
--#endregion
-- CROSS-MOD
--#region Talisman compat -----------------------------------------------------------------------------------
to_big = to_big or function(num)
return num
end
to_number = to_number or function(num)
return num
end
--#endregion
--#region TheFamily compat ----------------------------------------------------------------------------------
if TheFamily and Maximus_config.horoscopes then
TheFamily.create_tab_group({
key = "Maximus",
order = 1,
})
TheFamily.create_tab({
key = "horoscope",
group_key = "Maximus",
type = "switch",
keep = true,
front_label = function(definition, card)
return {
text = localize('b_mxms_stat_horoscopes'),
colour = Maximus.C.HOROSCOPE,
scale = 0.5,
}
end,
center = "c_mxms_taurus",
popup = function(definition, card)
return {
name = {
{
n = G.UIT.T,
config = {
text = localize('b_mxms_stat_horoscopes'),
colour = Maximus.C.HOROSCOPE,
scale = 0.4,
},
},
},
description = {
{
{
n = G.UIT.T,
config = {
text = "Show/Hide the Maximus Horoscope card area",
scale = 0.3,
colour = G.C.BLACK,
},
},
},
},
}
end,
keep_popup_when_highlighted = false,
alert = function(definition, card)
if not G.GAME.horoscope_alert or G.mxms_horoscope.states.visible then
G.GAME.horoscope_alert = false
return {
remove = true,
}
end
return {
text = "!",
}
end,
highlight = function(definition, card)
G.mxms_horoscope.states.visible = true
G.GAME.horoscope_alert = false
end,
unhighlight = function(definition, card)
G.mxms_horoscope.states.visible = false
end,
})
end
--#endregion
--#region JokerDisplay compat -------------------------------------------------------------------------------
if JokerDisplay then
assert(SMODS.load_file("jd_def.lua"))()
end
--#endregion
-- VARIABLES
--#region Misc Variables ------------------------------------------------------------------------------------
if not SMODS.ObjectTypes.Food then
SMODS.ObjectType {
key = 'Food',
default = 'j_egg',
cards = {
j_gros_michel = true,
j_selzer = true,
j_egg = true,
j_ice_cream = true,
j_popcorn = true,
j_cavendish = true,
j_turtle_bean = true,
j_diet_cola = true,
j_ramen = true
},
}
end
Maximus.invert_prob_cards = {
j_gros_michel = true,
j_cavendish = true,
j_mxms_hugo = true,
j_mxms_jestcoin = true,
c_ankh = true,
c_hex = true,
m_glass = true
}
--#endregion
--#region Round Changing Variables --------------------------------------------------------------------------
function SMODS.current_mod.reset_game_globals(run_start)
-- Impractical Joker
if G.GAME.challenge == 'c_mxms_biggest_loser' then
G.GAME.current_round.mxms_impractical_hand = 'Straight Flush'
elseif G.GAME.round ~= 1 then
G.GAME.current_round.mxms_impractical_hand = G.GAME.current_round.mxms_impractical_hand
local valid_hands = {}
for k, v in pairs(G.GAME.hands) do
if v.visible then
valid_hands[#valid_hands + 1] = k
end
end
local new_hand = G.GAME.current_round.mxms_impractical_hand
while new_hand == G.GAME.current_round.mxms_impractical_hand do
new_hand = pseudorandom_element(valid_hands, pseudoseed('impractical' .. G.GAME.round_resets.ante))
end
G.GAME.current_round.mxms_impractical_hand = new_hand
end
-- Marco Polo
if G.GAME.round ~= 1 then
local new_pos = G.GAME.current_round.mxms_marco_polo_pos
if #G.jokers.cards <= 1 then
new_pos = 1
else
while new_pos == G.GAME.current_round.mxms_marco_polo_pos do
new_pos = pseudorandom(pseudoseed('marcopolo' .. G.GAME.round_resets.ante), 1, #G.jokers.cards)
end
end
G.GAME.current_round.mxms_marco_polo_pos = new_pos
end
-- Go Fish
if G.GAME.round ~= 1 then
local valid_ranks = {}
local new_rank = G.GAME.current_round.mxms_go_fish.rank
local new_mult = 0
for k, v in ipairs(G.playing_cards) do
valid_ranks[#valid_ranks + 1] = v.base.value
end
new_rank = pseudorandom_element(valid_ranks, pseudoseed('mxms_go_fish' .. G.GAME.round_resets.ante))
G.GAME.current_round.mxms_go_fish.rank = new_rank
for k, v in ipairs(valid_ranks) do
if v == new_rank then
new_mult = new_mult + 1
end
end
G.GAME.current_round.mxms_go_fish.mult = new_mult * 2
end
-- Zombie
if next(SMODS.find_card('j_mxms_zombie')) and G.GAME.current_round.mxms_zombie_target.card ~= nil then
if not SMODS.is_eternal(G.GAME.current_round.mxms_zombie_target.card) then
G.E_MANAGER:add_event(Event({
func = function()
play_sound('timpani')
delay(0.4)
G.GAME.current_round.mxms_zombie_target.card:set_ability(G.P_CENTERS['j_mxms_zombie'])
G.GAME.current_round.mxms_zombie_target.card:juice_up(0.8, 0.8)
delay(0.4)
SMODS.calculate_effect({ message = localize('k_mxms_turned_ex'), colour = G.C.GREEN },
G.GAME.current_round.mxms_zombie_target.card)
G.GAME.current_round.mxms_zombie_target.card = nil
check_for_unlock({ type = "zombified" })
return true
end
}))
end
end
G.E_MANAGER:add_event(Event({
trigger = 'after',
func = function()
local eligible_jokers = {}
local new_target = G.GAME.current_round.mxms_zombie_target.card
if #G.jokers.cards <= 1 or not next(SMODS.find_card('j_mxms_zombie')) then
new_target = nil
else
for i = 1, #G.jokers.cards do
if G.jokers.cards[i].config.center_key ~= 'j_mxms_zombie' and G.jokers.cards[i] ~= new_target and G.jokers.cards[i].config.center.blueprint_compat then
eligible_jokers[#eligible_jokers + 1] = G.jokers.cards[i]
end
end
if next(eligible_jokers) then
new_target = pseudorandom_element(eligible_jokers,
pseudoseed('zombie' .. G.GAME.round_resets.ante))
else
new_target = nil
end
end
G.GAME.current_round.mxms_zombie_target.card = new_target
if G.GAME.current_round.mxms_zombie_target.card ~= nil then
SMODS.calculate_effect({ message = localize('k_mxms_infected_ex'), colour = G.C.GREEN },
G.GAME.current_round.mxms_zombie_target.card)
end
return true
end
}))
-- Jello
local jello_suits = {}
for k, v in ipairs({ 'Spades', 'Hearts', 'Clubs', 'Diamonds' }) do
if v ~= G.GAME.current_round.mxms_jello_suit then jello_suits[#jello_suits + 1] = v end
end
G.GAME.current_round.mxms_jello_suit = pseudorandom_element(jello_suits,
pseudoseed('jel' .. G.GAME.round_resets.ante))
end
--#endregion
-- FUNCTIONS
--#region Function Hooks ------------------------------------------------------------------------------------
local igo = Game.init_game_object
Game.init_game_object = function(self)
local ret = igo(self)
-- Conditional/tracking Modifiers
ret.mxms_choose_mod = 0
ret.mxms_war_mod = 1
ret.mxms_soy_mod = 0
ret.mxms_purchased_jokers = {}
ret.mxms_gambler_mod = 1
ret.mxms_creep_mod = 1
ret.mxms_last_bought = {
card = nil,
pos = nil
}
ret.mxms_v_destroy_reduction = 0
ret.mxms_shop_price_multiplier = 1
ret.mxms_base_planet_levels = 1
ret.mxms_breadstick_scales = 0
--Rotating Modifiers
ret.current_round.mxms_impractical_hand = 'Straight Flush'
ret.current_round.mxms_marco_polo_pos = 1
ret.current_round.mxms_go_fish = {
rank = "Ace",
mult = 8
}
ret.current_round.mxms_zombie_target = {
card = nil,
pos = nil
}
ret.current_round.mxms_jello_suit = 'Spades'
--Horoscope
ret.mxms_horoscope_buffer = 0
ret.zodiac_killer_pools = {
['Aries'] = true,
['Taurus'] = true,
['Gemini'] = true,
['Cancer'] = true,
['Leo'] = true,
['Virgo'] = true,
['Libra'] = true,
['Scorpio'] = true,
['Sagittarius'] = true,
['Capricorn'] = true,
['Aquarius'] = true,
['Pisces'] = true,
}
ret.astro_last_pack = 1
ret.mxms_aries_bonus = false
ret.mxms_cancer_bonus = 0
ret.mxms_leo_bonus = 0
ret.mxms_virgo_bonus = 0
ret.mxms_libra_bonus = 0
ret.mxms_sagittarius_bonus = false
--Pool Flags
ret.pool_flags.mxms_cavendish_removed = false
return ret
end
-- after_scoring hook; derived from Ortalab
local draw_discard = G.FUNCS.draw_from_play_to_discard
G.FUNCS.draw_from_play_to_discard = function(e)
local obj = G.GAME.blind.config.blind
if obj.after_scoring and not G.GAME.blind.disabled then
obj:after_scoring()
end
draw_discard(e)
end
local save_r = save_run
save_run = function(self)
if G.GAME.current_round.mxms_zombie_target and G.GAME.current_round.mxms_zombie_target.card then
local pos = 1
for k, v in pairs(G.jokers.cards) do
if v == G.GAME.current_round.mxms_zombie_target.card then
G.GAME.current_round.mxms_zombie_target.pos = pos
break
end
pos = pos + 1
end
end
if G.GAME.mxms_last_bought and G.GAME.mxms_last_bought.card then
local pos = 1
for k, v in pairs(G.jokers.cards) do
if v == G.GAME.mxms_last_bought.card then
G.GAME.mxms_last_bought.pos = pos
break
end
pos = pos + 1
end
end
local gutbusters = SMODS.find_card('j_mxms_gutbuster')
if next(gutbusters) then
for i = 1, #gutbusters do
for k, v in ipairs(G.jokers.cards) do
if gutbusters[i].ability.extra.card and v == gutbusters[i].ability.extra.card then
gutbusters[i].ability.extra.pos = k
break
end
end
end
end
save_r(self)
end
local start_r = Game.start_run
---@diagnostic disable-next-line: duplicate-set-field
Game.start_run = function(self, args)
start_r(self, args)
if G.GAME.mxms_last_bought and G.GAME.mxms_last_bought.pos then
G.GAME.mxms_last_bought.card = G.jokers.cards[G.GAME.mxms_last_bought.pos]
G.GAME.mxms_last_bought.pos = nil
end
if G.GAME.current_round.mxms_zombie_target and G.GAME.current_round.mxms_zombie_target.pos then
G.GAME.current_round.mxms_zombie_target.card = G.jokers.cards[G.GAME.current_round.mxms_zombie_target.pos]
G.GAME.current_round.mxms_zombie_target.pos = nil
end
local gutbusters = SMODS.find_card('j_mxms_gutbuster')
if next(gutbusters) then
for i = 1, #gutbusters do
if gutbusters[i].ability.extra.pos then
gutbusters[i].ability.extra.card = G.jokers.cards[gutbusters[i].ability.extra.pos]
gutbusters[i].ability.extra.pos = nil
end
end
end
end
local csc = Card.set_cost
function Card:set_cost()
csc(self)
self.cost = math.floor(self.cost * G.GAME.mxms_shop_price_multiplier)
self.cost = self.cost * G.GAME.mxms_creep_mod
end
-- Prevent other cards from spawning under certain conditions
local atp = SMODS.add_to_pool
function SMODS.add_to_pool(prototype_obj, args)
local ret = atp(prototype_obj, args)
if prototype_obj.set == 'Joker' then
if Maximus.config.only_maximus_jokers and (not prototype_obj.original_mod or prototype_obj.original_mod ~= 'Maximus') then
ret = false
end
if G.GAME.modifiers.mxms_feast and not prototype_obj.pools.Food and prototype_obj.center_key ~= 'j_mxms_microwave' and prototype_obj.center_key ~= 'j_mxms_refrigerator' then
ret = false
end
end
return ret
end
local cubt = create_UIBox_blind_tag
create_UIBox_blind_tag = function(blind_choice, run_info)
if not G.GAME.modifiers.disable_blind_skips then
return cubt(blind_choice, run_info)
end
end
--#endregion
--#region Helper Functions ----------------------------------------------------------------------------------
function Maximus.reset_horoscopes()
if G.GAME.mxms_aries_bonus then
G.GAME.mxms_aries_bonus = false
end
if G.GAME.mxms_cancer_bonus > 0 then
G.GAME.round_resets.hands = G.GAME.round_resets.hands - G.GAME.mxms_cancer_bonus
ease_hands_played(-G.GAME.mxms_cancer_bonus)
G.GAME.mxms_cancer_bonus = 0
end
if G.GAME.mxms_leo_bonus > 0 then
G.hand:change_size(-G.GAME.mxms_leo_bonus)
G.GAME.mxms_leo_bonus = 0
end
if G.GAME.mxms_virgo_bonus > 0 then
G.GAME.round_resets.discards = G.GAME.round_resets.discards - G.GAME.mxms_virgo_bonus
ease_discard(-G.GAME.mxms_virgo_bonus)
G.GAME.mxms_virgo_bonus = 0
end
end
-- Checks if a card should have an inverted check when evaluating prob results
function Maximus.is_invert_prob_check(card)
if card.config and card.config.center then
if Maximus.invert_prob_cards[card.config.center_key] then
return true
elseif next(SMODS.get_enhancements(card)) then
for k, v in pairs(SMODS.get_enhancements(card)) do
if Maximus.invert_prob_cards[v] then
return true
end
end
end
end
return false
end
-- Forces a game over
function Maximus.force_game_over()
G.E_MANAGER:add_event(Event({
delay = 0.2,
func = function()
G.STATE = G.STATES.GAME_OVER
if not G.GAME.seeded and not G.GAME.challenge then
G.PROFILES[G.SETTINGS.profile].high_scores.current_streak.amt = 0
end
G:save_settings()
G.FILE_HANDLER.force = true
G.STATE_COMPLETE = false
return true;
end
}))
end
---Tallies Maximus cards from a given pool and possible subset; Derived from SMODS modCollectionTally
function Maximus.getMaximusTallies(pool, set)
local set = set or nil
local obj_tally = { tally = 0, of = 0 }
for _, v in pairs(pool) do
if v.mod and 'Maximus' == v.mod.id and not v.no_collection then
if set then
if v.set and v.set == set then
obj_tally.of = obj_tally.of + 1
if v.discovered then
obj_tally.tally = obj_tally.tally + 1
end
end
else
obj_tally.of = obj_tally.of + 1
if v.discovered then
obj_tally.tally = obj_tally.tally + 1
end
end
end
end
return obj_tally
end
---Sets Horoscope success stats
function Maximus.set_horoscope_success(card)
if G.PROFILES[G.SETTINGS.profile].horoscope_completions[card.config.center_key] then
G.PROFILES[G.SETTINGS.profile].horoscope_completions[card.config.center_key].count = G.PROFILES
[G.SETTINGS.profile].horoscope_completions[card.config.center_key].count + 1
else
G.PROFILES[G.SETTINGS.profile].horoscope_completions[card.config.center_key] = {
count = 1,
order = card.config.center.order
}
end
G:save_settings()
end
---Returns the name of the most played poker hand
function Maximus.get_most_played_hand()
local _handname, _played, _order = 'High Card', -1, 100
for k, v in pairs(G.GAME.hands) do
if v.played > _played or (v.played == _played and _order > v.order) then
_played = v.played
_handname = k
end
end
return _handname
end
---Returns the range of rank chip values
function Maximus.get_nominal_sum()
local highest, lowest = nil, nil
for k, v in pairs(SMODS.Ranks) do
if not highest and not lowest then
highest = v.nominal
lowest = v.nominal
else
if v.nominal > highest then
highest = v.nominal
elseif v.nominal < lowest then
lowest = v.nominal
end
end
end
return highest + lowest
end
--#endregion
-- CREDITS SYSTEM
--#region Card Credits System (Derived from Cryptid's cry_credits) ------------------------------------------
local smcmb = SMODS.create_mod_badges
function SMODS.create_mod_badges(obj, badges)
smcmb(obj, badges)
if not SMODS.config.no_mod_badges and obj and obj.mxms_credits then
local function calc_scale_fac(text)
local size = 0.9
local font = G.LANG.font
local max_text_width = 2 - 2 * 0.05 - 4 * 0.03 * size - 2 * 0.03
local calced_text_width = 0
-- Math reproduced from DynaText:update_text
for _, c in utf8.chars(text) do
local tx = font.FONT:getWidth(c) * (0.33 * size) * G.TILESCALE * font.FONTSCALE
+ 2.7 * 1 * G.TILESCALE * font.FONTSCALE
calced_text_width = calced_text_width + tx / (G.TILESIZE * G.TILESCALE)
end
local scale_fac = calced_text_width > max_text_width and max_text_width / calced_text_width or 1
return scale_fac
end
if obj.mxms_credits.art or obj.mxms_credits.code or obj.mxms_credits.idea or obj.mxms_credits.custom then
local scale_fac = {}
local min_scale_fac = 1
local strings = { Maximus.display_name }
for _, v in ipairs({ "idea", "art", "code" }) do
if obj.mxms_credits[v] then
if type(obj.mxms_credits[v]) == "string" then obj.mxms_credits[v] = { obj.mxms_credits[v] } end
for i = 1, #obj.mxms_credits[v] do
strings[#strings + 1] =
localize({ type = "variable", key = "mxms_" .. v, vars = { obj.mxms_credits[v][i] } })[1]
end
end
end
if obj.mxms_credits.custom then
strings[#strings + 1] = localize({ type = "variable", key = obj.mxms_credits.custom.key, vars = { obj.mxms_credits.custom.text } })
end
for i = 1, #strings do
scale_fac[i] = calc_scale_fac(strings[i])
min_scale_fac = math.min(min_scale_fac, scale_fac[i])
end
local ct = {}
for i = 1, #strings do
ct[i] = {
string = strings[i],
}
end
local mxms_badge = {
n = G.UIT.R,
config = { align = "cm" },
nodes = {