Skip to content

Commit

Permalink
Merge pull request #1 from ronelm2000/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ianzzz94 authored Jul 1, 2020
2 parents 9416e60 + d15fa7b commit e1da873
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
23 changes: 17 additions & 6 deletions MontageWeissTools/Impls/Parsers/Cards/HeartOfTheCardsURLParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,28 +199,30 @@ private WeissSchwarzCard ParseHOTCText(string hotcText)
}

cursor.Next();

if(cursor.CurrentLine.ToString().Contains(traitsText)){
if (cursor.CurrentLine.ToString().Contains(traitsText))
{
res.Traits = cursor.CurrentLine
.Slice(c => c.IndexOf(traitsText) + traitsText.Length)
.Trim()
.ToString()
.Split(",")
.SplitWithRegex(@"([^(]+)\(([^\)]+)\),{0,1}")
.Select(this.ParseTrait)
.Where(o => o != null)
.ToList();
}
else if(cursor.CurrentLine.ToString().Contains(trait1Text)){
else if (cursor.CurrentLine.ToString().Contains(trait1Text))
{
res.Traits = cursor.CurrentLine
.Slice(c => c.IndexOf(trait1Text) + trait1Text.Length)
.Trim()
.ToString()
.Split(" Trait 2: ")
.Split("Trait 2: ")
.SelectMany(s => s.Trim().SplitWithRegex(@"([^(]+)\(([^\)]+)\),{0,1}")) //TODO: Duplicate Regex, may be identical with traitMatcher.
.Select(this.ParseTrait)
.Where(o => o != null)
.ToList();
}

cursor.Next();

var stringTriggers = cursor.CurrentLine
Expand Down Expand Up @@ -313,6 +315,15 @@ private MultiLanguageString ParseTrait(String traitString)
return result;
}

private MultiLanguageString ParseTrait(Match match)
{
MultiLanguageString result = new MultiLanguageString();
result["jp"] = match.Groups[1].Value.Trim();
result["en"] = match.Groups[2].Value.Trim();
Log.Debug("All Groups: {@groups}", match.Groups.OfType<Group>().Select(g => g.Value).ToArray());
return result;
}

private bool IsValidTrait(string traitString)
{
return traitMatcher.Matches(traitString).Count > 0;
Expand Down
8 changes: 8 additions & 0 deletions MontageWeissTools/Utilities/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Montage.Weiss.Tools.Utilities
Expand All @@ -26,6 +29,11 @@ public static string EscapeQuotes(this string str)
.Replace("\r", "\\\r");
}

public static IEnumerable<Match> SplitWithRegex(this string str, string regex)
{
return (new Regex(regex)).Matches(str);
}

public static string AsFileNameFriendly(this string str, char replacement = '_')
{
var res = str;
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ registering on GitHub.

#### Supported Exporters ####
* [Tabletop Simulator](https://steamcommunity.com/sharedfiles/filedetails/?id=1321170886)
* Local Deck JSON

#### Supported Deck Parsers ####
* [Encore Decks](https://www.encoredecks.com/)
* Local Deck JSON

#### Supported Card Set Parsers ####
* HOTC
Expand Down

0 comments on commit e1da873

Please sign in to comment.