Skip to content

Commit

Permalink
Prettier! Also try yet again to catch both temtems
Browse files Browse the repository at this point in the history
  • Loading branch information
Marilyth committed Jul 27, 2020
1 parent 326cff7 commit 4212c0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Encounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task CheckForEncounters()

//Check multiple times in case screen flashed
bool[] wasFound = {false, false};
for (int i = 0; i < 10; i++)
for (int i = 0; i < 20; i++)
{
for(int j = 0; j < bools.Length; j++)
{
Expand All @@ -52,6 +52,7 @@ public async Task CheckForEncounters()
Encounters[temtemType] = new EncounterInfo();

Encounters[temtemType].HowOften += 1;
Encounters[temtemType].HowOftenToday += 1;
Encounters[temtemType].LastEncounter = DateTime.UtcNow;
//await temtemEncountered(temtemType);
await Task.Delay(100);
Expand All @@ -64,6 +65,7 @@ public async Task CheckForEncounters()
await Program.DrawEncounterTable();
Save(this);

int counter = 0;
//Wait for encounter to end
while (true)
{
Expand All @@ -75,7 +77,10 @@ public async Task CheckForEncounters()
var temtemType = temtem.GetScreenText(await temtem.GetTemtem(b));
if (!string.IsNullOrEmpty(temtemType)) isEmpty = false;
}
if (isEmpty) break;
if (isEmpty) counter++;
else counter = 0;
if(counter == 10) break;
await Task.Delay(100);
}
}

Expand Down Expand Up @@ -122,5 +127,8 @@ public class EncounterInfo
{
public DateTime LastEncounter;
public int HowOften;

[JsonIgnore]
public int HowOftenToday;
}
}
6 changes: 4 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ public static async Task WriteEncounter(string temtem, int counter)
Console.Clear();
#endif

string table = String.Format("{0, -20} | {1, -10} | {2, -23}\n", "Temtem", "Encounters", "Last Encounter");
string table = String.Format("{0, -20} | {1, -13} | {2, -23}\n", "Temtem", "Encounters", "Last Encounter");
table += "------------------------------------------------------------------\n";
foreach(var temtem in encounter.Encounters.OrderByDescending(x => x.Value.LastEncounter)){
table += $"{temtem.Key, -20} | {temtem.Value.HowOften, -10} | {temtem.Value.LastEncounter, -23} UTC\n";
table += $"{temtem.Key, -20} | {temtem.Value.HowOften, -6} {(temtem.Value.HowOftenToday > 0 ? $"(+{temtem.Value.HowOftenToday})" : ""), -6} | {temtem.Value.LastEncounter, -23} UTC\n";
}
table += "------------------------------------------------------------------\n";
table += $"{"Total", -20} | {encounter.Encounters.Sum(x => x.Value.HowOften), -6} {(encounter.Encounters.Sum(x => x.Value.HowOftenToday) > 0 ? $"(+{encounter.Encounters.Sum(x => x.Value.HowOftenToday)})" : ""), -6} | \n";
Console.WriteLine(table);
}
}
Expand Down

0 comments on commit 4212c0b

Please sign in to comment.