Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

One dollar price limit #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Check only for paper or mtgo cards each time
Arturo committed Oct 2, 2018
commit 2f809e3976967d921e23fca6ad996c349da3bb6b
46 changes: 26 additions & 20 deletions src/main/java/setup/cardlists/MakeAllCardsList.java
Original file line number Diff line number Diff line change
@@ -109,8 +109,8 @@ private static Set<String> getLegalSnapshot(List<String> setCodes) throws Except
List<String> mtgoWebpage = FileConverter.readToList(mtgoUrl);
List<String> paperWebpage = FileConverter.readToList(paperUrl);

Map<String, Double> mtgoCards = getCardNamesAndPrices(mtgoWebpage);
Map<String, Double> paperCards = getCardNamesAndPrices(paperWebpage);
Map<String, Double> mtgoCards = getCardNamesAndPrices(mtgoWebpage, "online");
Map<String, Double> paperCards = getCardNamesAndPrices(paperWebpage, "paper");

mtgoCards.entrySet().stream() //
.filter(e -> e.getValue() == 0.01) //
@@ -138,17 +138,16 @@ private static Set<String> getLegalSnapshot(List<String> setCodes) throws Except
return legalCards;
}

private static Map<String, Double> getCardNamesAndPrices(List<String> html) {
private static Map<String, Double> getCardNamesAndPrices(List<String> html, String markerStr) {
Map<String, Double> cards = new HashMap<>();
int linesSinceMarker = -1;
String lastCardFound = null;

for (String str : html) {

linesSinceMarker++;

if (str.length() > 17 && str.substring(0, 17).equals("<td class='card'>") &&
((str.indexOf("#online\">") > -1) || (str.indexOf("#paper\">") > -1))) { //Looks for a marker line
String marker = "#" + markerStr + "\">";
if (str.length() > 17 && str.substring(0, 17).equals("<td class='card'>") && str.indexOf(marker) > -1) { //Looks for a marker line

//Get the locations of the second ">" and the third "<", the card's name is located between them
int secondClose = str.indexOf('>',str.indexOf('>')+1);
@@ -160,20 +159,27 @@ private static Map<String, Double> getCardNamesAndPrices(List<String> html) {

//MTGGoldfish doesn't include the accent, but it should, so I add it.
switch (cardname) {
case "Seance": cardname = "Séance";
break;
case "Dandan": cardname = "Dandân";
break;
case "Khabal Ghoul": cardname = "Khabál Ghoul";
break;
case "Junun Efreet": cardname = "Junún Efreet";
break;
case "Ghazban Ogre": cardname = "Ghazbán Ogre";
break;
case "Ifh-Biff Efreet": cardname = "Ifh-Bíff Efreet";
break;
case "Ring of Ma'ruf": cardname = "Ring of Ma'rûf";
break;
case "Seance":
cardname = "Séance";
break;
case "Dandan":
cardname = "Dandân";
break;
case "Khabal Ghoul":
cardname = "Khabál Ghoul";
break;
case "Junun Efreet":
cardname = "Junún Efreet";
break;
case "Ghazban Ogre":
cardname = "Ghazbán Ogre";
break;
case "Ifh-Biff Efreet":
cardname = "Ifh-Bíff Efreet";
break;
case "Ring of Ma'ruf":
cardname = "Ring of Ma'rûf";
break;
}

// Retain knowledge of the last card we found