-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjokers.lua
698 lines (676 loc) · 22.9 KB
/
jokers.lua
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
SMODS.Joker({
key = "swimmers",
config = { mult = 11 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.mult } }
end,
rarity = 2,
pos = { x = 0, y = 0 },
atlas = "jokers",
cost = 4,
blueprint_compat = true,
calculate = function(self, card, context)
if context.cardarea == G.play and context.individual then
local enhancement = nil;
for i = 1, #context.scoring_hand do
if enhancement then
if context.scoring_hand[i].ability.name ~= enhancement then
return {}
end
elseif context.scoring_hand[i].ability.name ~= "Default Base" then
enhancement = context.scoring_hand[i].ability.name
else
return {}
end
end
return { mult = card.ability.mult }
end
end,
})
function lassCount()
local queens = 0
for k, v in ipairs(G.playing_cards or {}) do
if v:is_suit("Clubs") and not SMODS.has_no_rank(v) and v.base.value == "Queen" then
queens = queens + 1
end
end
return queens
end
SMODS.Joker({
key = "lass",
config = { xmult_per_queen = 1 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.xmult_per_queen, math.max(lassCount() * card.ability.xmult_per_queen, 1) } }
end,
rarity = 3,
pos = { x = 1, y = 0 },
atlas = "jokers",
cost = 7,
pools = { clubs_pack = true },
blueprint_compat = true,
calculate = function(self, card, context)
if context.joker_main and lassCount() * card.ability.xmult_per_queen > 1 then
return { xmult = math.max(lassCount() * card.ability.xmult_per_queen, 1) }
end
end,
})
function forbidden_part_added(center, card, from_debuff)
if not (G.GAME.won or G.GAME.win_notified)
then
for k, v in ipairs({ "j_pencil_forbidden_one", "j_pencil_left_arm", "j_pencil_left_leg", "j_pencil_right_arm", "j_pencil_right_leg" }) do
if center.key ~= v and #SMODS.find_card(v) == 0 then
return
end
end
G.GAME.win_notified = true
G.E_MANAGER:add_event(Event({
trigger = 'immediate',
blocking = false,
blockable = false,
func = (function()
win_game()
G.GAME.won = true
return true
end)
}))
end
end
SMODS.Joker({
key = "forbidden_one",
config = { payout = 4 },
loc_vars = function(self, info_queue, card)
table.insert(info_queue, SMODS.Centers.j_pencil_left_arm)
table.insert(info_queue, SMODS.Centers.j_pencil_left_leg)
table.insert(info_queue, SMODS.Centers.j_pencil_right_arm)
table.insert(info_queue, SMODS.Centers.j_pencil_right_leg)
return { vars = { card.ability.payout } }
end,
rarity = 1,
pos = { x = 2, y = 1 },
atlas = "jokers",
cost = 8,
add_to_deck = forbidden_part_added,
calc_dollar_bonus = function(self, card)
return card.ability.payout
end
})
SMODS.Joker({
key = "left_arm",
config = { xchips = 2.5 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.xchips } }
end,
rarity = 1,
pos = { x = 3, y = 1 },
atlas = "jokers",
cost = 6,
blueprint_compat = true,
add_to_deck = forbidden_part_added,
calculate = function(self, card, context)
if context.joker_main then
return { xchips = card.ability.xchips }
end
end,
})
SMODS.Joker({
key = "left_leg",
config = { chips = 50 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.chips } }
end,
rarity = 1,
pos = { x = 4, y = 1 },
atlas = "jokers",
cost = 5,
blueprint_compat = true,
add_to_deck = forbidden_part_added,
calculate = function(self, card, context)
if context.joker_main then
return { chips = card.ability.chips }
end
end,
})
SMODS.Joker({
key = "right_arm",
config = { xmult = 1.5 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.xmult } }
end,
rarity = 1,
pos = { x = 1, y = 1 },
atlas = "jokers",
cost = 6,
blueprint_compat = true,
add_to_deck = forbidden_part_added,
calculate = function(self, card, context)
if context.joker_main then
return { xmult = card.ability.xmult }
end
end,
})
SMODS.Joker({
key = "right_leg",
config = { mult = 10 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.mult } }
end,
rarity = 1,
pos = { x = 0, y = 1 },
atlas = "jokers",
cost = 5,
blueprint_compat = true,
add_to_deck = forbidden_part_added,
calculate = function(self, card, context)
if context.joker_main then
return { mult = card.ability.mult }
end
end,
})
SMODS.Joker({
key = "doodlebob",
config = { chips_per_index = 10 },
loc_vars = function(self, info_queue, card)
return {
vars = {
card.ability.chips_per_index,
G.GAME.consumeable_usage_total and G.GAME.consumeable_usage_total.pencil_index and
card.ability.chips_per_index * G.GAME.consumeable_usage_total.pencil_index or 0,
}
}
end,
rarity = 1,
pos = { x = 2, y = 0 },
atlas = "jokers",
cost = 5,
blueprint_compat = true,
calculate = function(self, card, context)
if context.joker_main and G.GAME.consumeable_usage_total and G.GAME.consumeable_usage_total.pencil_index and G.GAME.consumeable_usage_total.pencil_index > 0 then
return { chips = card.ability.chips_per_index * G.GAME.consumeable_usage_total.pencil_index }
elseif context.using_consumeable and not context.blueprint and context.consumeable.ability.set == "index" then
return { message = localize({ type = "variable", key = "a_chips", vars = { card.ability.chips_per_index * G.GAME.consumeable_usage_total.pencil_index } }) }
end
end,
})
SMODS.Joker({
key = "pencil",
rarity = 4,
pos = { x = 3, y = 0 },
soul_pos = { x = 4, y = 0 },
atlas = "jokers",
cost = 20,
blueprint_compat = true,
calculate = function(self, card, context)
if context.using_consumeable and context.consumeable.ability.set ~= "index" then
G.E_MANAGER:add_event(Event({
trigger = 'after',
delay = 0.4,
func = function()
if G.consumeables.config.card_limit > #G.consumeables.cards then
play_sound('timpani')
SMODS.add_card({ set = "index" })
card:juice_up(0.3, 0.5)
end
return true
end
}))
end
end,
})
SMODS.Joker({
key = "forty_seven",
rarity = 3,
config = { factor = 1 },
loc_vars = function(self, info_queue, card)
if card.ability.factor == 1 then
return { vars = { "once" } }
elseif card.ability.factor == 2 then
return { vars = { "twice" } }
elseif card.ability.factor == 3 then
return { vars = { "thrice" } }
else
return { vars = { card.ability.factor .. " times" } }
end
end,
pos = { x = 5, y = 0 },
atlas = "jokers",
cost = 11,
blueprint_compat = true,
calculate = function(self, card, context)
if context.repetition and context.cardarea == G.play and context.other_card.base.value == "4" then
local repetitions = 0
local juicers = {}
local juice_i = 1
for k, v in ipairs(G.hand.cards) do
if v.base.value == "7" then
repetitions = repetitions + card.ability.factor
while #juicers < repetitions do
table.insert(juicers, v)
end
end
end
return {
remove_default_message = true,
repetitions = repetitions,
card = card,
func = function()
G.E_MANAGER:add_event(Event({
func = function()
juicers[juice_i]:juice_up(0.3, 0.5)
juice_i = juice_i + 1
return true
end
}))
SMODS.calculate_effect({ message = localize("k_again_ex") }, card)
end
}
end
end,
})
if not next(SMODS.find_mod("Talisman")) then
SMODS.Sound({
key = "echips",
path = "echips.wav"
})
end
SMODS.Joker({
key = "square",
rarity = 4,
config = { exponent = 2 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.exponent } }
end,
pos = { x = 0, y = 2 },
soul_pos = { x = 1, y = 2 },
atlas = "jokers",
cost = 20,
blueprint_compat = true,
calculate = next(SMODS.find_mod("Talisman")) and function(self, card, context)
if context.joker_main then
return { echips = card.ability.exponent }
end
end or function(self, card, context)
if context.joker_main then
return {
fchips = function(chips)
return chips ^ card.ability.exponent
end,
message = localize({ type = "variable", key = "a_echips", vars = { card.ability.exponent } }),
sound = "pencil_echips",
colour = G.C.CHIPS,
}
end
end,
})
SMODS.Joker({
key = "pee_pants",
rarity = 2,
config = { scaling = 4, mult = 0, required_diamonds = 2 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.scaling, card.ability.required_diamonds, card.ability.mult } }
end,
pos = { x = 5, y = 1 },
atlas = "jokers",
cost = 6,
blueprint_compat = true,
perishable_compat = false,
calculate = function(self, card, context)
if context.joker_main then
return { mult = card.ability.mult }
elseif context.before and not context.blueprint and next(context.poker_hands["Two Pair"]) then
local diamonds = 0
for k, v in ipairs(context.scoring_hand) do
if v:is_suit("Diamonds") then
diamonds = diamonds + 1
if diamonds >= card.ability.required_diamonds then
card.ability.mult = card.ability.mult + card.ability.scaling
return { message = localize('k_upgrade_ex'), colour = G.C.MULT }
end
end
end
end
end,
})
SMODS.Joker({
key = "squeeze",
rarity = 1,
config = { chance = 4, rounds = 0 },
loc_vars = function(self, info_queue, card)
return {
vars = { G.GAME.probabilities.normal, card.ability.chance, card.ability.rounds }
}
end,
pos = { x = 3, y = 2 },
atlas = "jokers",
cost = 5,
blueprint_compat = false,
eternal_compat = false,
calculate = function(self, card, context)
if context.end_of_round and not (context.individual or context.repetition or context.blueprint) then
if pseudorandom('j_pencil_squeeze') < G.GAME.probabilities.normal / card.ability.chance then
G.E_MANAGER:add_event(Event({
func = function()
G.jokers:remove_card(card)
card:shatter()
return true
end
}))
return { message = localize('k_cracked_ex') }
else
SMODS.calculate_effect({ message = localize("k_safe_ex") }, card)
card.ability.rounds = card.ability.rounds + 1
card.ability.extra_value = card.ability.extra_value + card.ability.rounds
card:set_cost()
delay(0.4)
return { message = localize("k_val_up"), colour = G.C.MONEY }
end
end
end,
})
SMODS.Joker({
key = "eclipse",
rarity = 2,
config = { gain = 1, loss = 1, mult = 0 },
loc_vars = function(self, info_queue, card)
return {
vars = { card.ability.gain, card.ability.loss, card.ability.mult }
}
end,
pos = { x = 4, y = 2 },
atlas = "jokers",
cost = 6,
pools = { clubs_pack = true },
blueprint_compat = true,
perishable_compat = false,
calculate = function(self, card, context)
if context.cardarea == G.play and context.individual and not context.blueprint then
if context.other_card:is_suit("Clubs") then
card.ability.mult = card.ability.mult + card.ability.gain
return {
message = localize({ type = "variable", key = "a_mult", vars = { card.ability.gain } }),
message_card = card
}
end
if context.other_card:is_suit("Hearts") and card.ability.mult ~= 0 then
card.ability.mult = math.max(card.ability.mult - card.ability.loss, 0)
return {
message = localize({ type = "variable", key = "a_mult_minus", vars = { card.ability.loss } }),
colour = G.C.RED,
message_card = card
}
end
elseif context.joker_main then
return { mult = card.ability.mult }
end
end,
})
SMODS.Joker({
key = "club",
rarity = 4,
config = { xmult = 1.3, retriggers = 3, dead = false },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.xmult, card.ability.retriggers } }
end,
pos = { x = 0, y = 3 },
soul_pos = { x = 1, y = 3 },
atlas = "jokers",
pools = { clubs_legendary = true },
cost = 20,
blueprint_compat = true,
eternal_compat = false,
calculate = function(self, card, context)
if context.cardarea == G.play and context.repetition and not card.ability.dead then
return { repetitions = card.ability.retriggers, card = card }
elseif context.cardarea == G.play and context.individual and not card.ability.dead then
return { x_mult = card.ability.xmult }
elseif context.before then
for k, v in ipairs(context.full_hand) do
if not v:is_suit("Clubs") then
card.ability.dead = true
G.E_MANAGER:add_event(Event({
func = function()
play_sound('tarot1')
card.T.r = -0.2
card:juice_up(0.3, 0.4)
card.states.drag.is = true
card.children.center.pinch.x = true
G.E_MANAGER:add_event(Event({
trigger = 'after',
delay = 0.3,
func = function()
G.jokers:remove_card(card)
card:remove()
return true
end
}))
return true
end
}))
delay(0.4)
return
end
end
end
end,
})
local calendar_date = os.date("*t")
local month_type = -1
if calendar_date.month == 4 or calendar_date.month == 6 or calendar_date.month == 9 or calendar_date.month == 11 then
month_type = 13
elseif calendar_date.month ~= 2 then
month_type = 20
elseif calendar_date.year % 4 == 0 and (calendar_date.year % 100 ~= 0 or calendar_date.year % 400 == 0) then
month_type = 6
end
SMODS.Joker({
key = "calendar",
rarity = 1,
config = { month = calendar_date.month, day = calendar_date.day },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.day, card.ability.month } }
end,
pos = { x = calendar_date.day - 1, y = month_type + calendar_date.wday },
atlas = "calendar",
immutable = true,
cost = 5,
pixel_size = { h = 59 },
blueprint_compat = true,
calculate = function(self, card, context)
if context.joker_main then
return { chips = card.ability.day, mult = card.ability.month }
end
end,
})
SMODS.Sound({
key = "doot",
path = "doot.ogg"
})
SMODS.Joker({
key = "doot",
rarity = 1,
config = { dollars = 5 },
loc_vars = function(self, info_queue, card)
table.insert(info_queue, SMODS.Centers.m_pencil_diseased)
table.insert(info_queue, SMODS.Centers.m_pencil_flagged)
return { vars = { card.ability.dollars } }
end,
pos = { x = 5, y = 2 },
atlas = "jokers",
cost = 4,
blueprint_compat = true,
calculate = function(self, card, context)
if context.before then
local diseased = false
local flagged = false
for k, v in ipairs(context.scoring_hand) do
if SMODS.has_enhancement(v, "m_pencil_diseased") then
diseased = true
end
if SMODS.has_enhancement(v, "m_pencil_flagged") then
flagged = true
end
if diseased and flagged then
G.E_MANAGER:add_event(Event({
func = function()
play_sound("pencil_doot")
return true
end
}))
return { dollars = card.ability.dollars }
end
end
end
end,
pools = { Meme = true }
})
function set_stonehenge(self, card, func)
card.ability.chips = G.PROFILES[G.SETTINGS.profile].pencil_stonehenge or 0
end
SMODS.Joker({
key = "stonehenge",
rarity = 1,
config = { chips = 0, extra = 5 },
loc_vars = function(self, info_queue, card)
return { vars = { card.ability.extra, card.ability.chips } }
end,
pos = { x = 2, y = 3 },
atlas = "jokers",
cost = 6,
blueprint_compat = true,
set_ability = set_stonehenge,
apply_glitched = set_stonehenge,
apply_oversat = set_stonehenge,
add_to_deck = function(self, card, from_debuff)
if not from_debuff then
card.ability.chips = card.ability.chips + card.ability.extra
G.PROFILES[G.SETTINGS.profile].pencil_stonehenge = card.ability.chips
G.E_MANAGER:add_event(Event({
func = function()
SMODS.calculate_effect({ message = localize("k_upgrade_ex"), colour = G.C.CHIPS }, card)
return true
end
}))
end
end,
calculate = function(self, card, context)
if context.joker_main then
return { chips = card.ability.chips }
end
end,
})
function calc_ratio()
if not G.playing_cards then
return
end
local tallies = {}
for k, v in ipairs(G.playing_cards) do
tallies[v.base.suit] = (tallies[v.base.suit] or 0) + 1
end
local most = nil
local active = false
for k, v in pairs(tallies) do
if not most or v > tallies[most] then
most = k
active = true
elseif v == tallies[most] then
active = false
end
end
if active then
return most, tallies[most] / #G.playing_cards
end
end
SMODS.Joker({
key = "ratio",
rarity = 2,
config = { xmult = 1 },
loc_vars = function(self, info_queue, card)
local suit
local ratio
suit, ratio = calc_ratio()
if not suit then
suit = "Inactive"
ratio = 0
end
return { vars = { suit, ratio, card.ability.xmult } }
end,
pos = { x = 2, y = 2 },
atlas = "jokers",
cost = 7,
blueprint_compat = true,
perishable_compat = false,
calculate = function(self, card, context)
if context.before and not context.blueprint then
local suit
local ratio
suit, ratio = calc_ratio()
for k, v in ipairs(context.scoring_hand) do
if v:is_suit(suit) then
card.ability.xmult = 1
return { message = localize('k_reset'), colour = G.C.MULT }
end
end
card.ability.xmult = card.ability.xmult + ratio
return {
message = localize({ type = 'variable', key = 'a_xmult', vars = { card.ability.xmult } }),
colour = G.C.MULT
}
elseif context.joker_main then
return { xmult = card.ability.xmult }
end
end,
})
SMODS.Joker({
key = "commie",
rarity = 2,
pos = { x = 3, y = 3 },
atlas = "jokers",
cost = 9,
blueprint_compat = false,
calculate = function(self, card, context)
if context.before and not context.blueprint then
local targets = {}
local target_total = 0
for k, v in ipairs(context.scoring_hand) do
if not SMODS.has_no_rank(v) then
table.insert(targets, v)
target_total = target_total + v.base.nominal
end
end
if #targets > 0 then
local ranks = {}
for k, v in pairs(SMODS.Ranks) do
table.insert(ranks, v)
end
table.sort(ranks, function(a, b)
return a.nominal == b.nominal and (a.face_nominal or 0) > (b.face_nominal or 0) or
a.nominal < b.nominal
end)
target_total = target_total / #targets
local target_rank = ranks[#ranks]
for k, v in ipairs(ranks) do
if target_total < v.nominal then
if k <= 1 then
sendErrorMessage("Mathematical paradox detected! Aborting calculation...", self.key)
return { message = "ERROR" }
else
target_rank = ranks[k - 1]
break
end
end
end
G.E_MANAGER:add_event(Event({
func = function()
for k, v in ipairs(targets) do
SMODS.change_base(v, nil, target_rank.key)
end
play_sound("gong", 0.94, 0.3)
play_sound("gong", 0.94 * 1.5, 0.2)
play_sound("tarot1", 1.5)
return true
end
}))
return { message = localize("k_balanced"), volume = 0, colour = { 0.8, 0.45, 0.85, 1 } }
end
end
end,
})