-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.lua
More file actions
1444 lines (1290 loc) · 48.3 KB
/
main.lua
File metadata and controls
1444 lines (1290 loc) · 48.3 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
G.Phanta = {}
G.Phanta.centers = {}
G.Phanta.profile_cost = 20 -- Eventually move this to be card-based, so the value can be modified.
G.C.PHANTA = {
Zodiac = HEX("4E5779"),
ZodiacAlt = HEX("5998ff"),
Hanafuda = HEX("DB534A"),
HanafudaAlt = HEX("FB8536")
}
G.C.PHANTA.MISC_COLOURS = {
COPPER_FRESH = HEX("904931"),
COPPER_EXPOSED = HEX("A77762"),
COPPER_WEATHERED = HEX("838A67"),
COPPER_OXIDISED = HEX("4FAB90"),
PHANTA = HEX("4d1575"),
PHANTA_MAIN_MENU_PRIMARY = HEX("4B96A0"),
PHANTA_MAIN_MENU_SECONDARY = HEX("8FFCDB")
}
G.Phanta.thetrick_supported_planets = {
"c_pluto",
"c_mercury",
"c_uranus",
"c_venus",
"c_saturn",
"c_jupiter",
"c_earth",
"c_mars",
"c_neptune",
"c_planet_x",
"c_ceres",
"c_eris",
"c_phanta_rubbish"
}
local loc_colour_ref = loc_colour
function loc_colour(_c, default)
if not G.ARGS.LOC_COLOURS then
loc_colour_ref(_c, default)
elseif not G.ARGS.LOC_COLOURS.phanta_colours then
G.ARGS.LOC_COLOURS.phanta_colours = true
local new_colors = {
copper_fresh = G.C.COPPER_FRESH,
copper_exposed = G.C.COPPER_EXPOSED,
copper_weathered = G.C.COPPER_WEATHERED,
copper_oxidised = G.C.COPPER_OXIDISED,
perishable = G.C.PERISHABLE
}
for k, v in pairs(new_colors) do
G.ARGS.LOC_COLOURS[k] = v
end
end
return loc_colour_ref(_c, default)
end
function phanta_poll_pool(type, append)
local _pool, _pool_key = get_current_pool(type, nil, nil, append)
local center = pseudorandom_element(_pool, pseudoseed(_pool_key))
local it = 1
while center == "UNAVAILABLE" do
it = it + 1
center = pseudorandom_element(_pool, pseudoseed(_pool_key .. "_resample" .. it))
end
return G.P_CENTERS[center]
end
function count_tarots()
local tarot_counter = 0
if G.consumeables then
for _, card in pairs(G.consumeables.cards) do
if card.ability.set == "Tarot" then
tarot_counter = tarot_counter + 1
end
end
end
return tarot_counter
end
function count_planets()
local planet_counter = 0
if G.consumeables then
for _, card in pairs(G.consumeables.cards) do
if card.ability.set == "Planet" then
planet_counter = planet_counter + 1
end
end
end
return planet_counter
end
function get_lowest(hand)
local lowest = nil
for k, v in ipairs(hand) do
if (not lowest or v:get_nominal() < lowest:get_nominal()) and not SMODS.has_no_rank(v) then
lowest = v
end
end
if #hand > 0 then return { { lowest } } else return {} end
end
function count_prognosticators(card)
return #SMODS.find_card("j_phanta_prognosticator") +
(G.GAME.selected_sleeve == "sleeve_phanta_todayandtomorrow" and 1 or 0) +
((card and is_current_month(card) and 2 or 0) * #SMODS.find_card("j_phanta_calendar")) +
(G.GAME and G.GAME.selected_back and G.GAME.selected_back and G.GAME.selected_back.effect and G.GAME.selected_back.effect.center.key == "b_phanta_todayandtomorrow" and 1 or 0)
end
function count_tricks(card)
if #SMODS.find_card("j_phanta_thetrick") == 0 then return 0 end
local supported_by_trick = false
for _, v in ipairs(G.Phanta.thetrick_supported_planets) do
if card.key == v or (card.config and card.config.center and card.config.center.key == v) then
supported_by_trick = true; break
end
end
return supported_by_trick and #SMODS.find_card("j_phanta_thetrick") or 0
end
function count_lucky_cards()
local lucky_counter = 0
if G.playing_cards then
for _, card in pairs(G.playing_cards) do
if SMODS.has_enhancement(card, "m_lucky") then
lucky_counter = lucky_counter + 1
end
end
end
return lucky_counter
end
function get_previous_blind()
if G.GAME.last_blind then
if G.GAME.last_blind.boss then
return "boss"
elseif G.GAME.last_blind.big then
return "big"
end
end
return "small"
end
function count_common_jokers()
if G.jokers then
local counter = 0
for i = 1, #G.jokers.cards do
if G.jokers.cards[i].config.center.rarity == 1 then counter = counter + 1 end
end
return counter
else
return 0
end
end
function count_consumables(args)
if next(SMODS.find_mod('GSCatan')) and args and args.ignore_catan then
local count = 0
for _, v in ipairs(G.consumeables.cards) do
if v.config.center.set ~= "catan_Resource"
and v.config.center.set ~= "catan_Building"
and v.config.center.set ~= "catan_DevelopmentCard" then
count = count + 1
end
end
return count
end
if G.consumeables.get_total_count then
return G.consumeables:get_total_count()
else
return #G.consumeables.cards + G.GAME.consumeable_buffer
end
end
function find_consumable(key)
local found = {}
if G.consumeables then
for _, card in pairs(G.consumeables.cards) do
if card.config.center.key == key then
found[#found + 1] = card
end
end
end
return found
end
function count_rank(rank)
local cards = {}
if G.playing_cards then
for i = 1, #G.playing_cards do
if not SMODS.has_no_rank(G.playing_cards[i]) and G.playing_cards[i]:get_id() == rank then
cards[#cards + 1] = G.playing_cards[i]
end
end
end
return cards
end
function is_current_month(card)
if not card or (not card.month_range and (not card.config or not card.config.center or not card.config.center.month_range)) then return false end
local card_range = card.month_range or card.config.center.month_range
if card_range.first.month < 0 or card_range.first.month > 12 or card_range.first.day < 0 or card_range.first.day > 31 then return false end
if card_range.last.month < 0 or card_range.last.month > 12 or card_range.last.day < 0 or card_range.last.day > 31 then return false end
-- Technically, it's possible to have dates like the 31st of February be valid, but those should work fine anyway.
local t = os.date("*t", os.time())
-- Commenting because I need to think aloud, to grasp this. Also, hi!
-- If the range doesn't wrap around (f <= l), then we can check if the date is <= l, AND >= f.
-- If the range does wrap around (f > l), then we can check if the date is <= l, OR >= f.
-- This works regardless of loopover. Examples:
-- . . F - - a - - L . b .
-- a comes after F, and before L, so it is in the range.
-- b comes after F, but does not come before L, so it is not in the range.
-- - a - L . . c . . F b -
-- a does not come after F, but it does come before L, so it is in the range.
-- b comes after F (and does not come before L, but irrelevant), so it is in the range.
-- c does not come after F, and does not come before L, so it is not in the range.
if orderify_date(card_range.first) <= orderify_date(card_range.last) then
return orderify_date(t) >= orderify_date(card_range.first) and orderify_date(t) <= orderify_date(card_range.last)
else
return orderify_date(t) >= orderify_date(card_range.first) or orderify_date(t) <= orderify_date(card_range.last)
end
end
function orderify_date(date) -- Used above, for convenience.
return (date.month * 100) + date.day
end
function find_current_zodiacs()
local matches = {}
for i, j in pairs(G.P_CENTER_POOLS.phanta_Zodiac) do
if is_current_month({ config = { center = j } }) then matches[#matches + 1] = { set = "phanta_Zodiac", config = { center = j } } end -- Cursed solution, but works.
end
if G.P_CENTER_POOLS.phanta_Birthstone then
for i, j in pairs(G.P_CENTER_POOLS.phanta_Birthstone) do
if is_current_month({ config = { center = j } }) then matches[#matches + 1] = { set = "phanta_Birthstone", config = { center = j } } end
end
end
return matches
end
function get_names_from_zodiacs(cards)
local names = {}
for i = 1, #cards do
names[#names + 1] = localize { type = 'name_text', set = cards[i].set, key = cards[i].config.center.key }
end
return names
end
function count_steel_kings()
local kings = {}
if G.playing_cards then
for i = 1, #G.playing_cards do
if SMODS.has_enhancement(G.playing_cards[i], 'm_steel') and G.playing_cards[i]:get_id() == 13 then
kings[#kings + 1] = G.playing_cards[i]
end
end
end
return kings
end
function is_blind_small()
return G.GAME.blind and G.GAME.blind:get_type() == 'Small'
end
function is_blind_big()
return G.GAME.blind and G.GAME.blind:get_type() == 'Big'
end
function is_blind_boss()
return G.GAME.blind and G.GAME.blind:get_type() == 'Boss'
end
function is_boss_active()
return G and G.GAME and G.GAME.blind and ((not G.GAME.blind.disabled) and (G.GAME.blind:get_type() == 'Boss'))
end
function count_missing_ranks()
if not G.playing_cards then return 0 end
local existing_ranks = {}
for i, j in pairs(G.playing_cards) do
if not SMODS.has_no_rank(j) then
local is_valid = true
for rank = 1, #existing_ranks do
if j:get_id() == existing_ranks[rank] then is_valid = false end
end
if is_valid then existing_ranks[#existing_ranks + 1] = j:get_id() end
end
end
if G.GAME and G.GAME.phanta_initial_ranks and #existing_ranks < #G.GAME.phanta_initial_ranks then
return #G.GAME.phanta_initial_ranks - #existing_ranks
end
return 0
end
function count_base_copper_grates()
if not G.playing_cards then return {} end
local grates = {}
for i, j in pairs(G.playing_cards) do
if (SMODS.has_enhancement(j, 'm_phanta_coppergratefresh')
or SMODS.has_enhancement(j, 'm_phanta_coppergrateexposed')
or SMODS.has_enhancement(j, 'm_phanta_coppergrateweathered')
or SMODS.has_enhancement(j, 'm_phanta_coppergrateoxidised'))
and not (j.edition and j.edition.key ~= nil) then
grates[#grates + 1] = j
end
end
return grates
end
function count_unique_tarots()
local tarots_used = 0
if G.GAME and G.GAME.consumeable_usage then
for k, v in pairs(G.GAME.consumeable_usage) do if v.set == 'Tarot' then tarots_used = tarots_used + 1 end end
end
return tarots_used
end
function count_unique_planets()
local planets_used = 0
if G.GAME and G.GAME.consumeable_usage then
for k, v in pairs(G.GAME.consumeable_usage) do if v.set == 'Planet' then planets_used = planets_used + 1 end end
end
return planets_used
end
function azran_active()
return G.GAME.selected_back.effect.center.key == "b_phanta_azran" or
(G.GAME and G.GAME.selected_sleeve == "sleeve_phanta_azran")
end
function count_boosters()
local boosters = {}
for _, v in ipairs(G.shop_booster.cards) do
if v.config and v.config.center and v.config.center.set == "Booster" then boosters[#boosters + 1] = v end
end
return boosters
end
function set_phanta_new2dsxl_streetpass(card, removed)
local found = SMODS.find_card("j_phanta_new2dsxl")
local count = 0
for _, v in ipairs(found) do
if v ~= card then
count = count + 1
end
end
if count < 1 + (removed and 1 or 0) then
for _, v in ipairs(found) do
if v.flipbook_anim_current_state == "streetpass" then
v:flipbook_set_anim_state("streetpass_off")
end
end
if card.flipbook_anim_current_state == "streetpass" then
card:flipbook_set_anim_state("streetpass_off")
end
else
for _, v in ipairs(found) do
if v.flipbook_anim_current_state ~= "streetpass" then
v:flipbook_set_anim_state("streetpass")
end
end
if card.flipbook_anim_current_state ~= "streetpass" then
card:flipbook_set_anim_state("streetpass")
end
end
end
function phanta_dougdimmadome_count_duplicates()
if not G.playing_cards then return 0 end
local tallies = {}
for i, j in pairs(G.playing_cards) do
if not SMODS.has_no_rank(j) and not SMODS.has_no_suit(j) then
local id = j:get_id()
if not tallies[id] then tallies[id] = {} end
if SMODS.has_any_suit(j) then
tallies[id].wilds = (tallies[id].wilds or 0) + 1
else
for k, v in pairs(SMODS.Suits) do
if j:is_suit(k) then
tallies[id][k] = (tallies[id][k] or 0) + 1
end
end
end
end
end
local largest = { count = 0 }
for r, i in pairs(tallies) do
for s, j in pairs(i) do
if j + (i.wilds or 0) > largest.count then
largest.rank = r
largest.suit = s
largest.count = j + (i.wilds or 0)
end
end
end
if largest.count < 1 then return 0 end
return largest.count - 1
end
local ref1 = Card.start_dissolve
function Card:start_dissolve()
if self.config and self.config.center and self.config.center.phanta_shatters then
return self:shatter()
else
return ref1(self)
end
end
--if not next(SMODS.find_mod('GSFlipbook')) then assert(SMODS.load_file("items/FlipbookFailsafe.lua"))() end
local allFolders = { "none", "items" }
local allFiles = {
["none"] = {},
["items"] = {
"Atlases",
"Sounds",
------------------------------------
"Blinds",
"Boosters",
"Decks",
"Editions",
"Enhancements",
"Zodiacs",
"Hanafudas",
"StarterPacks",
"Jokers1",
"Jokers2",
"Cataclysm",
"DeathNote",
"Legendaries",
"Misc",
"Planets",
"PlanetUpgrades",
"PokerHands",
"Seals",
"Shaders",
"Spectrals",
"Stakes",
"Stickers",
"Suits",
"Tags",
"Tarots",
"Unlocks",
"Vouchers",
"DeckJoker"
}
}
for i = 1, #allFolders do
if allFolders[i] == "none" then
for j = 1, #allFiles[allFolders[i]] do
assert(SMODS.load_file(allFiles[allFolders[i]][j] .. ".lua"))()
end
else
for j = 1, #allFiles[allFolders[i]] do
assert(SMODS.load_file(allFolders[i] .. "/" .. allFiles[allFolders[i]][j] .. ".lua"))()
end
end
end
if next(SMODS.find_mod('Bakery')) then assert(SMODS.load_file("items/Charms.lua"))() end
if next(SMODS.find_mod('partner')) then assert(SMODS.load_file("items/Partners.lua"))() end
if next(SMODS.find_mod('CardSleeves')) then assert(SMODS.load_file("items/Sleeves.lua"))() end
if next(SMODS.find_mod('artbox')) then assert(SMODS.load_file("items/ArtBox.lua"))() end
if next(SMODS.find_mod('entr')) then assert(SMODS.load_file("items/Entropy.lua"))() end
if JokerDisplay then
assert(SMODS.load_file("items/JokerDisplayDefs1.lua"))()
assert(SMODS.load_file("items/JokerDisplayDefs2.lua"))()
assert(SMODS.load_file("items/JokerDisplayDefsLegendaries.lua"))()
end
local aura_enabled = next(SMODS.find_mod('Aura'))
--Then, order everything.
assert(SMODS.load_file("items/Ordering.lua"))()
function SMODS.Consumable:phanta_update_zodiac_level_anim()
if (not self.discovered and not (self.params and self.params.bypass_discovery_center)) or not self.flipbook_anim_extra_states then
return
end
local progs = count_prognosticators(self)
local state = "0"
if progs == 1 then state = "1" end
if progs == 2 then state = "2" end
if progs == 3 then state = "3" end
if progs >= 4 then state = "4+" end
if not self.phanta_prev_prog_count then self.phanta_prev_prog_count = "silly" end
if state ~= self.phanta_prev_prog_count then
self.phanta_prev_prog_count = state
self:flipbook_set_anim_extra_state(state, "extra", true, true)
end
end
function phanta_update_planet_level_anim(center)
if (not center.discovered and not (center.params and center.params.bypass_discovery_center)) or not center.flipbook_anim_extra_states then
return
end
local tricks = count_tricks(center)
local state = "0"
if tricks == 1 then state = "1" end
if tricks == 2 then state = "2" end
if tricks == 3 then state = "3" end
if tricks >= 4 then state = "4+" end
if not center.phanta_prev_trick_count then center.phanta_prev_trick_count = "silly" end
if state ~= center.phanta_prev_trick_count then
center.phanta_prev_trick_count = state
center:flipbook_set_anim_extra_state(state, "extra", true, true)
end
end
local game_start_run_ref = Game.start_run
function Game:start_run(args)
game_start_run_ref(self, args)
G.GAME.phanta_sleepy_rounds = 2
phanta_assign_deck_joker()
G.E_MANAGER:add_event(Event({
func = function()
if not G.playing_cards then return false end
if G.GAME.phanta_initial_ranks then return true end
local existing_ranks = {}
for i, j in pairs(G.playing_cards) do
local is_valid = true
for _, rank in ipairs(existing_ranks) do
if j:get_id() == rank then is_valid = false end
end
if is_valid then existing_ranks[#existing_ranks + 1] = j:get_id() end
end
G.GAME.phanta_initial_ranks = existing_ranks
return true
end
}))
end
function SMODS.current_mod:calculate(context)
if context.end_of_round and not context.repetition and not context.individual then
if #G.deck.cards == 4 then
check_for_unlock({ type = 'phanta_four_cards_remaining' })
end
for i, v in ipairs(G.jokers.cards) do
if v.ability.phanta_sleepy then
v.ability.sleepy_tally = v.ability.sleepy_tally - 1
if v.ability.sleepy_tally > 0 then
card_eval_status_text(v, 'extra', nil, nil, nil,
{
message = localize { type = 'variable', key = 'a_remaining', vars = { v.ability.sleepy_tally } },
colour = G.C.FILTER,
message_card = v
})
else
v.ability.sleepy_tally = 0
v:set_debuff(false)
v.ability.phanta_sleepy = nil
card_eval_status_text(v, 'extra', nil, nil, nil,
{
message = localize('phanta_sleepy_awake'),
colour = G.C.FILTER,
message_card = v
})
end
end
end
end
if context.ending_shop then
G.GAME.current_shop_rerolls = 0
end
if context.remove_playing_cards then
for _, v in ipairs(context.removed) do
if SMODS.has_enhancement(v, "m_phanta_ghostcard") and v.seal == 'phanta_ghostseal' then
check_for_unlock({ type = 'phanta_remove_double_ghost' })
end
end
end
if context.before then
if G.play.cards then
local text, disp_text = G.FUNCS.get_poker_hand_info(G.play.cards)
if text == "phanta_junk" then
for _, v in ipairs(context.scoring_hand) do
if SMODS.has_enhancement(v, "m_steel") then
check_for_unlock({ type = 'phanta_junk_scoring_steel' })
end
end
end
local counted_marbles = 0
for _, v in ipairs(G.play.cards) do
if SMODS.has_enhancement(v, "m_phanta_marblecard") then
counted_marbles = counted_marbles + 1
end
end
if counted_marbles >= 5 then check_for_unlock({ type = 'phanta_five_marbles' }) end
local played_blue = false
local held_blue = false
for _, v in ipairs(G.play.cards) do
if v.seal == "Blue" then
played_blue = true; break
end
end
for _, v in ipairs(G.hand.cards) do
if v.seal == "Blue" then
held_blue = true; break
end
end
if played_blue and held_blue then check_for_unlock({ type = 'phanta_played_and_held_blue' }) end
end
if not G.GAME.phanta_number_of_unscored then G.GAME.phanta_number_of_unscored = 0 end
G.GAME.phanta_number_of_unscored = G.GAME.phanta_number_of_unscored + (#G.play.cards - #context.scoring_hand)
end
if context.reroll_shop and G.GAME.current_shop_rerolls >= 10 then
check_for_unlock({ type = 'phanta_ten_rerolls' })
end
end
local igo = Game.init_game_object
function Game:init_game_object()
local ret = igo(self)
ret.current_round.train_station_card = { id = nil, value = nil }
ret.current_round.fainfol_card = { suit = 'Spades' }
ret.current_round.puzzle_card = { id = nil }
ret.current_round.phanta_widget_suit = 'Clubs'
ret.current_round.datacube_card = { id = nil, value = nil }
return ret
end
local main_menu_ref = Game.main_menu
Game.main_menu = function(change_context)
local ret = main_menu_ref(change_context)
if Phanta.config["custom_title_screen"] then
math.randomseed(os.time())
local rand_x = math.random(0, 2)
local rand_y = math.random(0, 1)
local SC_scale = 1.1 * (G.debug_splash_size_toggle and 0.8 or 1)
G.SPLASH_LOGO_PHANTA_GHOST = Sprite(0, 0,
13 * SC_scale,
13 * SC_scale *
(G.ASSET_ATLAS["phanta_PhantaTitleScreenGhost"].py / G.ASSET_ATLAS["phanta_PhantaTitleScreenGhost"].px),
G.ASSET_ATLAS["phanta_PhantaTitleScreenGhost"], { x = rand_x, y = rand_y }
)
G.SPLASH_LOGO_PHANTA_GHOST:set_alignment({
major = G.title_top,
type = 'cm',
bond = 'Strong',
offset = { x = 0, y = 0 }
})
G.SPLASH_LOGO_PHANTA_GHOST:define_draw_steps({ {
shader = 'dissolve',
} })
G.SPLASH_LOGO_PHANTA_GHOST.dissolve_colours = { G.C.WHITE, G.C.WHITE }
G.SPLASH_LOGO_PHANTA_GHOST.dissolve = 1
G.E_MANAGER:add_event(Event({
trigger = 'after',
delay = change_context == 'splash' and 1.8 or change_context == 'game' and 2 or 0.5,
blockable = false,
blocking = false,
func = (function()
ease_value(G.SPLASH_LOGO_PHANTA_GHOST, 'dissolve', -1, nil, nil, nil,
change_context == 'splash' and 2.3 or 0.9)
G.VIBRATION = G.VIBRATION + 1.5
return true
end)
}))
end
--[[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 = G.C.PHANTA.MISC_COLOURS, ref_value = 'PHANTA_MAIN_MENU_PRIMARY' },
{ name = 'colour_2', ref_table = G.C.PHANTA.MISC_COLOURS, ref_value = 'PHANTA_MAIN_MENU_SECONDARY' },flipbook_set_anim_extra_state
}
} })]] --
for k, v in pairs(G.P_CENTERS) do
if v.set == "phanta_Zodiac" or v.set == "phanta_Birthstone" or v.set == "Planet" then
local valid = true
if v.set == "Planet" then
valid = false
for _, vv in ipairs(G.Phanta.thetrick_supported_planets) do
if vv == v.key then
valid = true
break
end
end
end
if valid then
if not v.flipbook_pos_extra then v.flipbook_pos_extra = { extra = { x = 0, y = 0 } } end
if not v.flipbook_pos_extra.extra.atlas then
if v.set == "phanta_Zodiac" then
v.flipbook_pos_extra.extra.atlas = "phanta_PhantaZodiacUpgrades"
elseif v.set == "phanta_Birthstone" then
v.flipbook_pos_extra.extra.atlas = "phanta_PhantaBirthstoneUpgrades"
elseif v.set == "Planet" then
v.flipbook_pos_extra.extra.atlas = "phanta_PhantaPlanetUpgrades"
end
end
v.flipbook_anim_extra_states = {
extra = {
["0"] = {
anim = {
{ x = 0, y = 0, t = 1 } }
},
["1"] = {
anim = {
{ xrange = { first = 0, last = 3 }, y = 1, t = 0.1 },
{ xrange = { first = 2, last = 1 }, y = 1, t = 0.1 }
}
},
["2"] = {
anim = {
{ xrange = { first = 0, last = 3 }, y = 2, t = 0.1 },
{ xrange = { first = 2, last = 1 }, y = 2, t = 0.1 }
}
},
["3"] = {
anim = {
{ xrange = { first = 0, last = 3 }, y = 3, t = 0.1 },
{ xrange = { first = 2, last = 1 }, y = 3, t = 0.1 }
}
},
["4+"] = {
anim = {
{ xrange = { first = 0, last = 3 }, y = 4, t = 0.1 },
{ xrange = { first = 2, last = 1 }, y = 4, t = 0.1 }
}
}
}
}
v.flipbook_anim_extra_initial_state = "0"
end
end
end
return ret
end
--[[
function Card:phanta_set_anim_state(state)
self.config.center.phanta_anim_current_state = state
self.config.center.phanta_anim_t = 0
end
function Card:phanta_set_anim_extra_state(state)
self.config.center.phanta_anim_extra_current_state = state
self.config.center.phanta_anim_extra_t = 0
end
function SMODS.Center:phanta_set_anim_state(state)
self.config.center.phanta_anim_current_state = state
self.config.center.phanta_anim_t = 0
end
function SMODS.Center:phanta_set_anim_extra_state(state)
self.phanta_anim_extra_current_state = state
self.phanta_anim_extra_t = 0
end
function phanta_set_anim_state(center, state)
center.config.center.phanta_anim_current_state = state
center.config.center.phanta_anim_t = 0
end
function phanta_set_anim_extra_state(center, state)
center.phanta_anim_extra_current_state = state
center.phanta_anim_extra_t = 0
end]] --
function SMODS.current_mod.reset_game_globals(run_start)
G.GAME.current_round.fainfol_card = G.GAME.current_round.fainfol_card or 'Clubs'
local valid_cards_fainfol = {}
for i, j in ipairs(G.playing_cards) do
if not SMODS.has_no_suit(j) and not j:is_suit(G.GAME.current_round.fainfol_card.suit) then
valid_cards_fainfol[#valid_cards_fainfol + 1] = j
end
end
if next(valid_cards_fainfol) then
local chosen_card = pseudorandom_element(valid_cards_fainfol, pseudoseed('fainfol' .. G.GAME.round_resets.ante))
G.GAME.current_round.fainfol_card.suit = chosen_card.base.suit
end
G.GAME.current_round.phanta_widget_suit = G.GAME.current_round.phanta_widget_suit or { suit = 'Spades' }
local valid_cards_widget = {}
for i, j in ipairs(G.playing_cards) do
if not SMODS.has_no_suit(j) and not j:is_suit(G.GAME.current_round.phanta_widget_suit) then
valid_cards_widget[#valid_cards_widget + 1] = j
end
end
if next(valid_cards_widget) then
local chosen_card = pseudorandom_element(valid_cards_widget, pseudoseed('widget' .. G.GAME.round_resets.ante))
G.GAME.current_round.phanta_widget_suit = chosen_card.base.suit
end
if not G.GAME.current_round.train_station_card.id then
G.GAME.current_round.train_station_card.id = 2
elseif G.GAME.current_round.train_station_card.id == 14 then
G.GAME.current_round.train_station_card.id = 2
else
G.GAME.current_round.train_station_card.id = G.GAME.current_round.train_station_card.id + 1
end
local value_table = { '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace' }
G.GAME.current_round.train_station_card.value = value_table[G.GAME.current_round.train_station_card.id - 1]
if not G.GAME.current_round.puzzle_card then G.GAME.current_round.puzzle_card = { id = 2 } end
local valid_cards_puzzle = {}
for i, j in ipairs(G.playing_cards) do
if not SMODS.has_no_rank(j) then
valid_cards_puzzle[#valid_cards_puzzle + 1] = j
end
end
if (get_previous_blind() and get_previous_blind() == "boss") or not G.GAME.last_blind then
if next(valid_cards_puzzle) then
local chosen_card = pseudorandom_element(valid_cards_puzzle, pseudoseed('puzzle' .. G.GAME.round_resets.ante))
G.GAME.current_round.puzzle_card = { id = chosen_card:get_id() }
end
end
if not G.GAME.current_round.datacube_card then G.GAME.current_round.datacube_card = { id = 2, value = "2" } end
local valid_cards_datacube = {}
for i, j in ipairs(G.playing_cards) do
if not SMODS.has_no_rank(j) then
valid_cards_datacube[#valid_cards_datacube + 1] = j
end
end
if next(valid_cards_datacube) then
local chosen_card = pseudorandom_element(valid_cards_datacube, pseudoseed('datacube' .. G.GAME.round_resets.ante))
G.GAME.current_round.datacube_card = { id = chosen_card:get_id(), value = chosen_card.base.value }
end
end
if not Phanta then Phanta = {} end
Phanta.config = SMODS.current_mod.config
if Phanta.config["custom_title_screen"] then
SMODS.Atlas {
key = "balatro",
path = "PhantaLogo.png",
px = 333,
py = 216,
prefix_config = { key = false }
}
end
local phantaConfigTab = function()
phanta_nodes = {}
config = { n = G.UIT.R, config = { align = "tm", padding = 0 }, nodes = { { n = G.UIT.C, config = { align = "tm", padding = 0.05 }, nodes = {} } } }
phanta_nodes[#phanta_nodes + 1] = config
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_junk_enabled"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "junk_enabled",
callback = function()
end,
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_zodiac_enabled"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "zodiac_enabled",
callback = function()
end,
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_hanafuda_enabled"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "hanafuda_enabled",
callback = function()
end,
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_starter_pack_enabled"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "starter_pack_enabled",
callback = function()
end,
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_disable_animations"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "animations_disabled",
callback = function()
end,
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_disable_custom_music"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "custom_music_disabled",
callback = function()
end,
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_custom_title_screen"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "custom_title_screen",
callback = function()
end,
info = { localize("phanta_requires_restart") }
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_copper_grate_expanded"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "copper_grate_expanded",
callback = function()
end,
})
phanta_nodes[#phanta_nodes + 1] = create_toggle({
label = localize("phanta_dougdimmadome_disable_hat"),
active_colour = HEX("40c76d"),
ref_table = Phanta.config,
ref_value = "dougdimmadome_disable_hat",
callback = function()
end,
})
return {
n = G.UIT.ROOT,
config = {
emboss = 0.05,
minh = 6,
r = 0.1,
minw = 10,
align = "cm",
padding = 0.2,
colour = G.C.BLACK,
},
nodes = phanta_nodes,
}
end
-- This DrawStep is courtesy of notmario. (Fix editions with this at some point, I know how to do that.)
SMODS.DrawStep {
key = "doug_hat",
order = -9,
func = function(self)
if not self:should_draw_base_shader() then return nil end
if not (self.config.center.discovered or self.bypass_discovery_center) then return nil end
if self.config.center.key ~= "j_phanta_dougdimmadome" then return nil end
if Phanta.config["dougdimmadome_disable_hat"] then return nil end