Skip to content

Commit a7fb70b

Browse files
committed
added folder setting, fixed bad replay bug
1 parent c0f5957 commit a7fb70b

15 files changed

Lines changed: 353 additions & 35 deletions

Main/.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

Main/.gitignore

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
[Dd]ebug/
46+
[Rr]elease/
47+
*_i.c
48+
*_p.c
49+
*.ilk
50+
*.meta
51+
*.obj
52+
*.pch
53+
*.pdb
54+
*.pgc
55+
*.pgd
56+
*.rsp
57+
*.sbr
58+
*.tlb
59+
*.tli
60+
*.tlh
61+
*.tmp
62+
*.vspscc
63+
.builds
64+
*.dotCover
65+
66+
## TODO: If you have NuGet Package Restore enabled, uncomment this
67+
#packages/
68+
69+
# Visual C++ cache files
70+
ipch/
71+
*.aps
72+
*.ncb
73+
*.opensdf
74+
*.sdf
75+
76+
# Visual Studio profiler
77+
*.psess
78+
*.vsp
79+
80+
# ReSharper is a .NET coding add-in
81+
_ReSharper*
82+
83+
# Installshield output folder
84+
[Ee]xpress
85+
86+
# DocProject is a documentation generator add-in
87+
DocProject/buildhelp/
88+
DocProject/Help/*.HxT
89+
DocProject/Help/*.HxC
90+
DocProject/Help/*.hhc
91+
DocProject/Help/*.hhk
92+
DocProject/Help/*.hhp
93+
DocProject/Help/Html2
94+
DocProject/Help/html
95+
96+
97+
*.rep
98+
99+
# Click-Once directory
100+
publish
101+
102+
# Others
103+
[Bb]in
104+
[Oo]bj
105+
sql
106+
TestResults
107+
*.Cache
108+
ClientBin
109+
stylecop.*
110+
~$*
111+
*.dbmdl
112+
Generated_Code #added for RIA/Silverlight projects
113+
114+
# Backup & report files from converting an old project file to a newer
115+
# Visual Studio version. Backup files are not needed, because we have git ;-)
116+
_UpgradeReport_Files/
117+
Backup*/
118+
UpgradeLog*.XML
119+
120+
121+
122+
############
123+
## Windows
124+
############
125+
126+
# Windows image file caches
127+
Thumbs.db
128+
129+
# Folder config file
130+
Desktop.ini
131+
132+
133+
#############
134+
## Python
135+
#############
136+
137+
*.py[co]
138+
139+
# Packages
140+
*.egg
141+
*.egg-info
142+
dist
143+
build
144+
eggs
145+
parts
146+
bin
147+
var
148+
sdist
149+
develop-eggs
150+
.installed.cfg
151+
152+
# Installer logs
153+
pip-log.txt
154+
155+
# Unit test / coverage reports
156+
.coverage
157+
.tox
158+
159+
#Translations
160+
*.mo
161+
162+
#Mr Developer
163+
.mr.developer.cfg
164+
165+
# Mac crap
166+
.DS_Store

Main/.vs/ReplayParser/v14/.suo

66.5 KB
Binary file not shown.

Main/ReplayParser.ReplaySorter/Program.cs

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ static void Main(string[] args)
5656

5757
// parse all replays in directory
5858

59-
var searchDirectory = User.AskDirectory();
59+
var searchDirectory = (SearchDirectory)User.AskDirectory(typeof(SearchDirectory));
6060
List<IReplay> ListReplays = new List<IReplay>();
6161
IEnumerable<string> files = Directory.EnumerateFiles(searchDirectory.Directory, "*.rep", searchDirectory.SearchOption);
6262

6363
while (files.Count() == 0)
6464
{
6565
Console.WriteLine("No replays found in {0}", searchDirectory.Directory);
66-
searchDirectory = User.AskDirectory();
66+
searchDirectory = (SearchDirectory)User.AskDirectory(typeof(SearchDirectory));
6767
files = Directory.EnumerateFiles(searchDirectory.Directory, "*.rep", searchDirectory.SearchOption);
6868
}
6969
// getting a lot of errors for replays, figure out why. Add possibility to rename the replays themselves.
@@ -72,7 +72,7 @@ static void Main(string[] args)
7272
// could I put a try/catch inside a nother catch? Or should I just use a stringbuilder and write the entirety of it to a file in the end
7373
StringBuilder ErrorMessages = new StringBuilder();
7474
List<string> ReplaysThrowingExceptions = new List<string>();
75-
var BadReplays = searchDirectory.Directory + @"\BadReplays";
75+
//var BadReplays = searchDirectory.Directory + @"\BadReplays";
7676
Stopwatch sw = new Stopwatch();
7777
sw.Start();
7878
//try
@@ -115,31 +115,47 @@ static void Main(string[] args)
115115
Console.WriteLine("Error writing error messages." + ex.Message);
116116
}
117117

118-
ReplayHandler.LogBadReplays(ReplaysThrowingExceptions, BadReplays);
119-
120118
if (ReplaysThrowingExceptions.Count() > 0)
121119
{
122-
Console.WriteLine("Move bad replays to designated folder {0}? Y(es)/N(o).", BadReplays);
120+
Console.WriteLine("Move bad replays to a designated folder? Y(es)/N(o).");
123121
var MoveBadReplays = User.AskYesNo();
124122
if (MoveBadReplays.Yes != null)
125123
{
126124
if ((bool)MoveBadReplays.Yes)
127125
{
126+
var BadReplaysOutputDirectory = (OutputDirectory)User.AskDirectory(typeof(OutputDirectory), "Specify a directory to put the bad replays.");
127+
bool CreateDirectorySuccess = false;
128+
while (!CreateDirectorySuccess)
129+
{
130+
try
131+
{
132+
Directory.CreateDirectory(BadReplaysOutputDirectory.Directory);
133+
CreateDirectorySuccess = true;
134+
}
135+
catch (Exception)
136+
{
137+
Console.WriteLine("Could not create directory. Invalid directory name or not enough privileges.");
138+
CreateDirectorySuccess = false;
139+
}
140+
}
141+
128142
foreach (var replay in ReplaysThrowingExceptions)
129143
{
130-
ReplayHandler.RemoveBadReplay(BadReplays, replay);
144+
ReplayHandler.RemoveBadReplay(BadReplaysOutputDirectory.Directory + @"\BadReplays", replay);
131145
}
146+
ReplayHandler.LogBadReplays(ReplaysThrowingExceptions, BadReplaysOutputDirectory.Directory + @"\BadReplays");
147+
132148
}
133149
}
134150
else
135151
{
136152
Console.WriteLine("Answer can not be null");
137153
return;
138154
}
139-
155+
// remove bad replay from files
156+
files = files.Where(x => !ReplaysThrowingExceptions.Contains(x));
140157
}
141158

142-
143159
// you might want to extract information and put everything into some sort of data structure, so you don't have to go through the list of replays for each
144160
// sort but instead can lookup in the datastructure/table?
145161

@@ -149,6 +165,36 @@ static void Main(string[] args)
149165

150166
// use a library to parse command line arguments => then return some sort of Enum
151167
// then pass this enum to a Sorter object
168+
OutputDirectory SortResultOutputDirectory = (OutputDirectory)User.AskDirectory(typeof(OutputDirectory), "Specify a directory for the sort result. If it does not exist, it will be created.");
169+
while (!Directory.Exists(SortResultOutputDirectory.Directory))
170+
{
171+
try
172+
{
173+
Directory.CreateDirectory(SortResultOutputDirectory.Directory);
174+
}
175+
catch (Exception)
176+
{
177+
Console.WriteLine("Could not create directory. Invalid directory name or not enough privileges.");
178+
Console.WriteLine("Retry?");
179+
var TryAgain = User.AskYesNo();
180+
if (TryAgain.Yes != null)
181+
{
182+
if ((bool)TryAgain.Yes)
183+
{
184+
continue;
185+
}
186+
else
187+
{
188+
SortResultOutputDirectory = (OutputDirectory)User.AskDirectory(typeof(OutputDirectory), "Specify a different directory for the sort result.If it does not exist, it will be created.");
189+
}
190+
}
191+
else
192+
{
193+
Console.WriteLine("Answer can not be null.");
194+
return;
195+
}
196+
}
197+
}
152198

153199
Console.WriteLine("Please enter criteria to sort replays on.");
154200
Console.WriteLine("Provide a space separated list of criteria.");
@@ -189,7 +235,7 @@ static void Main(string[] args)
189235
return;
190236
}
191237

192-
sorter.CurrentDirectory = searchDirectory.Directory;
238+
sorter.CurrentDirectory = SortResultOutputDirectory.Directory;
193239
sorter.Files = files;
194240
sorter.ListReplays = ListReplays;
195241
sorter.SortCriteria = SortCriteria.ChosenCriteria;

Main/ReplayParser.ReplaySorter/ReplayParser.ReplaySorter.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<BootstrapperEnabled>true</BootstrapperEnabled>
3636
</PropertyGroup>
3737
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
38-
<PlatformTarget>x86</PlatformTarget>
38+
<PlatformTarget>AnyCPU</PlatformTarget>
3939
<DebugSymbols>true</DebugSymbols>
4040
<DebugType>full</DebugType>
4141
<Optimize>false</Optimize>
@@ -102,6 +102,8 @@
102102
<Compile Include="Sorting\EqualityComparers\ReplayMapEqualityComparer.cs" />
103103
<Compile Include="Sorting\Sorter\Sorter.cs" />
104104
<Compile Include="UserInput\Answer.cs" />
105+
<Compile Include="UserInput\BaseDirectory.cs" />
106+
<Compile Include="UserInput\OutputDirectory.cs" />
105107
<Compile Include="UserInput\SearchDirectory.cs" />
106108
<Compile Include="UserInput\UserInput.cs" />
107109
</ItemGroup>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ReplayParser.ReplaySorter.UserInput
8+
{
9+
public class BaseDirectory
10+
{
11+
public BaseDirectory(string directory)
12+
{
13+
Directory = directory;
14+
}
15+
public string Directory { get; set; }
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ReplayParser.ReplaySorter.UserInput
8+
{
9+
public class OutputDirectory : BaseDirectory
10+
{
11+
public OutputDirectory(string directory, string message) : base(directory)
12+
{
13+
Message = message;
14+
}
15+
16+
public string Message { get; set; }
17+
}
18+
}

Main/ReplayParser.ReplaySorter/UserInput/SearchDirectory.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66

77
namespace ReplayParser.ReplaySorter.UserInput
88
{
9-
public class SearchDirectory
9+
public class SearchDirectory : BaseDirectory
1010
{
11-
public SearchDirectory(string directory, SearchOption searchoption)
11+
public SearchDirectory(string directory, SearchOption searchoption) : base(directory)
1212
{
13-
this.Directory = directory;
1413
this.SearchOption = searchoption;
1514
}
16-
public string Directory { get; set; }
1715
public SearchOption SearchOption { get; set; }
1816
}
1917
}

0 commit comments

Comments
 (0)