-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilter_magic.pl
1681 lines (1543 loc) · 120 KB
/
filter_magic.pl
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
#!/usr/bin/perl
##
# File : filter_magic.pl
# Date : 10/Sept/2013
# Author : spjspj
# Purpose : Search through the xmage list of files
##
use strict;
use POSIX;
use LWP::Simple;
use Socket;
use File::Copy;
my %all_cards;
my %card_names;
my %original_lines;
my %original_lines_just_card_names;
my %card_text;
my %card_text_not_like;
my %card_cost;
my %card_type;
my %card_converted_cost;
my %card_colour_identity;
my %all_cards_abilities;
my %expansion;
my $number_cards = 0;
sub print_card
{
my $card_to_check = $_ [0];
my $cn = card_name ($card_to_check);
my $ctype = card_type ($card_to_check);
my $ctxt = card_text ($card_to_check);
my $cc = card_cost ($card_to_check);
my $ccc = card_converted_cost ($card_to_check);
my $cid = card_colour_identity ($card_to_check);
my $exp = expansion ($card_to_check);
#print ("$card_to_check - $cn - $ctxt - $ctype ($cc,,,$ccc)\n");
return ("$card_to_check - nm,,$cn - txt,,$ctxt - typ,,$ctype ($cc,,,$ccc) -- $exp,,,cid=$cid");
}
# Filter for a sublist of cards in X (i.e. hand, deck, graveyard, exiled, named, tapped, type (artifact,sorcery,enchantment,equipment,creature), )
sub get_filtered_cards_advanced
{
my $cards = $_ [0];
my $has_minconvertedcost = $_ [1];
my $has_maxconvertedcost = $_ [2];
my $no_red = $_ [3];
my $no_green = $_ [4];
my $no_blue = $_ [5];
my $no_black = $_ [6];
my $no_white = $_ [7];
my $no_uncoloured = $_ [8];
my $use_full_format = $_ [9];
my $use_block = $_ [10];
my $use_unique = $_ [11];
my $card_text = $_ [12];
my $card_name = $_ [13];
my $use_colorid = $_ [14];
my $card_text_not_like = $_ [15];
my $order_by_rating = 0;
my $ret;
my %names_of_cards;
if ($card_text eq "") { $card_text = ".*"; }
if ($card_name eq "") { $card_name = ".*"; }
if ($card_name =~ m/\|/ && $card_name !~ m/^\(/)
{
$card_name = "($card_name)";
}
print ("has_minconvertedcost $has_minconvertedcost\n");
print ("has_maxconvertedcost $has_maxconvertedcost\n");
print ("no_red $no_red\n");
print ("no_green $no_green\n");
print ("no_blue $no_blue\n");
print ("no_black $no_black\n");
print ("no_white $no_white\n");
print ("no_uncoloured $no_uncoloured\n");
print ("use_full_format $use_full_format\n");
print ("use_colorid $use_colorid\n");
if ($_ [14] eq "true") { $use_colorid = 1; }
if ($_ [14] eq "false") { $use_colorid = 0; }
print ("use_block $use_block\n");
$card_text =~ s/%20/.*/img;
$card_text_not_like =~ s/%20/.*/img;
print ("card_text $card_text\n");
my $use_ctnl = 0;
if ($card_text_not_like =~ m/./)
{
$use_ctnl = 1;
}
print ("card_text_not_like $card_text_not_like (use?? $use_ctnl)\n");
print ("card_name $card_name\n");
print ("\n\n\n\n\n\nStarting checking all the cards...\n");
my $c;
my @filtered;
my $i;
my $count = 0;
{
my @c_nums;
@c_nums = sort keys (%card_names);
foreach $c (@c_nums)
{
my $xp = expansion ($c);
#print("$c >> $use_full_format ??? $xp");
if ($use_unique =~ m/true/i && defined ($names_of_cards {card_name ($c)}))
{
print ("Non unique >>> " . card_name ($c) . "\n");
next;
}
#print ("\n");
if (!$use_colorid)
{
my $cc = card_cost ($c);
# Must not have a color
if ($no_red == 1 && $cc =~ m/\{[^\}]*r[^\}]*\}/i) { next; }
if ($no_blue == 1 && $cc =~ m/\{[^\}]*u[^\}]*\}/i) { next; }
if ($no_green == 1 && $cc =~ m/\{[^\}]*g[^\}]*\}/i) { next; }
if ($no_black == 1 && $cc =~ m/\{[^\}]*b[^\}]*\}/i) { next; }
if ($no_white == 1 && $cc =~ m/\{[^\}]*w[^\}]*\}/i) { next; }
if ($no_uncoloured == 1 && $cc =~ m/\{[^\}]*\d+[^\}]*\}/i) { next; }
# Must have a color
if ($no_red == 2 && $cc !~ m/\{[^\}]*r[^\}]*\}/i) { next; }
if ($no_blue == 2 && $cc !~ m/\{[^\}]*u[^\}]*\}/i) { next; }
if ($no_green == 2 && $cc !~ m/\{[^\}]*g[^\}]*\}/i) { next; }
if ($no_black == 2 && $cc !~ m/\{[^\}]*b[^\}]*\}/i) { next; }
if ($no_white == 2 && $cc !~ m/\{[^\}]*w[^\}]*\}/i) { next; }
if ($no_uncoloured == 2 && $cc !~ m/\{[^\}]*\d+[^\}]*\}/i) { next; }
}
elsif ($use_colorid)
{
my $cc = card_colour_identity ($c);
# Must not have a color
if ($no_red == 1 && $cc =~ m/R/) { next; }
if ($no_blue == 1 && $cc =~ m/U/) { next; }
if ($no_green == 1 && $cc =~ m/G/) { next; }
if ($no_black == 1 && $cc =~ m/B/) { next; }
if ($no_white == 1 && $cc =~ m/W/) { next; }
# Must have a color
if ($no_red == 2 && $cc !~ m/R/) { next; }
if ($no_blue == 2 && $cc !~ m/U/) { next; }
if ($no_green == 2 && $cc !~ m/G/) { next; }
if ($no_black == 2 && $cc !~ m/B/) { next; }
if ($no_white == 2 && $cc !~ m/W/) { next; }
}
{
if ((card_converted_cost ($c) >= $has_minconvertedcost || $has_minconvertedcost eq "") &&
(card_converted_cost ($c) <= $has_maxconvertedcost || $has_maxconvertedcost eq ""))
{
my $cn = card_name ($c);
my $cn_condense = $cn;
$cn_condense =~ s/\W//g;
if ($cn =~ m/$card_name/i || $cn_condense =~ m/$card_name/i)
{
my $ct = card_text ($c);
my $ol = original_line ($c);
my $condense_ol = $ol;
$condense_ol =~ s/\W//g;
#print ("$card_name ---- CCcost=" . card_converted_cost ($c) . " --> Min,max = " . $has_minconvertedcost . "," . $has_maxconvertedcost . "\n");
$ct =~ s/\W//g;
if ($ct =~ m/kenrith/img)
{
print $ct, "\n";
}
if (($ct =~ m/$card_text/i || $ol =~ m/$card_text/i || $condense_ol =~ m/$card_text/i) && !($use_ctnl && $condense_ol =~ m/$card_text_not_like/i))
# 1 0 >> 0 !=1
# 1 1 >> 1 !=0
# 0 0 >> 0 !=1
# 0 1 >> 0 !=1
{
print (" >> $ol made it through\n");
my $ol = original_line ($c);
my $exp = expansion ($c);
$ol =~ s/^([^\|]*)\|([^\|]*)\|(.*)/$1|$exp|$3/gim;
$ol .= $exp;
$ret .= "$ol\n";
$names_of_cards {card_name ($c)} = 1;
$count++;
if ($count % 100 == 0) { print ($count, "\n"); }
if ($count > 99990) { $ret .= "TOO MANY CARDS\n"; return $ret; }
}
}
}
}
$i++;
}
}
return $ret . "\nHave found $count cards - and here it endth\n";
}
# Random card details!
my $random_card_name = "";
my $random_card_cmc = "";
my $random_card_cost = "";
my $random_card_cid = "";
my $random_card_text = "";
my $random_card_set = "";
my $random_card_type = "";
my $random_card_rarity = "";
my $random_card_rarity_num = "";
my $random_date = "";
my %random_choices;
my $random_num_choices = 0;
sub get_random_card
{
my @c_nums = sort keys (%card_names);
my $rand_num = rand ($number_cards);
$rand_num =~ s/\..*//;
my $c = @c_nums [$rand_num];
print ("Rand_num?? $c_nums[255], $c, $rand_num vs $number_cards\n");
$random_card_name = card_name ($c);
$random_card_cmc = card_converted_cost ($c);
$random_card_cost = card_cost ($c);
$random_card_cid = card_colour_identity ($c);
$random_card_text = card_text ($c);
$random_card_set = expansion ($c);
$random_card_type = card_type ($c);
my $l = original_line ($c);
if ($l =~ m/\|Special\|/im) { $random_card_rarity = "Special"; $random_card_rarity_num = 6; }
if ($l =~ m/\|Mythic Rare\|/im) { $random_card_rarity = "Mythic"; $random_card_rarity_num = 5; }
if ($l =~ m/\|Rare\|/im) { $random_card_rarity = "Rare"; $random_card_rarity_num = 4; }
if ($l =~ m/\|Uncommon\|/im) { $random_card_rarity = "Uncommon"; $random_card_rarity_num = 3; }
if ($l =~ m/\|Common\|/im) { $random_card_rarity = "Common"; $random_card_rarity_num = 2; }
if ($l =~ m/\|Land\|/im) { $random_card_rarity = "Common"; $random_card_rarity_num = 2; }
my %new_choices;
%random_choices = %new_choices;
$random_num_choices = 0;
print ("Random card was:<br>(set=$random_card_set) " . $random_card_name . "," . $random_card_cmc . "," . $random_card_cost . "," . $random_card_cid . "," . $random_card_text . "," . $random_card_set . "," . $random_card_type, " RARITY>>>=$random_card_rarity\n(based on $l)\n");
}
sub original_line
{
my $id = $_ [0];
return ($original_lines {$id});
}
sub original_line_from_cardname
{
my $id = $_ [0];
return ($original_lines_just_card_names {$id});
}
sub card_name
{
my $id = $_ [0];
return ($card_names {$id});
}
sub card_text
{
my $id = $_ [0];
return ($card_text {$id});
}
sub card_cost
{
my $id = $_ [0];
return ($card_cost {$id});
}
sub card_converted_cost
{
my $id = $_ [0];
return ($card_converted_cost{$id});
}
sub card_colour_identity
{
my $id = $_ [0];
return ($card_colour_identity{$id});
}
sub card_type
{
my $id = $_ [0];
return ($card_type {$id});
}
sub expansion
{
my $id = $_ [0];
return ($expansion {$id});
}
sub expansion_trigraph
{
my $expansion = $_ [0];
# This part is from: c:\xmage_release\mage\Mage.Client\src\main\java\org\mage\plugins\card\dl\sources\WizardCardsImageSource.java
#if ($expansion =~ m/^Core Sets/i) { $expansion .= " [M13]"; }
#if ($expansion =~ m/^Core Sets/i) { $expansion .= " [M19]"; }
#if ($expansion =~ m/^Core Sets/i) { $expansion .= " [ORI]"; }
#if ($expansion =~ m/^Invasion/i) { $expansion .= " [AP]"; }
#if ($expansion =~ m/^Urza/i) { $expansion .= " [UD]"; }
if ($expansion =~ m/^Aether Revolt/i) { $expansion .= " [AER]"; }
if ($expansion =~ m/^Alara Reborn/i) { $expansion .= " [ARB]"; }
if ($expansion =~ m/^Alliances/i) { $expansion .= " [ALL]"; }
if ($expansion =~ m/^Amonkhet/i) { $expansion .= " [AKH]"; }
if ($expansion =~ m/^Anthologies/i) { $expansion .= " [ATH]"; }
if ($expansion =~ m/^Antiquities/i) { $expansion .= " [ATQ]"; }
if ($expansion =~ m/^Apocalypse/i) { $expansion .= " [APC]"; }
if ($expansion =~ m/^Arabian Nights/i) { $expansion .= " [ARN]"; }
if ($expansion =~ m/^Archenemy/i) { $expansion .= " [ARC]"; }
if ($expansion =~ m/^Archenemy/i) { $expansion .= " [E01]"; }
if ($expansion =~ m/^Archenemy: Nicol Bolas/i) { $expansion .= " [ANB]"; }
if ($expansion =~ m/^Archenemy: Nicol Bolas/i) { $expansion .= " [E01]"; }
if ($expansion =~ m/^Avacyn Restored/i) { $expansion .= " [AVR]"; }
if ($expansion =~ m/^Battle Royale Box Set/i) { $expansion .= " [BRB]"; }
if ($expansion =~ m/^Battle for Zendikar/i) { $expansion .= " [BFZ]"; }
if ($expansion =~ m/^Battlebond/i) { $expansion .= " [BBD]"; }
if ($expansion =~ m/^Beatdown Box Set/i) { $expansion .= " [BTD]"; }
if ($expansion =~ m/^Betrayers of Kamigawa/i) { $expansion .= " [BOK]"; }
if ($expansion =~ m/^Born of the Gods/i) { $expansion .= " [BNG]"; }
if ($expansion =~ m/^Casual Supplements/i) { $expansion .= " [JMP]"; }
if ($expansion =~ m/^Champions of Kamigawa/i) { $expansion .= " [CHK]"; }
if ($expansion =~ m/^Chronicles/i) { $expansion .= " [CHR]"; }
if ($expansion =~ m/^Classic Sixth Edition/i) { $expansion .= " [6ED]"; }
if ($expansion =~ m/^Coldsnap/i) { $expansion .= " [CSP]"; }
if ($expansion =~ m/^Commander 2013 Edition/i) { $expansion .= " [C13]"; }
if ($expansion =~ m/^Commander 2014/i) { $expansion .= " [C14]"; }
if ($expansion =~ m/^Commander 2015/i) { $expansion .= " [C15]"; }
if ($expansion =~ m/^Commander 2016/i) { $expansion .= " [C16]"; }
if ($expansion =~ m/^Commander 2017/i) { $expansion .= " [C17]"; }
if ($expansion =~ m/^Commander 2018/i) { $expansion .= " [C18]"; }
if ($expansion =~ m/^Commander Anthology 2018/i) { $expansion .= " [CM2]"; }
if ($expansion =~ m/^Commander Anthology/i) { $expansion .= " [CMA]"; }
if ($expansion =~ m/^Conflux/i) { $expansion .= " [CON]"; }
if ($expansion =~ m/^Conspiracy: Take the Crown/i) { $expansion .= " [CN2]"; }
if ($expansion =~ m/^Core Set 2019/i) { $expansion .= " [M19]"; }
if ($expansion =~ m/^Core Set 2020/i) { $expansion .= " [M20]"; }
if ($expansion =~ m/^Core Set 2021/i) { $expansion .= " [M21]"; }
if ($expansion =~ m/^Dark Ascension/i) { $expansion .= " [DKA]"; }
if ($expansion =~ m/^Darksteel/i) { $expansion .= " [DST]"; }
if ($expansion =~ m/^Deckmasters/i) { $expansion .= " [DKM]"; }
if ($expansion =~ m/^Dissension/i) { $expansion .= " [DIS]"; }
if ($expansion =~ m/^Dominaria/i) { $expansion .= " [DOM]"; }
if ($expansion =~ m/^Double Masters/i) { $expansion .= " [2XM]"; }
if ($expansion =~ m/^Dragon's Maze/i) { $expansion .= " [DGM]"; }
if ($expansion =~ m/^Dragons of Tarkir/i) { $expansion .= " [DTK]"; }
if ($expansion =~ m/^Duel Decks Anthology, Divine vs. Demonic/i) { $expansion .= " [DD3DVD]"; }
if ($expansion =~ m/^Duel Decks Anthology, Elves vs. Goblins/i) { $expansion .= " [DD3EVG]"; }
if ($expansion =~ m/^Duel Decks Anthology, Garruk vs. Liliana/i) { $expansion .= " [DD3GVL]"; }
if ($expansion =~ m/^Duel Decks Anthology, Jace vs. Chandra/i) { $expansion .= " [DD3JVC]"; }
if ($expansion =~ m/^Duel Decks/i) { $expansion .= " [DDU]"; }
if ($expansion =~ m/^Duel Decks: Ajani vs. Nicol Bolas/i) { $expansion .= " [DDH]"; }
if ($expansion =~ m/^Duel Decks: Blessed vs. Cursed/i) { $expansion .= " [DDQ]"; }
if ($expansion =~ m/^Duel Decks: Divine vs. Demonic/i) { $expansion .= " [DDC]"; }
if ($expansion =~ m/^Duel Decks: Elspeth vs. Kiora/i) { $expansion .= " [DDO]"; }
if ($expansion =~ m/^Duel Decks: Elspeth vs. Tezzeret/i) { $expansion .= " [DDF]"; }
if ($expansion =~ m/^Duel Decks: Elves vs. Goblins/i) { $expansion .= " [EVG]"; }
if ($expansion =~ m/^Duel Decks: Elves vs. Inventors/i) { $expansion .= " [DDU]"; }
if ($expansion =~ m/^Duel Decks: Garruk vs. Liliana/i) { $expansion .= " [DDD]"; }
if ($expansion =~ m/^Duel Decks: Heroes vs. Monsters/i) { $expansion .= " [DDL]"; }
if ($expansion =~ m/^Duel Decks: Izzet vs. Golgari/i) { $expansion .= " [DDJ]"; }
if ($expansion =~ m/^Duel Decks: Jace vs. Chandra/i) { $expansion .= " [DD2]"; }
if ($expansion =~ m/^Duel Decks: Jace vs. Vraska/i) { $expansion .= " [DDM]"; }
if ($expansion =~ m/^Duel Decks: Knights vs. Dragons/i) { $expansion .= " [DDG]"; }
if ($expansion =~ m/^Duel Decks: Merfolk vs. Goblins/i) { $expansion .= " [DDT]"; }
if ($expansion =~ m/^Duel Decks: Mind vs. Might/i) { $expansion .= " [DDS]"; }
if ($expansion =~ m/^Duel Decks: Nissa vs. Ob Nixilis/i) { $expansion .= " [DDR]"; }
if ($expansion =~ m/^Duel Decks: Phyrexia vs. the Coalition/i) { $expansion .= " [DDE]"; }
if ($expansion =~ m/^Duel Decks: Sorin vs. Tibalt/i) { $expansion .= " [DDK]"; }
if ($expansion =~ m/^Duel Decks: Speed vs. Cunning/i) { $expansion .= " [DDN]"; }
if ($expansion =~ m/^Duel Decks: Venser vs. Koth/i) { $expansion .= " [DDI]"; }
if ($expansion =~ m/^Duel Decks: Zendikar vs. Eldrazi/i) { $expansion .= " [DDP]"; }
if ($expansion =~ m/^Eighth Edition/i) { $expansion .= " [8ED]"; }
if ($expansion =~ m/^Eldritch Moon/i) { $expansion .= " [EMN]"; }
if ($expansion =~ m/^Eternal Masters/i) { $expansion .= " [EMA]"; }
if ($expansion =~ m/^Eventide/i) { $expansion .= " [EVE]"; }
if ($expansion =~ m/^Exodus/i) { $expansion .= " [EXO]"; }
if ($expansion =~ m/^Expansions/i) { $expansion .= " [FEM]"; }
if ($expansion =~ m/^Fallen Empires/i) { $expansion .= " [FEM]"; }
if ($expansion =~ m/^Fate Reforged/i) { $expansion .= " [FRF]"; }
if ($expansion =~ m/^Fifth Dawn/i) { $expansion .= " [5DN]"; }
if ($expansion =~ m/^Fifth Edition/i) { $expansion .= " [5ED]"; }
if ($expansion =~ m/^Fourth Edition/i) { $expansion .= " [4ED]"; }
if ($expansion =~ m/^Friday Night Magic/i) { $expansion .= " [FNMP]"; }
if ($expansion =~ m/^Friday Night Magic/i) { $expansion .= " [FNM]"; }
if ($expansion =~ m/^From the Vault/i) { $expansion .= " [V17]"; }
if ($expansion =~ m/^From the Vault: Angels (2015)/i) { $expansion .= " [V15]"; }
if ($expansion =~ m/^From the Vault: Annihilation (2014)/i) { $expansion .= " [V14]"; }
if ($expansion =~ m/^From the Vault: Dragons/i) { $expansion .= " [DRB]"; }
if ($expansion =~ m/^From the Vault: Exiled/i) { $expansion .= " [V09]"; }
if ($expansion =~ m/^From the Vault: Legends/i) { $expansion .= " [V11]"; }
if ($expansion =~ m/^From the Vault: Lore (2016)/i) { $expansion .= " [V16]"; }
if ($expansion =~ m/^From the Vault: Lore/i) { $expansion .= " [V16]"; }
if ($expansion =~ m/^From the Vault: Realms/i) { $expansion .= " [V12]"; }
if ($expansion =~ m/^From the Vault: Relics/i) { $expansion .= " [V10]"; }
if ($expansion =~ m/^From the Vault: Twenty/i) { $expansion .= " [V13]"; }
if ($expansion =~ m/^Future Sight/i) { $expansion .= " [FUT]"; }
if ($expansion =~ m/^Game Day/i) { $expansion .= " [MGDC]"; }
if ($expansion =~ m/^Gatecrash/i) { $expansion .= " [GTC]"; }
if ($expansion =~ m/^Grand Prix/i) { $expansion .= " [GPX]"; }
if ($expansion =~ m/^Grand Prix/i) { $expansion .= " [PGPX]"; }
if ($expansion =~ m/^Guild Kits/i) { $expansion .= " [GK1]"; }
if ($expansion =~ m/^Guildpact/i) { $expansion .= " [GPT]"; }
if ($expansion =~ m/^Guilds of Ravnica/i) { $expansion .= "[GRN]"; }
if ($expansion =~ m/^Homelands/i) { $expansion .= " [HML]"; }
if ($expansion =~ m/^Hour of Devastation/i) { $expansion .= " [HOU]"; }
if ($expansion =~ m/^Ice Age/i) { $expansion .= " [ICE]"; }
if ($expansion =~ m/^Iconic Masters/i) { $expansion .= " [IMA]"; }
if ($expansion =~ m/^Ikoria: Lair of Behemoths/i) { $expansion .= " [IKO]"; }
if ($expansion =~ m/^Innistrad/i) { $expansion .= " [ISD]"; }
if ($expansion =~ m/^Invasion/i) { $expansion .= " [INV]"; }
if ($expansion =~ m/^Ixalan/i) { $expansion .= " [XLN]"; }
if ($expansion =~ m/^Journey into Nyx/i) { $expansion .= " [JOU]"; }
if ($expansion =~ m/^Judge Promo/i) { $expansion .= " [JR]"; }
if ($expansion =~ m/^Judgment/i) { $expansion .= " [JUD]"; }
if ($expansion =~ m/^Jumpstart/i) { $expansion .= " [JMP]"; }
if ($expansion =~ m/^Kaladesh/i) { $expansion .= " [KLD]"; }
if ($expansion =~ m/^Khans of Tarkir/i) { $expansion .= " [KTK]"; }
if ($expansion =~ m/^Launch Party/i) { $expansion .= " [MLP]"; }
if ($expansion =~ m/^Legends/i) { $expansion .= " [LEG]"; }
if ($expansion =~ m/^Legions/i) { $expansion .= " [LGN]"; }
if ($expansion =~ m/^Limited Edition Alpha/i) { $expansion .= " [LEA]"; }
if ($expansion =~ m/^Limited Edition Beta/i) { $expansion .= " [LEB]"; }
if ($expansion =~ m/^Lorwyn/i) { $expansion .= " [LRW]"; }
if ($expansion =~ m/^MTGO Vanguard/i) { $expansion .= " [VGO]"; }
if ($expansion =~ m/^Magic 2010/i) { $expansion .= " [M10]"; }
if ($expansion =~ m/^Magic 2011/i) { $expansion .= " [M11]"; }
if ($expansion =~ m/^Magic 2012/i) { $expansion .= " [M12]"; }
if ($expansion =~ m/^Magic 2013/i) { $expansion .= " [M13]"; }
if ($expansion =~ m/^Magic 2014/i) { $expansion .= " [M14]"; }
if ($expansion =~ m/^Magic 2015/i) { $expansion .= " [M15]"; }
if ($expansion =~ m/^Magic Origins/i) { $expansion .= " [ORI]"; }
if ($expansion =~ m/^Magic Player Rewards/i) { $expansion .= " [MPRP]"; }
if ($expansion =~ m/^Magic: The Gathering-Commander/i) { $expansion .= " [CMD]"; }
if ($expansion =~ m/^Magic: The Gathering.*Conspiracy/i) { $expansion .= " [CNS]"; }
if ($expansion =~ m/^Magic: The Gathering.*Conspiracy/i) { $expansion .= "[CNS]"; }
if ($expansion =~ m/^Magic: The Gathering—Conspiracy/i) { $expansion .= " [CNS]"; }
if ($expansion =~ m/^Masques/i) { $expansion .= " [PR]"; }
if ($expansion =~ m/^Masterpiece Series MED/i) { $expansion .= " [WAR]"; }
if ($expansion =~ m/^Masterpiece Series/i) { $expansion .= " [MPS]"; }
if ($expansion =~ m/^Masters Edition II/i) { $expansion .= " [ME2]"; }
if ($expansion =~ m/^Masters Edition III/i) { $expansion .= " [ME3]"; }
if ($expansion =~ m/^Masters Edition IV/i) { $expansion .= " [ME4]"; }
if ($expansion =~ m/^Masters Edition/i) { $expansion .= " [ME4]"; }
if ($expansion =~ m/^Masters Edition/i) { $expansion .= " [MED]"; }
if ($expansion =~ m/^Media Inserts/i) { $expansion .= " [MBP]"; }
if ($expansion =~ m/^Media Inserts/i) { $expansion .= " [PMEI]"; }
if ($expansion =~ m/^Mercadian Masques/i) { $expansion .= " [MMQ]"; }
if ($expansion =~ m/^Mirage/i) { $expansion .= " [MIR]"; }
if ($expansion =~ m/^Mirage/i) { $expansion .= " [WL]"; }
if ($expansion =~ m/^Mirrodin Besieged/i) { $expansion .= " [MBS]"; }
if ($expansion =~ m/^Mirrodin/i) { $expansion .= " [MRD]"; }
if ($expansion =~ m/^Modern Horizons/i) { $expansion .= " [MH1]"; }
if ($expansion =~ m/^Modern Masters 2015/i) { $expansion .= " [MM2]"; }
if ($expansion =~ m/^Modern Masters 2017/i) { $expansion .= " [MM3]"; }
if ($expansion =~ m/^Modern Masters/i) { $expansion .= " [MMA]"; }
if ($expansion =~ m/^Morningtide/i) { $expansion .= " [MOR]"; }
if ($expansion =~ m/^Nemesis/i) { $expansion .= " [NEM]"; }
if ($expansion =~ m/^New Phyrexia/i) { $expansion .= " [NPH]"; }
if ($expansion =~ m/^Ninth Edition/i) { $expansion .= " [9ED]"; }
if ($expansion =~ m/^Oath of the Gatewatch/i) { $expansion .= " [OGW]"; }
if ($expansion =~ m/^Odyssey/i) { $expansion .= " [ODY]"; }
if ($expansion =~ m/^Onslaught/i) { $expansion .= " [ONS]"; }
if ($expansion =~ m/^Planar Chaos/i) { $expansion .= " [PLC]"; }
if ($expansion =~ m/^Planechase 2012 Edition/i) { $expansion .= " [PC2]"; }
if ($expansion =~ m/^Planechase/i) { $expansion .= " [HOP]"; }
if ($expansion =~ m/^Planechase/i) { $expansion .= " [PC1]"; }
if ($expansion =~ m/^Planeshift/i) { $expansion .= " [PLS]"; }
if ($expansion =~ m/^Portal Second Age/i) { $expansion .= " [PO2]"; }
if ($expansion =~ m/^Portal Three Kingdoms/i) { $expansion .= " [PTK]"; }
if ($expansion =~ m/^Portal/i) { $expansion .= " [POR]"; }
if ($expansion =~ m/^Premium Deck Series/i) { $expansion .= " [PD3]"; }
if ($expansion =~ m/^Premium Deck Series: Fire and Lightning/i) { $expansion .= " [PD2]"; }
if ($expansion =~ m/^Premium Deck Series: Slivers/i) { $expansion .= " [H09]"; }
if ($expansion =~ m/^Prerelease Events/i) { $expansion .= " [PPRE]"; }
if ($expansion =~ m/^Prerelease Events/i) { $expansion .= " [PTC]"; }
if ($expansion =~ m/^Promotional/i) { $expansion .= " [PRM]"; }
if ($expansion =~ m/^Prophecy/i) { $expansion .= " [PCY]"; }
if ($expansion =~ m/^Ravnica Allegiance/i) { $expansion .= " [RNA]"; }
if ($expansion =~ m/^Ravnica: City of Guilds/i) { $expansion .= " [RAV]"; }
if ($expansion =~ m/^Reprints.*Anthologies/i) { $expansion .= " [BTD]"; }
if ($expansion =~ m/^Return to Ravnica/i) { $expansion .= " [DGM]"; }
if ($expansion =~ m/^Return to Ravnica/i) { $expansion .= " [RTR]"; }
if ($expansion =~ m/^Revised Edition/i) { $expansion .= " [3ED]"; }
if ($expansion =~ m/^Rise of the Eldrazi/i) { $expansion .= " [ROE]"; }
if ($expansion =~ m/^Rivals of Ixalan/i) { $expansion .= "[RIX]"; }
if ($expansion =~ m/^Saviors of Kamigawa/i) { $expansion .= " [SOK]"; }
if ($expansion =~ m/^Scars of Mirrodin/i) { $expansion .= " [SOM]"; }
if ($expansion =~ m/^Scourge/i) { $expansion .= " [SCG]"; }
if ($expansion =~ m/^Secret Lair/i) { $expansion .= " [SLD]"; }
if ($expansion =~ m/^Seventh Edition/i) { $expansion .= " [7ED]"; }
if ($expansion =~ m/^Shadowmoor/i) { $expansion .= " [SHM]"; }
if ($expansion =~ m/^Shadows over Innistrad/i) { $expansion .= " [SOI]"; }
if ($expansion =~ m/^Shards of Alara/i) { $expansion .= " [ALA]"; }
if ($expansion =~ m/^Special Sets/i) { $expansion .= " [MB1]"; }
if ($expansion =~ m/^Special Sets/i) { $expansion .= " [MH1]"; }
if ($expansion =~ m/^Spellbooks/i) { $expansion .= " [SS1]"; }
if ($expansion =~ m/^Starter 1999/i) { $expansion .= " [S99]"; }
if ($expansion =~ m/^Starter 2000/i) { $expansion .= " [S00]"; }
if ($expansion =~ m/^Starter/i) { $expansion .= " [S00]"; }
if ($expansion =~ m/^Stronghold/i) { $expansion .= " [STH]"; }
if ($expansion =~ m/^Tempest Remastered/i) { $expansion .= " [TPR]"; }
if ($expansion =~ m/^Tempest/i) { $expansion .= " [EX]"; }
if ($expansion =~ m/^Tempest/i) { $expansion .= " [TMP]"; }
if ($expansion =~ m/^Tenth Edition/i) { $expansion .= " [10E]"; }
if ($expansion =~ m/^The Dark/i) { $expansion .= " [DRK]"; }
if ($expansion =~ m/^Theros.*Beyond Death/i) { $expansion .= " [THB]"; }
elsif ($expansion =~ m/^Theros/i) { $expansion .= " [THS]"; }
if ($expansion =~ m/^Throne of Eldraine/i) { $expansion .= " [ELD]"; }
if ($expansion =~ m/^Time Spiral.*Timeshifted/i) { $expansion .= " [TSB]"; }
elsif ($expansion =~ m/^Time Spiral/i) { $expansion .= " [TSP]"; }
if ($expansion =~ m/^Time Spiral/i) { $expansion .= " [TSP]"; }
if ($expansion =~ m/^Torment/i) { $expansion .= " [TOR]"; }
if ($expansion =~ m/^Un-Sets/i) { $expansion .= " [UND]"; }
if ($expansion =~ m/^Unglued/i) { $expansion .= " [UGL]"; }
if ($expansion =~ m/^Unhinged/i) { $expansion .= " [UNH]"; }
if ($expansion =~ m/^Unlimited Edition/i) { $expansion .= " [2ED]"; }
if ($expansion =~ m/^Urza's Destiny/i) { $expansion .= " [UDS]"; }
if ($expansion =~ m/^Urza's Legacy/i) { $expansion .= " [ULG]"; }
if ($expansion =~ m/^Urza's Saga/i) { $expansion .= " [USG]"; }
if ($expansion =~ m/^Vanguard Set 1/i) { $expansion .= " [VG1]"; }
if ($expansion =~ m/^Vanguard Set 2/i) { $expansion .= " [VG2]"; }
if ($expansion =~ m/^Vanguard Set 3/i) { $expansion .= " [VG3]"; }
if ($expansion =~ m/^Vanguard Set 4/i) { $expansion .= " [VG4]"; }
if ($expansion =~ m/^Vintage Masters/i) { $expansion .= " [VMA]"; }
if ($expansion =~ m/^Visions/i) { $expansion .= " [VIS]"; }
if ($expansion =~ m/^WPN Gateway/i) { $expansion .= " [GRC]"; }
if ($expansion =~ m/^War of the Spark/i) { $expansion .= " [WAR]"; }
if ($expansion =~ m/^Weatherlight/i) { $expansion .= " [WTH]"; }
if ($expansion =~ m/^Welcome Deck 2016/i) { $expansion .= " [W16]"; }
if ($expansion =~ m/^Welcome Deck 2017/i) { $expansion .= " [W17]"; }
if ($expansion =~ m/^World Magic Cup Qualifier/i) { $expansion .= " [WMCQ]"; }
if ($expansion =~ m/^Worldwake/i) { $expansion .= " [WWK]"; }
if ($expansion =~ m/^Zendikar Rising/i) { $expansion .= " [ZNR]"; }
elsif ($expansion =~ m/^Zendikar/i) { $expansion .= " [ZEN]"; }
return $expansion;
}
# Read all cards
sub read_all_cards
{
#open ALL, "./modern_magic_cards";
#open ALL, "d:/perl_programs/new_all_modern_cards.txt";
#open ALL, "d:/perl_programs/all_magic_cards.txt";
# 20190322 - Use the xmage version of the cards..
#open ALL, "c:/xmage_release_xxx/mage/Utils/mtg-cards-data.txt";
my $CURRENT_FILE = "c:/xmage_clean/mage/Utils/mtg-cards-data.txt";
open ALL, $CURRENT_FILE;
print ("Reading from $CURRENT_FILE\n");
my $cards_count = 0;
while (<ALL>)
{
chomp $_;
my $line = $_;
$line =~ s/\|\|/| |/g;
$line =~ s/\|\|/| |/g;
$line =~ s/^([^\|]*)\|([^\|]*)\|([^\|]*)\|S\|(.*)/$1|$2|$3|Special|$4/gim;
$line =~ s/^([^\|]*)\|([^\|]*)\|([^\|]*)\|M\|(.*)/$1|$2|$3|Mythic Rare|$4/gim;
$line =~ s/^([^\|]*)\|([^\|]*)\|([^\|]*)\|R\|(.*)/$1|$2|$3|Rare|$4/gim;
$line =~ s/^([^\|]*)\|([^\|]*)\|([^\|]*)\|U\|(.*)/$1|$2|$3|Uncommon|$4/gim;
$line =~ s/^([^\|]*)\|([^\|]*)\|([^\|]*)\|C\|(.*)/$1|$2|$3|Common|$4/gim;
$line =~ s/^([^\|]*)\|([^\|]*)\|([^\|]*)\|L\|(.*)/$1|$2|$3|Land|$4/gim;
#print $line, "\n";
$number_cards ++;
my @fields = split /\|/, $line;
my $combined_name = $fields [0] . " - " . $fields [1];
if ($number_cards % 5000 == 4999)
{
print ("$number_cards lines ($combined_name)\n");
}
$all_cards {$combined_name} = $line;
my $f;
$original_lines {$combined_name} = $line;
$original_lines_just_card_names {$fields [0]} = $line;
my $expansion = expansion_trigraph ($fields [1]);
{
$card_names {$combined_name} = $fields [0];
$cards_count++;
$expansion {$combined_name} = $expansion;
$card_cost {$combined_name} = $fields [4];
$card_type {$combined_name} = $fields [5];
$card_text {$combined_name} = $fields [8];
my $CMC = $fields [4];
$CMC =~ s/P//g;
$CMC =~ s/X//g;
$CMC =~ s/Y//g;
$CMC =~ s/Z//g;
$CMC =~ s/{2\/.}/{2}/g;
$CMC =~ s/{W}/{1}/g;
$CMC =~ s/{U}/{1}/g;
$CMC =~ s/{B}/{1}/g;
$CMC =~ s/{R}/{1}/g;
$CMC =~ s/{G}/{1}/g;
$CMC =~ s/{S}/{1}/g;
$CMC =~ s/{C}/{1}/g;
$CMC =~ s/{[WUBRGSC][WUBRGSC]}/{1}/g;
$CMC =~ s/{[WUBRGSC]\/[WUBRGSC]}/{1}/g;
$CMC =~ s/[^0-9]/+/g;
$CMC =~ s/\++/+/g;
$CMC =~ s/\+*$//g;
$CMC =~ s/^\+*//g;
my $cmc = eval ($CMC);
$card_converted_cost {$combined_name} = $cmc;
my $cid;
if ($line =~ m/{[^}]*?[W]/) { $cid .= "W"; }
if ($line =~ m/{[^}]*?[U]/) { $cid .= "U"; }
if ($line =~ m/{[^}]*?[B]/) { $cid .= "B"; }
if ($line =~ m/{[^}]*?[R]/) { $cid .= "R"; }
if ($line =~ m/{[^}]*?[G]/) { $cid .= "G"; }
$card_colour_identity {$combined_name} = $cid;
}
}
print ("Read in: $cards_count cards in total\n");
}
#####
sub write_to_socket
{
my $sock_ref = $_ [0];
my $msg_body = $_ [1];
my $form = $_ [2];
my $redirect = $_ [3];
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $yyyymmddhhmmss = sprintf "%.4d%.2d%.2d-%.2d%.2d%.2d", $year+1900, $mon+1, $mday, $hour, $min, $sec;
print $yyyymmddhhmmss, "\n";
$msg_body = '<html><head><META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"><br><META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2094 11:12:01 GMT"></head><body>' . $form . $msg_body . "<body></html>";
my $header;
if ($redirect =~ m/^redirect(\d)/i)
{
$header = "HTTP/1.1 301 Moved\nLocation: /full$1\nLast-Modified: $yyyymmddhhmmss\nConnection: close\nContent-Type: text/html; charset=UTF-8\nContent-Length: " . length ($msg_body) . "\n\n";
}
elsif ($redirect =~ m/^noredirect/i)
{
$header = "HTTP/1.1 200 OK\nLast-Modified: $yyyymmddhhmmss\nConnection: close\nContent-Type: text/html; charset=UTF-8\nContent-Length: " . length ($msg_body) . "\n\n";
}
#my $header = "HTTP/1.1 200 OK\nLast-Modified: $yyyymmddhhmmss\nAccept-Ranges: bytes\nConnection: close\nContent-Type: text/html; charset=UTF-8\nContent-Length: " . length ($msg_body) . "\n\n";
#my $header = "HTTP/1.1 301 Moved\nLocation: /full0\nLast-Modified: $yyyymmddhhmmss\nAccept-Ranges: bytes\nConnection: close\nContent-Type: text/html; charset=UTF-8\nContent-Length: " . length ($msg_body) . "\n\n";
$msg_body =~ s/\n\n/\n/mig;
$msg_body =~ s/\n\n/\n/mig;
$msg_body =~ s/\n\n/\n/mig;
$msg_body = $header . $msg_body;
$msg_body =~ s/\.png/\.npg/;
$msg_body =~ s/img/mgi/;
#$msg_body .= chr(13) . chr(10);
$msg_body .= chr(13) . chr(10) . "0";
#print ("\n===========\nWrite to socket: $msg_body\n==========\n");
print ("\n===========\nWrite to socket: ", length($msg_body), " characters!\n==========\n");
#unless (defined (syswrite ($sock_ref, $msg_body)))
#{
# return 0;
#}
#print ("\n&&&$redirect&&&&&&&&&&&&\n", $msg_body, "\nRRRRRRRRRRRRRR\n");
syswrite ($sock_ref, $msg_body);
}
sub bin_write_to_socket
{
my $sock_ref = $_ [0];
my $img = $_ [1];
my $buffer;
my $size = 0;
if (-f $img)
{
$size = -s $img;
}
my $msg_body = "HTTP/2.0 200 OK\ndate: Mon, 20 May 2019 13:20:41 GMT\ncontent-type: image/jpeg\ncontent-length: $size\n\n";
print $msg_body, "\n";
syswrite ($sock_ref, $msg_body);
open IMAGE, $img;
binmode IMAGE;
my $buffer;
while (read (IMAGE, $buffer, 16384))
{
syswrite ($sock_ref, $buffer);
}
}
sub read_from_socket
{
my $sock_ref = $_ [0];
my $ch = "";
my $prev_ch = "";
my $header = "";
my $rin = "";
my $rout;
my $min;
my $max;
my $msg_type;
my $msg_body;
my $msg_len;
vec ($rin, fileno ($sock_ref), 1) = 1;
# Read the message header
my $num_chars_read = 0;
while ((!(ord ($ch) == 10 and ord ($prev_ch) == 13)))
{
if (select ($rout=$rin, undef, undef, 200) == 1)
{
$prev_ch = $ch;
# There is at least one byte ready to be read..
if (sysread ($sock_ref, $ch, 1) < 1)
{
print ("$header!!\n");
print (" ---> Unable to read a character\n");
return "resend";
}
$header .= $ch;
print ("Reading in at the moment - '$header'!!\n");
#if ($header =~ m/alive\n\n/m)
{
my $h = $header;
$h =~ s/(.)/",$1-" . ord ($1) . ";"/emg;
}
}
$num_chars_read++;
}
print "\n++++++++++++++++++++++\n", $header, "\n";
return $header;
}
sub do_checked
{
if ($_ [0] == 2) { return " checked "; }
if ($_ [0] eq "true") { return " checked "; }
return "";
}
sub no_checked
{
if ($_ [0] == 1) { return " checked "; }
return "";
}
sub compare_to_random
{
my $card_name = $_ [0];
if ($random_card_name eq $card_name) { return "Exact match!"; }
my $comp_string;
my @ac = sort (keys (%all_cards));
my $c;
foreach $c (@ac)
{
if ($c =~ m/^$card_name/i)
{
my $this_card_cmc = card_converted_cost ($c);
my $this_card_cid = card_colour_identity ($c);
my $this_card_type = card_type ($c) . " ";
my $orig_card_cmc = $this_card_cmc;
my $orig_card_cid = $this_card_cid;
my $orig_card_type = $this_card_type;
if ($this_card_cmc == $random_card_cmc) { $comp_string = "<font color=darkgreen>Same cmc ($orig_card_cmc)</font>";}
if ($this_card_cmc < $random_card_cmc) { $comp_string = "<font color=darkred>Higher cmc ($orig_card_cmc)</font>,";}
if ($this_card_cmc > $random_card_cmc) { $comp_string = "<font color=burntorange>Lower cmc ($orig_card_cmc)</font>,";}
if ($this_card_cid eq $random_card_cid)
{
$comp_string .= "<font color=darkgreen>Same coloridentity ($orig_card_cid)</font>,";
}
else
{
my $partial = 0;
while ($this_card_cid =~ s/^(.)//)
{
my $c = $1;
if ($random_card_cid =~ m/$c/)
{
$partial = 1;
}
}
if (!$partial)
{
$comp_string .= "nonmatching coloridentity ($orig_card_cid),";
}
else
{
$comp_string .= "<font color=burntorange>partially matching coloridentity ($orig_card_cid)</font>,";
}
}
my $this_card_set = expansion ($c);
print (">>> $this_card_set === set (vs $random_card_set) for this card $c\n");
if ($this_card_set eq $random_card_set)
{
$comp_string .= "<font color=darkgreen>same set ($this_card_set)</font>,";
}
elsif (($this_card_set cmp $random_card_set) > 0)
{
$comp_string .= "<font color=darkred>$this_card_set higher alphabetically</font>,";
}
elsif (($this_card_set cmp $random_card_set) < 0)
{
$comp_string .= "<font color=burntorange>$this_card_set lower alphabetically</font>,";
}
my $ct1 = $this_card_type . " ";
my $rt1 = $random_card_type . " ";
$ct1 =~ s/\W/ /img;
$ct1 =~ s/ */ /img;
$rt1 =~ s/\W/ /img;
$rt1 =~ s/ */ /img;
if ($ct1 eq $rt1)
{
$comp_string .= "<font color=darkgreen>same type ($orig_card_type)</font>,";
}
else
{
my $partial = 0;
$this_card_type =~ s/-//img;
$this_card_type =~ s/ / /img;
while ($this_card_type =~ s/^([^ ]+)( |$)//)
{
my $t = $1;
#$comp_string .= " (Comp:($t))";
if ($random_card_type =~ m/$t/)
{
$partial = 1;
}
}
if (!$partial)
{
$comp_string .= "nonmatching types ($orig_card_type),";
}
else
{
$comp_string .= "<font color=burntorange>partially matching types ($orig_card_type)</font>,";
}
}
my $l = original_line ($c);
my $this_card_rarity;
my $this_card_rarity_num;
if ($l =~ m/\|Special\|/im) { $this_card_rarity = "Special"; $this_card_rarity_num = 6; }
if ($l =~ m/\|Mythic Rare\|/im) { $this_card_rarity = "Mythic"; $this_card_rarity_num = 5; }
if ($l =~ m/\|Rare\|/im) { $this_card_rarity = "Rare"; $this_card_rarity_num = 4; }
if ($l =~ m/\|Uncommon\|/im) { $this_card_rarity = "Uncommon"; $this_card_rarity_num = 3; }
if ($l =~ m/\|Common\|/im) { $this_card_rarity = "Common"; $this_card_rarity_num = 2; }
if ($l =~ m/\|Land\|/im) { $this_card_rarity = "Common"; $this_card_rarity_num = 2; }
print ("Your chosen card was:<br>" . $card_name . "," . $orig_card_cmc . "," . $orig_card_cid . "," . $ct1, " RARITY>>>=$this_card_rarity\n(based on $l)\n");
if ($this_card_rarity eq $random_card_rarity)
{
$comp_string .= "<font color=darkgreen>Same rarities ($this_card_rarity)</font>.";
}
elsif ($this_card_rarity_num > $random_card_rarity_num)
{
$comp_string .= "<font color=darkred>higher rarity ($this_card_rarity)</font>.";
}
elsif ($this_card_rarity_num < $random_card_rarity_num)
{
$comp_string .= "<font color=burntorange>lower rarity ($this_card_rarity)</font>.";
}
print ("\nComparison::: $comp_string ($c)\n");
return $comp_string . " (Compared to $c)";
}
}
}
sub get_sets
{
my $expansion = $_ [0];
my $pack_number = $_ [1];
my $how_many_players = $_ [2];
my %exps;
my %exps_mins;
my $c;
my @ac = sort (keys (%all_cards));
foreach $c (@ac)
{
my $ol = original_line ($c);
if ($ol =~ m/Expansion: (.*?) \(/i)
{
my $set = $1;
$set =~ s/ /.*/g;
$set =~ s/'/.*/g;
if (!defined ($exps {$set}))
{
$exps {$set} = 1;
$exps_mins {$set} = $c;
}
if ($c < $exps_mins {$set})
{
$exps_mins {$set} = $c;
}
}
}
my $s = "<br>";
my $k;
my %mins;
foreach $k (sort (keys %exps_mins))
{
my $val = sprintf ("%08d", $exps_mins {$k});
$mins {$val . "---" . $k} = 1;
}
foreach $k (sort (keys %mins))
{
$s .= $k . "<br>\n";
}
$s =~ s/^.*?---//img;
my %seen_expansions;
foreach $k (sort (values %expansion))
{
if (!defined ($seen_expansions{$k}))
{
#http://127.0.0.1:56789/filter?0&89&0&0&0&0&0&0&false&false&return.*to.*ravnica.*&.*&[12345]..*
$seen_expansions {$k} = 1;
$k =~ s/ *\[.*\]//;
$s .= "<a href='/filter/filter?0&89&0&0&0&0&0&0&false&false&false&$k&.*&[12345]\..*'>$k.*rare</a><br>";
}
}
# Get the minimum/maximum of each sets and then order them!
return $s;
}
sub edh_lands
{
my $filter = $_ [0];
my %exps;
my %exps_mins;
# Get from https://edhrec.com/top/year or https://edhrec.com/top/lands
my %edh_land;
$edh_land {"Abandoned Outpost"} = 1; $edh_land {"Academy Ruins"} = 1; $edh_land {"Access Tunnel"} = 1; $edh_land {"Adarkar Wastes"} = 1; $edh_land {"Adventurers' Guildhouse"} = 1; $edh_land {"Aether Hub"} = 1; $edh_land {"Akoum Refuge"} = 1; $edh_land {"Alchemist's Refuge"} = 1; $edh_land {"Ally Encampment"} = 1; $edh_land {"Alpine Meadow"} = 1; $edh_land {"An-Havva Township"} = 1; $edh_land {"Ancient Amphitheater"} = 1; $edh_land {"Ancient Den"} = 1; $edh_land {"Ancient Spring"} = 1; $edh_land {"Ancient Tomb"} = 1; $edh_land {"Ancient Ziggurat"} = 1; $edh_land {"Animal Sanctuary"} = 1; $edh_land {"Arcane Lighthouse"} = 1; $edh_land {"Arcane Sanctum"} = 1; $edh_land {"Arch of Orazca"} = 1; $edh_land {"Archaeological Dig"} = 1; $edh_land {"Archway Commons"} = 1; $edh_land {"Arctic Flats"} = 1; $edh_land {"Arctic Treeline"} = 1; $edh_land {"Arena"} = 1; $edh_land {"Argoth, Sanctum of Nature"} = 1; $edh_land {"Arid Mesa"} = 1; $edh_land {"Ash Barrens"} = 1; $edh_land {"Auntie's Hovel"} = 1; $edh_land {"Axgard Armory"} = 1; $edh_land {"Aysen Abbey"} = 1; $edh_land {"Azorius Chancery"} = 1; $edh_land {"Azorius Guildgate"} = 1; $edh_land {"Bad River"} = 1; $edh_land {"Badlands"} = 1; $edh_land {"Baldur's Gate"} = 1; $edh_land {"Balduvian Trading Post"} = 1; $edh_land {"Bant Panorama"} = 1; $edh_land {"Barbarian Ring"} = 1; $edh_land {"Barkchannel Pathway"} = 1; $edh_land {"Barren Moor"} = 1; $edh_land {"Base Camp"} = 1; $edh_land {"Basilisk Gate"} = 1; $edh_land {"Battlefield Forge"} = 1; $edh_land {"Bayou"} = 1; $edh_land {"Bazaar of Baghdad"} = 1; $edh_land {"Black Dragon Gate"} = 1; $edh_land {"Blackcleave Cliffs"} = 1; $edh_land {"Blast Zone"} = 1; $edh_land {"Blasted Landscape"} = 1; $edh_land {"Blighted Cataract"} = 1; $edh_land {"Blighted Fen"} = 1; $edh_land {"Blighted Gorge"} = 1; $edh_land {"Blighted Steppe"} = 1; $edh_land {"Blighted Woodland"} = 1;
$edh_land {"Blightstep Pathway"} = 1; $edh_land {"Blinkmoth Nexus"} = 1; $edh_land {"Blinkmoth Well"} = 1; $edh_land {"Blood Crypt"} = 1; $edh_land {"Bloodfell Caves"} = 1; $edh_land {"Bloodstained Mire"} = 1; $edh_land {"Blooming Marsh"} = 1; $edh_land {"Blossoming Sands"} = 1; $edh_land {"Bog Wreckage"} = 1; $edh_land {"Bojuka Bog"} = 1; $edh_land {"Bonders' Enclave"} = 1; $edh_land {"Boreal Shelf"} = 1; $edh_land {"Boros Garrison"} = 1; $edh_land {"Boros Guildgate"} = 1; $edh_land {"Boseiju, Who Endures"} = 1; $edh_land {"Boseiju, Who Shelters All"} = 1; $edh_land {"Botanical Plaza"} = 1; $edh_land {"Botanical Sanctum"} = 1; $edh_land {"Bottomless Vault"} = 1; $edh_land {"Bountiful Promenade"} = 1; $edh_land {"Branchloft Pathway"} = 1; $edh_land {"Breeding Pool"} = 1; $edh_land {"Bretagard Stronghold"} = 1; $edh_land {"Brightclimb Pathway"} = 1; $edh_land {"Brokers Hideout"} = 1; $edh_land {"Brushland"} = 1; $edh_land {"Buried Ruin"} = 1; $edh_land {"Cabal Coffers"} = 1; $edh_land {"Cabal Pit"} = 1; $edh_land {"Cabal Stronghold"} = 1; $edh_land {"Cabaretti Courtyard"} = 1; $edh_land {"Calciform Pools"} = 1; $edh_land {"Caldera Lake"} = 1; $edh_land {"Canopy Vista"} = 1; $edh_land {"Canyon Slough"} = 1; $edh_land {"Cascade Bluffs"} = 1; $edh_land {"Cascading Cataracts"} = 1; $edh_land {"Castle Ardenvale"} = 1; $edh_land {"Castle Embereth"} = 1; $edh_land {"Castle Garenbrig"} = 1; $edh_land {"Castle Locthwain"} = 1; $edh_land {"Castle Sengir"} = 1; $edh_land {"Castle Vantress"} = 1; $edh_land {"Cathedral of Serra"} = 1; $edh_land {"Cathedral of War"} = 1; $edh_land {"Cave of Temptation"} = 1; $edh_land {"Cave of the Frost Dragon"} = 1; $edh_land {"Cavern of Souls"} = 1; $edh_land {"Caves of Koilos"} = 1; $edh_land {"Celestial Colonnade"} = 1; $edh_land {"Centaur Garden"} = 1; $edh_land {"Cephalid Coliseum"} = 1; $edh_land {"Choked Estuary"} = 1; $edh_land {"Cinder Barrens"} = 1; $edh_land {"Cinder Glade"} = 1;
$edh_land {"Cinder Marsh"} = 1; $edh_land {"Citadel Gate"} = 1; $edh_land {"City of Brass"} = 1; $edh_land {"City of Shadows"} = 1; $edh_land {"City of Traitors"} = 1; $edh_land {"Clearwater Pathway"} = 1; $edh_land {"Cliffgate"} = 1; $edh_land {"Clifftop Retreat"} = 1; $edh_land {"Cloudcrest Lake"} = 1; $edh_land {"Cloudpost"} = 1; $edh_land {"Coastal Tower"} = 1; $edh_land {"Command Beacon"} = 1; $edh_land {"Command Tower"} = 1; $edh_land {"Concealed Courtyard"} = 1; $edh_land {"Contaminated Aquifer"} = 1; $edh_land {"Contested Cliffs"} = 1; $edh_land {"Contested War Zone"} = 1; $edh_land {"Copperline Gorge"} = 1; $edh_land {"Coral Atoll"} = 1; $edh_land {"Corrupted Crossroads"} = 1; $edh_land {"Cradle of the Accursed"} = 1; $edh_land {"Cragcrown Pathway"} = 1; $edh_land {"Crawling Barrens"} = 1; $edh_land {"Creeping Tar Pit"} = 1; $edh_land {"Crosis's Catacombs"} = 1; $edh_land {"Crucible of the Spirit Dragon"} = 1; $edh_land {"Crumbling Necropolis"} = 1; $edh_land {"Crumbling Vestige"} = 1; $edh_land {"Crypt of Agadeem"} = 1; $edh_land {"Crypt of the Eternals"} = 1; $edh_land {"Cryptic Caves"} = 1; $edh_land {"Cryptic Spires"} = 1; $edh_land {"Crystal Grotto"} = 1; $edh_land {"Crystal Quarry"} = 1; $edh_land {"Crystal Vein"} = 1; $edh_land {"Dakmor Salvage"} = 1; $edh_land {"Darigaaz's Caldera"} = 1; $edh_land {"Dark Depths"} = 1; $edh_land {"Darkbore Pathway"} = 1; $edh_land {"Darkmoss Bridge"} = 1; $edh_land {"Darkslick Shores"} = 1; $edh_land {"Darksteel Citadel"} = 1; $edh_land {"Darkwater Catacombs"} = 1; $edh_land {"Daru Encampment"} = 1; $edh_land {"Deathcap Glade"} = 1; $edh_land {"Demolition Field"} = 1; $edh_land {"Den of the Bugbear"} = 1; $edh_land {"Desert of the Fervent"} = 1; $edh_land {"Desert of the Glorified"} = 1; $edh_land {"Desert of the Indomitable"} = 1; $edh_land {"Desert of the Mindful"} = 1; $edh_land {"Desert of the True"} = 1; $edh_land {"Desert"} = 1; $edh_land {"Deserted Beach"} = 1; $edh_land {"Deserted Temple"} = 1;
$edh_land {"Desolate Lighthouse"} = 1; $edh_land {"Detection Tower"} = 1; $edh_land {"Diamond Valley"} = 1; $edh_land {"Dimir Aqueduct"} = 1; $edh_land {"Dimir Guildgate"} = 1; $edh_land {"Dismal Backwater"} = 1; $edh_land {"Dormant Volcano"} = 1; $edh_land {"Dragonskull Summit"} = 1; $edh_land {"Dread Statuary"} = 1; $edh_land {"Dreadship Reef"} = 1; $edh_land {"Dreamroot Cascade"} = 1; $edh_land {"Drifting Meadow"} = 1; $edh_land {"Dromar's Cavern"} = 1; $edh_land {"Drossforge Bridge"} = 1; $edh_land {"Drowned Catacomb"} = 1; $edh_land {"Drownyard Temple"} = 1; $edh_land {"Dryad Arbor"} = 1; $edh_land {"Dunes of the Dead"} = 1; $edh_land {"Dungeon Descent"} = 1; $edh_land {"Duskmantle, House of Shadow"} = 1; $edh_land {"Dust Bowl"} = 1; $edh_land {"Dwarven Hold"} = 1; $edh_land {"Dwarven Mine"} = 1; $edh_land {"Dwarven Ruins"} = 1; $edh_land {"Ebon Stronghold"} = 1; $edh_land {"Eiganjo Castle"} = 1; $edh_land {"Eiganjo, Seat of the Empire"} = 1; $edh_land {"Eldrazi Temple"} = 1; $edh_land {"Elephant Graveyard"} = 1; $edh_land {"Elfhame Palace"} = 1; $edh_land {"Emergence Zone"} = 1; $edh_land {"Emeria, the Sky Ruin"} = 1; $edh_land {"Encroaching Wastes"} = 1; $edh_land {"Endless Sands"} = 1; $edh_land {"Esper Panorama"} = 1; $edh_land {"Everglades"} = 1; $edh_land {"Evolving Wilds"} = 1; $edh_land {"Exotic Orchard"} = 1; $edh_land {"Eye of Ugin"} = 1; $edh_land {"Fabled Passage"} = 1; $edh_land {"Faceless Haven"} = 1; $edh_land {"Faerie Conclave"} = 1; $edh_land {"Fertile Thicket"} = 1; $edh_land {"Fetid Heath"} = 1; $edh_land {"Fetid Pools"} = 1; $edh_land {"Field of Ruin"} = 1; $edh_land {"Field of the Dead"} = 1; $edh_land {"Fiery Islet"} = 1; $edh_land {"Fire-Lit Thicket"} = 1; $edh_land {"Flagstones of Trokair"} = 1; $edh_land {"Flamekin Village"} = 1; $edh_land {"Flood Plain"} = 1; $edh_land {"Flooded Grove"} = 1; $edh_land {"Flooded Strand"} = 1; $edh_land {"Forbidden Orchard"} = 1;
$edh_land {"Forbidding Watchtower"} = 1; $edh_land {"Foreboding Ruins"} = 1; $edh_land {"Forest"} = 1; $edh_land {"Forge of Heroes"} = 1; $edh_land {"Forgotten Cave"} = 1; $edh_land {"Forsaken City"} = 1; $edh_land {"Forsaken Sanctuary"} = 1; $edh_land {"Fortified Beachhead"} = 1; $edh_land {"Fortified Village"} = 1; $edh_land {"Foul Orchard"} = 1; $edh_land {"Foundry of the Consuls"} = 1; $edh_land {"Fountain of Cho"} = 1; $edh_land {"Frontier Bivouac"} = 1; $edh_land {"Frost Marsh"} = 1; $edh_land {"Frostboil Snarl"} = 1; $edh_land {"Frostwalk Bastion"} = 1; $edh_land {"Fungal Reaches"} = 1; $edh_land {"Furycalm Snarl"} = 1; $edh_land {"Gaea's Cradle"} = 1; $edh_land {"Game Trail"} = 1; $edh_land {"Gargoyle Castle"} = 1; $edh_land {"Gates of Istfell"} = 1; $edh_land {"Gateway Plaza"} = 1; $edh_land {"Gavony Township"} = 1; $edh_land {"Geier Reach Sanitarium"} = 1; $edh_land {"Gemstone Caverns"} = 1; $edh_land {"Gemstone Mine"} = 1; $edh_land {"Geothermal Bog"} = 1; $edh_land {"Geothermal Crevice"} = 1; $edh_land {"Ghitu Encampment"} = 1; $edh_land {"Ghost Quarter"} = 1; $edh_land {"Ghost Town"} = 1; $edh_land {"Gilt-Leaf Palace"} = 1; $edh_land {"Gingerbread Cabin"} = 1; $edh_land {"Glacial Chasm"} = 1; $edh_land {"Glacial Floodplain"} = 1; $edh_land {"Glacial Fortress"} = 1; $edh_land {"Glimmerpost"} = 1; $edh_land {"Glimmervoid"} = 1; $edh_land {"Gnottvold Slumbermound"} = 1; $edh_land {"Goblin Burrows"} = 1; $edh_land {"Godless Shrine"} = 1; $edh_land {"Gods' Eye, Gate to the Reikai"} = 1; $edh_land {"Goldmire Bridge"} = 1; $edh_land {"Golgari Guildgate"} = 1; $edh_land {"Golgari Rot Farm"} = 1; $edh_land {"Gond Gate"} = 1; $edh_land {"Grand Coliseum"} = 1; $edh_land {"Grasping Dunes"} = 1; $edh_land {"Grasslands"} = 1; $edh_land {"Graven Cairns"} = 1; $edh_land {"Graypelt Refuge"} = 1; $edh_land {"Great Furnace"} = 1; $edh_land {"Great Hall of Starnheim"} = 1; $edh_land {"Griffin Canyon"} = 1;
$edh_land {"Grim Backwoods"} = 1; $edh_land {"Grixis Panorama"} = 1; $edh_land {"Grove of the Burnwillows"} = 1; $edh_land {"Grove of the Guardian"} = 1; $edh_land {"Gruul Guildgate"} = 1; $edh_land {"Gruul Turf"} = 1; $edh_land {"Guildless Commons"} = 1; $edh_land {"Guildmages' Forum"} = 1; $edh_land {"Halimar Depths"} = 1; $edh_land {"Hall of Heliod's Generosity"} = 1; $edh_land {"Hall of Oracles"} = 1; $edh_land {"Hall of Storm Giants"} = 1; $edh_land {"Hall of Tagsin"} = 1; $edh_land {"Hall of the Bandit Lord"} = 1; $edh_land {"Hallowed Fountain"} = 1; $edh_land {"Halls of Mist"} = 1; $edh_land {"Hammerheim"} = 1; $edh_land {"Hanweir Battlements"} = 1; $edh_land {"Hashep Oasis"} = 1; $edh_land {"Haunted Fengraf"} = 1; $edh_land {"Haunted Mire"} = 1; $edh_land {"Haunted Ridge"} = 1; $edh_land {"Haven of the Spirit Dragon"} = 1; $edh_land {"Havengul Laboratory"} = 1; $edh_land {"Havenwood Battleground"} = 1; $edh_land {"Heap Gate"} = 1; $edh_land {"Heart of Yavimaya"} = 1; $edh_land {"Hellion Crucible"} = 1; $edh_land {"Henge of Ramos"} = 1; $edh_land {"Hengegate Pathway"} = 1; $edh_land {"Hickory Woodlot"} = 1; $edh_land {"High Market"} = 1; $edh_land {"Highland Forest"} = 1; $edh_land {"Highland Lake"} = 1; $edh_land {"Highland Weald"} = 1; $edh_land {"Hinterland Harbor"} = 1; $edh_land {"Hissing Quagmire"} = 1; $edh_land {"Hive of the Eye Tyrant"} = 1; $edh_land {"Holdout Settlement"} = 1; $edh_land {"Hollow Trees"} = 1; $edh_land {"Homeward Path"} = 1; $edh_land {"Horizon Canopy"} = 1; $edh_land {"Hostile Desert"} = 1; $edh_land {"Hostile Hostel"} = 1; $edh_land {"Howltooth Hollow"} = 1; $edh_land {"Icatian Store"} = 1; $edh_land {"Ice Floe"} = 1; $edh_land {"Ice Tunnel"} = 1; $edh_land {"Idyllic Beachfront"} = 1; $edh_land {"Idyllic Grange"} = 1; $edh_land {"Ifnir Deadlands"} = 1; $edh_land {"Immersturm Skullcairn"} = 1; $edh_land {"Indatha Triome"} = 1; $edh_land {"Inkmoth Nexus"} = 1; $edh_land {"Inspiring Vantage"} = 1;
$edh_land {"Interplanar Beacon"} = 1; $edh_land {"Inventors' Fair"} = 1; $edh_land {"Ipnu Rivulet"} = 1; $edh_land {"Irrigated Farmland"} = 1; $edh_land {"Irrigation Ditch"} = 1; $edh_land {"Island of Wak-Wak"} = 1; $edh_land {"Island"} = 1; $edh_land {"Isolated Chapel"} = 1; $edh_land {"Isolated Watchtower"} = 1; $edh_land {"Izzet Boilerworks"} = 1; $edh_land {"Izzet Guildgate"} = 1; $edh_land {"Jetmir's Garden"} = 1; $edh_land {"Jund Panorama"} = 1; $edh_land {"Jungle Basin"} = 1; $edh_land {"Jungle Hollow"} = 1; $edh_land {"Jungle Shrine"} = 1; $edh_land {"Jwar Isle Refuge"} = 1; $edh_land {"Kabira Crossroads"} = 1; $edh_land {"Karn's Bastion"} = 1; $edh_land {"Karoo"} = 1; $edh_land {"Karplusan Forest"} = 1; $edh_land {"Kazandu Refuge"} = 1; $edh_land {"Keldon Megaliths"} = 1; $edh_land {"Keldon Necropolis"} = 1; $edh_land {"Kessig Wolf Run"} = 1; $edh_land {"Ketria Triome"} = 1; $edh_land {"Khalni Garden"} = 1; $edh_land {"Kher Keep"} = 1; $edh_land {"Kjeldoran Outpost"} = 1; $edh_land {"Kor Haven"} = 1; $edh_land {"Koskun Keep"} = 1; $edh_land {"Krosan Verge"} = 1; $edh_land {"Labyrinth of Skophos"} = 1; $edh_land {"Lair of the Hydra"} = 1; $edh_land {"Lake of the Dead"} = 1; $edh_land {"Land Cap"} = 1; $edh_land {"Lantern-Lit Graveyard"} = 1; $edh_land {"Lava Tubes"} = 1; $edh_land {"Lavaclaw Reaches"} = 1; $edh_land {"Leechridden Swamp"} = 1; $edh_land {"Littjara Mirrorlake"} = 1; $edh_land {"Llanowar Reborn"} = 1; $edh_land {"Llanowar Wastes"} = 1; $edh_land {"Lonely Sandbar"} = 1; $edh_land {"Looming Spires"} = 1; $edh_land {"Lorehold Campus"} = 1; $edh_land {"Lotus Field"} = 1; $edh_land {"Lotus Vale"} = 1; $edh_land {"Lumbering Falls"} = 1; $edh_land {"Luxury Suite"} = 1; $edh_land {"Madblind Mountain"} = 1; $edh_land {"Maestros Theater"} = 1; $edh_land {"Mage-Ring Network"} = 1; $edh_land {"Magosi, the Waterveil"} = 1; $edh_land {"Mana Confluence"} = 1;
$edh_land {"Manor Gate"} = 1; $edh_land {"Marsh Flats"} = 1; $edh_land {"Maze of Ith"} = 1; $edh_land {"Maze of Shadows"} = 1; $edh_land {"Maze's End"} = 1; $edh_land {"Meandering River"} = 1; $edh_land {"Mech Hangar"} = 1; $edh_land {"Memorial to Folly"} = 1; $edh_land {"Memorial to Genius"} = 1; $edh_land {"Memorial to Glory"} = 1; $edh_land {"Memorial to Unity"} = 1; $edh_land {"Memorial to War"} = 1; $edh_land {"Mercadian Bazaar"} = 1; $edh_land {"Meteor Crater"} = 1; $edh_land {"Mikokoro, Center of the Sea"} = 1; $edh_land {"Minamo, School at Water's Edge"} = 1; $edh_land {"Miren, the Moaning Well"} = 1; $edh_land {"Mirrex"} = 1; $edh_land {"Mirrodin's Core"} = 1; $edh_land {"Mirrorpool"} = 1; $edh_land {"Mishra's Factory"} = 1; $edh_land {"Mishra's Foundry"} = 1; $edh_land {"Mishra's Workshop"} = 1; $edh_land {"Mistvault Bridge"} = 1; $edh_land {"Mistveil Plains"} = 1; $edh_land {"Misty Rainforest"} = 1; $edh_land {"Mobilized District"} = 1; $edh_land {"Mogg Hollows"} = 1; $edh_land {"Molten Slagheap"} = 1; $edh_land {"Molten Tributary"} = 1; $edh_land {"Moonring Island"} = 1; $edh_land {"Moorland Haunt"} = 1; $edh_land {"Morphic Pool"} = 1; $edh_land {"Mortuary Mire"} = 1; $edh_land {"Mossfire Valley"} = 1; $edh_land {"Mosswort Bridge"} = 1; $edh_land {"Mountain Stronghold"} = 1; $edh_land {"Mountain Valley"} = 1; $edh_land {"Mountain"} = 1; $edh_land {"Mouth of Ronom"} = 1; $edh_land {"Murmuring Bosk"} = 1; $edh_land {"Mutavault"} = 1; $edh_land {"Myriad Landscape"} = 1; $edh_land {"Mystic Gate"} = 1; $edh_land {"Mystic Monastery"} = 1; $edh_land {"Mystic Sanctuary"} = 1; $edh_land {"Mystifying Maze"} = 1; $edh_land {"Nantuko Monastery"} = 1; $edh_land {"Naya Panorama"} = 1; $edh_land {"Nearby Planet"} = 1; $edh_land {"Necroblossom Snarl"} = 1; $edh_land {"Needle Spires"} = 1; $edh_land {"Needleverge Pathway"} = 1; $edh_land {"Nephalia Academy"} = 1; $edh_land {"Nephalia Drownyard"} = 1;
$edh_land {"Nesting Grounds"} = 1; $edh_land {"New Benalia"} = 1; $edh_land {"Nimbus Maze"} = 1; $edh_land {"Nivix, Aerie of the Firemind"} = 1; $edh_land {"Nomad Outpost"} = 1; $edh_land {"Nomad Stadium"} = 1; $edh_land {"Novijen, Heart of Progress"} = 1; $edh_land {"Nurturing Peatland"} = 1; $edh_land {"Nykthos, Shrine to Nyx"} = 1; $edh_land {"Oasis"} = 1; $edh_land {"Oboro, Palace in the Clouds"} = 1; $edh_land {"Obscura Storefront"} = 1; $edh_land {"Okina, Temple to the Grandfathers"} = 1; $edh_land {"Opal Palace"} = 1; $edh_land {"Opulent Palace"} = 1; $edh_land {"Oran-Rief, the Vastwood"} = 1; $edh_land {"Orzhov Basilica"} = 1; $edh_land {"Orzhov Guildgate"} = 1; $edh_land {"Orzhova, the Church of Deals"} = 1; $edh_land {"Otawara, Soaring City"} = 1; $edh_land {"Overgrown Farmland"} = 1; $edh_land {"Overgrown Tomb"} = 1; $edh_land {"Painted Bluffs"} = 1; $edh_land {"Paliano, the High City"} = 1; $edh_land {"Path of Ancestry"} = 1; $edh_land {"Peat Bog"} = 1; $edh_land {"Pendelhaven"} = 1; $edh_land {"Petrified Field"} = 1; $edh_land {"Phyrexia's Core"} = 1; $edh_land {"Phyrexian Tower"} = 1; $edh_land {"Pillar of the Paruns"} = 1; $edh_land {"Pine Barrens"} = 1; $edh_land {"Pinecrest Ridge"} = 1; $edh_land {"Piranha Marsh"} = 1; $edh_land {"Plains"} = 1; $edh_land {"Plateau"} = 1; $edh_land {"Plaza of Harmony"} = 1; $edh_land {"Plaza of Heroes"} = 1; $edh_land {"Polluted Delta"} = 1; $edh_land {"Polluted Mire"} = 1; $edh_land {"Port Town"} = 1; $edh_land {"Port of Karfell"} = 1; $edh_land {"Power Depot"} = 1; $edh_land {"Prahv, Spires of Order"} = 1; $edh_land {"Prairie Stream"} = 1; $edh_land {"Primal Beyond"} = 1; $edh_land {"Prismari Campus"} = 1; $edh_land {"Prismatic Vista"} = 1; $edh_land {"Quandrix Campus"} = 1; $edh_land {"Quicksand"} = 1; $edh_land {"Racers' Ring"} = 1; $edh_land {"Radiant Fountain"} = 1; $edh_land {"Radiant Grove"} = 1; $edh_land {"Raffine's Tower"} = 1; $edh_land {"Raging Ravine"} = 1;
$edh_land {"Rainbow Vale"} = 1; $edh_land {"Rakdos Carnarium"} = 1; $edh_land {"Rakdos Guildgate"} = 1; $edh_land {"Ramunap Ruins"} = 1; $edh_land {"Rath's Edge"} = 1; $edh_land {"Raugrin Triome"} = 1; $edh_land {"Ravaged Highlands"} = 1; $edh_land {"Razortide Bridge"} = 1; $edh_land {"Razorverge Thicket"} = 1; $edh_land {"Reflecting Pool"} = 1; $edh_land {"Rejuvenating Springs"} = 1; $edh_land {"Reliquary Tower"} = 1; $edh_land {"Remote Farm"} = 1; $edh_land {"Remote Isle"} = 1; $edh_land {"Rhystic Cave"} = 1; $edh_land {"Riftstone Portal"} = 1; $edh_land {"Rimewood Falls"} = 1; $edh_land {"Riptide Laboratory"} = 1; $edh_land {"Rishadan Port"} = 1; $edh_land {"Rith's Grove"} = 1; $edh_land {"River Delta"} = 1; $edh_land {"River of Tears"} = 1; $edh_land {"Riverglide Pathway"} = 1; $edh_land {"Riveteers Overlook"} = 1; $edh_land {"Rix Maadi, Dungeon Palace"} = 1; $edh_land {"Roadside Reliquary"} = 1; $edh_land {"Rockfall Vale"} = 1; $edh_land {"Rocky Tar Pit"} = 1; $edh_land {"Rogue's Passage"} = 1; $edh_land {"Rootbound Crag"} = 1; $edh_land {"Rootwater Depths"} = 1; $edh_land {"Rugged Highlands"} = 1; $edh_land {"Rugged Prairie"} = 1; $edh_land {"Ruins of Oran-Rief"} = 1; $edh_land {"Ruins of Trokair"} = 1; $edh_land {"Rupture Spire"} = 1; $edh_land {"Rushwood Grove"} = 1; $edh_land {"Rustic Clachan"} = 1; $edh_land {"Rustvale Bridge"} = 1; $edh_land {"Sacred Foundry"} = 1; $edh_land {"Sacred Peaks"} = 1; $edh_land {"Safe Haven"} = 1; $edh_land {"Salt Flats"} = 1; $edh_land {"Salt Marsh"} = 1; $edh_land {"Saltcrusted Steppe"} = 1; $edh_land {"Sanctum of Eternity"} = 1; $edh_land {"Sanctum of Ugin"} = 1; $edh_land {"Sand Silos"} = 1; $edh_land {"Sandsteppe Citadel"} = 1; $edh_land {"Sandstone Bridge"} = 1; $edh_land {"Sandstone Needle"} = 1; $edh_land {"Saprazzan Cove"} = 1; $edh_land {"Saprazzan Skerry"} = 1; $edh_land {"Sapseep Forest"} = 1; $edh_land {"Savage Lands"} = 1;
$edh_land {"Savai Triome"} = 1; $edh_land {"Savannah"} = 1; $edh_land {"Scabland"} = 1; $edh_land {"Scalding Tarn"} = 1; $edh_land {"Scattered Groves"} = 1; $edh_land {"Scavenger Grounds"} = 1; $edh_land {"School of the Unseen"} = 1; $edh_land {"Scorched Ruins"} = 1; $edh_land {"Scoured Barrens"} = 1; $edh_land {"Scrubland"} = 1; $edh_land {"Scrying Sheets"} = 1; $edh_land {"Sea Gate Wreckage"} = 1; $edh_land {"Sea Gate"} = 1; $edh_land {"Sea of Clouds"} = 1; $edh_land {"Seachrome Coast"} = 1; $edh_land {"Seafarer's Quay"} = 1; $edh_land {"Seafloor Debris"} = 1; $edh_land {"Seaside Citadel"} = 1; $edh_land {"Seaside Haven"} = 1; $edh_land {"Seat of the Synod"} = 1; $edh_land {"Secluded Courtyard"} = 1; $edh_land {"Secluded Glen"} = 1; $edh_land {"Secluded Steppe"} = 1; $edh_land {"Sejiri Refuge"} = 1; $edh_land {"Sejiri Steppe"} = 1; $edh_land {"Selesnya Guildgate"} = 1; $edh_land {"Selesnya Sanctuary"} = 1; $edh_land {"Sequestered Stash"} = 1; $edh_land {"Seraph Sanctuary"} = 1; $edh_land {"Serra's Sanctum"} = 1; $edh_land {"Shadowblood Ridge"} = 1; $edh_land {"Shambling Vent"} = 1; $edh_land {"Shattered Sanctum"} = 1; $edh_land {"Shefet Dunes"} = 1; $edh_land {"Shelldock Isle"} = 1; $edh_land {"Sheltered Thicket"} = 1; $edh_land {"Sheltered Valley"} = 1; $edh_land {"Shimmerdrift Vale"} = 1; $edh_land {"Shimmering Grotto"} = 1; $edh_land {"Shineshadow Snarl"} = 1; $edh_land {"Shinka, the Bloodsoaked Keep"} = 1; $edh_land {"Shipwreck Marsh"} = 1; $edh_land {"Shivan Gorge"} = 1; $edh_land {"Shivan Oasis"} = 1; $edh_land {"Shivan Reef"} = 1; $edh_land {"Shizo, Death's Storehouse"} = 1; $edh_land {"Shrine of the Forsaken Gods"} = 1; $edh_land {"Silent Clearing"} = 1; $edh_land {"Silverbluff Bridge"} = 1; $edh_land {"Silverquill Campus"} = 1; $edh_land {"Simic Growth Chamber"} = 1; $edh_land {"Simic Guildgate"} = 1; $edh_land {"Skarrg, the Rage Pits"} = 1; $edh_land {"Skemfar Elderhall"} = 1; $edh_land {"Skybridge Towers"} = 1;
$edh_land {"Skycloud Expanse"} = 1; $edh_land {"Skyline Cascade"} = 1; $edh_land {"Skyshroud Forest"} = 1; $edh_land {"Slagwoods Bridge"} = 1; $edh_land {"Slayers' Stronghold"} = 1; $edh_land {"Slippery Karst"} = 1; $edh_land {"Sliver Hive"} = 1; $edh_land {"Smoldering Crater"} = 1; $edh_land {"Smoldering Marsh"} = 1; $edh_land {"Smoldering Spires"} = 1; $edh_land {"Snow-Covered Forest"} = 1; $edh_land {"Snow-Covered Island"} = 1; $edh_land {"Snow-Covered Mountain"} = 1; $edh_land {"Snow-Covered Plains"} = 1; $edh_land {"Snow-Covered Swamp"} = 1; $edh_land {"Snowfield Sinkhole"} = 1; $edh_land {"Soaring Seacliff"} = 1; $edh_land {"Sokenzan, Crucible of Defiance"} = 1; $edh_land {"Soldevi Excavations"} = 1; $edh_land {"Sorrow's Path"} = 1; $edh_land {"Spara's Headquarters"} = 1; $edh_land {"Spawning Bed"} = 1; $edh_land {"Spawning Pool"} = 1; $edh_land {"Spectator Seating"} = 1; $edh_land {"Spinerock Knoll"} = 1; $edh_land {"Spire Garden"} = 1; $edh_land {"Spire of Industry"} = 1; $edh_land {"Spirebluff Canal"} = 1; $edh_land {"Springjack Pasture"} = 1; $edh_land {"Stalking Stones"} = 1; $edh_land {"Starlit Sanctum"} = 1; $edh_land {"Steam Vents"} = 1; $edh_land {"Stensia Bloodhall"} = 1; $edh_land {"Stirring Wildwood"} = 1; $edh_land {"Stomping Ground"} = 1; $edh_land {"Stone Quarry"} = 1; $edh_land {"Stormcarved Coast"} = 1; $edh_land {"Strip Mine"} = 1; $edh_land {"Study Hall"} = 1; $edh_land {"Submerged Boneyard"} = 1; $edh_land {"Subterranean Hangar"} = 1; $edh_land {"Sulfur Falls"} = 1; $edh_land {"Sulfur Vent"} = 1; $edh_land {"Sulfurous Mire"} = 1; $edh_land {"Sulfurous Springs"} = 1; $edh_land {"Sunbaked Canyon"} = 1; $edh_land {"Sundown Pass"} = 1; $edh_land {"Sungrass Prairie"} = 1; $edh_land {"Sunhome, Fortress of the Legion"} = 1; $edh_land {"Sunken Hollow"} = 1; $edh_land {"Sunken Ruins"} = 1; $edh_land {"Sunlit Marsh"} = 1; $edh_land {"Sunpetal Grove"} = 1; $edh_land {"Sunscorched Desert"} = 1; $edh_land {"Surtland Frostpyre"} = 1;
$edh_land {"Survivors' Encampment"} = 1; $edh_land {"Svogthos, the Restless Tomb"} = 1; $edh_land {"Svyelunite Temple"} = 1; $edh_land {"Swamp"} = 1; $edh_land {"Swarmyard"} = 1; $edh_land {"Swiftwater Cliffs"} = 1; $edh_land {"Taiga"} = 1; $edh_land {"Tainted Field"} = 1; $edh_land {"Tainted Isle"} = 1; $edh_land {"Tainted Peak"} = 1; $edh_land {"Tainted Wood"} = 1; $edh_land {"Takenuma, Abandoned Mire"} = 1; $edh_land {"Tangled Islet"} = 1; $edh_land {"Tanglepool Bridge"} = 1; $edh_land {"Tarnished Citadel"} = 1; $edh_land {"Tectonic Edge"} = 1; $edh_land {"Teetering Peaks"} = 1; $edh_land {"Teferi's Isle"} = 1; $edh_land {"Temple Garden"} = 1; $edh_land {"Temple of Abandon"} = 1; $edh_land {"Temple of Deceit"} = 1; $edh_land {"Temple of Enlightenment"} = 1; $edh_land {"Temple of Epiphany"} = 1; $edh_land {"Temple of Malady"} = 1; $edh_land {"Temple of Malice"} = 1; $edh_land {"Temple of Mystery"} = 1; $edh_land {"Temple of Plenty"} = 1; $edh_land {"Temple of Silence"} = 1; $edh_land {"Temple of Triumph"} = 1; $edh_land {"Temple of the Dragon Queen"} = 1; $edh_land {"Temple of the False God"} = 1; $edh_land {"Tendo Ice Bridge"} = 1; $edh_land {"Terminal Moraine"} = 1; $edh_land {"Terrain Generator"} = 1; $edh_land {"Terramorphic Expanse"} = 1; $edh_land {"Thalakos Lowlands"} = 1; $edh_land {"Thawing Glaciers"} = 1; $edh_land {"The Autonomous Furnace"} = 1; $edh_land {"The Biblioplex"} = 1; $edh_land {"The Big Top"} = 1; $edh_land {"The Dross Pits"} = 1; $edh_land {"The Fair Basilica"} = 1; $edh_land {"The Hunter Maze"} = 1; $edh_land {"The Monumental Facade"} = 1; $edh_land {"The Mycosynth Gardens"} = 1; $edh_land {"The Seedcore"} = 1; $edh_land {"The Surgical Bay"} = 1; $edh_land {"The Tabernacle at Pendrell Vale"} = 1; $edh_land {"The World Tree"} = 1; $edh_land {"Thespian's Stage"} = 1; $edh_land {"Thornglint Bridge"} = 1; $edh_land {"Thornwood Falls"} = 1; $edh_land {"Thran Portal"} = 1; $edh_land {"Thran Quarry"} = 1; $edh_land {"Thriving Bluff"} = 1;
$edh_land {"Thriving Grove"} = 1; $edh_land {"Thriving Heath"} = 1; $edh_land {"Thriving Isle"} = 1; $edh_land {"Thriving Moor"} = 1; $edh_land {"Throne of Makindi"} = 1; $edh_land {"Throne of the High City"} = 1; $edh_land {"Timber Gorge"} = 1; $edh_land {"Timberland Ruins"} = 1; $edh_land {"Timberline Ridge"} = 1; $edh_land {"Tinder Farm"} = 1; $edh_land {"Tocasia's Dig Site"} = 1; $edh_land {"Tolaria West"} = 1; $edh_land {"Tolaria"} = 1; $edh_land {"Tomb Fortress"} = 1; $edh_land {"Tomb of Urami"} = 1; $edh_land {"Tomb of the Spirit Dragon"} = 1; $edh_land {"Tournament Grounds"} = 1; $edh_land {"Tower of the Magistrate"} = 1; $edh_land {"Training Center"} = 1; $edh_land {"Tramway Station"} = 1; $edh_land {"Tranquil Cove"} = 1; $edh_land {"Tranquil Expanse"} = 1; $edh_land {"Tranquil Garden"} = 1; $edh_land {"Tranquil Thicket"} = 1; $edh_land {"Transguild Promenade"} = 1; $edh_land {"Treasure Vault"} = 1; $edh_land {"Tree of Tales"} = 1; $edh_land {"Treetop Village"} = 1; $edh_land {"Tresserhorn Sinks"} = 1; $edh_land {"Treva's Ruins"} = 1; $edh_land {"Tropical Island"} = 1; $edh_land {"Tundra"} = 1; $edh_land {"Turntimber Grove"} = 1; $edh_land {"Twilight Mire"} = 1; $edh_land {"Tyrite Sanctum"} = 1; $edh_land {"Uncharted Haven"} = 1; $edh_land {"Unclaimed Territory"} = 1; $edh_land {"Underdark Rift"} = 1; $edh_land {"Underground River"} = 1; $edh_land {"Underground Sea"} = 1; $edh_land {"Undergrowth Stadium"} = 1; $edh_land {"Undiscovered Paradise"} = 1; $edh_land {"Unholy Citadel"} = 1; $edh_land {"Unholy Grotto"} = 1; $edh_land {"Unknown Shores"} = 1; $edh_land {"Unstable Frontier"} = 1; $edh_land {"Untaidake, the Cloud Keeper"} = 1; $edh_land {"Urborg Volcano"} = 1; $edh_land {"Urborg"} = 1; $edh_land {"Urborg, Tomb of Yawgmoth"} = 1; $edh_land {"Urza's Factory"} = 1; $edh_land {"Urza's Fun House"} = 1; $edh_land {"Urza's Mine"} = 1; $edh_land {"Urza's Power Plant"} = 1; $edh_land {"Urza's Saga"} = 1;
$edh_land {"Urza's Tower"} = 1; $edh_land {"Urza's Workshop"} = 1; $edh_land {"Valakut, the Molten Pinnacle"} = 1; $edh_land {"Vault of Champions"} = 1; $edh_land {"Vault of Whispers"} = 1; $edh_land {"Vault of the Archangel"} = 1; $edh_land {"Vec Townships"} = 1; $edh_land {"Veldt"} = 1; $edh_land {"Verdant Catacombs"} = 1; $edh_land {"Vesuva"} = 1; $edh_land {"Vineglimmer Snarl"} = 1; $edh_land {"Vitu-Ghazi, the City-Tree"} = 1; $edh_land {"Vivid Crag"} = 1; $edh_land {"Vivid Creek"} = 1; $edh_land {"Vivid Grove"} = 1; $edh_land {"Vivid Marsh"} = 1; $edh_land {"Vivid Meadow"} = 1; $edh_land {"Volatile Fjord"} = 1; $edh_land {"Volcanic Island"} = 1; $edh_land {"Voldaren Estate"} = 1; $edh_land {"Volrath's Stronghold"} = 1; $edh_land {"Wandering Fumarole"} = 1; $edh_land {"Wanderwine Hub"} = 1; $edh_land {"War Room"} = 1; $edh_land {"Warped Landscape"} = 1; $edh_land {"Wasteland"} = 1; $edh_land {"Wastes"} = 1; $edh_land {"Waterfront District"} = 1; $edh_land {"Waterlogged Grove"} = 1; $edh_land {"Waterveil Cavern"} = 1; $edh_land {"Watery Grave"} = 1; $edh_land {"Westvale Abbey"} = 1; $edh_land {"Wind-Scarred Crag"} = 1; $edh_land {"Windbrisk Heights"} = 1; $edh_land {"Winding Canyons"} = 1; $edh_land {"Windswept Heath"} = 1; $edh_land {"Wintermoon Mesa"} = 1; $edh_land {"Wirewood Lodge"} = 1; $edh_land {"Witch's Clinic"} = 1; $edh_land {"Witch's Cottage"} = 1; $edh_land {"Witherbloom Campus"} = 1; $edh_land {"Wizards' School"} = 1; $edh_land {"Wooded Bastion"} = 1; $edh_land {"Wooded Foothills"} = 1; $edh_land {"Wooded Ridgeline"} = 1; $edh_land {"Woodland Cemetery"} = 1; $edh_land {"Woodland Chasm"} = 1; $edh_land {"Woodland Stream"} = 1; $edh_land {"Xander's Lounge"} = 1; $edh_land {"Yavimaya Coast"} = 1; $edh_land {"Yavimaya Hollow"} = 1; $edh_land {"Yavimaya, Cradle of Growth"} = 1; $edh_land {"Zagoth Triome"} = 1; $edh_land {"Zhalfirin Void"} = 1; $edh_land {"Ziatora's Proving Ground"} = 1; $edh_land {"Zoetic Cavern"} = 1;
my $s = "<br>\n";
my $just_cards;
my $c;
{
foreach $c (sort (keys (%edh_land)))
{
{
my $ol = original_line_from_cardname ($c);
$s .= " <font size=-2>$c -- ";
my $coled = 0;
if ($ol =~ m/\{[^}]*?W[^{]*?\}/im) { $s .= " white, "; $coled = 1; }
if ($ol =~ m/\{[^}]*?U[^{]*?\}/im) { $s .= " blue, "; $coled = 1; }
if ($ol =~ m/\{[^}]*?B[^{]*?\}/im) { $s .= " black, "; $coled = 1; }
if ($ol =~ m/\{[^}]*?R[^{]*?\}/im) { $s .= " red, "; $coled = 1; }
if ($ol =~ m/\{[^}]*?G[^{]*?\}/im) { $s .= " green, "; $coled = 1; }
my $ol2 = $ol;
if ($ol2 =~ s/Land - Plains */Land - /i) { $s .= " white, "; $coled = 1; }
if ($ol2 =~ s/Land - Island */Land - /i) { $s .= " blue, "; $coled = 1; }
if ($ol2 =~ s/Land - Swamp */Land - /i) { $s .= " black, "; $coled = 1; }
if ($ol2 =~ s/Land - Mountain */Land - /im) { $s .= " red, "; $coled = 1; }
if ($ol2 =~ s/Land - Forest */Land - /im) { $s .= " green, "; $coled = 1; }