forked from stupxd/JensBalatroCollection
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIncantation.lua
More file actions
1364 lines (1275 loc) · 40.3 KB
/
Copy pathIncantation.lua
File metadata and controls
1364 lines (1275 loc) · 40.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
--- STEAMODDED HEADER
--- MOD_NAME: Incantation
--- MOD_ID: incantation
--- MOD_AUTHOR: [jenwalter666, MathIsFun_]
--- MOD_DESCRIPTION: Enables the ability to stack identical consumables.
--- PRIORITY: 89999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
--- BADGE_COLOR: 000000
--- PREFIX: inc
--- VERSION: 0.6.0~dev
--- LOADER_VERSION_GEQ: 1.0.0
Incantation = {consumable_in_use = false, accelerate = false} --will port more things over to this global later, but for now it's going to be mostly empty
local CFG = SMODS.current_mod.config
local MaxStack = 9999
local BulkUseLimit = 9999
local NaiveBulkUseCancel = 100
local AccelerateThreshold = 3
local HardLimit = 9007199254740992
SMODS.current_mod.config_tab = function()
return {n = G.UIT.ROOT, config = {r = 0.1, align = "cm", padding = 0.1, colour = G.C.BLACK, minw = 8, minh = 4}, nodes = {
{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 = 0.85, w = 0, shadow = true, ref_table = CFG, ref_value = "NegativesOnly" },
}},
{n = G.UIT.C, config = { align = "c", padding = 0 }, nodes = {
{ n = G.UIT.T, config = { text = localize('incant_negatives_only'), scale = 0.35, colour = G.C.UI.TEXT_LIGHT }},
}},
}},
{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 = 0.85, w = 0, shadow = true, ref_table = CFG, ref_value = "StackAnything" },
}},
{n = G.UIT.C, config = { align = "c", padding = 0 }, nodes = {
{ n = G.UIT.T, config = { text = localize('incant_stack_anything'), scale = 0.35, colour = G.C.RED }},
}},
}},
{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 = 0.85, w = 0, shadow = true, ref_table = CFG, ref_value = "UnsafeMode" },
}},
{n = G.UIT.C, config = { align = "c", padding = 0 }, nodes = {
{ n = G.UIT.T, config = { text = localize('incant_unsafe_mode'), scale = 0.35, colour = G.C.RED }},
}},
}}
}}
end
local function tablecontains(haystack, needle)
for k, v in pairs(haystack) do
if v == needle then
return true
end
end
return false
end
local Stackable = {
'Planet',
'Tarot',
'Spectral'
}
local StackableIndividual = {
'c_black_hole',
'c_cry_white_hole'
}
local Divisible = {
'Planet',
'Tarot',
'Spectral'
}
local DivisibleIndividual = {
'c_black_hole',
'c_cry_white_hole'
}
local BulkUsable = {
'Planet'
}
local BulkUsableIndividual = {
'c_black_hole',
'c_cry_white_hole'
}
--Allow mods to add/remove their own card types to the list
function AllowStacking(set)
if not tablecontains(Stackable, set) then
table.insert(Stackable, set)
end
end
function AllowStackingIndividual(key)
if not tablecontains(StackableIndividual, key) then
table.insert(StackableIndividual, key)
end
end
function AllowDividing(set)
AllowStacking(set)
if not tablecontains(Divisible, set) then
table.insert(Divisible, set)
end
end
function AllowDividingIndividual(key)
AllowStackingIndividual(key)
if not tablecontains(DivisibleIndividual, key) then
table.insert(DivisibleIndividual, key)
end
end
function AllowBulkUse(set)
AllowStacking(set)
AllowDividing(set)
if not tablecontains(BulkUsable, set) then
table.insert(BulkUsable, set)
end
end
function AllowBulkUseIndividual(key)
AllowStackingIndividual(key)
AllowDividingIndividual(key)
if not tablecontains(BulkUsableIndividual, key) then
table.insert(BulkUsableIndividual, key)
end
end
--[[
+++ MOD SUPPORT SKELETON : ALWAYS INCLUDE THIS IN YOUR MOD'S INITIALISATION SOMEWHERE +++
if not IncantationAddons then
IncantationAddons = {
Stacking = {},
Dividing = {},
BulkUse = {},
StackingIndividual = {},
DividingIndividual = {},
BulkUseIndividual = {}
}
end
then you can use table.insert() to insert sets/keys into the subtables contained within IncantationAddons
]]
if IncantationAddons then
if #IncantationAddons.Stacking > 0 then
for _, v in pairs(IncantationAddons.Stacking) do
AllowStacking(v)
end
end
if #IncantationAddons.StackingIndividual > 0 then
for _, v in pairs(IncantationAddons.StackingIndividual) do
AllowStackingIndividual(v)
end
end
if #IncantationAddons.Dividing > 0 then
for _, v in pairs(IncantationAddons.Dividing) do
AllowDividing(v)
end
end
if #IncantationAddons.DividingIndividual > 0 then
for _, v in pairs(IncantationAddons.DividingIndividual) do
AllowDividingIndividual(v)
end
end
if #IncantationAddons.BulkUse > 0 then
for _, v in pairs(IncantationAddons.BulkUse) do
AllowBulkUse(v)
end
end
if #IncantationAddons.BulkUseIndividual > 0 then
for _, v in pairs(IncantationAddons.BulkUseIndividual) do
AllowBulkUseIndividual(v)
end
end
end
function Card:getQty()
return (self.ability or {}).qty or 1
end
function Card:setQty(quantity)
if not quantity then quantity = 1 end
if self:CanStack() then
if self.ability then
self.ability.qty = math.min(HardLimit, math.floor(quantity))
self:create_stack_display()
self:set_cost()
end
end
end
function Card:addQty(quantity)
self:setQty(self:getQty() + math.floor(quantity))
end
function Card:subQty(quantity, dont_dissolve)
if quantity >= self:getQty() and not dont_dissolve then
self:setQty(0)
self.ignorestacking = true
self:start_dissolve()
else
self:setQty(math.max(0, self:getQty() + math.ceil(quantity)))
end
end
function Card:CanStack()
if self.area and G.consumeables and self.area ~= G.consumeables then
return false
elseif CFG.NegativesOnly and not (self.edition and self.edition.negative) then
return false
elseif CFG.StackAnything then
return true
end
return (self.config.center and (type(self.config.center.can_stack) == 'function' and self.config.center:can_stack() or self.config.center.can_stack)) or tablecontains(Stackable, self.ability.set) or tablecontains(StackableIndividual, self.config.center_key)
end
function Card:CanDivide()
if CFG.StackAnything then
return true
end
return (self.config.center and (type(self.config.center.can_divide) == 'function' and self.config.center:can_divide() or self.config.center.can_divide)) or tablecontains(Divisible, self.ability.set) or tablecontains(DivisibleIndividual, self.config.center_key)
end
function Card:CanBulkUse(ignoreunsafe)
return (not ignoreunsafe and CFG.UnsafeMode) or (self.config.center and (type(self.config.center.can_bulk_use) == 'function' and self.config.center:can_bulk_use() or (self.config.center.can_bulk_use or (self.config.center.bulk_use and (type(self.config.center.bulk_use) == 'function'))))) or tablecontains(BulkUsable, self.ability.set) or tablecontains(BulkUsableIndividual, self.config.center_key)
end
function Card:getmaxuse()
--let modders define their own bulk-use limit in case of concerns with performance
return (self.config.center.bulk_use_limit or UseBulkCap) and math.min((self.config.center.bulk_use_limit or BulkUseLimit), self:getQty()) or (self:getQty())
end
function set_consumeable_usage(card, qty)
qty = math.floor(qty or 1)
if card.config.center_key and card.ability.consumeable then
if G.PROFILES[G.SETTINGS.profile].consumeable_usage[card.config.center_key] then
G.PROFILES[G.SETTINGS.profile].consumeable_usage[card.config.center_key].count = G.PROFILES[G.SETTINGS.profile].consumeable_usage[card.config.center_key].count + qty
else
G.PROFILES[G.SETTINGS.profile].consumeable_usage[card.config.center_key] = {count = 1, order = card.config.center.order}
end
if G.GAME.consumeable_usage[card.config.center_key] then
G.GAME.consumeable_usage[card.config.center_key].count = G.GAME.consumeable_usage[card.config.center_key].count + qty
else
G.GAME.consumeable_usage[card.config.center_key] = {count = 1, order = card.config.center.order, set = card.ability.set}
end
G.GAME.consumeable_usage_total = G.GAME.consumeable_usage_total or {tarot = 0, planet = 0, spectral = 0, tarot_planet = 0, all = 0}
if card.config.center.set == 'Tarot' then
G.GAME.consumeable_usage_total.tarot = G.GAME.consumeable_usage_total.tarot + qty
G.GAME.consumeable_usage_total.tarot_planet = G.GAME.consumeable_usage_total.tarot_planet + qty
elseif card.config.center.set == 'Planet' then
G.GAME.consumeable_usage_total.planet = G.GAME.consumeable_usage_total.planet + qty
G.GAME.consumeable_usage_total.tarot_planet = G.GAME.consumeable_usage_total.tarot_planet + qty
elseif card.config.center.set == 'Spectral' then G.GAME.consumeable_usage_total.spectral = G.GAME.consumeable_usage_total.spectral + qty
end
G.GAME.consumeable_usage_total.all = G.GAME.consumeable_usage_total.all + qty
if not card.config.center.discovered then
discover_card(card)
end
if card.config.center.set == 'Tarot' or card.config.center.set == 'Planet' then
G.E_MANAGER:add_event(Event({
trigger = 'immediate',
func = function()
G.E_MANAGER:add_event(Event({
trigger = 'immediate',
func = function()
G.GAME.last_tarot_planet = card.config.center_key
return true
end
}))
return true
end
}))
end
end
G:save_settings()
end
function Card:split(amount, forced, fullmax)
if not amount then amount = math.floor((self:getQty()) / 2) end
amount = math.max(1, amount)
if (self.ability.qty or 0) > (fullmax and 0 or 1) and (self:CanDivide() or forced) and not self.ignorestacking then
local traysize = G.consumeables.config.card_limit
if (self.edition or {}).negative then
traysize = traysize + 1
end
local split = copy_card(self)
local qty2 = math.min(self.ability.qty - (fullmax and 0 or 1), amount)
G.consumeables.config.card_limit = #G.consumeables.cards + 1
split.ignorestacking = true
split.created_from_split = true
split:add_to_deck()
G.consumeables:emplace(split, nil, nil, true)
split.ability.qty = qty2
self.ability.qty = self.ability.qty - qty2
G.consumeables.config.card_limit = traysize
if qty2 > 1 then
split:create_stack_display()
end
split:set_cost()
self:set_cost()
play_sound('card1')
return split
end
end
function Card:try_merge()
if self:CanStack() and not self.ignorestacking then
for _, v in pairs(G.consumeables.cards) do
if CFG.NegativesOnly and not (v.edition or {}).negative then
-- Ignore this
elseif v ~= self and not v.nomerging and not v.ignorestacking and v.config.center_key == self.config.center_key and (((v.edition or {}).type or '') == ((self.edition or {}).type or '')) and (v:getQty() < (UseStackCap and MaxStack or HardLimit)) then
local space = (UseStackCap and MaxStack or HardLimit) - (v:getQty())
v.ability.qty = (v:getQty()) + math.min((self:getQty()), space)
v:create_stack_display()
v:juice_up(0.5, 0.5)
play_sound('card1')
v:set_cost()
if (self:getQty()) - space < 1 then
self.ignorestacking = true
self.area:remove_card(self)
self:remove()
return true
else
self.ability.qty = (self:getQty()) - space
self:set_cost()
end
end
end
end
end
function Card:getEvalQty()
return self.cardinuse and math.min(self:getQty(), (self.bulkuse and not self.naivebulkuse) and self:getQty() or (self.OverrideBulkUseLimit or NaiveBulkUseCancel)) or self:getQty()
end
local useconsumeref = Card.use_consumeable
function Card:use_consumeable(area, copier)
local obj = self.config.center
local uselim = self.OverrideBulkUseLimit or NaiveBulkUseCancel
local qty = self:getQty()
if qty <= 0 then
self:setQty(1)
qty = 1
end
if self.ability then
self.ability.qty_initial = qty
end
if not self.naivebulkuse and self.bulkuse and obj.bulk_use and type(obj.bulk_use) == 'function' then
set_consumeable_usage(self, qty)
return obj:bulk_use(self, area, copier, qty)
elseif not self.naivebulkuse and self.ability.consumeable.hand_type then
update_hand_text({sound = 'button', volume = 0.7, pitch = 0.8, delay = 0.3}, {handname=localize(self.ability.consumeable.hand_type, 'poker_hands'),chips = G.GAME.hands[self.ability.consumeable.hand_type].chips, mult = G.GAME.hands[self.ability.consumeable.hand_type].mult, level=G.GAME.hands[self.ability.consumeable.hand_type].level})
level_up_hand(copier or self, self.ability.consumeable.hand_type, nil, qty)
update_hand_text({sound = 'button', volume = 0.7, pitch = 1.1, delay = 0}, {mult = 0, chips = 0, handname = '', level = ''})
set_consumeable_usage(self, qty)
elseif not self.naivebulkuse and self.ability.name == 'Black Hole' then
update_hand_text({sound = 'button', volume = 0.7, pitch = 0.8, delay = 0.3}, {handname=localize('k_all_hands'),chips = '...', mult = '...', level=''})
G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.2, func = function()
play_sound('tarot1')
self:juice_up(0.8, 0.5)
G.TAROT_INTERRUPT_PULSE = true
return true end }))
update_hand_text({delay = 0}, {mult = '+', StatusText = true})
G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.9, func = function()
play_sound('tarot1')
self:juice_up(0.8, 0.5)
return true end }))
update_hand_text({delay = 0}, {chips = '+', StatusText = true})
G.E_MANAGER:add_event(Event({trigger = 'after', delay = 0.9, func = function()
play_sound('tarot1')
self:juice_up(0.8, 0.5)
G.TAROT_INTERRUPT_PULSE = nil
return true end }))
update_hand_text({sound = 'button', volume = 0.7, pitch = 0.9, delay = 0}, {level='+' .. qty})
delay(1.3)
for k, v in pairs(G.GAME.hands) do
level_up_hand(self, k, true, qty)
end
update_hand_text({sound = 'button', volume = 0.7, pitch = 1.1, delay = 0}, {mult = 0, chips = 0, handname = '', level = ''})
set_consumeable_usage(self, qty)
else
Incantation.accelerate = qty > AccelerateThreshold or self.force_incantation_acceleration
self.cardinuse = true
Incantation.consumable_in_use = true
local lim = math.min(qty, uselim)
local newqty = math.max(0, qty - lim)
if not self.ability.qty then self.ability.qty = 1 end
for i = 1, lim do
useconsumeref(self,area,copier)
G.E_MANAGER:add_event(Event({
trigger = 'immediate',
delay = 0.1,
blockable = true,
func = function()
self.ability.qty = self.ability.qty - 1
play_sound('button', self.ability.qty <= 0 and 1 or 0.85, 0.7)
return true
end
}))
end
G.E_MANAGER:add_event(Event({
trigger = 'after',
delay = 0.1,
blockable = true,
func = function()
Incantation.consumable_in_use = false
Incantation.accelerate = false
self.cardinuse = nil
self.bulkuse = nil
self.naivebulkuse = nil
self.OverrideBulkUseLimit = nil
if obj.keep_on_use and obj:keep_on_use(self) then
self.ignorestacking = false
self.ability.qty = obj.keep_on_use_retain_stack and qty or (newqty + 1)
else
if newqty > 0 then
self:split(newqty, true, true)
end
end
return true
end
}))
end
end
local startdissolveref = Card.start_dissolve
function Card:start_dissolve(a,b,c,d)
if self.ability.qty and self.ability.qty > 1 and Incantation.consumable_in_use and not self.ignore_incantation_consumable_in_use then return end
self.ignorestacking = true
return startdissolveref(self,a,b,c,d)
end
local usecardref = G.FUNCS.use_card
function CanUseStackButtons()
if ((G.play and #G.play.cards > 0) or (G.CONTROLLER.locked) or (G.GAME.STOP_USE and G.GAME.STOP_USE > 0)) and G.STATE ~= G.STATES.HAND_PLAYED and G.STATE ~= G.STATES.DRAW_TO_HAND and G.STATE ~= G.STATES.PLAY_TAROT then
return false
end
return true
end
G.FUNCS.use_card = function(e, mute, nosave)
local card = e.config.ref_table
local useamount = card.bulkuse and card:getmaxuse() or 1
if ((card.ability or {}).qty or 1) > useamount then
card.highlighted = false
card.bulkuse = false
card.OverrideBulkUseLimit = useamount
end
usecardref(e, mute, nosave)
end
G.FUNCS.can_split_card = function(e)
local card = e.config.ref_table
local splitone = e.config.issplitone
if (card:getQty()) > 1 and card.highlighted and CanUseStackButtons() and not card.ignorestacking then
e.config.colour = splitone and G.C.GREEN or G.C.PURPLE
e.config.button = splitone and 'split_one' or 'split_half'
e.states.visible = true
else
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
e.config.button = nil
e.states.visible = false
end
end
function Card:MergeAvailable()
for k, v in pairs(G.consumeables.cards) do
if v then
if v ~= self and (v.config or {}).center_key == (self.config or {}).center_key and ((v.edition or {}).type or '') == ((self.edition or {}).type or '') then
return true
end
end
end
end
G.FUNCS.can_merge_card = function(e)
local card = e.config.ref_table
if card:CanStack() and card.highlighted and not card.ignorestacking and CanUseStackButtons() and card:MergeAvailable() then
e.config.colour = G.C.BLUE
e.config.button = 'merge_card'
e.states.visible = true
else
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
e.config.button = nil
e.states.visible = false
end
end
G.FUNCS.can_use_all = function(e)
local card = e.config.ref_table
local obj = card.config.center
if card:CanBulkUse() and ((tablecontains(BulkUsable, card.ability.set) or tablecontains(BulkUsableIndividual, card.config.center_key)) or (obj.bulk_use and type(obj.bulk_use) == 'function')) and (card:getQty()) > 1 and card.highlighted and CanUseStackButtons() and not card.ignorestacking then
e.config.colour = G.C.DARK_EDITION
e.config.button = 'use_all'
e.states.visible = true
else
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
e.config.button = nil
e.states.visible = false
end
end
G.FUNCS.can_use_every_planet = function(e)
local card = e.config.ref_table
local obj = card.config.center
if (((card.config or {}).center or {}).set or '') == 'Planet' and card:CanBulkUse() and CanUseStackButtons() and not card.ignorestacking then
e.config.colour = G.C.SECONDARY_SET.Planet
e.config.button = 'use_every_planet'
e.states.visible = true
else
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
e.config.button = nil
e.states.visible = false
end
end
G.FUNCS.can_use_naivebulk = function(e)
local card = e.config.ref_table
local obj = card.config.center
if (card:CanBulkUse() or CFG.UnsafeMode) and (CFG.UnsafeMode or not obj.bulk_use or type(obj.bulk_use) ~= 'function') and (card:getQty()) > 1 and card.highlighted and CanUseStackButtons() and not card.ignorestacking then
e.config.colour = G.C.BLACK
e.config.button = 'use_naivebulk'
e.states.visible = true
else
e.config.colour = G.C.UI.BACKGROUND_INACTIVE
e.config.button = nil
e.states.visible = false
end
end
G.FUNCS.split_half = function(e)
local card = e.config.ref_table
card:split(math.floor(card.ability.qty / 2))
end
G.FUNCS.split_one = function(e)
local card = e.config.ref_table
card:split(1)
end
G.FUNCS.merge_card = function(e)
local card = e.config.ref_table
card:try_merge()
end
G.FUNCS.use_all = function(e)
local card = e.config.ref_table
local obj = card.config.center
if card:CanBulkUse() and (not obj.can_use or obj:can_use(card)) and (card:getQty()) > 1 and card.highlighted then
card.bulkuse = true
G.FUNCS.use_card(e, false, true)
end
end
function runthrough_planets()
for i = 1, #G.play.cards do
local card = G.play.cards[i]
if card then
local obj = card.config.center
if (((card.config or {}).center or {}).set or '') == 'Planet' then
card.bulkuse = card:CanBulkUse() and math.max(1, card:getQty()) > 1
card.force_incantation_acceleration = true
card:use_consumeable(G.consumeables)
if G.betmma_abilities then
for i = 1, #G.betmma_abilities.cards do
G.betmma_abilities.cards[i]:calculate_joker({using_consumeable = true, consumeable = card})
end
end
for i = 1, #G.jokers.cards do
local effects = G.jokers.cards[i]:calculate_joker({using_consumeable = true, consumeable = card})
if (SMODS.Mods['Cryptid'] or {}).can_load and effects and effects.joker_repetitions then
rep_list = effects.joker_repetitions
for z=1, #rep_list do
if type(rep_list[z]) == 'table' and rep_list[z].repetitions then
for r=1, rep_list[z].repetitions do
card_eval_status_text(rep_list[z].card, 'jokers', nil, nil, nil, rep_list[z])
G.jokers.cards[i]:calculate_joker({using_consumeable = true, consumeable = card, retrigger_joker = true})
end
end
end
end
end
G.E_MANAGER:add_event(Event({func = function()
card.ignore_incantation_consumable_in_use = true
card:start_dissolve()
return true
end}))
end
end
end
end
G.FUNCS.use_every_planet = function(e)
local targets = {}
for i = 1, #G.consumeables.cards do
local card = G.consumeables.cards[i]
if card then
local obj = card.config.center
if (((card.config or {}).center or {}).set or '') == 'Planet' and (not obj.can_use or obj:can_use(card)) then
table.insert(targets, card)
end
end
end
for i = 1, #targets do
local card = targets[i]
G.E_MANAGER:add_event(Event({func = function()
if math.ceil(i/2) == i/2 then play_sound('card1') end
card.area:remove_card(card)
G.play:emplace(card)
return true
end}))
end
G.E_MANAGER:add_event(Event({func = function()
runthrough_planets()
return true
end}))
end
G.FUNCS.use_naivebulk = function(e)
local card = e.config.ref_table
local obj = card.config.center
if card:CanBulkUse() and (not obj.can_use or obj:can_use(card)) and (card:getQty()) > 1 and card.highlighted and CFG.UnsafeMode then
card.naivebulkuse = true
card.bulkuse = true
G.FUNCS.use_card(e, false, true)
end
end
G.FUNCS.disablestackdisplay = function(e)
local card = e.config.ref_table
e.states.visible = ((card:getQty()) > 1 and not card.ignorestacking) or card.cardinuse
end
function Card:create_stack_display()
if not self.children.stackdisplay and self:CanStack() and not self.playing_card then
self.children.stackdisplay = UIBox {
definition = {
n = G.UIT.ROOT,
config = {
minh = 0.6,
maxh = 1.2,
minw = 0.5,
maxw = 2,
r = 0.001,
padding = 0.1,
align = 'cm',
colour = adjust_alpha(darken(G.C.BLACK, 0.2), 0.4),
shadow = false,
func = 'disablestackdisplay',
ref_table = self
},
nodes = {
{
n = G.UIT.T,
config = {
text = 'x',
scale = 0.4,
colour = G.C.MULT
}
},
{
n = G.UIT.T,
config = {
ref_table = self.ability,
ref_value = 'qty',
scale = 0.4,
colour = G.C.UI.TEXT_LIGHT
}
}
}
},
config = {
align = 'tm',
bond = 'Strong',
parent = self
},
states = {
collide = { can = false },
drag = { can = true }
}
}
end
end
local card_load_ref = Card.load
function Card:load(cardTable, other_card)
card_load_ref(self, cardTable, other_card)
if self.ability then
if self.ability.qty then
self:create_stack_display()
end
end
end
local deckadd = Card.add_to_deck
function Card:add_to_deck(from_debuff)
deckadd(self, from_debuff)
if G.consumeables then
if self:CanStack() then
if not self.ignorestacking then
G.E_MANAGER:add_event(Event({
trigger = 'after',
delay = 0.1,
blocking = false,
func = function()
if self and self.area and self.area ~= 'shop' and self.area ~= 'pack_cards' then
self:try_merge()
end
return true
end
}))
end
self.ignorestacking = nil
end
end
end
local hlref = Card.highlight
function Card:highlight(is_highlighted)
local isplanet = ((self.ability or {}).set or '') == 'Planet'
if self:CanStack() and self.added_to_deck and not self.ignorestacking then
if is_highlighted then
if isplanet then
self.children.everyplanetbutton = UIBox {
definition = {
n = G.UIT.ROOT,
config = {
minh = 0.3,
maxh = 0.6,
minw = 0.3,
maxw = 4,
r = 0.08,
padding = 0.1,
align = 'cm',
colour = G.C.SECONDARY_SET.Planet,
shadow = true,
button = 'use_every_planet',
func = 'can_use_every_planet',
ref_table = self
},
nodes = {
{
n = G.UIT.T,
config = {
text = 'MASS-USE PLANETS',
scale = 0.3,
colour = G.C.UI.TEXT_LIGHT
}
}
}
},
config = {
align = 'bmi',
offset = {
x = 0,
y = 1
},
bond = 'Strong',
parent = self
}
}
end
self.children.useallbutton = UIBox {
definition = {
n = G.UIT.ROOT,
config = {
minh = 0.3,
maxh = 0.6,
minw = 0.3,
maxw = 4,
r = 0.08,
padding = 0.1,
align = 'cm',
colour = G.C.DARK_EDITION,
shadow = true,
button = 'use_all',
func = 'can_use_all',
ref_table = self
},
nodes = {
{
n = G.UIT.T,
config = {
text = 'BULK USE' .. (CFG.UnsafeMode and ' (NORMAL)' or ''),
scale = 0.3,
colour = G.C.UI.TEXT_LIGHT
}
}
}
},
config = {
align = 'bmi',
offset = {
x = 0,
y = 0.5
},
bond = 'Strong',
parent = self
}
}
self.children.mergebutton = UIBox {
definition = {
n = G.UIT.ROOT,
config = {
minh = 0.3,
maxh = 0.6,
minw = 0.3,
maxw = 4,
r = 0.08,
padding = 0.1,
align = 'cm',
colour = G.C.BLUE,
shadow = true,
button = 'merge_card',
func = 'can_merge_card',
ref_table = self
},
nodes = {
{
n = G.UIT.T,
config = {
text = 'MERGE',
scale = 0.3,
colour = G.C.UI.TEXT_LIGHT
}
}
}
},
config = {
align = 'bmi',
offset = {
x = 0,
y = 1 + (isplanet and 0.5 or 0)
},
bond = 'Strong',
parent = self
}
}
self.children.splithalfbutton = UIBox {
definition = {
n = G.UIT.ROOT,
config = {
minh = 0.3,
maxh = 0.6,
minw = 0.3,
maxw = 4,
r = 0.08,
padding = 0.1,
align = 'cm',
colour = G.C.PURPLE,
shadow = true,
button = 'split_half',
func = 'can_split_card',
ref_table = self
},
nodes = {
{
n = G.UIT.T,
config = {
text = 'SPLIT HALF',
scale = 0.3,
colour = G.C.UI.TEXT_LIGHT
}
}
}
},
config = {
align = 'bmi',
offset = {
x = 0,
y = 1.5 + (isplanet and 0.5 or 0)
},
bond = 'Strong',
parent = self
}
}
self.children.splitonebutton = UIBox {
definition = {
n = G.UIT.ROOT,
config = {
minh = 0.3,
maxh = 0.6,
minw = 0.3,
maxw = 4,
r = 0.08,
padding = 0.1,
align = 'cm',
issplitone = true,
colour = G.C.GREEN,
shadow = true,
button = 'split_one',
func = 'can_split_card',
ref_table = self
},
nodes = {
{
n = G.UIT.T,
config = {
text = 'SPLIT ONE',
scale = 0.3,
colour = G.C.UI.TEXT_LIGHT
}
}
}
},
config = {
align = 'bmi',
offset = {
x = 0,
y = 2 + (isplanet and 0.5 or 0)
},
bond = 'Strong',
parent = self
}
}
if CFG.UnsafeMode then
self.children.useallnaivebutton = UIBox {
definition = {
n = G.UIT.ROOT,
config = {
minh = 0.3,
maxh = 0.6,
minw = 0.3,
maxw = 4,
r = 0.08,
padding = 0.1,
align = 'cm',
colour = G.C.BLACK,
shadow = true,
button = 'use_naivebulk',
func = 'can_use_naivebulk',
ref_table = self
},
nodes = {
{
n = G.UIT.T,
config = {
text = 'BULK USE (ONE-AT-A-TIME)',
scale = 0.3,
colour = G.C.RED
}
}
}
},
config = {
align = 'bmi',
offset = {
x = 0,
y = 2.5 + (isplanet and 0.5 or 0)
},
bond = 'Strong',
parent = self
}
}
end
else
if isplanet then
if self.children.everyplanetbutton then self.children.everyplanetbutton:remove();self.children.everyplanetbutton = nil end
end
if self.children.splithalfbutton then self.children.splithalfbutton:remove();self.children.splithalfbutton = nil end
if self.children.splitonebutton then self.children.splitonebutton:remove();self.children.splitonebutton = nil end
if self.children.mergebutton then self.children.mergebutton:remove();self.children.mergebutton = nil end
if self.children.useallbutton then self.children.useallbutton:remove();self.children.useallbutton = nil end
if CFG.UnsafeMode then
if self.children.useallnaivebutton then self.children.useallnaivebutton:remove();self.children.useallnaivebutton = nil end
end
end
end
return hlref(self,is_highlighted)
end
local ccr = copy_card
function copy_card(other, new_card, card_scale, playing_card, strip_edition)
local card = ccr(other, new_card, card_scale, playing_card, strip_edition)
if card then
if card:getQty() <= 0 then card:setQty(1) end
end
card.OverrideBulkUseLimit = nil