Fixed Txt file import improvements.

Neo001992

Well-known member
Currently modo processes double sided/split cards in a manner that does not recognize how most of the deckbuilding sites output txt files, and I'm hoping that this could be updated.

Modo will output/read split cards like Life/Death in a txt file as 'Life/Death', but when you download a txt file from another site it is always formatted as 'Life // Death'.

The same is true for double sided cards like Growing Rites of Itlimoc. Modo will output/read Growing Rites of Itlimoc in a txt file as 'Growing Rites of Itlimoc', but when you download a txt file from another site it is always formatted as 'Growing Rites of Itlimoc // Itlimoc, Cradle of the Sun'.

I would like modo to be able to recognize both formatting types when importing a txt file if possible purely as a quality of life improvement.
 

Firedrake

Well-known member
And don't forget capitalization... Growing Rites Of Itlimoc won't be recognized, either. I get that a lot with Bridge From Below. Oddly enough, if I search the Collection view for "bridge from below" it is found just fine. Isn't the same game engine searching for these cards?
 
Hello,

I know that the MTGO client is built with C# + WPF. It's been many years that the text importer hits a wall when a text file has characters that is not recognized one by one with the database.

With the help of ChatGPT, it gave me the full algorithm called Levenshtein distance (https://en.wikipedia.org/wiki/Levenshtein_distance).

You can see my code below or from pastebin https://pastebin.com/HFLfghUU

ArchieCoder

---

using System.Diagnostics;

namespace MTGOImporter
{
internal class Program
{
private string[] _allCards = new string[]
{
"Plains",
"Mountain",
"Island",
"Swamp",
"Forest",
"Up the Beanstalk",
"Lórien Revealed",
"Fire/Ice",
"Fireblast",
"Fireball"
};

static void Main(string[] args)
{
var closestCard1 = FindClosestCard("Fire // Ice");
Debug.Assert(closestCard1 == "Fire/Ice");

var closestCard2 = FindClosestCard("L356ie Revealed");
Debug.Assert(closestCard2 == "Lórien Revealed");

var closestCard3 = FindClosestCard("Plains");
Debug.Assert(closestCard3 == "Plains");

var closestCard4 = FindClosestCard("Forest");
Debug.Assert(closestCard4 == "Forest");
}

private static string FindClosestCard(string input)
{
string[] cardList = { "Plains", "Mountain", "Island", "Swamp", "Forest", "Up the Beanstalk", "Lórien Revealed", "Fire/Ice", "Fireblast", "Fireball" };
string closestCard = string.Empty;
int closestDistance = int.MaxValue;

foreach (string card in cardList)
{
int distance = ComputeLevenshteinDistance(card, input);

if (distance < closestDistance)
{
closestDistance = distance;
closestCard = card;
}
}

return closestCard;
}

private static int ComputeLevenshteinDistance(string s, string t)
{
int[,] distance = new int[s.Length + 1, t.Length + 1];

for (int i = 0; i <= s.Length; i++)
{
distance[i, 0] = i;
}
for (int j = 0; j <= t.Length; j++)
{
distance[0, j] = j;
}

for (int j = 1; j <= t.Length; j++)
{
for (int i = 1; i <= s.Length; i++)
{
if (s[i - 1] == t[j - 1])
{
distance[i, j] = distance[i - 1, j - 1];
}
else
{
distance[i, j] = Math.Min(distance[i - 1, j] + 1, Math.Min(distance[i, j - 1] + 1, distance[i - 1, j - 1] + 1));
}
}
}

return distance[s.Length, t.Length];
}
}
}
 

Neo001992

Well-known member
I love the update we got on 12/6 addressing a lot of these issues, but it still seems to be a problem for some double sided cards where modo doesn't want the second name to be present when reading a txt file.

 

Neo001992

Well-known member
Where are you getting text files that present DFCs this way? Most downloadable files now have just the front face of the card listed
Answered in PM, but will answer here too for posterities sake. The site is Archidekt whenever I find a decklist there I want to import into modo.
 

Firedrake

Well-known member
I always Search & Replace " // " with "/" in Notepad before importing. Quick 'n easy, and it imports fine.
 
Top