cardpack 0.11.1

Generic Deck of Cards
Documentation
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
use crate::funky::types::hands::HandType;
use crate::prelude::PipType;
use crate::preludes::funky::BCardType;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};

#[derive(
    Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, Deserialize,
)]
pub enum CardLocation {
    #[default]
    Playing,
    InHand,
    InPile,
    Discarded,
    Deleted,
}

#[derive(
    Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, Deserialize,
)]
pub enum MPip {
    #[default]
    Blank,
    AddBaseChips(usize),
    AddCardTypeWhenBlindSelected(BCardType),
    /// A `numerator`-in-`denominator` chance the card is destroyed at end of
    /// round, and **nothing else**. Rolled by
    /// `BuffoonBoard::on_round_end_with_rng` like its compound siblings.
    ///
    /// Prefer a compound variant like
    /// [`MultPlusChanceDestroyed`](Self::MultPlusChanceDestroyed) for any card
    /// that also scores. Encoding only the destruction half is what hid Gros
    /// Michel's +15 mult: the reachability guard classifies by variant, and this
    /// variant legitimately does not score, so a card wearing it is invisible to
    /// the guard whether or not it *should* have scored.
    ChanceDestroyed(usize, usize),
    Chips(usize),
    ChipsMultPlus(usize, usize),
    ChipsMultPlusOnHand(usize, usize, HandType),
    ChipsOnFlush(usize),
    ChipsOnPair(usize),
    ChipsOn2Pair(usize),
    ChipsOnStraight(usize),
    ChipsOnTrips(usize),
    ChipsPerRemainingDiscard(usize),
    ChipsPlusOn5Ranks(usize, [char; 5]),
    CreateCardOnRankPlay(usize, char, BCardType),
    Credit(usize),
    Death(usize),
    DoubleMoney(usize),
    FourFlushAndStraight,
    /// Shortcut: straights may skip a rank (a one-gap straight, e.g. 5-7-9-J-K).
    GappedStraight,
    /// Pareidolia: every card counts as a face card, feeding the face-reading
    /// jokers (Scary Face, Sock and Buskin). No standalone score of its own.
    AllCardsAreFaces,
    /// Smeared Joker: Hearts≡Diamonds and Spades≡Clubs when sizing a flush.
    SmearedSuits,
    /// Splash: every played card scores. Inert in this engine, which already
    /// scores every played card (it has no scoring-vs-kicker distinction).
    AllPlayedCardsScore,
    /// Oops! All 6s: doubles every listed probability (a 1-in-N roll wins twice
    /// as often); stacks, capped at certainty.
    DoubleOdds,
    FreeReroll(usize),
    Glass(usize, usize),
    Gold(usize),
    Hanged(usize),
    JokersValue(usize),
    Lucky(usize, usize),
    MultPlus(usize),
    /// Gros Michel: `+mult` unconditionally, **and** a `numerator`-in-`denominator`
    /// chance the joker is destroyed at end of round —
    /// `MultPlusChanceDestroyed(15, 1, 6)`.
    ///
    /// Compound because one card is one `MPip`, and both halves are the card:
    /// splitting them is what let the mult go missing. The scoring half is a
    /// pure `AddMult`, applied in `builtin_joker_op`. The destruction half
    /// rolls in `BuffoonBoard::on_round_end_with_rng`, routed through
    /// `BuffoonBoard::probability_numerator` so it inherits Oops! All 6s for
    /// free, the way the seeded-RNG path already works.
    MultPlusChanceDestroyed(usize, usize, usize),
    /// Cavendish: ×mult unconditionally, **and** a `numerator`-in-`denominator`
    /// chance the joker is destroyed at end of round —
    /// `MultTimesChanceDestroyed(3, 1, 1000)`. The
    /// [`MultPlusChanceDestroyed`](Self::MultPlusChanceDestroyed) compound
    /// shape, on the ×mult side: the scoring half applies in `joker_x_mult`,
    /// the destruction half rolls in `BuffoonBoard::on_round_end_with_rng`,
    /// routed through `probability_numerator` so Oops! All 6s doubles it.
    MultTimesChanceDestroyed(usize, usize, usize),
    MultPlusChipsOnRank(usize, usize, char),
    MultPlusDoubleValueDestroyJokerOnRight(usize),
    MultPlusOn5Ranks(usize, [char; 5]),
    MultPlusOnConsecutiveHandsNo3Ranks(usize, usize, [char; 3]),
    MultPlusOnFlush(usize),
    MultPlusOnHandPlays,
    MultPlusOnPair(usize),
    MultPlusOn2Pair(usize),
    MultPlusOnStraight(usize),
    MultPlusOnTrips(usize),
    MultPlusOnSuit(usize, char),
    MultPlusOnUpToXCards(usize, usize),
    MultPlusOnZeroDiscards(usize),
    MultPlusXOnLowestRankInHand(usize),
    MultPlusRandomTo(usize),
    MultPlusZeroDiscards(usize),
    MultTimes(usize),
    MultTimesEveryXHands(usize, usize),
    MultTimesOnEmptyJokerSlots(usize),
    MultTimes1Dot(usize),
    MultTimesOnPair(usize),
    MultTimesOnTrips(usize),
    MultTimesOn4OfAKind(usize),
    MultTimesOnStraight(usize),
    MultTimesOnFlush(usize),
    /// ×n mult for **each** played card whose rank is in the set — the factor
    /// compounds (`n^count`). Used by Triboulet (×2 per played King or Queen).
    MultTimesPerScoredRank(usize, [char; 2]),
    /// +n mult for **each** joker on the board (counting the source). Used by
    /// Abstract Joker (+3 per joker).
    MultPlusPerJoker(usize),
    /// +n chips for **each** card remaining in the deck. Used by Blue Joker
    /// (+2 per card in deck).
    ///
    /// Note this reads the **undealt remainder**, not the full deck; contrast
    /// [`ChipsPerFullDeckStone`](Self::ChipsPerFullDeckStone).
    ChipsPerDeckCard(usize),
    /// ×mult that gains ×(n/10) for **each** Steel card in the run's *full*
    /// deck. The factor is additive, not compounding: `1 + (n/10) × count`, so
    /// Steel Joker (`n = 2`) is ×1 with no Steel and ×1.4 with two.
    MultTimesPlusPerFullDeckSteel(usize),
    /// +n chips for **each** Stone card in the run's *full* deck. Used by Stone
    /// Joker (+25 per Stone).
    ChipsPerFullDeckStone(usize),
    /// +n mult for **each** card the run's *full* deck is **below** its
    /// starting size — i.e. per card destroyed. Used by Erosion (+4).
    MultPlusPerMissingDeckCard(usize),
    /// ×(n/10) mult for **each** card of the given rank **held in hand** — the
    /// factor compounds. Used by Baron (×1.5 per held King).
    MultTimesPerHeldRank(usize, char),
    /// +n chips for **each** played face card (J/Q/K). Used by Scary Face (+30).
    ChipsPlusPerScoredFace(usize),
    /// +chips and +mult for **each** played card whose rank is in the set. Used
    /// by Walkie Talkie (+10 chips, +4 mult per played 10 or 4).
    ChipsMultPlusPerScoredRanks(usize, usize, [char; 2]),
    /// ×(n/10) mult for **each** Uncommon joker on the board — compounds. Used
    /// by Baseball Card (×1.5 per Uncommon joker).
    MultTimesPerUncommonJoker(usize),
    /// ×n mult if **every** card held in hand has a suit in the set (vacuously
    /// true when the hand is empty). Used by Blackboard (×3 if all held are
    /// Spades or Clubs).
    MultTimesIfHeldAllSuits(usize, [char; 2]),
    /// +n chips for **each** $1 of money the run holds; debt (negative money)
    /// scores nothing. Used by Bull (+2 chips per dollar).
    ChipsPerDollar(usize),
    /// Earn $n at end of round. Used by Golden Joker ($4). Paid by
    /// `BuffoonBoard::on_round_end`, never by a scoring arm.
    CashOnRoundEnd(usize),
    /// Earn $n per **remaining** discard at end of round, forfeited entirely
    /// if any discard was used this round. Used by Delayed Gratification ($2).
    CashPerDiscardIfNoneUsed(usize),
    /// Earn $n per card of the given rank in the run's **full deck** at end of
    /// round. Used by Cloud 9 ($1 per 9) — destroyed 9s stop paying, added
    /// ones start.
    CashPerFullDeckRank(usize, char),
    /// Earn $n extra interest per $5 held at end of round, capped at the base
    /// interest cap (5 steps); debt earns nothing. Used by To the Moon ($1).
    ExtraInterest(usize),
    /// Earn $cash when at least `min` face cards are discarded at once. Used
    /// by Faceless Joker ($5 at ≥3 faces); Pareidolia widens what counts as a
    /// face, as in Balatro.
    CashOnFacesDiscarded(usize, usize),
    /// +n hand size while held. Used by Juggler (+1). Applied when
    /// `BuffoonBoard::on_blind_selected` recomputes the round's `Draws`.
    HandSizeIncrement(usize),
    /// +n discards per round while held. Used by Drunkard (+1). Applied when
    /// `BuffoonBoard::on_blind_selected` recomputes the round's `Draws`.
    DiscardIncrement(usize),
    /// Burglar: when a Blind is selected, gain +n hands and lose **all**
    /// discards — including any other joker's discard bonus, as in Balatro.
    GainHandsLoseDiscardsWhenBlindSelected(usize),
    /// Green Joker: +n mult per hand played, −n per discard; the accumulator is
    /// the net (hands − discards), the read floors it at 0.
    GainMultPerHandLessDiscard(usize),
    /// Ramen: starts at `base`/100 ×mult and loses `per`/100 per card discarded;
    /// the accumulator counts cards discarded. Read floors at ×1.
    LoseMultTimesPerDiscard(usize, usize),
    /// Ice Cream: starts at `base` chips and loses `per` per hand played; the
    /// accumulator counts hands played. Read floors at 0.
    LoseChipsPerHand(usize, usize),
    /// Square Joker: +`rate` chips per hand played with exactly `n` cards; the
    /// accumulator counts qualifying hands.
    GainChipsPerCardCountHand(usize, usize),
    /// Spare Trousers: +`rate` mult per hand played containing a Two Pair.
    GainMultPerTwoPairHand(usize),
    /// Runner: +`rate` chips per hand played containing a Straight.
    GainChipsPerStraightHand(usize),
    /// Hiker: every played card **permanently** gains `n` chips when scored.
    ///
    /// Unlike its `Gain*` neighbours this is not a counter — nothing accumulates
    /// on the joker. The growth lives on the *cards*: each scored card's base
    /// chips are bumped for the rest of the run, so the joker's contribution is
    /// whatever those fattened cards go on to score. Applied by
    /// `BuffoonBoard::on_scored`, not by a scoring arm.
    GainChipsOnScored(usize),
    /// Popcorn: starts at `base` mult and loses `per` per **round ended**; the
    /// accumulator counts rounds. Read floors at 0, and the joker is destroyed
    /// by the round that empties it — Ice Cream's
    /// [`LoseChipsPerHand`](Self::LoseChipsPerHand) shape on the mult side,
    /// decaying per round rather than per hand.
    LoseMultPerRound(usize, usize),
    /// Yorick: gains `rate`/100 ×mult per `per` **cards discarded** — the
    /// accumulator counts cards, not discard *actions*, so one big discard and
    /// several small ones of the same size are worth the same. Base ×1.
    GainMultTimesPerDiscardedCards(usize, usize),
    /// Hologram: gains `rate`/100 ×mult per playing card **added to the run's
    /// deck** (`BuffoonBoard::add_card_to_deck`). Base ×1.
    GainMultTimesPerCardAdded(usize),
    /// Canio: gains `rate`/100 ×mult per **face card destroyed**
    /// (`BuffoonBoard::destroy_deck_card`), classified through
    /// `BuffoonBoard::is_face_card` — so Pareidolia makes every destroyed card
    /// feed it, as it does Faceless Joker. Base ×1.
    GainMultTimesPerFaceDestroyed(usize),
    /// Riff-Raff: create `n` jokers of the given rarity when a Blind is
    /// selected, **while there is room** — `CreateJokersWhenBlindSelected(2,
    /// BCardType::CommonJoker)`.
    ///
    /// Room is checked per joker, not all-or-nothing: with one slot free, a
    /// `n = 2` creator fills it and stops. A full board creates nothing.
    /// Applied by `BuffoonBoard::on_blind_selected_with_rng`, since which
    /// jokers arrive is a random draw from the rarity's pool.
    CreateJokersWhenBlindSelected(usize, BCardType),
    /// Superposition: create a Tarot when the played hand is a **Straight** and
    /// contains an **Ace**, if there is a free consumable slot. Both conditions
    /// are required.
    CreateTarotOnAceStraight,
    /// Vagabond: create a Tarot when a hand is played holding **$n or less**, if
    /// there is a free consumable slot.
    CreateTarotOnLowMoney(usize),
    /// Séance: create a random **Spectral** when the played hand is a **Straight
    /// Flush**, if there is a free consumable slot. The spectral twin of
    /// [`CreateTarotOnAceStraight`](Self::CreateTarotOnAceStraight).
    CreateSpectralOnStraightFlush,
    /// Sixth Sense: when the **first hand of the round** is a **single 6**,
    /// destroy that 6 and create a random Spectral (if there is room).
    CreateSpectralOnFirstSingleSix,
    /// Black Hole (spectral): level **every** poker hand up by one.
    SpectralLevelAllHands,
    /// The Soul (spectral): create a random **Legendary** joker (if there is room).
    SpectralCreateLegendaryJoker,
    /// Wraith (spectral): create a random **Rare** joker (if there is room) and
    /// set money to **$0**.
    SpectralCreateRareJokerZeroMoney,
    /// Ectoplasm (spectral): add **Negative** to a random joker and reduce hand
    /// size by 1 (permanent, per use).
    SpectralNegativeRandomJokerMinusHandSize,
    /// Hex (spectral): add **Polychrome** to a random joker, then destroy the
    /// others.
    SpectralPolychromeRandomJokerDestroyOthers,
    /// Ankh (spectral): copy a random joker, then destroy the others — the
    /// original and its copy remain.
    SpectralCopyRandomJokerDestroyOthers,
    /// Aura (spectral): add a random edition — Foil, Holographic, or Polychrome —
    /// to the **selected hand card** (`targets[0]`). The stamp is permanent, so it
    /// persists onto the run roster.
    SpectralEditionRandomHandCard,
    /// Sigil (spectral): convert **every** held card to a single random suit.
    SpectralHandToRandomSuit,
    /// Ouija (spectral): convert **every** held card to a single random rank, and
    /// reduce hand size by 1 (permanent, per use).
    SpectralHandToRandomRankMinusHandSize,
    /// Immolate (spectral): destroy `n` random held cards, then gain `$m`.
    SpectralDestroyRandomHandGainMoney(usize, usize),
    /// Familiar (spectral): destroy 1 random held card, then add `n` random
    /// **Enhanced face** cards to the hand.
    SpectralDestroyOneAddEnhancedFaces(usize),
    /// Grim (spectral): destroy 1 random held card, then add `n` random
    /// **Enhanced Aces** to the hand.
    SpectralDestroyOneAddEnhancedAces(usize),
    /// Incantation (spectral): destroy 1 random held card, then add `n` random
    /// **Enhanced numbered** cards (2–10) to the hand.
    SpectralDestroyOneAddEnhancedNumbered(usize),
    /// Cryptid (spectral): add `n` copies of the **selected hand card**
    /// (`targets[0]`) to the hand.
    SpectralCopySelectedHandCard(usize),
    /// Card Sharp: ×n mult if the played hand type has **already been played
    /// this round**. Reads `BuffoonBoard::hands_by_type_this_round`.
    MultTimesOnRepeatedHandThisRound(usize),
    /// Ancient Joker: ×(n/10) mult for **each** played card of the run's current
    /// "ancient" suit (`BuffoonBoard::ancient_suit`), which re-rolls at the end
    /// of every round. The factor **compounds**, so three matching cards at
    /// ×1.5 is ×3.375.
    ///
    /// The suit lives on the board rather than in this variant because it is run
    /// state: two Ancient Jokers share it.
    MultTimesPerScoredAncientSuit(usize),
    /// Madness: gains `rate`/100 ×mult when a **Small or Big** Blind is selected
    /// — never on a Boss Blind — and destroys a random other joker. Base ×1.
    ///
    /// The two halves are independent: the ×mult is gained whether or not there
    /// was anything to destroy, so a lone Madness still grows. The destruction
    /// is random, so it lives in
    /// `BuffoonBoard::on_blind_selected_with_rng` while the gain is applied by
    /// the pure hook.
    GainMultTimesOnNonBossBlindDestroyingJoker(usize),
    /// Luchador: selling it disables the **current** Boss Blind's ability.
    /// Handled by `BuffoonBoard::sell_joker`; no standalone score.
    DisableBossBlindOnSell,
    /// Chicot: disables the ability of **every** Boss Blind, passively, while it
    /// is on the board. Read live by `BuffoonBoard::boss_ability_active`.
    DisablesAllBossBlinds,
    /// Rocket: earn `base` at end of round, with the payout growing by `increase`
    /// for each **Boss Blind defeated** — `CashOnRoundEndGrowingOnBossDefeat(1, 2)`.
    ///
    /// The accumulator counts bosses defeated. The increment lands *before* the
    /// round it was earned in pays out, so the boss round itself pays the
    /// already-raised amount.
    CashOnRoundEndGrowingOnBossDefeat(usize, usize),
    /// Constellation: gains `rate`/100 ×mult per **Planet card used**. Base ×1.
    ///
    /// A plain counter — it does **not** scale retroactively, so a Constellation
    /// bought after ten Planets starts at ×1. Contrast
    /// [`MultPlusPerTarotUsedThisRun`](Self::MultPlusPerTarotUsedThisRun).
    GainMultTimesPerPlanetUsed(usize),
    /// Fortune Teller: `+n` mult per Tarot card used **this run**.
    ///
    /// Reads `BuffoonBoard::tarots_used`, a run-wide statistic, rather than a
    /// per-joker accumulator — Balatro's Fortune Teller is retroactive, so one
    /// bought after ten Tarots is immediately worth +10.
    MultPlusPerTarotUsedThisRun(usize),
    /// Flash Card: `+n` mult per shop **reroll**.
    ///
    /// A plain per-joker counter grown on `GrowthEvent::ShopRerolled` — the
    /// Green Joker shape, *not* retroactive: a Flash Card bought after five
    /// rerolls starts at +0, and only climbs on rerolls that happen while it is
    /// held.
    MultPlusPerReroll(usize),
    /// Red Card: `+n` mult per booster pack **skipped**.
    ///
    /// The counter twin of [`MultPlusPerReroll`](Self::MultPlusPerReroll), grown
    /// on `GrowthEvent::PackSkipped` and read as `+n × skipped` at scoring time.
    MultPlusPerPackSkipped(usize),
    /// Hallucination: on each booster pack **opened**, a `numerator`-in-`denominator`
    /// chance (base 1-in-2) to create a Tarot, "(Must have room)".
    ///
    /// A probabilistic *creation*, not a counter — it is rolled immediately when
    /// a pack is opened (through the shared `probability_numerator`, so Oops! All
    /// 6s doubles it), the Riff-Raff shape rather than the Green Joker shape.
    /// Scores nothing on its own.
    CreateTarotOnPackOpen(usize, usize),
    /// Perkeo: at end of round, create a **Negative copy** of a random held
    /// consumable. A creation (the Riff-Raff shape), rolled on the seeded
    /// round-end path; the Negative copy takes no slot, so it always lands.
    /// Scores nothing on its own.
    CreateNegativeConsumableCopy,
    /// Vampire: gains `rate`/100 ×mult per **enhanced card played**, and strips
    /// the enhancement off each one it counts. Base ×1.
    ///
    /// Both halves land in `BuffoonBoard::on_scored`, i.e. **before** the hand
    /// scores. That order is the joker: the ×mult applies to the hand it just
    /// ate, and the eaten enhancement does *not* — a Glass card Vampire eats
    /// gives neither its ×2 nor its chance to break.
    GainMultTimesPerEnhancedPlayed(usize),
    Planet(usize),
    RandomJoker(usize),
    RandomTarot(usize),
    RetriggerCardsInHand(usize),
    RetriggerPlayedCardsInFinalRound,
    /// Hack: re-score each played card of one of these ranks `n` additional
    /// times. `RetriggerPlayedRanks(1, ['2','3','4','5'])` retriggers every
    /// played 2, 3, 4, or 5 once more.
    RetriggerPlayedRanks(usize, [char; 4]),
    /// Sock and Buskin: re-score each played **face** card (K/Q/J) `n`
    /// additional times.
    RetriggerPlayedFaces(usize),
    /// Hanging Chad: re-score the **first** played card `n` additional times
    /// (`RetriggerFirstPlayed(2)` = scored 3× total).
    RetriggerFirstPlayed(usize),
    /// Seltzer: re-score **every** played card `n` additional times, for the
    /// joker's first `hands` hands — `RetriggerAllPlayedForHands(1, 10)` — after
    /// which it is destroyed.
    ///
    /// The counter is hands *completed*, so the tenth hand still retriggers and
    /// `BuffoonBoard::melt_emptied_jokers` takes the joker straight after it —
    /// the Ice Cream clock, spending retriggers instead of chips.
    RetriggerAllPlayedForHands(usize, usize),
    SellValueIncrement(usize),
    Stone(usize),
    Strength,
    Odds1in(usize),
    Odds1inCashOn3Ranks(usize, usize, [char; 3]),
    Odds1inUpgradeHand(usize),
    Wild(PipType),
    Diamonds(usize),
    Clubs(usize),
    Hearts(usize),
    Spades(usize),
    /// A mod-defined effect, resolved through an
    /// [`EffectRegistry`](crate::funky::types::effect::EffectRegistry) by this
    /// id. Kept a plain `u32` so cards stay `Copy`, `const` and `Serialize`.
    Custom(u32),
}

impl MPip {
    pub const BONUS: Self = Self::Chips(30);
    pub const DEVIL: Self = Self::Gold(3);
    pub const MULT_PLUS3_ON_DIAMONDS: Self = Self::MultPlusOnSuit(3, 'D');
    pub const MULT_PLUS3_ON_HEARTS: Self = Self::MultPlusOnSuit(3, 'H');
    pub const MULT_PLUS3_ON_SPADES: Self = Self::MultPlusOnSuit(3, 'S');
    pub const MULT_PLUS3_ON_CLUBS: Self = Self::MultPlusOnSuit(3, 'C');
    pub const STEEL: Self = Self::MultTimes1Dot(15); // 1.5
    pub const TEMPERANCE: Self = Self::JokersValue(50);
    pub const TOWER: Self = Self::Stone(50);
    pub const WORLD: Self = Self::MultTimes(2);
    pub const WHEEL_OF_FORTUNE: Self = Self::Odds1in(4);
    pub const JUDGEMENT: Self = Self::RandomJoker(1);

    #[must_use]
    pub fn new_chips(chips: usize) -> Self {
        Self::Chips(chips)
    }

    #[must_use]
    pub fn is_wild(&self) -> bool {
        matches!(self, Self::Wild(_))
    }
}

impl Display for MPip {
    // One arm per variant — a long but flat exhaustive match.
    #[allow(clippy::too_many_lines)]
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Blank => write!(f, "Blank"),
            Self::AddBaseChips(chips) => write!(f, "AddBaseChips({chips}) "),
            Self::AddCardTypeWhenBlindSelected(card_type) => {
                write!(f, "AddStoneCardWhenBlindSelected({card_type:?})")
            }
            Self::ChanceDestroyed(chips, value) => {
                write!(f, "ChanceDestroyed({chips}, {value})")
            }
            Self::Chips(chips) => write!(f, "Chips({chips})"),
            Self::ChipsMultPlus(chips, value) => {
                write!(f, "ChipsMultPlus({chips}, {value})")
            }
            Self::ChipsMultPlusOnHand(chips, mult, hand_type) => {
                write!(f, "ChipsMultPlusOnHand({chips}, {mult}, {hand_type:?})")
            }
            Self::ChipsOnFlush(chips) => write!(f, "ChipsOnFlush({chips})"),
            Self::ChipsOnPair(chips) => write!(f, "ChipsOnPair({chips})"),
            Self::ChipsOn2Pair(chips) => write!(f, "ChipsOn2Pair({chips})"),
            Self::ChipsOnStraight(chips) => write!(f, "ChipsOnStraight({chips})"),
            Self::ChipsOnTrips(chips) => write!(f, "ChipsOnTrips({chips})"),
            Self::ChipsPerRemainingDiscard(chips) => write!(f, "ChipsPerRemainingDiscard({chips})"),
            Self::ChipsPlusOn5Ranks(chips, ranks) => {
                write!(f, "ChipsPlusOn5Ranks({chips}, {ranks:?})")
            }
            Self::CreateCardOnRankPlay(odds, rank_char, card_type) => {
                write!(
                    f,
                    "CreateCardOnRankPlay({odds}, {rank_char}, {card_type:?})"
                )
            }
            Self::Credit(value) => write!(f, "Credit({value})"),
            Self::Death(value) => write!(f, "Death({value})"),
            Self::DoubleMoney(value) => write!(f, "DoubleMoney({value})"),
            Self::FourFlushAndStraight => write!(f, "FourFlushAndStraight"),
            Self::GappedStraight => write!(f, "GappedStraight"),
            Self::AllCardsAreFaces => write!(f, "AllCardsAreFaces"),
            Self::SmearedSuits => write!(f, "SmearedSuits"),
            Self::AllPlayedCardsScore => write!(f, "AllPlayedCardsScore"),
            Self::DoubleOdds => write!(f, "DoubleOdds"),
            Self::FreeReroll(value) => write!(f, "FreeReroll({value})"),
            Self::Glass(a, b) => write!(f, "Glass({a}, {b})"),
            Self::Gold(value) => write!(f, "Gold({value})"),
            Self::Hanged(value) => write!(f, "Hanged({value})"),
            Self::JokersValue(value) => write!(f, "JokersValue({value})"),
            Self::Lucky(a, b) => write!(f, "Lucky({a}, {b})"),
            Self::MultPlus(value) => write!(f, "MultPlus({value})"),
            Self::MultPlusChanceDestroyed(mult, numerator, denominator) => {
                write!(
                    f,
                    "MultPlusChanceDestroyed({mult}, {numerator}, {denominator})"
                )
            }
            Self::MultTimesChanceDestroyed(mult, numerator, denominator) => {
                write!(
                    f,
                    "MultTimesChanceDestroyed({mult}, {numerator}, {denominator})"
                )
            }
            Self::MultPlusChipsOnRank(mult, chips, rank_char) => {
                write!(f, "MultPlusChipsOnRank({mult}, {chips}, {rank_char})")
            }
            Self::MultPlusDoubleValueDestroyJokerOnRight(value) => {
                write!(f, "MultPlusDoubleValueDestroyJokerOnRight({value})")
            }
            Self::MultPlusOn5Ranks(value, ranks) => {
                write!(f, "MultPlusOn5Ranks({value}, {ranks:?})")
            }
            Self::MultPlusOnConsecutiveHandsNo3Ranks(value, increment, ranks) => {
                write!(
                    f,
                    "MultPlusOnConsecutiveHandsNo3Ranks({value}, {increment}, {ranks:?})"
                )
            }
            Self::MultPlusOnFlush(value) => write!(f, "MultPlusOnFlush({value})"),
            Self::MultPlusOnHandPlays => write!(f, "MultPlusOnHandPlays"),
            Self::MultPlusOnPair(value) => write!(f, "MultPlusOnPair({value})"),
            Self::MultPlusOn2Pair(value) => write!(f, "MultPlusOn2Pair({value})"),
            Self::MultPlusOnStraight(value) => write!(f, "MultPlusOnStraight({value})"),
            Self::MultPlusOnTrips(value) => write!(f, "MultPlusOnTrips({value})"),
            Self::MultPlusOnSuit(value, c) => write!(f, "MultPlusOnSuit({value}, {c})"),
            Self::MultPlusOnUpToXCards(value, cards) => {
                write!(f, "MultPlusOnUpToXCards({value}, {cards})")
            }
            Self::MultPlusOnZeroDiscards(value) => write!(f, "MultPlusOnZeroDiscards({value})"),
            Self::MultPlusXOnLowestRankInHand(value) => {
                write!(f, "MultPlusXOnLowestRankInHand({value})")
            }
            Self::MultPlusRandomTo(value) => write!(f, "MultPlusRandomTo({value})"),
            Self::MultPlusZeroDiscards(value) => write!(f, "MultPlusZeroDiscards({value})"),
            Self::MultTimes(value) => write!(f, "MultTimes({value})"),
            Self::MultTimesEveryXHands(value, hands) => {
                write!(f, "MultTimesEveryXHands({value}, {hands})")
            }
            Self::MultTimesOnEmptyJokerSlots(value) => {
                write!(f, "MultTimesOnEmptyJokerSlots({value})")
            }
            Self::MultTimes1Dot(value) => write!(f, "MultTimes1Dot({value})"),
            Self::MultTimesOnPair(value) => write!(f, "MultTimesOnPair({value})"),
            Self::MultTimesOnTrips(value) => write!(f, "MultTimesOnTrips({value})"),
            Self::MultTimesOn4OfAKind(value) => write!(f, "MultTimesOn4OfAKind({value})"),
            Self::MultTimesOnStraight(value) => write!(f, "MultTimesOnStraight({value})"),
            Self::MultTimesOnFlush(value) => write!(f, "MultTimesOnFlush({value})"),
            Self::MultTimesPerScoredRank(value, ranks) => {
                write!(f, "MultTimesPerScoredRank({value}, {ranks:?})")
            }
            Self::MultPlusPerJoker(value) => write!(f, "MultPlusPerJoker({value})"),
            Self::ChipsPerDeckCard(value) => write!(f, "ChipsPerDeckCard({value})"),
            Self::MultTimesPlusPerFullDeckSteel(value) => {
                write!(f, "MultTimesPlusPerFullDeckSteel({value})")
            }
            Self::ChipsPerFullDeckStone(value) => write!(f, "ChipsPerFullDeckStone({value})"),
            Self::MultPlusPerMissingDeckCard(value) => {
                write!(f, "MultPlusPerMissingDeckCard({value})")
            }
            Self::MultTimesPerHeldRank(value, rank) => {
                write!(f, "MultTimesPerHeldRank({value}, {rank})")
            }
            Self::ChipsPlusPerScoredFace(value) => write!(f, "ChipsPlusPerScoredFace({value})"),
            Self::ChipsMultPlusPerScoredRanks(chips, mult, ranks) => {
                write!(f, "ChipsMultPlusPerScoredRanks({chips}, {mult}, {ranks:?})")
            }
            Self::MultTimesPerUncommonJoker(value) => {
                write!(f, "MultTimesPerUncommonJoker({value})")
            }
            Self::MultTimesIfHeldAllSuits(value, suits) => {
                write!(f, "MultTimesIfHeldAllSuits({value}, {suits:?})")
            }
            Self::ChipsPerDollar(value) => write!(f, "ChipsPerDollar({value})"),
            Self::CashOnRoundEnd(value) => write!(f, "CashOnRoundEnd({value})"),
            Self::CashPerDiscardIfNoneUsed(value) => {
                write!(f, "CashPerDiscardIfNoneUsed({value})")
            }
            Self::CashPerFullDeckRank(value, rank) => {
                write!(f, "CashPerFullDeckRank({value}, {rank})")
            }
            Self::ExtraInterest(value) => write!(f, "ExtraInterest({value})"),
            Self::CashOnFacesDiscarded(cash, min_faces) => {
                write!(f, "CashOnFacesDiscarded({cash}, {min_faces})")
            }
            Self::HandSizeIncrement(value) => write!(f, "HandSizeIncrement({value})"),
            Self::DiscardIncrement(value) => write!(f, "DiscardIncrement({value})"),
            Self::GainHandsLoseDiscardsWhenBlindSelected(value) => {
                write!(f, "GainHandsLoseDiscardsWhenBlindSelected({value})")
            }
            Self::GainMultPerHandLessDiscard(n) => write!(f, "GainMultPerHandLessDiscard({n})"),
            Self::LoseMultTimesPerDiscard(base, per) => {
                write!(f, "LoseMultTimesPerDiscard({base}, {per})")
            }
            Self::LoseChipsPerHand(base, per) => write!(f, "LoseChipsPerHand({base}, {per})"),
            Self::GainChipsPerCardCountHand(rate, n) => {
                write!(f, "GainChipsPerCardCountHand({rate}, {n})")
            }
            Self::GainMultPerTwoPairHand(n) => write!(f, "GainMultPerTwoPairHand({n})"),
            Self::GainChipsPerStraightHand(n) => write!(f, "GainChipsPerStraightHand({n})"),
            Self::GainChipsOnScored(n) => write!(f, "GainChipsOnScored({n})"),
            Self::LoseMultPerRound(base, per) => write!(f, "LoseMultPerRound({base}, {per})"),
            Self::GainMultTimesPerDiscardedCards(rate, per) => {
                write!(f, "GainMultTimesPerDiscardedCards({rate}, {per})")
            }
            Self::GainMultTimesPerCardAdded(rate) => {
                write!(f, "GainMultTimesPerCardAdded({rate})")
            }
            Self::GainMultTimesPerFaceDestroyed(rate) => {
                write!(f, "GainMultTimesPerFaceDestroyed({rate})")
            }
            Self::GainMultTimesPerEnhancedPlayed(rate) => {
                write!(f, "GainMultTimesPerEnhancedPlayed({rate})")
            }
            Self::GainMultTimesPerPlanetUsed(rate) => {
                write!(f, "GainMultTimesPerPlanetUsed({rate})")
            }
            Self::CreateJokersWhenBlindSelected(n, rarity) => {
                write!(f, "CreateJokersWhenBlindSelected({n}, {rarity:?})")
            }
            Self::CreateTarotOnAceStraight => write!(f, "CreateTarotOnAceStraight"),
            Self::CreateTarotOnLowMoney(n) => write!(f, "CreateTarotOnLowMoney({n})"),
            Self::CreateSpectralOnStraightFlush => write!(f, "CreateSpectralOnStraightFlush"),
            Self::CreateSpectralOnFirstSingleSix => write!(f, "CreateSpectralOnFirstSingleSix"),
            Self::SpectralLevelAllHands => write!(f, "SpectralLevelAllHands"),
            Self::SpectralCreateLegendaryJoker => write!(f, "SpectralCreateLegendaryJoker"),
            Self::SpectralCreateRareJokerZeroMoney => {
                write!(f, "SpectralCreateRareJokerZeroMoney")
            }
            Self::SpectralNegativeRandomJokerMinusHandSize => {
                write!(f, "SpectralNegativeRandomJokerMinusHandSize")
            }
            Self::SpectralPolychromeRandomJokerDestroyOthers => {
                write!(f, "SpectralPolychromeRandomJokerDestroyOthers")
            }
            Self::SpectralEditionRandomHandCard => write!(f, "SpectralEditionRandomHandCard"),
            Self::SpectralHandToRandomSuit => write!(f, "SpectralHandToRandomSuit"),
            Self::SpectralHandToRandomRankMinusHandSize => {
                write!(f, "SpectralHandToRandomRankMinusHandSize")
            }
            Self::SpectralDestroyRandomHandGainMoney(n, m) => {
                write!(f, "SpectralDestroyRandomHandGainMoney({n}, {m})")
            }
            Self::SpectralDestroyOneAddEnhancedFaces(n) => {
                write!(f, "SpectralDestroyOneAddEnhancedFaces({n})")
            }
            Self::SpectralDestroyOneAddEnhancedAces(n) => {
                write!(f, "SpectralDestroyOneAddEnhancedAces({n})")
            }
            Self::SpectralDestroyOneAddEnhancedNumbered(n) => {
                write!(f, "SpectralDestroyOneAddEnhancedNumbered({n})")
            }
            Self::SpectralCopySelectedHandCard(n) => write!(f, "SpectralCopySelectedHandCard({n})"),
            Self::SpectralCopyRandomJokerDestroyOthers => {
                write!(f, "SpectralCopyRandomJokerDestroyOthers")
            }
            Self::MultTimesOnRepeatedHandThisRound(n) => {
                write!(f, "MultTimesOnRepeatedHandThisRound({n})")
            }
            Self::MultTimesPerScoredAncientSuit(n) => {
                write!(f, "MultTimesPerScoredAncientSuit({n})")
            }
            Self::GainMultTimesOnNonBossBlindDestroyingJoker(rate) => {
                write!(f, "GainMultTimesOnNonBossBlindDestroyingJoker({rate})")
            }
            Self::DisableBossBlindOnSell => write!(f, "DisableBossBlindOnSell"),
            Self::DisablesAllBossBlinds => write!(f, "DisablesAllBossBlinds"),
            Self::CashOnRoundEndGrowingOnBossDefeat(base, increase) => {
                write!(f, "CashOnRoundEndGrowingOnBossDefeat({base}, {increase})")
            }
            Self::MultPlusPerTarotUsedThisRun(n) => {
                write!(f, "MultPlusPerTarotUsedThisRun({n})")
            }
            Self::MultPlusPerReroll(n) => write!(f, "MultPlusPerReroll({n})"),
            Self::MultPlusPerPackSkipped(n) => write!(f, "MultPlusPerPackSkipped({n})"),
            Self::CreateTarotOnPackOpen(num, den) => {
                write!(f, "CreateTarotOnPackOpen({num}, {den})")
            }
            Self::CreateNegativeConsumableCopy => write!(f, "CreateNegativeConsumableCopy"),
            Self::Planet(value) => write!(f, "Planet({value})"),
            Self::RandomJoker(value) => write!(f, "RandomJoker({value})"),
            Self::RandomTarot(value) => write!(f, "RandomTarot({value})"),
            Self::RetriggerCardsInHand(value) => write!(f, "RetriggerCardsInHand({value})"),
            Self::RetriggerPlayedCardsInFinalRound => write!(f, "RetriggerPlayedCardsInFinalRound"),
            Self::RetriggerPlayedRanks(value, ranks) => {
                write!(f, "RetriggerPlayedRanks({value}, {ranks:?})")
            }
            Self::RetriggerPlayedFaces(value) => write!(f, "RetriggerPlayedFaces({value})"),
            Self::RetriggerFirstPlayed(value) => write!(f, "RetriggerFirstPlayed({value})"),
            Self::RetriggerAllPlayedForHands(value, hands) => {
                write!(f, "RetriggerAllPlayedForHands({value}, {hands})")
            }
            Self::SellValueIncrement(value) => write!(f, "SellValueIncrement({value})"),
            Self::Stone(value) => write!(f, "Stone({value})"),
            Self::Strength => write!(f, "Strength"),
            Self::Odds1in(value) => write!(f, "Wheel({value})"),
            Self::Odds1inCashOn3Ranks(value, cash, ranks) => {
                write!(f, "Odds1inCashOn3Ranks({value}, {cash}, {ranks:?})")
            }
            Self::Odds1inUpgradeHand(value) => write!(f, "Odds1inUpgradeHand({value})"),
            Self::Wild(pip_type) => write!(f, "Wild({pip_type:?})"),
            Self::Diamonds(value) => write!(f, "Diamonds({value})"),
            Self::Clubs(value) => write!(f, "Clubs({value})"),
            Self::Hearts(value) => write!(f, "Hearts({value})"),
            Self::Spades(value) => write!(f, "Spades({value})"),
            Self::Custom(id) => write!(f, "Custom({id})"),
        }
    }
}

#[cfg(test)]
#[allow(non_snake_case, unused_imports)]
mod funky__types__mpips_tests {
    use super::*;

    #[test]
    fn default() {
        assert_eq!(MPip::default(), MPip::Blank);
    }

    #[test]
    fn display__counter_variants() {
        assert_eq!(
            MPip::GainMultPerHandLessDiscard(1).to_string(),
            "GainMultPerHandLessDiscard(1)"
        );
        assert_eq!(
            MPip::LoseMultTimesPerDiscard(200, 1).to_string(),
            "LoseMultTimesPerDiscard(200, 1)"
        );
        assert_eq!(
            MPip::LoseChipsPerHand(100, 5).to_string(),
            "LoseChipsPerHand(100, 5)"
        );
        assert_eq!(
            MPip::GainChipsPerCardCountHand(4, 4).to_string(),
            "GainChipsPerCardCountHand(4, 4)"
        );
        assert_eq!(
            MPip::GainMultPerTwoPairHand(2).to_string(),
            "GainMultPerTwoPairHand(2)"
        );
        assert_eq!(
            MPip::GainChipsPerStraightHand(15).to_string(),
            "GainChipsPerStraightHand(15)"
        );
        assert_eq!(
            MPip::GainChipsOnScored(4).to_string(),
            "GainChipsOnScored(4)"
        );
        assert_eq!(
            MPip::MultPlusChanceDestroyed(15, 1, 6).to_string(),
            "MultPlusChanceDestroyed(15, 1, 6)"
        );
    }

    #[test]
    fn display__payout_variants() {
        assert_eq!(MPip::CashOnRoundEnd(4).to_string(), "CashOnRoundEnd(4)");
        assert_eq!(
            MPip::CashPerDiscardIfNoneUsed(2).to_string(),
            "CashPerDiscardIfNoneUsed(2)"
        );
        assert_eq!(
            MPip::CashPerFullDeckRank(1, '9').to_string(),
            "CashPerFullDeckRank(1, 9)"
        );
        assert_eq!(MPip::ExtraInterest(1).to_string(), "ExtraInterest(1)");
        assert_eq!(
            MPip::CashOnFacesDiscarded(5, 3).to_string(),
            "CashOnFacesDiscarded(5, 3)"
        );
        assert_eq!(
            MPip::MultTimesChanceDestroyed(3, 1, 1000).to_string(),
            "MultTimesChanceDestroyed(3, 1, 1000)"
        );
    }

    #[test]
    fn display__draw_modifier_variants() {
        assert_eq!(
            MPip::HandSizeIncrement(1).to_string(),
            "HandSizeIncrement(1)"
        );
        assert_eq!(MPip::DiscardIncrement(1).to_string(), "DiscardIncrement(1)");
        assert_eq!(
            MPip::GainHandsLoseDiscardsWhenBlindSelected(3).to_string(),
            "GainHandsLoseDiscardsWhenBlindSelected(3)"
        );
    }
}