-
Notifications
You must be signed in to change notification settings - Fork 0
/
cardgame.php
1891 lines (1642 loc) · 88 KB
/
cardgame.php
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
<?
define("TRICK_TAKER", 1);
define("CLIMBING_GAME", 2);
define("MELDING_GAME", 3);
define("MATCHING_GAME", 4);
function generateCardGame($gametype=0)
{
$rules = "";
$basicStructure = rand(1,3);
$rarity = 8;
$countrycode = purerandword("en","fr","de");
$gameName = villageName($countrycode);
$alsoName = ""; $thirdName = "";
while ($alsoName == $thirdName)
{
$alsoName = similarName($gameName);
$thirdName = similarName($gameName);
}
$minplayers = rand(2,3);
$maxplayers = rand(3,6);
if ($minplayers == $maxplayers) { $maxplayers++; }
$adjectives = array();
$facts = array();
//$gametype = rand(1,4);
// cards used
$rules .= heading($gameName,2);
$decktype = randword("a standard 52 card pack","a standard 52 card pack");
$specialdeck=0;
$bomb = ""; $rocket = "";
if (rand(1,15)==1) { $decktype = "a tarot deck"; $specialdeck=1; }
if (rand(1,15)==1 && $countrycode == "de") { $decktype = "a 32-card German deck"; $specialdeck=2; }
if (rand(1,15)==1 && $countrycode == "fr") { $decktype = "a 32-card French deck"; $specialdeck=3; }
$deck = array();
$cardpara = "!INTRODUCTION!";
$ranknote = "";
$removenote = "";
$easytoremove = 0;
if ($specialdeck==1)
{ $ranks = array("K","Q","N","P","10","9","8","7","6","5","4","3","2","A"); $easytoremove = 1; }
elseif ($specialdeck==2)
{ $ranks = array("A","K","O","U","10","9","8","7"); }
elseif ($specialdeck==3)
{ $ranks = array("A","K","Q","J","10","9","8","7"); }
elseif (rand(1,4)==1)
{ $ranks = array("10","9","8","7","6","5","4","3","2","A"); $removenote = "Remove court cards. "; }
elseif (rand(1,10)==1)
{ $ranks = array("2","A","K","Q","J","10","9","8","7","6","5","4","3"); $ranknote .= "2s are higher than Aces"; }
elseif (rand(1,10)==1)
{ $ranks = array("3","2","A","K","Q","J","10","9","8","7","6","5","4"); $ranknote .= "3s and 2s are ranked above Aces"; }
elseif (rand(1,10)==1)
{
$ranks = array("A","K","Q","J","10","9","8","7","6","5","4","3","2");
$promoted = rand(0,count($ranks)-1);
$promotedrank = $ranks[$promoted];
unset($ranks[$promoted]);
array_unshift($ranks, $promotedrank);
$ranks = array_values($ranks);
$ranknote .= rankword($promotedrank)."s are higher than aces";
}
elseif (rand(1,2)==1)
{
$ranks = array("A","K","Q","J","10","9","8","7","6","5","4","3","2");
//$ranknote = "Aces are high";
$easytoremove = 1;
}
else
{
$ranks = array("K","Q","J","10","9","8","7","6","5","4","3","2","A");
//$ranknote = "Aces are low";
$easytoremove = 1;
}
if ($removenote == "")
{
$fromwhere = "";
if ($specialdeck==1)
{ $fromwhere = " from the minor arcana"; }
if ($specialdeck==2)
{} // small deck, leave it alone
else if ($ranknote != "")
{} // mentioned cards when changing ranks, may be contradicted if cards are removed at random
else if ($gametype == MELDING_GAME)
{} // need all the cards we can get for this
else if (rand(1,5)==1) // remove a card
{
$removed = rand(0,count($ranks)-1);
$removedrank = $ranks[$removed];
unset($ranks[$removed]);
$ranks = array_values($ranks);
$removenote .= "Remove all ".rankword($removedrank)."s$fromwhere. ";
}
elseif (rand(1,8)==1 && $easytoremove == 1) // remove range of cards
{
$start = rand(0,count($ranks)-4);
$end = rand($start+1,count($ranks)-1);
if ($end-$start>4) { $end = $start+4; }
//print"<li>Before removing cards:"; print_r($ranks);
if ($end==$start+1)
{ $removedranks = rankword($ranks[$end])."s and ".rankword($ranks[$start+1])."s"; }
else
{ $removedranks = rankword($ranks[$end])."s through ".rankword($ranks[$start+1])."s"; }
for ($i=$start+1; $i<$end+1; $i++)
{
unset($ranks[$i]);
}
$ranks = array_values($ranks);
//print"<li>After removing $removedranks ($start/$end):"; print_r($ranks);
$removenote .= "Remove ".$removedranks."$fromwhere.";
}
elseif (rand(1,6)==1) // remove two cards
{
$removed = rand(0,count($ranks)-1);
$removedrank = $ranks[$removed];
unset($ranks[$removed]);
$ranks = array_values($ranks);
$removed = rand(0,count($ranks)-1);
$removedrank2 = $ranks[$removed];
unset($ranks[$removed]);
$ranks = array_values($ranks);
$removenote .= "Remove ".rankword($removedrank)."s and ".rankword($removedrank2)."s$fromwhere.";
}
}
$rankphrase = "";
foreach ($ranks as $rank)
{ $rankphrase .= $rank.", "; }
$rankphrase = preg_replace("/, ([^,]+), $/",", $1",$rankphrase);
//$rankphrase = preg_replace("/ /"," ",$rankphrase);
if ($specialdeck==1)
{
$rankphrase = preg_replace("/K,/","King,",$rankphrase);
$rankphrase = preg_replace("/Q,/","Queen,",$rankphrase);
$rankphrase = preg_replace("/P,/","Page,",$rankphrase);
$rankphrase = preg_replace("/N,/","Knight,",$rankphrase);
}
else if ($specialdeck==2)
{
$rankphrase = preg_replace("/U,/","Unter,",$rankphrase);
$rankphrase = preg_replace("/O,/","Ober,",$rankphrase);
$rankphrase = preg_replace("/K,/","King,",$rankphrase);
}
$cardpara .= $removenote;
if ($ranknote != "")
{ $cardpara .= "$ranknote: cards rank $rankphrase."; }
else
{ $cardpara .= "Cards rank $rankphrase."; }
$therewillberuns = 0;
if (rand(1,$rarity)==1 && ($gametype == MELDING_GAME || $gametype == CLIMBING_GAME))
{
$therewillberuns = 1;
$cardpara.= rankword($ranks[sizeof($ranks)-1])."s can be counted either high or low in a run, such that ".rankword($ranks[sizeof($ranks)-1])."-".rankword($ranks[sizeof($ranks)-2])."-".rankword($ranks[sizeof($ranks)-3])."
and ".rankword($ranks[1])."-".rankword($ranks[0])."-".rankword($ranks[sizeof($ranks)-1])." are both valid runs (but ".rankword($ranks[0])."-".rankword($ranks[sizeof($ranks)-1])."-".rankword($ranks[sizeof($ranks)-2])." is not).";
}
if ($specialdeck!=1)
{
if (rand(1,$rarity)==1) { $cardpara .= "Include two jokers, one red and one black."; array_unshift($deck, "1J"); array_unshift($deck, "2J"); }
elseif ( rand(1,20)==1) { $cardpara .= "Include one red joker."; array_unshift($deck, "1J"); }
}
// build the deck array
foreach ($ranks as $rank)
{
if ($specialdeck==1)
{
array_unshift($deck, $rank."w");
array_unshift($deck, $rank."p");
array_unshift($deck, $rank."s");
array_unshift($deck, $rank."c");
}
elseif ($specialdeck==2)
{
array_unshift($deck, $rank."H");
array_unshift($deck, $rank."B");
array_unshift($deck, $rank."A");
array_unshift($deck, $rank."L");
}
else
{
array_unshift($deck, $rank."C");
array_unshift($deck, $rank."D");
array_unshift($deck, $rank."H");
array_unshift($deck, $rank."S");
}
}
if ($specialdeck==1)
{
for ($i=0; $i<21; $i++)
{
array_unshift($deck, $i."m");
}
}
$rules .= paragraph($cardpara);
$playpara = "";
$handsize = 999;
while ($handsize*$maxplayers>sizeof($deck))
{
$handsize = rand(5,15);
if (sizeof($deck)<31) { $handsize = rand(3,15); }
if (sizeof($deck)<10) { $handsize = rand(1,15); }
}
if ($gametype == MELDING_GAME && $handsize>10) { $handsize -= 6;}
$handsizeword = numberWord($handsize);
$badsuit = randsuit($specialdeck);
$slangsuit = $badsuit;
if ($slangsuit == "major arcana card") { $slangsuit = "the arcana"; }
$sticheln = "";
$countdown = 0; $currency = "";
$positivepoints = 0;
$noneremain = 0;
$maorule = ""; $bartok = 0; $explainmao = "";
// SETUP
$rules .= heading("Setup");
if (rand(1,3)==1 && $handsize>10 && $gametype != MELDING_GAME && $gametype != MATCHING_GAME)
{
$playpara .= "Deal out cards until none remain.";
$noneremain = 1;
}
else
{
if (rand(1,$rarity*3)==1 && ($gametype == CLIMBING_GAME || $gametype == MELDING_GAME || $gametype == MATCHING_GAME))
{
$countdown = 1; $currency = randword("coin","counter","penny","token","poker chip","match");
$playpara .= "Each player starts with $handsizeword ".$currency."s. Each round, deal each player as many cards as they have ".$currency."s.";
array_push($facts,"hand sizes gradually decrease");
}
else
{
$playpara .= randword("Each player is dealt $handsizeword cards.","Deal $handsizeword cards per player.","Deal $handsizeword cards to each player.","Each player is dealt $handsizeword cards.");
if ($handsize>8 && $maxplayers>3 && rand(1,2)==1) { $playpara .= "With more than three players, deal ".numberWord($handsize-rand(3,4))." per player."; }
}
}
$numberoftricks = $handsize;
if ($noneremain == 1) { $numberoftricks = -1; }
if (rand(1,$rarity)==1 && $noneremain == 0) { $playpara .= "The ".randword("player to the right of the dealer","player to the left of the dealer","dealer")." receives ".randword("an extra","one fewer")." card. "; }
if (rand(1,$rarity*3)==1)
{
$playpara .= "Any player who was dealt no ".randsuit($specialdeck)."s ".randword("must","may")." reveal their hand: all players must throw in their hands, and the cards are shuffled and re-dealt.";
}
$rules .= paragraph($playpara);
$playpara = "";
$wildmeld=0;
$cheat = 0;
$seconddiscard = 0;
$shithead = 0;
if ($gametype == MELDING_GAME || $gametype == MATCHING_GAME)
{
if (rand(1,$rarity*2)==1 && $gametype == MATCHING_GAME)
{
if (rand(1,$rarity*2)==1)
{
$playpara .= "Deal two cards to form two face-up discard piles; when every player has seen the cards, turn them both face-down.";
$seconddiscard = 1;
array_push($facts,"there are two discard piles");
}
else
{ $playpara .= "Deal one card to form a face-up discard pile; when every player has seen it, turn it face-down."; }
$cheat = 1;
array_push($facts,"players may lie about their cards");
array_push($adjectives,randword("deceptive","crafty","sneaky","deceitful","duplicitous"));
}
elseif (rand(1,$rarity*2)==1)
{
$playpara .= "Deal one card to form a face-up discard pile, and another to form a second discard pile.";
$seconddiscard = 1;
array_push($facts,"there are two discard piles");
}
else
{
$playpara .= "Deal one card to form a face-up discard pile.";
}
if (rand(1,$rarity)==1)
{
$wildmeld = 1;
$playpara .= "Deal another card face-up and place it to one side where players can see it: cards of this rank are considered to be <b>jokers</b> instead of their usual rank.";
if (in_array("1J",$deck) && !in_array("2J",$deck)) { $playpara .= " (If the dealt card is literally the joker card, shuffle it back in and deal a replacement.)"; }
}
$playpara .= "Undealt cards form the <b>stock</b>.";
}
$kitty = ""; $nomoredealing = 0; $nameofdeck = "deck";
if ($handsize*$maxplayers<sizeof($deck)-6 && rand(1,$rarity)==1)
{
$kitty = randword("kitty","crib","pot","box","talon","cradle","rack","pit","claw","crypt","heap","stash","reliquary","coffer","crate","grapnel","hook");
if ($noneremain == 1)
{ $playpara .= "Each player chooses one card from their hand and plays it into a face-down <b>\"$kitty\"</b>, which is shuffled."; }
else if ($handsize*$maxplayers>sizeof($deck)-10 && $gametype != MELDING_GAME && $gametype != MATCHING_GAME)
{ $playpara .= "The undealt cards form a face-down <b>\"$kitty\"</b>."; $nomoredealing = 1; }
else
{ $playpara .= "Deal ".numberword(rand(3,5))." cards to form a face-down <b>\"$kitty\"</b>."; }
$nameofdeck = $kitty;
}
if (rand(1,$rarity*2)==1 && $gametype != TRICK_TAKER) // Shithead
{
$shithead = 1;
$playpara .= "Deal each player a row of three face-down cards: for each of these cards deal another card face-up on top of it.";
}
$trumps = 0; $antitrumps = 0; $choosetrumpslater = 0;
if (rand(1,3)==1 || $gametype != TRICK_TAKER)
{
// no trumps
}
elseif (rand(1,$rarity*4)==1) { $choosetrumpslater = 1; }
else
{
$trumps = 1;
if (rand(1,$rarity*4)==1)
{
$playpara .= "Place the top card of the $nameofdeck face-down: this determines trump suit, but is not revealed (and does not apply) until the first time a player plays a suit that does not match the lead suit. ";
array_push($adjectives,randword("suspenseful","tense"));
array_push($facts,"trumps are not revealed immediately");
}
else if ($noneremain == 1)
{ $playpara .= randword(randword("The dealer","The player to the dealer's left")." calls a trump suit before looking at their hand.","Reveal the final card as it is dealt; it determines trump suit.","Trumps alternate club/diamonds/hearts/spades for each deal.",ucfirst(randsuit($specialdeck))."s are always trumps.")." "; }
else
{ $playpara .= randword("Turn the top card of the $nameofdeck to determine trump suit.","Reveal the top card of the $nameofdeck to determine trump suit.",randword("The dealer","The player to the dealer's left")." calls a trump suit before looking at their hand.","Reveal the final card as it is dealt; it determines trump suit.","Trumps alternate club/diamonds/hearts/spades for each deal.",ucfirst(randsuit($specialdeck))."s are always trumps.")." "; }
if (preg_match("/discard/",$playpara) && in_array("1J",$deck)) { $playpara .= "(Jokers may not be discarded in this way.)"; }
if (preg_match("/discard/",$playpara)) { $numberoftricks -= 1; }
if (rand(1,$rarity)==1 && !preg_match("/(face-down)/",$playpara))
{
$antitrumps = 1;
if (preg_match("/discard/",$playpara))
{ $playpara .= "At the start of each hand, before looking at their cards,the dealer calls any suit other than the trump suit as <b>anti-trumps</b>."; }
else
{ $playpara .= "Without looking at their hand, the dealer then calls any suit other than the trump suit as <b>anti-trumps</b>."; }
array_push($adjectives,randword("vindictive","cruel","spiteful"));
array_push($facts,"there are both trumps and anti-trumps");
}
if (strpos($playpara,"top card") && rand(1,$rarity)==1)
{ $playpara .= "If a player has the ".rankword($ranks[sizeof($ranks)-1])." of trumps they may at this point <b>\"".randword("rob","steal","loot","swipe","lift","pinch","pilfer","plunder")."\"</b> the revealed trump card, ".randword("taking it into their hand and discarding any other card face-down","swapping the ".rankword($ranks[sizeof($ranks)-1])." for it")."."; }
if ($specialdeck==1)
{ $playpara = preg_replace("/club\/diamonds\/hearts\/spades/","cups/pentacles/swords/wands/major-arcana",$playpara); }
if ($specialdeck==2)
{ $playpara = preg_replace("/club\/diamonds\/hearts\/spades/","hearts/bells/acorns/leaves",$playpara); }
if (preg_match("/(reveal|top card)/",$playpara) && in_array("1J",$deck)) { $playpara .= "If a joker is revealed, there is no trump."; }
if (rand(1,$rarity)==1)
{ $playpara .= "If any player has the ".rankword($ranks[0])." of trumps in their hand, they may optionally at this point score one point by revealing it."; }
}
if ($specialdeck==1)
{
if (rand(1,3)==1 && $trumps == 0 && $gametype == TRICK_TAKER)
{ $playpara .= "The major arcana are trumps"; $trumps = 1; }
else
{ $playpara .= "The major arcana is considered to be its own suit"; }
$playpara .= ".";
}
$rules .= paragraph($playpara);
$nullo = 0; $pig = "";
if (rand(1,20)==1 && $gametype == TRICK_TAKER)
{
if ($specialdeck==1)
{ $rules .= paragraph("Each hand is played either \"high\" or \"low\". Before the hand each player chooses a major or minor arcana card from their hand, and these are revealed simultaneously: if all cards are major arcana the hand is played low, otherwise it is played high."); }
elseif ($specialdeck==2)
{ $rules .= paragraph("Each hand is played either \"high\" or \"low\". Before the hand each player chooses a plant (leaves/acorns) or non-plant (hearts/bells) card from their hand, and these are revealed simultaneously: if all cards are plants the hand is played low, otherwise it is played high."); }
else
{ $rules .= paragraph("Each hand is played either \"high\" or \"low\". Before the hand each player chooses a red or black card from their hand, and these are revealed simultaneously: if all cards are red the hand is played low, otherwise it is played high."); }
$nullo = 1;
array_push($adjectives,randword("uneasy"));
array_push($facts,"hands are played high or low");
}
if (rand(1,$rarity)==1)
{
$choosepig = "may choose to";
//if ($gametype == MELDING_GAME) { $choosepig = "must"; }
if ($specialdeck==1)
{
$time = 999;
$pigcard = "";
while (!strpos($pigcard, "m") && $time>0) // pick major arcana only, if possible
{
$pigcard = $deck[array_rand($deck)];
$time--;
}
$pig = cardname($pigcard);
$rules .= paragraph("A player who holds $pig $choosepig reveal it at this point.");
$pigname = $pig; // no nickname needed for major arcana
}
else
{
$pigcard = $deck[array_rand($deck)];
$pig = cardname($pigcard);
$pigname = "the ".randword("sheep","pig","cow","goat","duck","goose","horse","bull","piglet","hen","lamb","turkey","donkey","chicken","duckling","rat","mouse","beast","bird");
$rules .= paragraph("A player who holds $pig (<b>$pigname</b>) $choosepig reveal it at this point.");
}
array_push($facts,"players must keep track of \"$pigname\"");
}
if (rand(1,$rarity*4)==1)
{
$firstsuit = ""; $secondsuit = "";
while ($firstsuit == $secondsuit)
{
$firstsuit = randsuit($specialdeck);
$secondsuit = randsuit($specialdeck);
}
$godcard = cardname($deck[array_rand($deck)]);
$playpara = "";
if (rand(1,2)==1)
{
$bartok = 1;
$maorule = randword("bonus","mystic","occult")." ".randword("rule","law","order","code","edict","decree","bylaw");
$playpara .= "After the first hand of the game, players may have to obey additional <b>".$maorule."s</b>.";
array_push($facts,"players invent their own extra rules");
array_push($adjectives,randword("creative","imaginative","inventive","curious","increasingly complex"));
}
else
{
$maorule = randword("secret","god","mystic","occult","unseen","unspoken","chairman")." ".randword("rule","law","order","code","edict","decree","bylaw");
$playpara .= "Before players look at their cards for the first hand, ".randword("the dealer invents a","a randomly-chosen player invents a","the dealer and the player to their right each invents their own")." <b>$maorule</b>
and does not inform the other players of it.";
array_push($facts,"players must obey secret rules");
array_push($adjectives,randword("deductive","analytical","mysterious","logical","cerebral"));
}
if ($gametype == MELDING_GAME)
{
$playpara .= "(A $maorule can be a constraint on card play, such as <i>\"cannot play a meld that lacks a $firstsuit\"</i> or <i>\"can't discard a ".rankword($ranks[rand(0,count($ranks)-1)])."\"</i>,
or a bonus ability, eg. <i>\"after playing a meld with a ".rankword($ranks[rand(0,count($ranks)-1)])." in it, ".randword("take another turn","discard a card for free","play order is reversed","the next player skips their turn")."\"</i>.)";
}
else
{
$playpara .= "(A $maorule can be a constraint on card play, such as <i>\"cannot play a ".randword("$firstsuit after a $secondsuit")."\"</i>,
or a bonus ability, eg. <i>\"after playing a ".rankword($ranks[rand(0,count($ranks)-1)]).", ".randword("take another turn","draw a card","play order is reversed","the next player skips their turn")."\"</i>.)";
}
if ($bartok==0) { $playpara .= "A $maorule remains in force until the end of the game."; }
$rules .= paragraph($playpara);
}
if (rand(1,$rarity)==1 && $nomoredealing == 0)
{
$exchange = randword("exchange","redraw","mulligan","swap","shift","switch","barter","turnabout");
$rules .= paragraph(randword("After looking at their cards, any player may suggest a <b>$exchange</b> of a specific number of cards. If all players agree to it, each player discards that many cards face-down and is dealt replacements. (If insufficient cards remain, a $exchange may not be suggested.) When no further ".$exchange."s are requested, play proceeds.",
"After looking at their cards, any player may suggest a <b>$exchange</b> of a single card. If all players agree to it, each player discards one card face-down and is dealt a replacement. (If insufficient cards remain, a $exchange may not be suggested.) When no further ".$exchange."s are requested, play proceeds."));
array_push($facts,"opening hands can be negotiated");
}
$playpara = "";
$bidding = 0; $blindbid = 0;
if (rand(1,$rarity)==1 && $gametype == TRICK_TAKER)
{
// BIDDING
$bidding = 1;
$rules .= heading("Bidding");
if (rand(1,4)==1)
{
$playpara = "Players simultaneously bid the number of tricks they think they will take during the hand, to a minimum of zero.";
}
else
{
$playpara = "Starting with the ".randword("dealer","player to the left of the dealer").", each player bids the number of tricks they think they will take during the hand, to a minimum of zero.";
if (rand(1,$rarity)==1) { $blindbid = 1; $playpara .= "A player may bid \"blind\" by bidding without looking at their cards".randword("","",", but this bid can only be zero")."."; }
if (rand(1,3)>1) $playpara .= "The final bidder cannot bid a number that would cause the total bids to equal the number of tricks available.";
}
array_push($facts,"players predict how many tricks they will take during a hand");
array_push($adjectives,randword("thoughtful","subtle"));
$rules .= paragraph($playpara);
}
$landlord = "";
if (rand(1,$rarity/2)==1 && $kitty!="" && $minplayers>2)
{
if ($bidding == 0) { $rules .= heading("Bidding"); }
$landlord = randword("squire","banker","lord","baron","noble","patrician","duke","count","innkeeper","house","guard","dragon","gangster","gendarme");
$playpara = "Starting with the dealer, players ";
if ($bidding == 1) { $playpara .= "then "; }
$playpara .= "bid to become the <b>$landlord</b>. A bid may be a number from one to ".numberword($maxplayers)." (which must be larger than all previous bids), or a pass. As soon as two consecutive players pass, or a bid of ".numberword($maxplayers)." is made, the highest bidder becomes the $landlord and takes the $kitty into their hand. If all players pass, the hand is redealt.";
$rules .= paragraph($playpara);
$kitty = "";
array_push($facts,"players ".randword("work together","gang up")." against the \"$landlord\"");
array_push($adjectives,randword("collaborative","combative","competitive","antagonistic","ruthless"));
}
$playpara = "";
// PLAY
$rules .= heading("Play");
if ($gametype == TRICK_TAKER)
{
if ($choosetrumpslater == 1) { $playpara .= "The suit of first card played in the hand will determine the trump for the entire hand."; }
if ($numberoftricks == -1 && rand(1,3)==1 && $choosetrumpslater == 0)
{
$playpara .= "Whoever has ".cardname($deck[array_rand($deck)])." plays it to lead the first trick.";
}
else
{
if ($landlord != "")
{ $playpara .= "The $landlord"; }
else
{ $playpara .= randword("The dealer","The player to the dealer's left"); }
$playpara .= " ".randword("starts by leading","leads","may lead")." ";
if ($trumps == 0 || $choosetrumpslater == 1)
{ $playpara .= "any card."; }
else
{ $playpara .= randword("any card","any card","any card which is not the trump suit (unless they only have trump cards)")."."; }
}
if (rand(1,$rarity)==1) // sticheln
{
$sticheln = randword("weak","poor","poison","hollow","small","pale","quiet","thin","slight","bad","wrong","dim","dull","faint","rotten","waste");
if ($trumps == 1)
{ $playpara .= "If the card led is not a trump, its suit"; }
else
{ $playpara .= "The suit led"; }
$playpara .= " is the <b>".$sticheln."</b> suit for the trick.";
array_push($facts,"the led suit is weaker than the rest");
}
if (rand(1,$rarity)==1)
{
if ($trumps == 0)
{ $playpara .= randword("Players must follow the lead suit if they can"); }
else
{ $playpara .= randword("Players may either follow the lead suit or play a trump"); }
$playpara .= ", ";
$playpara .= randword("otherwise they may play any card","otherwise any card may be played","otherwise they may play any card").".";
}
elseif (rand(1,$rarity)==1)
{ $playpara .= randword("Players need not follow suit.","Players are not required to follow suit."); }
else
{
$playpara .= randword("Players must follow suit if possible");
$playpara .= ", ";
if (rand(1,$rarity)==1 && $trumps == 1)
{
$playpara .= "otherwise must play a trump card if they have one, ";
}
else if (rand(1,$rarity)==1)
{
$playpara .= "otherwise must play ".randword("a higher card","a suit which hasn't yet been played","a rank which hasn't yet been played")." if they can do so, ";
}
$playpara .= randword("otherwise may play any card","otherwise any card may be played","otherwise they may play any card").".";
}
if (in_array("1J",$deck) && rand(1,2)==1)
{
if (in_array("2J",$deck)) { $playpara .= "The jokers are "; }
else { $playpara .= "The joker is ";}
$playpara .= "wild and can be played as any card.";
}
else
{
if (in_array("2J",$deck) && $trumps == 1) { $playpara .= randword("The red joker (or <b>".maleDiminutive()."</b>) counts as the highest card in the trump suit, the black joker (the <b>".maleDiminutive()."</b>) ".randword("second-highest","second-highest","lowest")."."); }
else if (in_array("1J",$deck) && $trumps == 1) { $playpara .= randword("The red joker (or <b>".maleDiminutive()."</b>) counts as the highest card in the trump suit.","The red joker (or <b>".maleDiminutive()."</b>) is considered to be of the trump suit, but lower than all other trumps."); }
}
$rules .= paragraph($playpara);
$restrictpara = "";
if (rand(1,$rarity)==1 && in_array("1J",$deck)) { $restrictpara .= "If the first card of a trick is a joker, subsequent players must play their highest $badsuit (if they have one)."; }
if (rand(1,$rarity)==1) { $restrictpara .= "A player cannot lead with a $badsuit until after a $badsuit has been played to a previous trick, unless their hand contains nothing but ".$badsuit."s. (Playing the first $badsuit of the game is known as <b>\"".randword("dropping","blasting","smashing","breaking","cracking","releasing","bursting","freeing","popping","tapping","flourishing","throwing","breaking out the","getting out the")." ".$slangsuit."s\"</b>.) "; }
if (rand(1,$rarity)==1) { $restrictpara .= ucfirst($badsuit)."s cannot be played during the first trick, except by a player who has nothing but ".$badsuit."s in their hand."; }
if ($pig != "" && rand(1,2)==1)
{
$restrictpara .= "If $pigname was revealed, it cannot be ";
if (rand(1,3)==1) { $restrictpara .= "played into the first trick in which its suit is led, nor "; }
$restrictpara .= "used to lead a trick, unless it is the player's only card of that suit.";
}
$rules .= paragraph($restrictpara);
$boosted = 0;
if (rand(1,$rarity)==1) { $rules .= paragraph("If a trick is led with a ".rankword($ranks[rand(0,count($ranks)-1)]).", it is played as a <b>".randword("boost","double","lift","shove","push","rush","rocket","fire","heavy","two-headed")."</b> trick: after each player has played a card, it continues around the table again until each player has played two cards to the trick."); $boosted = 1; }
if ($maorule != "")
{
$rule = "rule";
if (preg_match("/^[a-z]+ ([a-z]+)$/",$maorule,$matches)) { $rule = $matches[1]; }
if ($bartok == 1)
{
$playpara = "If the ".$maorule."s mean that a player has no valid play open to them, they must pass.";
$rules .= paragraph($playpara);
}
else
{
$example = randword("that player leading the next trick","changing the play order","swapping cards in play","awarding or removing points","ending the trick early");
if ($trumps == 1) { $example = randword("changing the trump","cancelling trumps","changing the play order","swapping cards in play","awarding or removing points","ending the trick early"); }
$playpara = "Players must obey ".$maorule."s. If a player breaks one without realising, the player who invented the $rule informs them that they have done so (without explaining the rule): the ".$rule."-breaker must take back their play";
$playpara .= " and play again. If no play is possible, they may pass.";
$playpara .= "If a $maorule causes an effect to occur when a card is played (such as $example), the ".$rule."'s inventor informs the players of this when it happens.";
$rules .= paragraph($playpara);
}
}
$playpara = "";
$playpara .= "The trick is won by ";
if ($trumps == 1)
{
$playpara .= randword("the highest trump");
if ($antitrumps == 1)
{ $playpara .= ", unless there were no trumps or an anti-trump was played to the trick, in which case it is won by "; }
else
{ $playpara .= ", or if it contains no trump by "; }
}
if ($sticheln != "")
{ $playpara .= "the highest card not in the $sticheln suit (with the earliest card played breaking ties), or the highest $sticheln card if all cards were $sticheln. "; }
else
{
$playpara .= randword("the highest card of the lead suit","the highest card of the lead suit","the highest card irrespective of suit (with the earliest card played breaking ties)").". ";
}
if ($specialdeck==1 && strpos($playpara, "irrespective"))
{ $playpara .= "For the major arcana, the cards rank equal to their number (such that Temperance equals a King, etc.)."; }
$playpara .= "The ".randword("winner of the trick","winner of the trick","player to the left of the previous leader","player of the lowest ranked card (breaking ties by first card played)")." leads the next trick.";
$rules .= paragraph($playpara);
if ($kitty != "") { $rules .= paragraph("The first time a player wins a trick which contains ".randword("a $badsuit",cardname($deck[array_rand($deck)])." (the <b>".maleDiminutive($specialdeck)."</b>)").", they also take the $kitty as if it were a separate, won trick."); }
}
$cardssetaside = 0;
$tookastrick = 0;
if ($gametype == CLIMBING_GAME)
{
$sets = 0; $runs = 0;
if ($numberoftricks == -1 && rand(1,$rarity)==1 && $therewillberuns==0)
{
$playpara .= "Whoever has ".cardname($deck[array_rand($deck)])." plays it to lead the first trick.";
}
else
{
if ($landlord != "")
{ $playpara .= "The $landlord"; }
else
{ $playpara .= randword("The dealer","The player to the dealer's left"); }
$playpara .= " ".randword("starts by leading","leads","may lead")." ";
if (rand(1,$rarity*2)==1 || $shithead==1)
{ $playpara .= "any single card."; }
elseif (rand(1,3)>1)
{
$runstart = rand(0,sizeof($ranks)-3);
$sets = 1; $runs = 1;
$playpara .= "any single card, or set of cards of equal rank (eg. ".randword("a pair of","three")." ".rankword($ranks[rand(0,count($ranks)-1)])."s),
or run of three or more cards ";
if (rand(1,4)==1)
{
$firstsuit = ""; $secondsuit = ""; $thirdsuit = "";
while ($firstsuit == $secondsuit || $firstsuit == $thirdsuit || $thirdsuit == $secondsuit)
{
$firstsuit = randsuit($specialdeck);
$secondsuit = randsuit($specialdeck);
$thirdsuit = randsuit($specialdeck);
}
$playpara .= "across any suits (eg. ".rankword($ranks[$runstart+2])." of ".$firstsuit."s, ".rankword($ranks[$runstart+1])." of ".$secondsuit."s, ".rankword($ranks[$runstart])." of ".$thirdsuit."s).";
}
else
{ $playpara .= "of the same suit (eg. ".rankword($ranks[$runstart+2])."-".rankword($ranks[$runstart+1])."-".rankword($ranks[$runstart])." of ".randsuit($specialdeck)."s)."; }
}
else
{ $sets = 1; $playpara .= "any single card, or set of cards of equal rank (eg. ".randword("a pair of","three")." ".rankword($ranks[rand(0,count($ranks)-1)])."s)."; }
}
$rules .= paragraph($playpara);
$playpara = "Each player in turn must either pass or play a card ";
if ($sets==1) { $playpara .= "or set of cards "; }
$playpara .= "which beats the previous play.";
if (rand(1,$rarity*2)==1) { $playpara .= "(A player <i>must</i> play if they are able to do so.)"; }
$singlebomb = 0;
if (rand(1,$rarity)==1) { $singlebomb = 1; }
if (rand(1,$rarity)==1)
{
$playpara .= "A single card is beaten by a higher single card, ";
if ($runs == 1) { $playpara .= "by any run, "; }
$playpara .= "or by any pair, triple or quartet set (even if the set's rank is lower).";
$playpara .= "A set is beaten by a set of the same size with higher ranks, or a larger set of any rank.";
$example = rand(0,sizeof($ranks)-3); $off = rand(1,2);
$playpara .= "(For example, ".rankword($ranks[$example])."-".rankword($ranks[$example])." can be beaten by ".rankword($ranks[$example+$off])."-".rankword($ranks[$example+$off])."-".rankword($ranks[$example+$off]).".)";
$sets = 1;
}
elseif (rand(1,$rarity)==1)
{
$playpara .= "A single card is beaten by a higher single card, ";
if ($runs == 1) { $playpara .= "by any run that includes a higher ranked card, "; }
$playpara .= "or by any set of cards";
if ($sets == 0) { $playpara .= " (eg. a ".randword("pair of","set of three")." ".rankword($ranks[rand(0,count($ranks)-1)])."s)"; }
$playpara .= " of higher rank.";
$playpara .= "A set is beaten by a set of the same size with higher ranks, or a larger set of a higher rank.";
$example = rand(0,sizeof($ranks)-3); $off = rand(1,2);
$playpara .= "(For example, a ".rankword($ranks[$example])." can be beaten by a ".rankword($ranks[$example+$off])."-".rankword($ranks[$example+$off]).".)";
$sets = 1;
}
else
{
if ($sets==1)
{
$playpara .= "A single card is beaten by a higher single card";
$playpara .= ", and a set is beaten by a set of the same size with a higher card rank.";
//if ($singlebomb == 0) { $playpara .= "(A set cannot be played onto a single card, or vice versa.)"; }
//else { $playpara .= "(A set cannot be played onto a single card, and a single card cannot be played onto a set it doesn't beat.)"; }
}
else
{ $playpara .= "A card is beaten by any card of a higher rank."; }
}
if ($runs == 1) { $playpara .= "Runs are beaten by runs of the same size, starting at a higher rank."; }
$rules .= paragraph($playpara);
$playpara = "";
if (in_array("1J",$deck))
{
if (rand(1,$rarity)==1)
{ $playpara .= "A single joker can be played at any time, and beats any other play."; }
else
{
if (in_array("2J",$deck)) { $playpara .= "The jokers are "; }
else { $playpara .= "The joker is ";}
$playpara .= "wild and can be played as any card.";
if (rand(1,$rarity)==1 && $sets==1)
{
$example = rankword($ranks[rand(0,count($ranks)-1)]);
$playpara .= "A set with a joker can be beaten by the same natural version of the set (eg. $example-joker is beaten by $example-$example).";
}
}
}
if ($singlebomb == 1)
{ $playpara .= "A single ".rankword($ranks[sizeof($ranks)-1])." can be played at any time, and beats any other play."; }
elseif (rand(1,$rarity)==1 && $specialdeck==0)
{ $playpara .= "A single card can be beaten by a card of the same rank in the opposite colour suit."; }
if (rand(1,$rarity)==1 && $singlebomb==0)
{
$bomb = randword("bomb","shell","petard","trap","snare","bolt","dart","dagger");
if (rand(1,4)==1 && in_array("2J",$deck))
{
$rocket = randword("rocket","missile","firework","torpedo","fireball");
$playpara .= "Four cards of the same rank are a <b>$bomb</b>, and can be played at any time to beat anything except a $rocket or a higher-ranking $bomb.";
$playpara .= "A pair of jokers is a <b>$rocket</b>, which beats all other plays and cannot be beaten.";
}
else
{
$playpara .= "Four cards of the same rank are a <b>$bomb</b>, and can be played at any time to beat anything except a higher-ranking $bomb.";
}
array_push($facts,"powerful \"".$bomb."s\" can defeat weaker plays");
}
if (rand(1,$rarity)==1)
{
$glass = $ranks[rand(0,count($ranks)-1)];
$playpara .= ucfirst(numberword(rankword($glass)))."s are <b>".randword("transparent","invisible","glass","clear","crystal","ghosts")."</b>: after you play a ".rankword($glass);
if ($sets == 1) { $playpara .= " or a set of ".rankword($glass)."s, they are counted as copies of the card beneath them."; }
else { $playpara .= ", it is counted as a copy of the card beneath it."; }
$playpara .= "If there is no card beneath it, it counts as a ".rankword($glass).".";
}
$rules .= paragraph($playpara);
if ($maorule != "")
{
$rule = "rule";
if (preg_match("/^[a-z]+ ([a-z]+)$/",$maorule,$matches)) { $rule = $matches[1]; }
$example = randword("that card being unbeatable","changing the play order","skipping the next player","forcing a player to draw cards","swapping cards in play","eliminating a player from the hand");
if ($bartok == 1)
{
$playpara = "If the ".$maorule."s mean that a player has no valid play open to them, they must pass.";
$rules .= paragraph($playpara);
}
else
{
$playpara = "Players must obey ".$maorule."s. If a player breaks one without realising, the player who invented the $rule informs them that they have done so (without explaining the rule): the ".$rule."-breaker must take back their play";
$playpara .= ", draw one penalty card";
$playpara .= " and play again. If no play is possible, they may pass.";
$playpara .= "If a $maorule causes an effect to occur when a card is played (such as $example), the ".$rule."'s inventor informs the players of this when it happens.";
$rules .= paragraph($playpara);
}
}
$playpara = "";
if (rand(1,2)==1 && $sets == 0) // Skitgubbe
{
$playpara = "The hand continues until a player passes, or until there are as many cards in the middle as there are players.";
array_push($adjectives,randword("high-pressure"));
}
else
{
if ($minplayers == 2)
{
$playpara .= "In a two-player game, the hand continues until a player passes.";
if ($maxplayers == 3) { $playpara .= "With three, it"; } else { $playpara .= "With more, it"; }
}
else
{ $playpara .= "The hand"; }
$playpara .= " continues until all but one player has passed in sequence.";
if (rand(1,$rarity)==1) { $playpara .= "(Once a player has passed during a trick they cannot rejoin it.)"; }
else { $playpara .= "(Otherwise, a player that has passed may still play a card later in the trick.)"; }
}
if (rand(1,2)==1)
{
$playpara .= "When this happens, the player who played the final card takes the pile of played cards as a trick, and leads the next.";
if ($kitty != "") { $rules .= paragraph("The first time a player wins a trick which contains ".randword("a $badsuit",cardname($deck[array_rand($deck)])." (the <b>".maleDiminutive($specialdeck)."</b>)").", they also take the $kitty as if it were a separate, won trick."); }
$tookastrick = 1;
}
else
{
$cardssetaside = 1;
$playpara .= "When the hand ends, the pile of played cards is set aside face-down and the player who played the final card to it leads the next trick.";
if ($kitty != "") { $playpara .= "The first time that ".randword("a $badsuit",cardname($deck[array_rand($deck)])." (the <b>".maleDiminutive($specialdeck)."</b>)")." is in the cards set aside, the player takes the $kitty into their hand."; }
}
$rules .= paragraph($playpara);
$playpara = "";
}
$packterm = "";
if ($gametype == MELDING_GAME)
{
$playpara = "";
$playpara .= "The ".randword("dealer","player to the dealer's left")." takes the first turn.";
$machiavelli = 0;
if (rand(1,$rarity)==1)
{ $machiavelli = 1; $playpara .= "On their turn a player may take <i>one</i> of the following actions:</p><ul>"; }
else
{ $playpara .= "A player's turn consists of the following steps in sequence:</p><ul>"; }
if (rand(1,$rarity)==1)
{
$packterm = randword("desert","ditch","sink","load","stow","drop","slip","bundle","flop");
if ($machiavelli == 1)
{ $playpara .= "<li><b>".ucfirst($packterm)."</b>"; }
else
{ $playpara .= "<li>Optionally <b>$packterm</b>"; }
$playpara .= ": shuffle a third of your hand (of your choice, and rounding down) into the stock; if this is your first turn you shuffle a half of your hand instead. A player who has ".$packterm."ed holds onto their remaining cards but takes no further part in the round.";
$playpara = preg_replace("/bundleed/","bundled",$playpara);
$playpara = preg_replace("/sinked/","sunk",$playpara);
$playpara = preg_replace("/(dro|sli|flo)ped/","$1pped",$playpara);
array_push($facts,"players can opt to drop out early");
array_push($adjectives,randword("tactical","skilful","thoughtful"));
}
$wipe=0;
$playpara .= "<li><b>Draw</b> ";
if (rand(1,$rarity)==1)
{
$playpara .= randword("two","one or two")." cards from the top of the stock";
if ($kitty != "") { $playpara .= ", one card from the top of the the $kitty,"; }
}
else
{
$playpara .= "one card from the top of the stock";
if ($kitty != "") { $playpara .= " or the $kitty,"; }
}
if (rand(1,$rarity)==1)
{ $wipe=1; $playpara .= " or any number of cards from the top of the discard pile"; }
else
{ $playpara .= " or one card from the top of the discard pile"; }
if (rand(1,$rarity)==1) { $playpara .= ". A player who has not yet played a meld may not draw from the discard pile"; }
if (rand(1,$rarity)==1 && $machiavelli==0)
{
$playpara .= ". If the player draws from the discard pile, they must play ";
if ($wipe==1) { $playpara .= "all of those cards"; } else { $playpara .= "that card"; }
$playpara .= " into a meld this turn";
}
$playpara .= ".</li>";
if ($machiavelli == 1)
{ $playpara .= "<li>Play "; }
else
{ $playpara .= "<li>Optionally play "; }
$playpara .= "".randword("one <b>meld</b>","one or more <b>melds</b>")." from your hand";
if ($machiavelli == 0) { $playpara .= ", if you can do so"; }
$playpara .= ", placing your melds face-up on the table in front of you. A meld ";
$playpara .= "can either be three or more cards of equal rank (eg. ".randword("four","three")." ".rankword($ranks[rand(0,count($ranks)-1)])."s),
or run of three or more cards ";
$runstart = rand(0,sizeof($ranks)-3);
if (rand(1,4)==1)
{
$firstsuit = ""; $secondsuit = ""; $thirdsuit = "";
while ($firstsuit == $secondsuit || $firstsuit == $thirdsuit || $thirdsuit == $secondsuit)
{
$firstsuit = randsuit($specialdeck);
$secondsuit = randsuit($specialdeck);
$thirdsuit = randsuit($specialdeck);
}
$playpara .= "across any suits (eg. ".rankword($ranks[$runstart+2])." of ".$firstsuit."s, ".rankword($ranks[$runstart+1])." of ".$secondsuit."s, ".rankword($ranks[$runstart])." of ".$thirdsuit."s).";
}
else
{ $playpara .= "of the same suit (eg. ".rankword($ranks[$runstart+2])."-".rankword($ranks[$runstart+1])."-".rankword($ranks[$runstart])." of ".randsuit($specialdeck)."s)."; }
if (rand(1,$rarity)==1) { $playpara .= "A single ".rankword($ranks[rand(0,count($ranks)-1)])." by itself is also a valid meld."; }
if (rand(1,$rarity)==1)
{
$playpara .= "Each player's first meld of the round must be a run";
if (in_array("1J",$deck) || $wildmeld==1) { $playpara .= " containing no jokers"; }
$playpara .= ".";
}
if (rand(1,$rarity)==1) { $playpara .= "A player is not permitted to meld all of their cards on their first turn."; }
elseif (rand(1,$rarity)==1) { $playpara .= "If you have any full and valid melds in your hand you <i>must</i> play one of them."; }
$keepcard=0;
$rearrangemelds=0;
if (rand(1,$rarity)==1 && $machiavelli==0) { $keepcard=1; $playpara .= "You can never have an empty hand after playing a meld: you must keep one card back to discard at the end of the turn."; }
if (rand(1,$rarity)==1)
{
$rearrangemelds = 1;
$playpara .= "You may break up and rearrange ";
if (rand(1,$rarity)==1)
{ $playpara .= "your own melds"; }
else
{ $playpara .= "any melds on the table"; }
$playpara .= " when playing a new meld, so long as you are adding at least one card to the table and leave the table as a collection of valid melds.";
array_push($facts,"melds can be rearranged");
array_push($adjectives,randword("complex","expansive","convoluted","elaborate","labyrinthine","tangled","byzantine"));
}