Skip to content

Commit

Permalink
csv dumping thanks to rowellx68
Browse files Browse the repository at this point in the history
  • Loading branch information
NecronomiconCoding committed Jul 31, 2016
1 parent 37a91e5 commit 1f51cf4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions PoGo.NecroBot.Logic/DataDumper/Dumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public static class Dumper
/// <param name="session"></param>
/// <param name="filename" />
/// File to clear/param>
public static void ClearDumpFile(ISession session, string filename)
public static void ClearDumpFile(ISession session, string filename, string extension = "csv")
{
var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps");
var file = Path.Combine(path,
$"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.txt");
$"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}");
if (!Directory.Exists(path)) Directory.CreateDirectory(path);

// Clears all contents of a file first if overwrite is true
Expand All @@ -33,11 +33,12 @@ public static void ClearDumpFile(ISession session, string filename)
/// <param name="session"></param>
/// <param name="data">Dumps the string data to the file</param>
/// <param name="filename">Filename to be used for naming the file.</param>
public static void Dump(ISession session, string data, string filename)
/// <param name="extension">FileExt.</param>
public static void Dump(ISession session, string data, string filename, string extension = "csv")
{
string uniqueFileName = $"{filename}";

DumpToFile(session, data, uniqueFileName);
DumpToFile(session, data, uniqueFileName, extension);
}

/// <summary>
Expand All @@ -46,10 +47,10 @@ public static void Dump(ISession session, string data, string filename)
/// <param name="session"></param>
/// <param name="data">Dumps the string data to the file</param>
/// <param name="filename">Filename to be used for naming the file.</param>
private static void DumpToFile(ISession session, string data, string filename)
private static void DumpToFile(ISession session, string data, string filename, string extension = "csv")
{
var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps",
$"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.txt");
$"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}");

using (
var dumpFile =
Expand Down
4 changes: 2 additions & 2 deletions PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static async Task Execute(ISession session)
if (session.LogicSettings.DumpPokemonStats)
{
const string dumpFileName = "PokeBagStats";
Dumper.ClearDumpFile(session, dumpFileName);
Dumper.ClearDumpFile(session, dumpFileName, "csv");
foreach (var pokemon in allPokemonInBag)
{
int candy = PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings);
Expand All @@ -123,7 +123,7 @@ public static async Task Execute(ISession session)

Dumper.Dump(session,
string.Format($"NAME: {pokeName, -25} LVL: {PokemonInfo.GetLevel(pokemon).ToString("00"), -7} CP: {pokemon.Cp.ToString() + " / " + PokemonInfo.CalculateMaxCp(pokemon).ToString(), -15} IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00"), -10} MOVE1: {pokemon.Move1, -20} MOVE2: {pokemon.Move2, -20} Candies: {candy}"),
dumpFileName);
dumpFileName, "csv");
}
}
await Task.Delay(500);
Expand Down

0 comments on commit 1f51cf4

Please sign in to comment.