Browse Source

feat(Storage) Storage feature done

main
Jonathan McCaffrey 4 years ago
parent
commit
adbf36da9f
  1. 2
      Components/Feedback/ToastComponent.razor
  2. 2
      IGP/Dialog/EntityDialogComponent.razor
  3. 2
      IGP/Dialog/SearchDialogComponent.razor
  4. 2
      IGP/Index.razor
  5. 4
      IGP/Pages/BuildCalculator/BuildCalculatorPage.razor
  6. 4
      IGP/Pages/BuildCalculator/Parts/EntityClickViewComponent.razor
  7. 34
      IGP/Pages/BuildCalculator/Parts/FilterComponent.razor
  8. 12
      IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor
  9. 58
      IGP/Pages/BuildCalculator/Parts/OptionsComponent.razor
  10. 11
      IGP/Pages/BuildCalculator/Parts/TimingComponent.razor
  11. 4
      IGP/Pages/Comparision/ComparisionPage.razor
  12. 8
      IGP/Pages/Database/DatabasePage.razor
  13. 8
      IGP/Pages/Database/Parts/EntityFilterComponent.razor
  14. 2
      IGP/Pages/Documentation/DocumentationIndexPage.razor
  15. 2
      IGP/Pages/Documentation/DocumentationPage.razor
  16. 2
      IGP/Pages/Notes/NotesIndexPage.razor
  17. 2
      IGP/Pages/Notes/NotesPage.razor
  18. 2
      IGP/Pages/PermissionsPage.razor
  19. 159
      IGP/Pages/StoragePage.razor
  20. 2
      IGP/Portals/EntityDialogPortal.razor
  21. 2
      IGP/Portals/SearchPortal.razor
  22. 2
      IGP/Portals/ToastPortal.razor
  23. 342
      Model/Entity/Data/DATA.cs
  24. 5
      Model/Entity/Data/Ids_Entity.cs
  25. 5
      Model/Entity/Parts/EntityFactionModel.cs
  26. 14
      Model/Entity/Types/FactionType.cs
  27. 7
      Model/Entity/Types/ImmortalType.cs
  28. 4
      Model/Model.csproj
  29. 16
      Services/IServices.cs
  30. 31
      Services/Immortal/BuildOrderService.cs
  31. 8
      Services/Immortal/EntityDisplayService.cs
  32. 24
      Services/Immortal/EntityFilterService.cs
  33. 54
      Services/Immortal/ImmortalSelectionService.cs
  34. 48
      Services/Immortal/TimingService.cs
  35. 10
      Services/Services.csproj
  36. 11
      Services/Website/PermissionService.cs
  37. 49
      Services/Website/StorageService.cs

2
Components/Feedback/ToastComponent.razor

@ -84,7 +84,7 @@ else
toastService.RemoveToast(Toast!);
}
public void Dispose()
void IDisposable.Dispose()
{
toastService.Unsubscribe(OnUpdate);
}

2
IGP/Dialog/EntityDialogComponent.razor

@ -150,7 +150,7 @@
entityDialogService.Subscribe(OnUpdate);
}
public void Dispose()
void IDisposable.Dispose()
{
entityDialogService.Unsubscribe(OnUpdate);
}

2
IGP/Dialog/SearchDialogComponent.razor

@ -144,7 +144,7 @@
StateHasChanged();
}
public void Dispose()
void IDisposable.Dispose()
{
searchService.Unsubscribe(OnSearchChanged);
timer.Elapsed -= FocusTimer;

2
IGP/Index.razor

@ -3,7 +3,7 @@
@layout PageLayout
<DevOnlyComponent>
<PermissionsPage/>
<StoragePage/>
</DevOnlyComponent>
<HomePage/>

4
IGP/Pages/BuildCalculator/BuildCalculatorPage.razor

@ -257,8 +257,8 @@
var hotkeyGroup = keyService.GetHotkeyGroup();
var isHoldSpace = keyService.IsHoldingSpace();
var faction = filterService.GetFactionType();
var immortal = filterService.GetImmortalType();
var faction = filterService.GetFaction();
var immortal = filterService.GetImmortal();
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);

4
IGP/Pages/BuildCalculator/Parts/EntityClickViewComponent.razor

@ -68,8 +68,8 @@
var hotkey = KeyService.GetHotkey();
var hotkeyGroup = KeyService.GetHotkeyGroup();
var isHoldSpace = KeyService.IsHoldingSpace();
var faction = FilterService.GetFactionType();
var immortal = FilterService.GetImmortalType();
var faction = FilterService.GetFaction();
var immortal = FilterService.GetImmortal();
var foundEntity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);

34
IGP/Pages/BuildCalculator/Parts/FilterComponent.razor

@ -1,27 +1,33 @@
@inject IJSRuntime jsRuntime;
@inject IImmortalSelectionService filterService
@inject IJSRuntime JsRuntime;
@inject IImmortalSelectionService FilterService
<FormLayoutComponent>
<FormSelectComponent OnChange="@OnFactionChanged">
<FormLabelComponent>Faction</FormLabelComponent>
<ChildContent>
<option value="@FactionType.Aru">Aru</option>
<option value="@FactionType.QRath" selected>Q'Rath</option>
<option value="@DataType.FACTION_Aru"
selected="@(FilterService.GetFaction().Equals(DataType.FACTION_Aru))">Aru</option>
<option value="@DataType.FACTION_QRath"
selected="@(FilterService.GetFaction().Equals(DataType.FACTION_QRath))">Q'Rath</option>
</ChildContent>
</FormSelectComponent>
<FormSelectComponent OnChange="@OnImmortalChanged">
<FormLabelComponent>Immortal</FormLabelComponent>
<ChildContent>
@if (filterService.GetFactionType() == FactionType.QRath)
@if (FilterService.GetFaction() == DataType.FACTION_QRath)
{
<option value="@DataType.IMMORTAL_Orzum" selected>Orzum</option>
<option value="@DataType.IMMORTAL_Ajari">Ajari</option>
<option value="@DataType.IMMORTAL_Orzum"
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Orzum))">Orzum</option>
<option value="@DataType.IMMORTAL_Ajari"
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Ajari))">Ajari</option>
}
@if (filterService.GetFactionType() == FactionType.Aru)
@if (FilterService.GetFaction() == DataType.FACTION_Aru)
{
<option value="@DataType.IMMORTAL_Mala" selected>Mala</option>
<option value="@DataType.IMMORTAL_Xol">Xol</option>
<option value="@DataType.IMMORTAL_Mala"
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Mala))">Mala</option>
<option value="@DataType.IMMORTAL_Xol"
selected="@(FilterService.GetImmortal().Equals(DataType.IMMORTAL_Xol))">Xol</option>
}
</ChildContent>
</FormSelectComponent>
@ -31,18 +37,18 @@
void OnFactionChanged(ChangeEventArgs e)
{
filterService.SelectFactionType(e.Value!.ToString()!);
FilterService.SelectFaction(e.Value!.ToString()!);
}
void OnImmortalChanged(ChangeEventArgs e)
{
filterService.SelectImmortalType(e.Value!.ToString()!);
FilterService.SelectImmortal(e.Value!.ToString()!);
}
protected override bool ShouldRender()
{
#if DEBUG
jsRuntime.InvokeVoidAsync("console.time", "FilterComponent");
JsRuntime.InvokeVoidAsync("console.time", "FilterComponent");
#endif
return true;
@ -51,7 +57,7 @@
protected override void OnAfterRender(bool firstRender)
{
#if DEBUG
jsRuntime.InvokeVoidAsync("console.timeEnd", "FilterComponent");
JsRuntime.InvokeVoidAsync("console.timeEnd", "FilterComponent");
#endif
}

12
IGP/Pages/BuildCalculator/Parts/HotkeyViewerComponent.razor

@ -164,7 +164,7 @@
// Move to Filter Service
bool InvalidFaction(EntityModel entity)
{
if (entity.Faction() != null && entity.Faction()?.Faction != filterService.GetFactionType() && filterService.GetFactionType() != FactionType.Any)
if (entity.Faction() != null && entity.Faction()?.Faction != filterService.GetFaction() && filterService.GetFaction() != DataType.Any)
{
return true;
}
@ -176,8 +176,8 @@
bool InvalidVanguard(EntityModel entity)
{
if (entity.VanguardAdded() != null
&& entity.VanguardAdded()?.ImmortalId != filterService.GetImmortalType()
&& filterService.GetImmortalType() != ImmortalType.Any)
&& entity.VanguardAdded()?.ImmortalId != filterService.GetImmortal()
&& filterService.GetImmortal() != DataType.Any)
{
return true;
}
@ -192,7 +192,7 @@
{
foreach (var replaced in entity.Replaceds())
{
if (filterService.GetImmortalType() == replaced.ImmortalId)
if (filterService.GetImmortal() == replaced.ImmortalId)
{
return true;
}
@ -319,8 +319,8 @@
var hotkeyGroup = keyService.GetHotkeyGroup();
var isHoldSpace = keyService.IsHoldingSpace();
var faction = filterService.GetFactionType();
var immortal = filterService.GetImmortalType();
var faction = filterService.GetFaction();
var immortal = filterService.GetImmortal();
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);

58
IGP/Pages/BuildCalculator/Parts/OptionsComponent.razor

@ -1,14 +1,17 @@
@inject IJSRuntime jsRuntime;
@inject IJSRuntime JsRuntime;
@inject IBuildOrderService buildOrderService
@inject IEconomyService economyService
@inject IToastService toastService
@inject ITimingService timingService
@inject IBuildOrderService BuildOrderService
@inject IEconomyService EconomyService
@inject IToastService ToastService
@inject ITimingService TimingService
@using System.Data
@implements IDisposable
<FormLayoutComponent>
<FormNumberComponent Max="600"
Min="0"
Value="@buildOrderService.BuildingInputDelay"
Value="BuildDelay"
OnChange="@OnBuildingInputDelayChanged">
<FormLabelComponent>Building Input Delay</FormLabelComponent>
<FormInfoComponent>Add a input delay to constructing buildings for simulating worker movement and player micro.</FormInfoComponent>
@ -17,7 +20,7 @@
<FormLayoutComponent>
<FormNumberComponent Max="600"
Min="1"
Value="@WaitTime"
Value="WaitTime"
OnChange="@OnWaitTimeChanged">
<FormLabelComponent>Wait Time</FormLabelComponent>
</FormNumberComponent>
@ -26,7 +29,7 @@
<FormLayoutComponent>
<FormNumberComponent Max="2048"
Min="1"
Value="@WaitTo"
Value="WaitTo"
OnChange="@OnWaitToChanged">
<FormLabelComponent>Wait To</FormLabelComponent>
</FormNumberComponent>
@ -43,45 +46,69 @@
</style>
@code {
private int BuildDelay { get; set; } = 2;
private int WaitTime { get; set; } = 30;
private int WaitTo { get; set; } = 30;
protected override void OnInitialized()
{
TimingService.Subscribe(RefreshDefaults);
RefreshDefaults();
}
void IDisposable.Dispose()
{
TimingService.Unsubscribe(RefreshDefaults);
}
void RefreshDefaults()
{
BuildDelay = TimingService.BuildingInputDelay;
WaitTime = TimingService.WaitTime;
WaitTo = TimingService.WaitTo;
StateHasChanged();
}
void OnBuildingInputDelayChanged(ChangeEventArgs changeEventArgs)
{
buildOrderService.BuildingInputDelay = int.Parse(changeEventArgs.Value!.ToString()!);
TimingService.BuildingInputDelay = int.Parse(changeEventArgs.Value!.ToString()!);
}
void OnWaitTimeChanged(ChangeEventArgs changeEventArgs)
{
TimingService.WaitTime = (int)changeEventArgs.Value!;
WaitTime = (int)changeEventArgs.Value!;
}
void OnWaitToChanged(ChangeEventArgs changeEventArgs)
{
TimingService.WaitTo = (int)changeEventArgs.Value!;
WaitTo = (int)changeEventArgs.Value!;
}
private void OnWaitClicked()
{
if (buildOrderService.AddWait(WaitTime))
if (BuildOrderService.AddWait(WaitTime))
{
economyService.Calculate(buildOrderService, timingService, buildOrderService.GetLastRequestInterval());
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
}
}
private void OnWaitToClicked()
{
if (buildOrderService.AddWaitTo(WaitTo))
if (BuildOrderService.AddWaitTo(WaitTo))
{
economyService.Calculate(buildOrderService, timingService, buildOrderService.GetLastRequestInterval());
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
}
}
protected override bool ShouldRender()
{
#if DEBUG
jsRuntime.InvokeVoidAsync("console.time", "TimingComponent");
JsRuntime.InvokeVoidAsync("console.time", "TimingComponent");
#endif
return true;
@ -90,9 +117,8 @@
protected override void OnAfterRender(bool firstRender)
{
#if DEBUG
jsRuntime.InvokeVoidAsync("console.timeEnd", "TimingComponent");
JsRuntime.InvokeVoidAsync("console.timeEnd", "TimingComponent");
#endif
}
}

11
IGP/Pages/BuildCalculator/Parts/TimingComponent.razor

@ -4,6 +4,7 @@
@inject IEconomyService economyService
@inject IToastService toastService
@inject ITimingService timingService
@implements IDisposable
<FormLayoutComponent>
<FormNumberComponent Max="2048"
@ -30,6 +31,16 @@
@code {
protected override void OnInitialized()
{
timingService.Subscribe(StateHasChanged);
}
void IDisposable.Dispose()
{
timingService.Unsubscribe(StateHasChanged);
}
void OnAttackTimeChanged(ChangeEventArgs changeEventArgs)
{
timingService.SetAttackTime(int.Parse(changeEventArgs.Value!.ToString()!));

4
IGP/Pages/Comparision/ComparisionPage.razor

@ -79,8 +79,8 @@ grid-template-areas: 'loader sand compare compare' ;">
var hotkey = KeyService.GetHotkey();
var hotkeyGroup = KeyService.GetHotkeyGroup();
var isHoldSpace = KeyService.IsHoldingSpace();
var faction = FilterService.GetFactionType();
var immortal = FilterService.GetImmortalType();
var faction = FilterService.GetFaction();
var immortal = FilterService.GetImmortal();
if (hotkey == "`")
{

8
IGP/Pages/Database/DatabasePage.razor

@ -127,8 +127,8 @@
List<EntityModel> searches = default!;
string selectedFactionType = FactionType.Any;
string selectedImmortalType = ImmortalType.Any;
string selectedFactionType = DataType.Any;
string selectedImmortalType = DataType.Any;
string selectedEntityType = EntityType.Army;
string searchText = "";
@ -174,7 +174,7 @@
{
selectedFactionType = EntityFilterService.GetFactionType();
if (selectedFactionType == FactionType.Any)
if (selectedFactionType == DataType.Any)
{
factions = defaults.ToList();
}
@ -199,7 +199,7 @@
{
selectedImmortalType = EntityFilterService.GetImmortalType();
if (selectedImmortalType == ImmortalType.Any)
if (selectedImmortalType == DataType.Any)
{
immortals = factions.ToList();
}

8
IGP/Pages/Database/Parts/EntityFilterComponent.razor

@ -51,16 +51,16 @@
<FormSelectComponent OnChange="@OnFactionChanged">
<FormLabelComponent>Faction</FormLabelComponent>
<ChildContent>
<option value="@FactionType.Any" selected>Any</option>
<option value="@FactionType.Aru">Aru</option>
<option value="@FactionType.QRath">Q'Rath</option>
<option value="@DataType.Any" selected>Any</option>
<option value="@DataType.FACTION_Aru">Aru</option>
<option value="@DataType.FACTION_QRath">Q'Rath</option>
</ChildContent>
</FormSelectComponent>
<FormSelectComponent OnChange="@OnImmortalChanged">
<FormLabelComponent>Immortal</FormLabelComponent>
<ChildContent>
<option value="@ImmortalType.Any" selected>Any</option>
<option value="@DataType.Any" selected>Any</option>
<option value="@DataType.IMMORTAL_Mala">Mala</option>
<option value="@DataType.IMMORTAL_Xol">Xol</option>
<option value="@DataType.IMMORTAL_Orzum">Orzum</option>

2
IGP/Pages/Documentation/DocumentationIndexPage.razor

@ -107,7 +107,7 @@ else
documentationService.Load();
}
public void Dispose()
void IDisposable.Dispose()
{
documentationService.Unsubscribe(StateHasChanged);
}

2
IGP/Pages/Documentation/DocumentationPage.razor

@ -113,7 +113,7 @@ else
documentationService.Load();
}
public void Dispose()
void IDisposable.Dispose()
{
documentationService.Unsubscribe(StateHasChanged);
}

2
IGP/Pages/Notes/NotesIndexPage.razor

@ -125,7 +125,7 @@ else
}
public void Dispose()
void IDisposable.Dispose()
{
noteService.Unsubscribe(StateHasChanged);
}

2
IGP/Pages/Notes/NotesPage.razor

@ -112,7 +112,7 @@ else
noteService.Load();
}
public void Dispose()
void IDisposable.Dispose()
{
noteService.Unsubscribe(StateHasChanged);
}

2
IGP/Pages/PermissionsPage.razor

@ -74,7 +74,7 @@
StateHasChanged();
}
public void Dispose()
void IDisposable.Dispose()
{
PermissionService.Unsubscribe(Update);
}

159
IGP/Pages/StoragePage.razor

@ -1,13 +1,11 @@
@page "/storage"
@inject IStorageService StorageService
@using Services.Website
@implements IDisposable
@layout PageLayout
<LayoutMediumContentComponent>
@if (!_enabledPermissions)
{
<AlertComponent Type="@SeverityType.Error">
@ -25,6 +23,90 @@
OnChange="EntityViewChanged"/>
</FormLayoutComponent>
</PaperComponent>
<PaperComponent>
<FormLayoutComponent>
<FormNumberComponent Max="2048"
Min="0"
Value="@(_attackTime == null ? 0 : (int)_attackTime)"
OnChange="AttackTimeChanged">
<FormLabelComponent>Attack Time</FormLabelComponent>
<FormInfoComponent>
@if (_attackTime != null)
{
<i>&emsp; T @Interval.ToTime((int)_attackTime)</i>
}
</FormInfoComponent>
</FormNumberComponent>
<FormNumberComponent Max="2048"
Min="0"
Value="@(_travelTime == null ? 0 : (int)_travelTime)"
OnChange="TravelTimeChanged">
<FormLabelComponent>Travel Time</FormLabelComponent>
<FormInfoComponent>
@if (_travelTime != null)
{
<i>&emsp; T @Interval.ToTime((int)_travelTime)</i>
}
</FormInfoComponent>
</FormNumberComponent>
<FormSelectComponent OnChange="@OnFactionChanged">
<FormLabelComponent>Faction</FormLabelComponent>
<ChildContent>
<option value="@DataType.FACTION_Aru"
selected="@(Faction.Equals(DataType.FACTION_Aru))">Aru</option>
<option value="@DataType.FACTION_QRath"
selected="@(Faction.Equals(DataType.FACTION_QRath))">Q'Rath</option>
</ChildContent>
</FormSelectComponent>
<FormSelectComponent OnChange="@OnImmortalChanged">
<FormLabelComponent>Immortal</FormLabelComponent>
<ChildContent>
@if (Faction == DataType.FACTION_QRath)
{
<option value="@DataType.IMMORTAL_Orzum"
selected="@(Immortal.Equals(DataType.IMMORTAL_Orzum))">Orzum</option>
<option value="@DataType.IMMORTAL_Ajari"
selected="@(Immortal.Equals(DataType.IMMORTAL_Ajari))">Ajari</option>
}
@if (Faction == DataType.FACTION_Aru)
{
<option value="@DataType.IMMORTAL_Mala"
selected="@(Immortal.Equals(DataType.IMMORTAL_Mala))">Mala</option>
<option value="@DataType.IMMORTAL_Xol"
selected="@(Immortal.Equals(DataType.IMMORTAL_Xol))">Xol</option>
}
</ChildContent>
</FormSelectComponent>
<FormNumberComponent Max="600"
Min="0"
Value="@(_buildingInputDelay == null ? 0 : (int)_buildingInputDelay)"
OnChange="OnBuildingInputDelayChanged">
<FormLabelComponent>Building Input Delay</FormLabelComponent>
<FormInfoComponent>Add a input delay to constructing buildings for simulating worker movement and player micro.</FormInfoComponent>
</FormNumberComponent>
<FormNumberComponent Max="600"
Min="1"
Value="@(_waitTime == null ? 0 : (int)_waitTime)"
OnChange="@OnWaitTimeChanged">
<FormLabelComponent>Wait Time</FormLabelComponent>
</FormNumberComponent>
</FormLayoutComponent>
<FormLayoutComponent>
<FormNumberComponent Max="2048"
Min="1"
Value="@(_waitTo == null ? 0 : (int)_waitTo)"
OnChange="@OnWaitToChanged">
<FormLabelComponent>Wait To</FormLabelComponent>
</FormNumberComponent>
</FormLayoutComponent>
</PaperComponent>
}
<ContentDividerComponent/>
@ -41,20 +123,46 @@
{
_enabledPermissions = StorageService.GetValue<bool>(StorageKeys.EnabledStorage);
Update();
RefreshDefaults();
StorageService.Subscribe(Update);
StorageService.Subscribe(RefreshDefaults);
}
public void Dispose()
void IDisposable.Dispose()
{
StorageService.Unsubscribe(Update);
StorageService.Unsubscribe(RefreshDefaults);
}
void Update()
private int? _attackTime = null;
private int? _travelTime = null;
private string? _faction = null;
private string? _immortal = null;
private string? Faction => _faction == null ? DataType.FACTION_QRath : _faction;
private string? Immortal => _immortal == null ? DataType.IMMORTAL_Orzum : _immortal;
private int? _buildingInputDelay;
private int? _waitTime;
private int? _waitTo;
void RefreshDefaults()
{
_isEntityPlainView = StorageService.GetValue<bool>(StorageKeys.IsPlainView);
_attackTime = StorageService.GetValue<int?>(StorageKeys.AttackTime);
_travelTime = StorageService.GetValue<int?>(StorageKeys.TravelTime);
_faction = StorageService.GetValue<string?>(StorageKeys.SelectedFaction);
_immortal = StorageService.GetValue<string?>(StorageKeys.SelectedImmortal);
_buildingInputDelay = StorageService.GetValue<int?>(StorageKeys.BuildInputDelay);
_waitTime = StorageService.GetValue<int?>(StorageKeys.WaitTime);
_waitTo = StorageService.GetValue<int?>(StorageKeys.WaitTo);
StateHasChanged();
}
@ -65,4 +173,39 @@
{
StorageService.SetValue(StorageKeys.IsPlainView, obj.Value);
}
private void AttackTimeChanged(ChangeEventArgs obj)
{
StorageService.SetValue(StorageKeys.AttackTime, obj.Value);
}
private void TravelTimeChanged(ChangeEventArgs obj)
{
StorageService.SetValue(StorageKeys.TravelTime, obj.Value);
}
private void OnFactionChanged(ChangeEventArgs obj)
{
StorageService.SetValue(StorageKeys.SelectedFaction, obj.Value);
}
private void OnImmortalChanged(ChangeEventArgs obj)
{
StorageService.SetValue(StorageKeys.SelectedImmortal, obj.Value);
}
private void OnBuildingInputDelayChanged(ChangeEventArgs obj)
{
StorageService.SetValue(StorageKeys.BuildInputDelay, obj.Value);
}
private void OnWaitTimeChanged(ChangeEventArgs obj)
{
StorageService.SetValue(StorageKeys.WaitTime, obj.Value);
}
private void OnWaitToChanged(ChangeEventArgs obj)
{
StorageService.SetValue(StorageKeys.WaitTo, obj.Value);
}
}

2
IGP/Portals/EntityDialogPortal.razor

@ -15,7 +15,7 @@
entityDialogService.Subscribe(OnUpdate);
}
public void Dispose()
void IDisposable.Dispose()
{
entityDialogService.Unsubscribe(OnUpdate);
}

2
IGP/Portals/SearchPortal.razor

@ -21,7 +21,7 @@
public void Dispose()
void IDisposable.Dispose()
{
searchService.Unsubscribe(OnUpdate);
}

2
IGP/Portals/ToastPortal.razor

@ -38,7 +38,7 @@
ageTimer.Enabled = true;
}
public void Dispose()
void IDisposable.Dispose()
{
toastService.Unsubscribe(OnUpdate);
}

342
Model/Entity/Data/DATA.cs

File diff suppressed because it is too large Load Diff

5
Model/Entity/Data/Ids_Entity.cs

@ -2,6 +2,9 @@
public static class DataType
{
public static string Any = "Any";
public static string None = "None";
public static string PYREEVENT_TowerKilled = "9a923928-b016-49f2-8c7d-950abf09e287";
public static string PYREEVENT_CampTaken = "cc27a9b2-69e2-4322-8102-7a9f8bea7871";
public static string PYREEVENT_MinerTaken = "5b158cf2-2810-4a2a-8131-c4fe4b392ce9";
@ -14,6 +17,8 @@ public static class DataType
public static string FAMILY_Rae = "ce8d60f3-b590-4619-ad90-27e65f77312b";
public static string FAMILY_Demonic = "f61a3630-9474-4ec3-bc71-997cacc52bc1";
public static string FAMILY_NazRa = "56cc934f-57a9-442c-909a-25690f836679";
public static string FACTION_Neutral = "95da29af-99da-45fe-80f6-4ae1cc0d0f47";
public static string FACTION_Aru = "fb103962-7518-48df-b7d9-83906a009db8";
public static string FACTION_Iratek = "dbc12bda-b4f2-4fa0-8270-18dc1646d62d";
public static string FACTION_Yul = "9c0492af-1ef8-4113-9010-92178493f8b3";

5
Model/Entity/Parts/EntityFactionModel.cs

@ -1,9 +1,10 @@
using Model.Types;
using Model.Entity.Data;
using Model.Types;
namespace Model.Entity.Parts;
public class EntityFactionModel : IEntityPartInterface
{
public string Type { get; set; } = "EntityFactionModel";
public string Faction { get; set; } = FactionType.QRath;
public string Faction { get; set; } = DataType.FACTION_QRath;
}

14
Model/Entity/Types/FactionType.cs

@ -1,14 +0,0 @@
namespace Model.Types;
public static class FactionType
{
public static string None = "None";
public static string Any = "Any";
public static string Neutral = "Neutral";
public static string QRath = "QRath";
public static string Aru = "Aru";
public static string Jora = "Jora";
public static string Talmetra = "Talmetra";
public static string Iratek = "Iratek";
public static string Herlesh = "Herlesh";
}

7
Model/Entity/Types/ImmortalType.cs

@ -1,7 +0,0 @@
namespace Model.Types;
public static class ImmortalType
{
public static string None = "None";
public static string Any = "Any";
}

4
Model/Model.csproj

@ -4,7 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
</ItemGroup>
</Project>

16
Services/IServices.cs

@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components.ProtectedBrowserStorage;
using Model.BuildOrders;
using Model.BuildOrders;
using Model.Doc;
using Model.Economy;
using Model.Entity;
@ -11,7 +10,6 @@ using Model.Website;
using Model.Website.Enums;
using Model.Work.Tasks;
using Services.Immortal;
using Services.Website;
namespace Services;
@ -226,6 +224,9 @@ public interface IBuildComparisonService
public interface ITimingService
{
public int BuildingInputDelay { get; set; }
public int WaitTime { get; set; }
public int WaitTo { get; set; }
public int GetAttackTime();
public void SetAttackTime(int timing);
public int GetTravelTime();
@ -284,10 +285,10 @@ public interface IEntityDisplayService
public interface IImmortalSelectionService
{
public string GetFactionType();
public string GetImmortalType();
public bool SelectFactionType(string factionType);
public bool SelectImmortalType(string immortalType);
public string GetFaction();
public string GetImmortal();
public bool SelectFaction(string faction);
public bool SelectImmortal(string immortal);
public void Subscribe(Action action);
public void Unsubscribe(Action action);
}
@ -323,7 +324,6 @@ public interface IMemoryTesterService
public interface IBuildOrderService
{
public int BuildingInputDelay { get; set; }
public Dictionary<int, List<EntityModel>> StartedOrders { get; }
public Dictionary<int, List<EntityModel>> CompletedOrders { get; }
public Dictionary<string, int> UniqueCompletedTimes { get; }

31
Services/Immortal/BuildOrderService.cs

@ -14,18 +14,20 @@ public class BuildOrderService : IBuildOrderService
{
private readonly BuildOrderModel _buildOrder = new();
private readonly ITimingService _timingService;
private readonly IToastService _toastService;
private int _lastInterval;
public BuildOrderService(IToastService toastService)
public BuildOrderService(IToastService toastService, ITimingService timingService)
{
_toastService = toastService;
_timingService = timingService;
Reset();
}
public int BuildingInputDelay { get; set; } = 2;
public Dictionary<int, List<EntityModel>> StartedOrders => _buildOrder.StartedOrders;
public Dictionary<int, List<EntityModel>> CompletedOrders => _buildOrder.CompletedOrders;
public Dictionary<string, int> UniqueCompletedTimes => _buildOrder.UniqueCompletedTimes;
@ -245,9 +247,7 @@ public class BuildOrderService : IBuildOrderService
&& entityRemoved.Production()!.ProducedBy != null
&& entityRemoved.Supply() != null
&& entityRemoved.Supply()!.Takes > 0)
{
_buildOrder.TrainingCapacityUsed.Remove(_buildOrder.TrainingCapacityUsed.Last());
}
if (entityRemoved.Info().Descriptive == DescriptiveType.Worker)
{
@ -358,11 +358,12 @@ public class BuildOrderService : IBuildOrderService
Console.WriteLine("Produced by Nothing");
return 1;
}
var uniqueCompleted = _buildOrder.UniqueCompleted[producedBy];
var shortestIncrement = int.MaxValue;
var trainingSlots = 0;
bool didDelay = false;
var didDelay = false;
foreach (var productionEntity in uniqueCompleted) trainingSlots += productionEntity.Supply()!.Grants;
@ -377,28 +378,30 @@ public class BuildOrderService : IBuildOrderService
var duration = used.StopUsageTime - used.StartingUsageTime;
if (duration < shortestIncrement) shortestIncrement = duration;
Console.WriteLine($"Used slots {used.UsedSlots} Duration {duration} Start {used.StartingUsageTime} Stop {used.StopUsageTime} ");
Console.WriteLine(
$"Used slots {used.UsedSlots} Duration {duration} Start {used.StartingUsageTime} Stop {used.StopUsageTime} ");
}
if (usedSlots + supply.Takes <= trainingSlots)
{
if (didDelay)
{
_toastService.AddToast(new ToastModel{Title = "Waited", SeverityType = SeverityType.Information, Message = $"Had to wait {checkedInterval - _lastInterval}s for Training Queue."});
}
_toastService.AddToast(new ToastModel
{
Title = "Waited", SeverityType = SeverityType.Information,
Message = $"Had to wait {checkedInterval - _lastInterval}s for Training Queue."
});
Console.WriteLine($"Time {checkedInterval} did Delay {didDelay}");
return checkedInterval;
}
checkedInterval += shortestIncrement;
didDelay = true;
if (shortestIncrement == int.MaxValue)
{
Console.WriteLine($"MaxValue");
Console.WriteLine("MaxValue");
return null;
}
}
@ -421,7 +424,7 @@ public class BuildOrderService : IBuildOrderService
{
atInterval = interval;
if (entity.EntityType != EntityType.Army) atInterval += BuildingInputDelay;
if (entity.EntityType != EntityType.Army) atInterval += _timingService.BuildingInputDelay;
return true;
}

8
Services/Immortal/EntityDisplayService.cs

@ -6,8 +6,8 @@ public class EntityViewType
{
public static string Detailed = "Detailed";
public static string Plain = "Plain";
}
public class EntityDisplayService : IEntityDisplayService
{
private string _displayType;
@ -15,11 +15,11 @@ public class EntityDisplayService : IEntityDisplayService
public EntityDisplayService(IStorageService storageService)
{
_displayType = storageService.GetValue<bool>(StorageKeys.IsPlainView)
? EntityViewType.Plain : EntityViewType.Detailed;
? EntityViewType.Plain
: EntityViewType.Detailed;
}
public List<string> DefaultChoices()
{
return new List<string> { EntityViewType.Detailed, EntityViewType.Plain };
@ -42,7 +42,7 @@ public class EntityDisplayService : IEntityDisplayService
public void SetDisplayType(string displayType)
{
this._displayType = displayType;
_displayType = displayType;
NotifyDataChanged();
}

24
Services/Immortal/EntityFilterService.cs

@ -16,12 +16,12 @@ public class EntityFilterService : IEntityFilterService
{
private readonly List<string> _entityChoices = new();
private readonly List<string> _factionChoices = new() { FactionType.Any, FactionType.QRath, FactionType.Aru };
private readonly List<string> _factionChoices = new() { DataType.Any, DataType.FACTION_QRath, DataType.FACTION_Aru };
private readonly List<string> _immortalChoices = new();
private string _entityType = EntityType.Army;
private string _searchText = "";
private string _selectedFaction = FactionType.Any;
private string _selectedImmortal = ImmortalType.Any;
private string _selectedFaction = DataType.Any;
private string _selectedImmortal = DataType.Any;
public EntityFilterService()
{
@ -59,8 +59,8 @@ public class EntityFilterService : IEntityFilterService
{
if (_selectedFaction == factionType)
{
_selectedFaction = FactionType.None;
_selectedImmortal = ImmortalType.None;
_selectedFaction = DataType.None;
_selectedImmortal = DataType.None;
RefreshImmortalChoices();
RefreshEntityChoices();
@ -71,7 +71,7 @@ public class EntityFilterService : IEntityFilterService
}
_selectedFaction = factionType;
_selectedImmortal = ImmortalType.Any;
_selectedImmortal = DataType.Any;
RefreshImmortalChoices();
RefreshEntityChoices();
@ -84,7 +84,7 @@ public class EntityFilterService : IEntityFilterService
{
if (_selectedImmortal == immortalType)
{
_selectedImmortal = ImmortalType.None;
_selectedImmortal = DataType.None;
NotifyDataChanged(EntityFilterEvent.OnRefreshImmortal);
return true;
}
@ -148,13 +148,13 @@ public class EntityFilterService : IEntityFilterService
_immortalChoices.Add(ImmortalType.Xol);
}*/
if (_selectedFaction == FactionType.QRath || _selectedFaction == FactionType.Any)
if (_selectedFaction == DataType.FACTION_QRath || _selectedFaction == DataType.Any)
{
_immortalChoices.Add(DataType.IMMORTAL_Orzum);
_immortalChoices.Add(DataType.IMMORTAL_Ajari);
}
if (_selectedFaction == FactionType.Aru || _selectedFaction == FactionType.Any)
if (_selectedFaction == DataType.FACTION_Aru || _selectedFaction == DataType.Any)
{
_immortalChoices.Add(DataType.IMMORTAL_Mala);
_immortalChoices.Add(DataType.IMMORTAL_Xol);
@ -165,8 +165,8 @@ public class EntityFilterService : IEntityFilterService
{
_entityChoices.Clear();
if (_selectedFaction == FactionType.QRath || _selectedFaction == FactionType.Aru ||
_selectedFaction == FactionType.Any)
if (_selectedFaction == DataType.FACTION_QRath || _selectedFaction == DataType.FACTION_Aru ||
_selectedFaction == DataType.Any)
{
_entityChoices.Add(EntityType.Army);
_entityChoices.Add(EntityType.Immortal);
@ -178,7 +178,7 @@ public class EntityFilterService : IEntityFilterService
_entityChoices.Add(EntityType.Worker);
}
if (_selectedFaction == FactionType.Any) _entityChoices.Add(EntityType.Any);
if (_selectedFaction == DataType.Any) _entityChoices.Add(EntityType.Any);
}

54
Services/Immortal/ImmortalSelectionService.cs

@ -1,13 +1,29 @@
using Model.Entity.Data;
using Model.Types;
using Services.Website;
namespace Services.Immortal;
public class ImmortalSelectionService : IImmortalSelectionService
public class ImmortalSelectionService : IImmortalSelectionService, IDisposable
{
private string _selectedFaction = FactionType.QRath;
private string _selectedFaction = DataType.FACTION_QRath;
private string _selectedImmortal = DataType.IMMORTAL_Orzum;
private readonly IStorageService _storageService;
public ImmortalSelectionService(IStorageService storageService)
{
_storageService = storageService;
_storageService.Subscribe(RefreshDefaults);
RefreshDefaults();
}
void IDisposable.Dispose()
{
_storageService.Unsubscribe(RefreshDefaults);
}
public void Subscribe(Action action)
{
OnChange += action;
@ -18,37 +34,49 @@ public class ImmortalSelectionService : IImmortalSelectionService
OnChange -= action;
}
public string GetFactionType()
public string GetFaction()
{
return _selectedFaction;
}
public string GetImmortalType()
public string GetImmortal()
{
return _selectedImmortal;
}
public bool SelectFactionType(string factionType)
public bool SelectFaction(string faction)
{
if (_selectedFaction == factionType) return false;
_selectedFaction = factionType;
if (_selectedFaction == faction) return false;
_selectedFaction = faction;
if (_selectedFaction == FactionType.QRath) _selectedImmortal = DataType.IMMORTAL_Orzum;
if (_selectedFaction == DataType.FACTION_QRath) _selectedImmortal = DataType.IMMORTAL_Orzum;
if (_selectedFaction == FactionType.Aru) _selectedImmortal = DataType.IMMORTAL_Mala;
if (_selectedFaction == DataType.FACTION_Aru) _selectedImmortal = DataType.IMMORTAL_Mala;
NotifyDataChanged();
return true;
}
public bool SelectImmortalType(string immortalType)
public bool SelectImmortal(string immortal)
{
if (_selectedImmortal == immortalType) return false;
_selectedImmortal = immortalType;
if (_selectedImmortal == immortal) return false;
_selectedImmortal = immortal;
NotifyDataChanged();
return true;
}
private void RefreshDefaults()
{
var foundFaction = _storageService.GetValue<string?>(StorageKeys.SelectedFaction);
var foundImmortal = _storageService.GetValue<string?>(StorageKeys.SelectedImmortal);
if (foundFaction != null) _selectedFaction = foundFaction;
if (foundImmortal != null) _selectedImmortal = foundImmortal;
NotifyDataChanged();
}
private event Action OnChange = null!;
private void NotifyDataChanged()

48
Services/Immortal/TimingService.cs

@ -1,10 +1,27 @@
namespace Services.Immortal;
using Services.Website;
public class TimingService : ITimingService
namespace Services.Immortal;
public class TimingService : ITimingService, IDisposable
{
private readonly IStorageService _storageService;
private int attackTime = 1500;
private int travelTime = 30;
public TimingService(IStorageService storageService)
{
_storageService = storageService;
_storageService.Subscribe(RefreshDefaults);
RefreshDefaults();
}
void IDisposable.Dispose()
{
_storageService.Unsubscribe(RefreshDefaults);
}
public void Subscribe(Action? action)
{
OnChange += action;
@ -15,6 +32,10 @@ public class TimingService : ITimingService
OnChange -= action;
}
public int BuildingInputDelay { get; set; } = 2;
public int WaitTime { get; set; } = 30;
public int WaitTo { get; set; } = 60;
public int GetAttackTime()
{
return attackTime;
@ -43,6 +64,29 @@ public class TimingService : ITimingService
}
}
private void RefreshDefaults()
{
//TODO Timing has changed in Storage
//TODO Timing has changed in itself
var foundAttackTime = _storageService.GetValue<int?>(StorageKeys.AttackTime);
var foundTravelTime = _storageService.GetValue<int?>(StorageKeys.TravelTime);
var foundBuildInputDefault = _storageService.GetValue<int?>(StorageKeys.BuildInputDelay);
var foundWaitTime = _storageService.GetValue<int?>(StorageKeys.WaitTime);
var foundWaitTo = _storageService.GetValue<int?>(StorageKeys.WaitTo);
if (foundAttackTime != null) attackTime = (int)foundAttackTime;
if (foundTravelTime != null) travelTime = (int)foundTravelTime;
if (foundBuildInputDefault != null) BuildingInputDelay = (int)foundBuildInputDefault;
if (foundWaitTime != null) WaitTime = (int)foundWaitTime;
if (foundWaitTo != null) WaitTo = (int)foundWaitTo;
NotifyDataChanged();
}
private event Action? OnChange;
private void NotifyDataChanged()

10
Services/Services.csproj

@ -15,14 +15,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0-preview.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.ProtectedBrowserStorage" Version="5.0.0-rc.1.20451.17" />
<PackageReference Include="Microsoft.JSInterop" Version="7.0.0-preview.2.22153.2" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0-preview.1"/>
<PackageReference Include="Microsoft.AspNetCore.Components.ProtectedBrowserStorage" Version="5.0.0-rc.1.20451.17"/>
<PackageReference Include="Microsoft.JSInterop" Version="7.0.0-preview.2.22153.2"/>
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\Model\Model.csproj"/>
</ItemGroup>
</Project>

11
Services/Website/PermissionService.cs

@ -1,17 +1,14 @@
using Blazored.LocalStorage;
using Microsoft.JSInterop;
using Microsoft.JSInterop;
namespace Services.Website;
public class PermissionService : IPermissionService
{
private bool isLoaded;
private IJSRuntime _jsRuntime;
private bool isStorageEnabled = false;
private readonly IStorageService _storageService;
private IToastService _toastService;
private IStorageService _storageService;
private bool isLoaded;
private bool isStorageEnabled = false;
public PermissionService(IJSRuntime jsRuntime, IToastService toastService, IStorageService storageService)
{

49
Services/Website/StorageService.cs

@ -1,5 +1,4 @@
using Blazored.LocalStorage;
using Microsoft.JSInterop;
using Model.Feedback;
namespace Services.Website;
@ -9,27 +8,30 @@ public class StorageKeys
public static string EnabledStorage = "StorageEnabled";
public static string EnabledDataCollection = "StorageDataCollection";
public static string IsPlainView { get; set; } = "IsPlainView";
public static string AttackTime { get; set; } = "AttackTime";
public static string TravelTime { get; set; } = "TravelTime";
public static string SelectedFaction { get; set; } = "SelectedFaction";
public static string SelectedImmortal { get; set; } = "SelectedImmortal";
public static string BuildInputDelay { get; set; } = "BuildInputDelay";
public static string WaitTime { get; set; } = "WaitTime";
public static string WaitTo { get; set; } = "WaitTo";
}
public class StorageService : IStorageService
{
private readonly ISyncLocalStorageService _localStorageService;
private IJSRuntime _jsRuntime;
private readonly IToastService _toastService;
private bool isLoaded;
private bool isStorageEnabled;
public StorageService(IJSRuntime jsRuntime, IToastService toastService,
public StorageService(IToastService toastService,
ISyncLocalStorageService localStorageService)
{
_jsRuntime = jsRuntime;
_toastService = toastService;
_localStorageService = localStorageService;
}
private string enabledKey => StorageKeys.EnabledStorage;
public void Subscribe(Action action)
{
OnChange += action;
@ -51,12 +53,28 @@ public class StorageService : IStorageService
{
_localStorageService.SetItem(key, value);
NotifyDataChanged();
_toastService.AddToast(new ToastModel
{
Title = "Test 1",
SeverityType = SeverityType.Error,
Message = "Storage must be enabled before Storage can be used."
});
return;
}
if (key.Equals(StorageKeys.EnabledStorage))
{
_localStorageService.Clear();
_toastService.AddToast(new ToastModel
{
Title = "Test 2",
SeverityType = SeverityType.Error,
Message = "Storage must be enabled before Storage can be used."
});
NotifyDataChanged();
return;
}
@ -78,29 +96,20 @@ public class StorageService : IStorageService
NotifyDataChanged();
}
public async Task Load()
public Task Load()
{
if (!isLoaded) return;
if (!isLoaded) return Task.CompletedTask;
isLoaded = true;
isStorageEnabled = GetValue<bool>(enabledKey);
NotifyDataChanged();
return Task.CompletedTask;
}
private event Action OnChange = null!;
private void NotifyDataChanged()
{
try
{
OnChange();
}
catch (Exception e)
{
}
OnChange();
}
}
Loading…
Cancel
Save