-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
962 lines (899 loc) · 45.9 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>MtG Manabase Builder</title>
<script src="https://unpkg.com/javascript-lp-solver/prod/solver.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<style>
.content {
max-width: 800px;
margin: auto;
}
</style>
<script type="text/javascript">
// extended by guessing, original taken from https://www.channelfireball.com/all-strategy/articles/how-many-colored-mana-sources-do-you-need-to-consistently-cast-your-spells-a-guilds-of-ravnica-update/
// karstens60CardsTable[3][2] returns colored sources required for 3 cmc spell with 2 specific mana
var karstens60CardsTable = {
1: { 1: 14 },
2: { 1: 13, 2: 20 },
3: { 1: 11, 2: 18, 3: 23 },
4: { 1: 10, 2: 16, 3: 20, 4: 24 },
5: { 1: 9, 2: 14, 3: 18, 4: 21, 5: 24 },
6: { 1: 8, 2: 13, 3: 16, 4: 19, 5: 22, 6: 24 },
7: { 1: 7, 2: 11, 3: 14, 4: 17, 5: 20, 6: 22, 7: 24 },
}
var landNames = [
"Azorius Guildgate",
"Blast Zone",
"Blood Crypt",
"Bloodfell Caves",
"Blossoming Sands",
"Bonders' Enclave",
"Boros Guildgate",
"Breeding Pool",
"Castle Ardenvale",
"Castle Embereth",
"Castle Garenbrig",
"Castle Locthwain",
"Castle Vantress",
"Command Tower",
"Cryptic Caves",
"Dimir Guildgate",
"Dismal Backwater",
"Dwarven Mine",
"Emergence Zone",
"Evolving Wilds",
"Fabled Passage",
"Field of Ruin",
"Forest",
"Gateway Plaza",
"Gingerbread Cabin",
"Godless Shrine",
"Golgari Guildgate",
"Gruul Guildgate",
"Guildmages' Forum",
"Hallowed Fountain",
"Idyllic Grange",
"Indatha Triome",
"Interplanar Beacon",
"Island",
"Izzet Guildgate",
"Jungle Hollow",
"Karn's Bastion",
"Ketria Triome",
"Labyrinth of Skophos",
"Lotus Field",
"Mobilized District",
"Mountain",
"Mystic Sanctuary",
"Orzhov Guildgate",
"Overgrown Tomb",
"Plains",
"Plaza of Harmony",
"Rakdos Guildgate",
"Raugrin Triome",
"Rugged Highlands",
"Sacred Foundry",
"Savai Triome",
"Scoured Barrens",
"Selesnya Guildgate",
"Simic Guildgate",
"Steam Vents",
"Stomping Ground",
"Swamp",
"Swiftwater Cliffs",
"Temple Garden",
"Temple of Abandon",
"Temple of Deceit",
"Temple of Enlightenment",
"Temple of Epiphany",
"Temple of Malady",
"Temple of Malice",
"Temple of Mystery",
"Temple of Plenty",
"Temple of Silence",
"Temple of Triumph",
"Thornwood Falls",
"Tournament Grounds",
"Tranquil Cove",
"Unknown Shores",
"Watery Grave",
"Wind-Scarred Crag",
"Witch's Cottage",
"Zagoth Triome"
]
var castleNames = [
"Castle Ardenvale",
"Castle Embereth",
"Castle Garenbrig",
"Castle Locthwain",
"Castle Vantress"
]
function getInt(id) {
return parseInt(document.getElementById(id).value || 0, 10)
}
function countInString(string, searchString) {
return string.split(searchString).length - 1
}
function analyzeManaCost(manaCostString) {
var result = { cmc: 0 }
manaCostString.replace(/}|\//g, "").split("{").slice(1).forEach(function (token) {
token = token.toUpperCase().split("").sort().join("")
result.cmc += token === "X" ? xInManaCost : (parseInt(token) || 1)
result[token] = (result[token] || 0) + 1
})
result.multicolor = "W,U,B,R,G".split(",").map(function(c) { return (result[c] || 0) > 0 }).filter(Boolean).length >= 2
return result
}
function showTab(tabId) {
var tabSections = document.getElementsByClassName("tab-section")
var navLinks = document.getElementsByClassName("nav-link")
for (var i = 0; i < tabSections.length; i++) {
tabSections[i].classList.add("d-none")
navLinks[i].classList.remove("active")
}
document.getElementById(tabId).classList.remove("d-none")
document.getElementById(tabId + "NavLink").classList.add("active")
}
function toggleHybridMana() {
document.getElementById("hybridManaFields").classList.toggle("d-none")
}
function deriveColorRequirements() {
var solutionPre = document.getElementById("solutionPre")
solutionPre.innerHTML = "Reading decklist..."
var xInManaCost = getInt("xInManaCost")
var deck = document.getElementById("deck").value
var numberOfNonLandCards = 0
var numberOfLandsInDeck = 0
var sideboard = false
var expectedDeckSize = 60
var scryfallIdentifiers = []
var lines = deck.split("\n")
for (var i = 0; i < lines.length; i++) {
var line = lines[i]
var lineSplit = line.split(" ")
if (line.toLowerCase() === "companion") {
i += 3 // skip companion line, empty line, "Deck" - as exported by MtG Arena
continue
} else if (line === "") {
sideboard = true
continue
} else if (lineSplit.length <= 1) {
continue
}
var maybeExpansion = lineSplit[lineSplit.length - 2]
if (maybeExpansion.length === 5 && maybeExpansion[0] === "(" && maybeExpansion[4] === ")"
&& !isNaN(parseInt(lineSplit[lineSplit.length - 1]))) {
// set and collector_number are present
var name = lineSplit.slice(1, -2).join(" ")
var scryfallIdentifier = {
"name": name,
"set": maybeExpansion.slice(1, -1),
"collector_number": lineSplit[lineSplit.length - 1]
}
} else {
var name = lineSplit.slice(1).join(" ")
var scryfallIdentifier = {"name": name}
}
var numberOfCopies = parseInt(lineSplit[0]) || 0
if (landNames.includes(name)) {
numberOfLandsInDeck += sideboard ? 0 : numberOfCopies
if (castleNames.includes(name)) {
document.getElementById(name).value = numberOfCopies
}
} else {
if (sideboard && name === "Yorion, Sky Nomad") {
expectedDeckSize = 80
}
numberOfNonLandCards += sideboard ? 0 : numberOfCopies
scryfallIdentifiers.push(scryfallIdentifier)
}
}
var xhttp = new XMLHttpRequest()
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var required = {
numberOfLands: numberOfLandsInDeck >= 15 ? numberOfLandsInDeck : expectedDeckSize - numberOfNonLandCards
}
var answer = JSON.parse(this.response)
answer.data.forEach(function (card) {
if (card.cmc > 0) {
card.mana_cost.split(" // ").forEach(function (manaCostString) {
var cost = analyzeManaCost(manaCostString)
if (1 <= cost.cmc && cost.cmc <= 7) {
"W,U,B,R,G,UW,BW,RW,GW,BU,RU,GU,BR,BG,GR".split(",").forEach(function (c) {
required[c] = Math.max(required[c] || 0,
Math.ceil(((karstens60CardsTable[cost.cmc][cost[c] || 0] || -1) + (cost.multicolor ? 1 : 0))
* (expectedDeckSize === 80 ? 1.2 : 1)) // hack for yorion decks
)
})
}
})
}
})
Object.keys(required).forEach(function (key) {
document.getElementById(key).value = required[key]
})
solveManabase()
}
}
xhttp.open("POST", "https://api.scryfall.com/cards/collection", true)
xhttp.setRequestHeader("Content-type", "application/json")
solutionPre.innerHTML = "Requesting mana costs from Scryfall..."
xhttp.send(JSON.stringify({ "identifiers": scryfallIdentifiers }))
}
function solveManabase() {
var solutionPre = document.getElementById("solutionPre")
solutionPre.innerHTML = "Solving mana base..."
var numberOfLands = getInt("numberOfLands")
var castleW = getInt("Castle Ardenvale")
var castleU = getInt("Castle Vantress")
var castleB = getInt("Castle Locthwain")
var castleR = getInt("Castle Embereth")
var castleG = getInt("Castle Garenbrig")
var isRequiredW = getInt("W") > 0 ? 1 : 0
var isRequiredU = getInt("U") > 0 ? 1 : 0
var isRequiredB = getInt("B") > 0 ? 1 : 0
var isRequiredR = getInt("R") > 0 ? 1 : 0
var isRequiredG = getInt("G") > 0 ? 1 : 0
var requiredW = getInt("W") - castleW
var requiredU = getInt("U") - castleU
var requiredB = getInt("B") - castleB
var requiredR = getInt("R") - castleR
var requiredG = getInt("G") - castleG
var requiredUW = getInt("UW")
var requiredBW = getInt("BW")
var requiredRW = getInt("RW")
var requiredGW = getInt("GW")
var requiredBU = getInt("BU")
var requiredRU = getInt("RU")
var requiredGU = getInt("GU")
var requiredBR = getInt("BR")
var requiredBG = getInt("BG")
var requiredGR = getInt("GR")
var sumCastles = castleW + castleU + castleB + castleR + castleG
var scoreBasics = getInt("scoreBasics")
var scoreFabledPassage = getInt("scoreFabledPassage")
var scoreShocks = getInt("scoreShocks")
var scoreTemples = getInt("scoreTemples")
var scoreTriomes = getInt("scoreTriomes")
var scoreChecks = getInt("scoreChecks")
var minBasics = getInt("minBasics")
var minFabledPassages = getInt("minFabledPassages")
var minShocks = getInt("minShocks")
var minTemples = getInt("minTemples")
var minTriomes = getInt("minTriomes")
var minChecks = getInt("minChecks")
var maxBasics = getInt("maxBasics")
var maxFabledPassages = getInt("maxFabledPassages")
var maxShocks = getInt("maxShocks")
var maxTemples = getInt("maxTemples")
var maxTriomes = getInt("maxTriomes")
var maxChecks = getInt("maxChecks")
var fractionFP = getInt("fractionFP")
var variables = {
"Plains (Basic W)": {"W": 1, "UW": 1, "BW": 1, "RW": 1, "GW": 1, "opt": scoreBasics + isRequiredW,
"numberOfLands": 1, "Plains (Basic W)": 1,
"Basics - Fabled Passages - (Fabled Passages > 0)": 1, "Plains - (Fabled Passages > 0)": 1, "sumBasics": 1},
"Island (Basic U)": {"U": 1, "UW": 1, "BU": 1, "RU": 1, "GU": 1, "opt": scoreBasics + isRequiredU,
"numberOfLands": 1, "Island (Basic U)": 1,
"Basics - Fabled Passages - (Fabled Passages > 0)": 1, "Islands - (Fabled Passages > 0)": 1, "sumBasics": 1},
"Swamp (Basic B)": {"B": 1, "BW": 1, "BU": 1, "BR": 1, "BG": 1, "opt": scoreBasics + isRequiredB,
"numberOfLands": 1, "Swamp (Basic B)": 1,
"Basics - Fabled Passages - (Fabled Passages > 0)": 1, "Swamps - (Fabled Passages > 0)": 1, "sumBasics": 1},
"Mountain (Basic R)": {"R": 1, "RW": 1, "RU": 1, "BR": 1, "GR": 1, "opt": scoreBasics + isRequiredR,
"numberOfLands": 1, "Mountain (Basic R)": 1,
"Basics - Fabled Passages - (Fabled Passages > 0)": 1, "Mountains - (Fabled Passages > 0)": 1, "sumBasics": 1},
"Forest (Basic G)": {"G": 1, "GW": 1, "GU": 1, "BG": 1, "GR": 1, "opt": scoreBasics + isRequiredG,
"numberOfLands": 1, "Forest (Basic G)": 1,
"Basics - Fabled Passages - (Fabled Passages > 0)": 1, "Forests - (Fabled Passages > 0)": 1, "sumBasics": 1},
"Fabled Passage": {"W": fractionFP, "U": fractionFP, "B": fractionFP, "R": fractionFP, "G": fractionFP,
"UW": fractionFP, "BW": fractionFP, "RW": fractionFP, "GW": fractionFP, "BU": fractionFP,
"RU": fractionFP, "GU": fractionFP, "BR": fractionFP, "BG": fractionFP, "GR": fractionFP,
"opt": scoreFabledPassage,
"numberOfLands": 1, "Fabled Passage": 1,
"Basics - Fabled Passages - (Fabled Passages > 0)": -1.25,
"Plains - (Fabled Passages > 0)": -0.25,
"Islands - (Fabled Passages > 0)": -0.25,
"Swamps - (Fabled Passages > 0)": -0.25,
"Mountains - (Fabled Passages > 0)": -0.25,
"Forests - (Fabled Passages > 0)": -0.25},
"Hallowed Fountain (Shock WU)": {"W": 1, "U": 1, "opt": scoreShocks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1,
"numberOfLands": 1, "Hallowed Fountain (Shock WU)": 1, "sumShocks": 1},
"Godless Shrine (Shock WB)": {"W": 1, "B": 1, "opt": scoreShocks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "BR": 1, "BG": 1,
"numberOfLands": 1, "Godless Shrine (Shock WB)": 1, "sumShocks": 1},
"Sacred Foundry (Shock WR)": {"W": 1, "R": 1, "opt": scoreShocks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "RU": 1, "BR": 1, "GR": 1,
"numberOfLands": 1, "Sacred Foundry (Shock WR)": 1, "sumShocks": 1},
"Temple Garden (Shock WG)": {"W": 1, "G": 1, "opt": scoreShocks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "GU": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Temple Garden (Shock WG)": 1, "sumShocks": 1},
"Watery Grave (Shock UB)": {"U": 1, "B": 1, "opt": scoreShocks,
"UW": 1, "BW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1,
"numberOfLands": 1, "Watery Grave (Shock UB)": 1, "sumShocks": 1},
"Steam Vents (Shock UR)": {"U": 1, "R": 1, "opt": scoreShocks,
"UW": 1, "RW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "GR": 1,
"numberOfLands": 1, "Steam Vents (Shock UR)": 1, "sumShocks": 1},
"Breeding Pool (Shock UG)": {"U": 1, "G": 1, "opt": scoreShocks,
"UW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Breeding Pool (Shock UG)": 1, "sumShocks": 1},
"Blood Crypt (Shock BR)": {"B": 1, "R": 1, "opt": scoreShocks,
"BW": 1, "RW": 1, "BU": 1, "RU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Blood Crypt (Shock BR)": 1, "sumShocks": 1},
"Overgrown Tomb (Shock BG)": {"B": 1, "G": 1, "opt": scoreShocks,
"BW": 1, "GW": 1, "BU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Overgrown Tomb (Shock BG)": 1, "sumShocks": 1},
"Stomping Grounds (Shock RG)": {"R": 1, "G": 1, "opt": scoreShocks,
"RW": 1, "GW": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Stomping Grounds (Shock RG)": 1, "sumShocks": 1},
"Temple of Enlightenment (Temple WU)": {"W": 1, "U": 1, "opt": scoreTemples,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1,
"numberOfLands": 1, "Temple of Enlightenment (Temple WU)": 1, "sumTemples": 1},
"Temple of Silence (Temple WB)": {"W": 1, "B": 1, "opt": scoreTemples,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "BR": 1, "BG": 1,
"numberOfLands": 1, "Temple of Silence (Temple WB)": 1, "sumTemples": 1},
"Temple of Triumph (Temple WR)": {"W": 1, "R": 1, "opt": scoreTemples,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "RU": 1, "BR": 1, "GR": 1,
"numberOfLands": 1, "Temple of Triumph (Temple WR)": 1, "sumTemples": 1},
"Temple of Plenty (Temple WG)": {"W": 1, "G": 1, "opt": scoreTemples,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "GU": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Temple of Plenty (Temple WG)": 1, "sumTemples": 1},
"Temple of Deceit (Temple UB)": {"U": 1, "B": 1, "opt": scoreTemples,
"UW": 1, "BW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1,
"numberOfLands": 1, "Temple of Deceit (Temple UB)": 1, "sumTemples": 1},
"Temple of Epiphany (Temple UR)": {"U": 1, "R": 1, "opt": scoreTemples,
"UW": 1, "RW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "GR": 1,
"numberOfLands": 1, "Temple of Epiphany (Temple UR)": 1, "sumTemples": 1},
"Temple of Mystery (Temple UG)": {"U": 1, "G": 1, "opt": scoreTemples,
"UW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Temple of Mystery (Temple UG)": 1, "sumTemples": 1},
"Temple of Malice (Temple BR)": {"B": 1, "R": 1, "opt": scoreTemples,
"BW": 1, "RW": 1, "BU": 1, "RU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Temple of Malice (Temple BR)": 1, "sumTemples": 1},
"Temple of Malady (Temple BG)": {"B": 1, "G": 1, "opt": scoreTemples,
"BW": 1, "GW": 1, "BU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Temple of Malady (Temple BG)": 1, "sumTemples": 1},
"Temple of Abandon (Temple RG)": {"R": 1, "G": 1, "opt": scoreTemples,
"RW": 1, "GW": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Temple of Abandon (Temple RG)": 1, "sumTemples": 1},
"Raugrin Triome (Triome WUR)": {"W": 1, "U": 1, "R": 1, "opt": scoreTriomes,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "GR": 1,
"numberOfLands": 1, "Raugrin Triome (Triome WUR)": 1, "sumTriomes": 1},
"Savai Triome (Triome WBR)": {"W": 1, "B": 1, "R": 1, "opt": scoreTriomes,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "RU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Savai Triome (Triome WBR)": 1, "sumTriomes": 1},
"Indatha Triome (Triome WBG)": {"W": 1, "B": 1, "G": 1, "opt": scoreTriomes,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Indatha Triome (Triome WBG)": 1, "sumTriomes": 1},
"Zagoth Triome (Triome UBG)": {"U": 1, "B": 1, "G": 1, "opt": scoreTriomes,
"UW": 1, "BW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Zagoth Triome (Triome UBG)": 1, "sumTriomes": 1},
"Ketria Triome (Triome URG)": {"U": 1, "R": 1, "G": 1, "opt": scoreTriomes,
"UW": 1, "RW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Ketria Triome (Triome URG)": 1, "sumTriomes": 1},
"Glacial Fortress (Check WU)": {"W": 1, "U": 1, "opt": scoreChecks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1,
"numberOfLands": 1, "Glacial Fortress (Check WU)": 1, "sumChecks": 1},
"Isolated Chapel (Check WB)": {"W": 1, "B": 1, "opt": scoreChecks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "BU": 1, "BR": 1, "BG": 1,
"numberOfLands": 1, "Isolated Chapel (Check WB)": 1, "sumChecks": 1},
"Clifftop Retreat (Check WR)": {"W": 1, "R": 1, "opt": scoreChecks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "RU": 1, "BR": 1, "GR": 1,
"numberOfLands": 1, "Clifftop Retreat (Check WR)": 1, "sumChecks": 1},
"Sunpetal Grove (Check WG)": {"W": 1, "G": 1, "opt": scoreChecks,
"UW": 1, "BW": 1, "RW": 1, "GW": 1, "GU": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Sunpetal Grove (Check WG)": 1, "sumChecks": 1},
"Drowned Catacomb (Check UB)": {"U": 1, "B": 1, "opt": scoreChecks,
"UW": 1, "BW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1,
"numberOfLands": 1, "Drowned Catacomb (Check UB)": 1, "sumChecks": 1},
"Sulfur Falls (Check UR)": {"U": 1, "R": 1, "opt": scoreChecks,
"UW": 1, "RW": 1, "BU": 1, "RU": 1, "GU": 1, "BR": 1, "GR": 1,
"numberOfLands": 1, "Sulfur Falls (Check UR)": 1, "sumChecks": 1},
"Hinterland Harbor (Check UG)": {"U": 1, "G": 1, "opt": scoreChecks,
"UW": 1, "GW": 1, "BU": 1, "RU": 1, "GU": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Hinterland Harbor (Check UG)": 1, "sumChecks": 1},
"Dragonskull Summit (Check BR)": {"B": 1, "R": 1, "opt": scoreChecks,
"BW": 1, "RW": 1, "BU": 1, "RU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Dragonskull Summit (Check BR)": 1, "sumChecks": 1},
"Woodland Cemetery (Check BG)": {"B": 1, "G": 1, "opt": scoreChecks,
"BW": 1, "GW": 1, "BU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Woodland Cemetery (Check BG)": 1, "sumChecks": 1},
"Rootbound Crag (Check RG)": {"R": 1, "G": 1, "opt": scoreChecks,
"RW": 1, "GW": 1, "RU": 1, "GU": 1, "BR": 1, "BG": 1, "GR": 1,
"numberOfLands": 1, "Rootbound Crag (Check RG)": 1, "sumChecks": 1},
}
var ints = {}
Object.keys(variables).forEach(function (key) {
ints[key] = 1
})
var model = {
"optimize": "opt",
"opType": "max",
"constraints": {
"numberOfLands": {"equal": numberOfLands - sumCastles},
"W": {"min": requiredW},
"U": {"min": requiredU},
"B": {"min": requiredB},
"R": {"min": requiredR},
"G": {"min": requiredG},
"UW": {"min": requiredUW},
"BW": {"min": requiredBW},
"RW": {"min": requiredRW},
"GW": {"min": requiredGW},
"BU": {"min": requiredBU},
"RU": {"min": requiredRU},
"GU": {"min": requiredGU},
"BR": {"min": requiredBR},
"BG": {"min": requiredBG},
"GR": {"min": requiredGR},
"Plains (Basic W)": {"min": 0, "max": 999},
"Island (Basic U)": {"min": 0, "max": 999},
"Swamp (Basic B)": {"min": 0, "max": 999},
"Mountain (Basic R)": {"min": 0, "max": 999},
"Forest (Basic G)": {"min": 0, "max": 999},
"sumBasics": {"min": minBasics, "max": maxBasics},
"Fabled Passage": {"min": minFabledPassages, "max": maxFabledPassages},
// if running Fabled Passage enforce more basics than Fabled Passages
"Basics - Fabled Passages - (Fabled Passages > 0)": {"min": 0},
// if we want any white make sure we get a plains when running a Fabled Passage
"Plains - (Fabled Passages > 0)": {"min": requiredW > 0 ? 0 : -100},
"Islands - (Fabled Passages > 0)": {"min": requiredU > 0 ? 0 : -100},
"Swamps - (Fabled Passages > 0)": {"min": requiredB > 0 ? 0 : -100},
"Mountains - (Fabled Passages > 0)": {"min": requiredR > 0 ? 0 : -100},
"Forests - (Fabled Passages > 0)": {"min": requiredG > 0 ? 0 : -100},
"Hallowed Fountain (Shock WU)": {"min": 0, "max": 4},
"Godless Shrine (Shock WB)": {"min": 0, "max": 4},
"Sacred Foundry (Shock WR)": {"min": 0, "max": 4},
"Temple Garden (Shock WG)": {"min": 0, "max": 4},
"Watery Grave (Shock UB)": {"min": 0, "max": 4},
"Steam Vents (Shock UR)": {"min": 0, "max": 4},
"Breeding Pool (Shock UG)": {"min": 0, "max": 4},
"Blood Crypt (Shock BR)": {"min": 0, "max": 4},
"Overgrown Tomb (Shock BG)": {"min": 0, "max": 4},
"Stomping Grounds (Shock RG)": {"min": 0, "max": 4},
"sumShocks": {"min": minShocks, "max": maxShocks},
"Temple of Enlightenment (Temple WU)": {"min": 0, "max": 4},
"Temple of Silence (Temple WB)": {"min": 0, "max": 4},
"Temple of Triumph (Temple WR)": {"min": 0, "max": 4},
"Temple of Plenty (Temple WG)": {"min": 0, "max": 4},
"Temple of Deceit (Temple UB)": {"min": 0, "max": 4},
"Temple of Epiphany (Temple UR)": {"min": 0, "max": 4},
"Temple of Mystery (Temple UG)": {"min": 0, "max": 4},
"Temple of Malice (Temple BR)": {"min": 0, "max": 4},
"Temple of Malady (Temple BG)": {"min": 0, "max": 4},
"Temple of Abandon (Temple RG)": {"min": 0, "max": 4},
"sumTemples": {"min": minTemples, "max": maxTemples},
"Raugrin Triome (Triome WUR)": {"min": 0, "max": 4},
"Savai Triome (Triome WBR)": {"min": 0, "max": 4},
"Indatha Triome (Triome WBG)": {"min": 0, "max": 4},
"Zagoth Triome (Triome UBG)": {"min": 0, "max": 4},
"Ketria Triome (Triome URG)": {"min": 0, "max": 4},
"sumTriomes": {"min": minTriomes, "max": maxTriomes},
"Glacial Fortress (Check WU)": {"min": 0, "max": 4},
"Isolated Chapel (Check WB)": {"min": 0, "max": 4},
"Clifftop Retreat (Check WR)": {"min": 0, "max": 4},
"Sunpetal Grove (Check WG)": {"min": 0, "max": 4},
"Drowned Catacomb (Check UB)": {"min": 0, "max": 4},
"Sulfur Falls (Check UR)": {"min": 0, "max": 4},
"Hinterland Harbor (Check UG)": {"min": 0, "max": 4},
"Dragonskull Summit (Check BR)": {"min": 0, "max": 4},
"Woodland Cemetery (Check BG)": {"min": 0, "max": 4},
"Rootbound Crag (Check RG)": {"min": 0, "max": 4},
"sumChecks": {"min": minChecks, "max": maxChecks},
},
"variables": variables,
"ints": ints
}
var solution = solver.Solve(model)
var output = "result manabase:\n\n"
output += castleW === 0 ? "" : castleW + " Castle Ardenvale (Castle W)\n"
output += castleU === 0 ? "" : castleU + " Castle Vantress (Castle U)\n"
output += castleB === 0 ? "" : castleB + " Castle Locthwain (Castle B)\n"
output += castleR === 0 ? "" : castleR + " Castle Embereth (Castle R)\n"
output += castleG === 0 ? "" : castleG + " Castle Garenbrig (Castle G)\n"
if (solution.feasible) {
Object.keys(solution).forEach(function(prop) {
if (Object.keys(variables).includes(prop)) {
output += solution[prop] + " " + prop + "\n"
}
})
solutionPre.innerHTML = output
} else {
solutionPre.innerHTML = "impossible - try increasing total number of lands"
document.getElementById("actualTotalLands").innerHTML = ""
document.getElementById("actualW").innerHTML = ""
document.getElementById("actualU").innerHTML = ""
document.getElementById("actualB").innerHTML = ""
document.getElementById("actualR").innerHTML = ""
document.getElementById("actualG").innerHTML = ""
return
}
var actualTotalLands = sumCastles
var actualW = castleW
var actualU = castleU
var actualB = castleB
var actualR = castleR
var actualG = castleG
var actualUW = 0
var actualBW = 0
var actualRW = 0
var actualGW = 0
var actualBU = 0
var actualRU = 0
var actualGU = 0
var actualBR = 0
var actualBG = 0
var actualGR = 0
Object.keys(solution).forEach(function(prop) {
if (Object.keys(variables).includes(prop)) {
actualTotalLands += solution[prop]
if (prop === "Fabled Passage") {
actualW += solution["Plains (Basic W)"] > 0 ? solution[prop] : 0
actualU += solution["Island (Basic U)"] > 0 ? solution[prop] : 0
actualB += solution["Swamp (Basic B)"] > 0 ? solution[prop] : 0
actualR += solution["Mountain (Basic R)"] > 0 ? solution[prop] : 0
actualG += solution["Forest (Basic G)"] > 0 ? solution[prop] : 0
actualUW += (solution["Plains (Basic W)"] > 0 || solution["Island (Basic U)"] > 0) ? solution[prop] : 0
actualBW += (solution["Plains (Basic W)"] > 0 || solution["Swamp (Basic B)"] > 0) ? solution[prop] : 0
actualRW += (solution["Plains (Basic W)"] > 0 || solution["Mountain (Basic R)"] > 0) ? solution[prop] : 0
actualGW += (solution["Plains (Basic W)"] > 0 || solution["Forest (Basic G)"] > 0) ? solution[prop] : 0
actualBU += (solution["Island (Basic U)"] > 0 || solution["Swamp (Basic B)"] > 0) ? solution[prop] : 0
actualRU += (solution["Island (Basic U)"] > 0 || solution["Mountain (Basic R)"] > 0) ? solution[prop] : 0
actualGU += (solution["Island (Basic U)"] > 0 || solution["Forest (Basic G)"] > 0) ? solution[prop] : 0
actualBR += (solution["Swamp (Basic B)"] > 0 || solution["Mountain (Basic R)"] > 0) ? solution[prop] : 0
actualBG += (solution["Swamp (Basic B)"] > 0 || solution["Forest (Basic G)"] > 0) ? solution[prop] : 0
actualGR += (solution["Mountain (Basic R)"] > 0 || solution["Forest (Basic G)"] > 0) ? solution[prop] : 0
} else {
actualW += solution[prop] * (variables[prop]["W"] || 0)
actualU += solution[prop] * (variables[prop]["U"] || 0)
actualB += solution[prop] * (variables[prop]["B"] || 0)
actualR += solution[prop] * (variables[prop]["R"] || 0)
actualG += solution[prop] * (variables[prop]["G"] || 0)
actualUW += solution[prop] * (variables[prop]["UW"] || 0)
actualBW += solution[prop] * (variables[prop]["BW"] || 0)
actualRW += solution[prop] * (variables[prop]["RW"] || 0)
actualGW += solution[prop] * (variables[prop]["GW"] || 0)
actualBU += solution[prop] * (variables[prop]["BU"] || 0)
actualRU += solution[prop] * (variables[prop]["RU"] || 0)
actualGU += solution[prop] * (variables[prop]["GU"] || 0)
actualBR += solution[prop] * (variables[prop]["BR"] || 0)
actualBG += solution[prop] * (variables[prop]["BG"] || 0)
actualGR += solution[prop] * (variables[prop]["GR"] || 0)
}
}
})
document.getElementById("actualTotalLands").innerHTML = actualTotalLands
document.getElementById("actualW").innerHTML = actualW
document.getElementById("actualU").innerHTML = actualU
document.getElementById("actualB").innerHTML = actualB
document.getElementById("actualR").innerHTML = actualR
document.getElementById("actualG").innerHTML = actualG
document.getElementById("actualUW").innerHTML = actualUW
document.getElementById("actualBW").innerHTML = actualBW
document.getElementById("actualRW").innerHTML = actualRW
document.getElementById("actualGW").innerHTML = actualGW
document.getElementById("actualBU").innerHTML = actualBU
document.getElementById("actualRU").innerHTML = actualRU
document.getElementById("actualGU").innerHTML = actualGU
document.getElementById("actualBR").innerHTML = actualBR
document.getElementById("actualBG").innerHTML = actualBG
document.getElementById("actualGR").innerHTML = actualGR
document.getElementById("donate").classList.remove("d-none")
}
</script>
</head>
<body>
<div class="content my-4">
<h1>MtG Manabase Builder</h1>
<ul class="nav nav-tabs mb-3">
<li class="nav-item">
<a id="pasteDeckNavLink" class="nav-link active" href="#" onclick="showTab('pasteDeck')">Paste Deck</a>
</li>
<li class="nav-item">
<a id="colorRequirementsNavLink" class="nav-link" href="#" onclick="showTab('colorRequirements')">Color Requirements</a>
</li>
<li class="nav-item">
<a id="optimizationScoresNavLink" class="nav-link" href="#" onclick="showTab('optimizationScores')">Optimization Scores</a>
</li>
<li class="nav-item">
<a id="faqNavLink" class="nav-link" href="#" onclick="showTab('faq')">FAQ</a>
</li>
</ul>
<div id="pasteDeck" class="tab-section">
<form onsubmit="deriveColorRequirements(); return false">
<div class="form-group row">
<label class="col-4 col-form-label" for="xInManaCost">count <img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/3/3f/X.svg" width="36px" height="36px"/> in mana cost as</label>
<div class="col-2">
<input id="xInManaCost" type="number" class="form-control" value="1" required>
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="deck">deck export from MtG Arena</label>
<div class="col"><textarea id="deck" class="row" cols="40" rows="8"></textarea></div>
</div>
<button type="submit" class="btn btn-primary">Derive Color Requirements</button>
</form>
</div>
<div id="colorRequirements" class="d-none tab-section">
<form class="my-3" onsubmit="solveManabase(); return false">
<div class="form-group row">
<div class="col-4"></div>
<div class="col">required</div>
<div class="col">castles</div>
<div class="col">actual</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="numberOfLands">total number of lands</label>
<div class="col">
<input id="numberOfLands" type="number" class="form-control" required>
</div>
<div class="col"></div>
<div id="actualTotalLands" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="W">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/8/8e/W.svg" height="36px" alt="white mana"/>
</label>
<div class="col">
<input id="W" type="number" class="form-control" placeholder="0">
</div>
<div class="col">
<input id="Castle Ardenvale" type="number" class="form-control" placeholder="0">
</div>
<div id="actualW" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="U">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/9/9f/U.svg" height="36px" alt="blue mana"/>
</label>
<div class="col">
<input id="U" type="number" class="form-control" placeholder="0">
</div>
<div class="col">
<input id="Castle Vantress" type="number" class="form-control" placeholder="0">
</div>
<div id="actualU" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="B">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/2/2f/B.svg" height="36px" alt="black mana"/>
</label>
<div class="col">
<input id="B" type="number" class="form-control" placeholder="0">
</div>
<div class="col">
<input id="Castle Locthwain" type="number" class="form-control" placeholder="0">
</div>
<div id="actualB" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="R">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/8/87/R.svg" height="36px" alt="red mana"/>
</label>
<div class="col">
<input id="R" type="number" class="form-control" placeholder="0">
</div>
<div class="col">
<input id="Castle Embereth" type="number" class="form-control" placeholder="0">
</div>
<div id="actualR" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="G">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/8/88/G.svg" height="36px" alt="green mana"/>
</label>
<div class="col">
<input id="G" type="number" class="form-control" placeholder="0">
</div>
<div class="col">
<input id="Castle Garenbrig" type="number" class="form-control" placeholder="0">
</div>
<div id="actualG" class="col"></div>
</div>
<div id="hybridManaFields" class="d-none">
<div class="form-group row">
<label class="col-4 col-form-label" for="UW">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/3/39/WU.svg" height="36px" alt="white or blue mana"/>
</label>
<div class="col">
<input id="UW" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualUW" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="BW">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/a/a6/WB.svg" height="36px" alt="white or black mana"/>
</label>
<div class="col">
<input id="BW" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualBW" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="RW">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/6/6b/RW.svg" height="36px" alt="red or white mana"/>
</label>
<div class="col">
<input id="RW" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualRW" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="GW">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/2/2e/GW.svg" height="36px" alt="green or white mana"/>
</label>
<div class="col">
<input id="GW" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualGW" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="BU">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/1/13/UB.svg" height="36px" alt="blue or black mana"/>
</label>
<div class="col">
<input id="BU" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualBU" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="RU">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/0/09/UR.svg" height="36px" alt="blue or red mana"/>
</label>
<div class="col">
<input id="RU" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualRU" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="GU">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/6/6f/GU.svg" height="36px" alt="green or blue mana"/>
</label>
<div class="col">
<input id="GU" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualGU" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="BR">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/b/bf/BR.svg" height="36px" alt="black or red mana"/>
</label>
<div class="col">
<input id="BR" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualBR" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="BG">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/6/62/BG.svg" height="36px" alt="black or green mana"/>
</label>
<div class="col">
<input id="BG" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualBG" class="col"></div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label" for="GR">
number of lands producing
<img src="https://gamepedia.cursecdn.com/mtgsalvation_gamepedia/2/24/RG.svg" height="36px" alt="red or green mana"/>
</label>
<div class="col">
<input id="GR" type="number" class="form-control" placeholder="0">
</div>
<div class="col"></div>
<div id="actualGR" class="col"></div>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<button class="btn btn-warning" onclick="toggleHybridMana()">Toggle Hybrid Mana</button>
</div>
<div id="optimizationScores" class="d-none tab-section">
<form onsubmit="solveManabase(); return false" class="p-2 col-sm-8 my-3">
<div class="mb-3">
color requirements and min/max will ALWAYS be met, further optimization takes scores into account
</div>
<div class="form-group row">
<div class="col"></div>
<div class="col">score</div>
<div class="col">min</div>
<div class="col">max</div>
</div>
<div class="form-group row">
<label class="col">Basic Lands</label>
<div class="col"><input id="scoreBasics" class="form-control" type="number" value="102"></div>
<div class="col"><input id="minBasics" class="form-control" type="number" value="0"></div>
<div class="col"><input id="maxBasics" class="form-control" type="number" value="99"></div>
</div>
<div class="form-group row">
<label class="col">Fabled Passage</label>
<div class="col"><input id="scoreFabledPassage" class="form-control" type="number" value="90"></div>
<div class="col"><input id="minFabledPassages" class="form-control" type="number" value="0"></div>
<div class="col"><input id="maxFabledPassages" class="form-control" type="number" value="4"></div>
</div>
<div class="form-group row">
<label class="col">Shocklands</label>
<div class="col"><input id="scoreShocks" class="form-control" type="number" value="100"></div>
<div class="col"><input id="minShocks" class="form-control" type="number" value="0"></div>
<div class="col"><input id="maxShocks" class="form-control" type="number" value="40"></div>
</div>
<div class="form-group row">
<label class="col">Temples</label>
<div class="col"><input id="scoreTemples" class="form-control" type="number" value="80"></div>
<div class="col"><input id="minTemples" class="form-control" type="number" value="0"></div>
<div class="col"><input id="maxTemples" class="form-control" type="number" value="40"></div>
</div>
<div class="form-group row">
<label class="col">Triomes</label>
<div class="col"><input id="scoreTriomes" class="form-control" type="number" value="70"></div>
<div class="col"><input id="minTriomes" class="form-control" type="number" value="0"></div>
<div class="col"><input id="maxTriomes" class="form-control" type="number" value="40"></div>
</div>
<div class="form-group row">
<label class="col">Checklands</label>
<div class="col"><input id="scoreChecks" class="form-control" type="number" value="101"></div>
<div class="col"><input id="minChecks" class="form-control" type="number" value="0"></div>
<div class="col"><input id="maxChecks" class="form-control" type="number" value="0"></div>
</div>
<div class="form-group row">
<label class="col-sm-6">count Fabled Passage as fractional source (Frank suggests 0.67 for 3 color decks)</label>
<div class="col">
<input id="fractionFP" class="form-control" type="number" value="0.67" min="0" max="1" step="0.01">
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<div id="faq" class="d-none tab-section">
<h4 class="mt-2">How many lands should I play?</h4>
Check out Frank Karsten's <a href="https://www.channelfireball.com/all-strategy/articles/how-many-lands-do-you-need-to-consistently-hit-your-land-drops/">awesome article</a>.
<h4 class="mt-2">How many sources of each color should I play?</h4>
Check out Frank Karsten's <a href="https://www.channelfireball.com/all-strategy/articles/how-many-colored-mana-sources-do-you-need-to-consistently-cast-your-spells-a-guilds-of-ravnica-update/">other awesome article</a>.
<h4 class="mt-2">How does this work?</h4>
Manabase building can be modeled as a <a href="https://en.wikipedia.org/wiki/Linear_programming#Integer_unknowns">linear program with integer variables</a>, where all color requirements must be met while maximizing the number of untapped sources. There are solvers for these type of problems, like the <a href="https://github.com/JWally/jsLPSolver">amazing jsLPSolver</a>, which I used here.
</div>
<pre id="solutionPre" class="my-3"></pre>
<div id="donate" class="d-none">
<a href='https://ko-fi.com/Z8Z51NG5X' target='_blank'>
<img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi2.png?v=2' border='0'
alt='Buy Me a Coffee at ko-fi.com' />
</a>
<form class="mt-2" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="TJ8E5ZSCKA4YG" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0"
name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
</div>
</div>
</body>
</html>