Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
I'm certain that the checklist is working properly now, it has to be.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirdoombox committed Mar 25, 2022
1 parent ec40c35 commit 9eacc6e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
</Grid.RowDefinitions>
<controls:ChecklistHeader OnAddClicked="{s:Action AddWeeklyClicked}"
Header="Character Weeklies"
TotalTasks="10"
TasksCompleted="5"
TotalTasks="{Binding Weeklies.TaskCount}"
TasksCompleted="{Binding Weeklies.CompletedCount}"
Grid.Row="0" />
<ContentControl s:View.Model="{Binding Weeklies}"
Grid.Row="1" />
<controls:ChecklistHeader OnAddClicked="{s:Action AddDailyClicked}"
Header="Character Dailies"
TotalTasks="{Binding Dailies.TaskCount}"
TasksCompleted="{Binding Dailies.CompletedCount}"
Grid.Row="2" />
<ContentControl s:View.Model="{Binding Dailies}"
Grid.Row="3" />
Expand Down
1 change: 1 addition & 0 deletions LostArkTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Nullable>disable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationIcon>lostarktools.ico</ApplicationIcon>
<AssemblyVersion>0.0.6</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
2 changes: 1 addition & 1 deletion Services/ChecklistDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override void OnLoadFailed()

protected override void BeforeSave()
{
Data.LastOpened = _ts.Now;
Data.LastOpened = TimeService.Now;
}

public IEnumerable<Character> GetCharacters() =>
Expand Down
22 changes: 13 additions & 9 deletions Services/TimeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ public class TimeService
public Action DailyReset { get; set; } = () => { };
public Action SecondsTick { get; set; } = () => { };

private DateTime Today => DateTime.UtcNow.Date;
private static DateTime Today => DateTime.UtcNow.Date;

public DateTime Now => DateTime.UtcNow;
public static DateTime Now => DateTime.UtcNow;

public DateTime ServerTime =>
public DateTime ServerNow =>
DateTime.UtcNow + _currentTimezone.BaseUtcOffset;

public string ServerTimeString =>
$"Server Time ({_currentServer}): {ServerTime:HH:mm}";
$"Server Time ({_currentServer}): {ServerNow:HH:mm}";

public DateTime ResetToday =>
Today.AddHours(10);

public DateTime NextDailyReset =>
Now >= ResetToday ? ResetToday.AddDays(1) : ResetToday;
Now > ResetToday ? ResetToday.AddDays(1) : ResetToday;

public DateTime LastDailyReset =>
Now < ResetToday ? ResetToday.AddDays(-1) : ResetToday;
Expand All @@ -50,7 +50,7 @@ public class TimeService
NextWeeklyReset - Now;

public bool IsWeeklyResetDay =>
ServerTime.DayOfWeek == DayOfWeek.Thursday;
Now.DayOfWeek == DayOfWeek.Thursday;

private TimeZoneInfo _currentTimezone = Servers["EU Central/West"];
private string _currentServer = "EU Central/West";
Expand All @@ -60,8 +60,12 @@ public TimeService(IContainer container)
JobManager.UseUtcTime();
JobManager.Initialize();
JobManager.AddJob(() => SecondsTick(), s => s.ToRunEvery(1).Seconds());
JobManager.AddJob(() => DailyReset(), s => s.ToRunEvery(1).Days().At(10,00));
JobManager.AddJob(() => WeeklyReset(), s => s.ToRunEvery(1).Weeks().On(DayOfWeek.Thursday).At(10,00));
JobManager.AddJob(() =>
{
DailyReset();
if (IsWeeklyResetDay)
WeeklyReset();
}, s => s.ToRunEvery(1).Days().At(10,00));
}

public IEnumerable<string> GetRegions() => Servers.Select(x => x.Key);
Expand All @@ -73,5 +77,5 @@ public void SetTimezone(string serverName)
}

public bool HasResetPassedSinceLastLaunch(DateTime lastOpened) =>
Now >= LastDailyReset && lastOpened < LastDailyReset;
Now > LastDailyReset && lastOpened < LastDailyReset;
}

0 comments on commit 9eacc6e

Please sign in to comment.