Browse Source

feat(Variables) Added variable service and new game patch

main
Jonathan McCaffrey 4 years ago
parent
commit
c0c4e251a0
  1. 2
      Contexts/DatabaseContext.cs
  2. 16
      IGP/App.razor
  3. BIN
      IGP/Database.db
  4. 5
      IGP/Pages/Database/DatabasePage.razor
  5. 3
      IGP/Pages/Database/DatabaseSinglePage.razor
  6. 2
      IGP/Program.cs
  7. 2
      IGP/wwwroot/generated/GitChangeModels.json
  8. 2
      IGP/wwwroot/generated/GitPatchModels.json
  9. 1
      IGP/wwwroot/generated/Variables.json
  10. 2
      IGP_Convert/Program.cs
  11. 2
      Model/Entity/Data/DATA.cs
  12. 2
      Model/Entity/EntityModel.cs
  13. 10
      Model/Variable.cs
  14. 7
      Services/IServices.cs
  15. 40
      Services/Website/VariableService.cs

2
Contexts/DatabaseContext.cs

@ -2,6 +2,7 @@
#else
using Microsoft.EntityFrameworkCore;
using Model;
using Model.Doc;
using Model.Git;
using Model.Notes;
@ -29,6 +30,7 @@ public class DatabaseContext : DbContext
public DbSet<NoteContentModel> NoteContentModels { get; set; } = default!;
public DbSet<NoteConnectionModel> NoteConnectionModels { get; set; } = default!;
public DbSet<NoteSectionModel> NoteSectionModels { get; set; } = default!;
public DbSet<Variable> Variables { get; set; } = default!;
}
#endif

16
IGP/App.razor

@ -1,9 +1,13 @@
@inject HttpClient httpClient
@inject IVariableService variableService
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
@if (isLoaded)
{
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
}
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
@ -68,5 +72,13 @@
</style>
@code {
private bool isLoaded = false;
protected override async Task OnInitializedAsync()
{
await variableService.Load();
isLoaded = true;
StateHasChanged();
}
}

BIN
IGP/Database.db

Binary file not shown.

5
IGP/Pages/Database/DatabasePage.razor

@ -5,6 +5,7 @@
@implements IDisposable
@inject IEntityDisplayService entityDisplayService
@inject IVariableService variableService
<LayoutLargeContentComponent>
<WebsiteTitleComponent>Database</WebsiteTitleComponent>
@ -12,7 +13,7 @@
<PaperComponent>
<FormDisplayComponent Label="Patch">
<Display>
Game Patch: @EntityModel.GameVersion
Game Patch: @variableService.Variables["GamePatch"]
</Display>
</FormDisplayComponent>
</PaperComponent>
@ -66,7 +67,7 @@
Is this database updated to the latest version?
</InfoQuestionComponent>
<InfoAnswerComponent>
Maybe. Check this <b>@EntityModel.GameVersion</b> version number, and compare it to the number on discord, in the <b>#game-updates</b> channel. That should give a general sense of how out of date the data is.
Maybe. Check this <b>@variableService.Variables["GamePatch"]</b> version number, and compare it to the number on discord, in the <b>#game-updates</b> channel. That should give a general sense of how out of date the data is.
</InfoAnswerComponent>
</InfoBodyComponent>

3
IGP/Pages/Database/DatabaseSinglePage.razor

@ -4,6 +4,7 @@
@inject IEntityDisplayService entityDisplayService
@inject IVariableService variableService
@implements IDisposable
<LayoutLargeContentComponent>
@ -11,7 +12,7 @@
<PaperComponent>
<FormDisplayComponent Label="Patch">
<Display>
Game Patch: @EntityModel.GameVersion
Game Patch: @variableService.Variables["GamePatch"]
</Display>
</FormDisplayComponent>
</PaperComponent>

2
IGP/Program.cs

@ -2,6 +2,7 @@ using System.Globalization;
using IGP;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Services;
using Model;
using Services;
using Services.Development;
using Services.Immortal;
@ -39,6 +40,7 @@ builder.Services.AddSingleton<IGitService, GitService>();
builder.Services.AddSingleton<INoteService, NoteService>();
builder.Services.AddSingleton<IDocumentationService, DocumentationService>();
builder.Services.AddSingleton<ISearchService, SearchService>();
builder.Services.AddSingleton<IVariableService, VariableService>();
builder.Services.AddSingleton<IEconomyComparisonService, EconomyComparisionService>();

2
IGP/wwwroot/generated/GitChangeModels.json

File diff suppressed because one or more lines are too long

2
IGP/wwwroot/generated/GitPatchModels.json

@ -1 +1 @@
[{"Id":1,"Name":"Database UX Patch","Date":"2022-03-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":2,"Name":"Thrum Stats Hotfix","Date":"2022-03-12T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":3,"Name":"Memory Tester Patch","Date":"2022-03-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":4,"Name":"Hide Pyre Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":5,"Name":"Stream Patch","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":6,"Name":"Agile UI Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":7,"Name":"Armor Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":8,"Name":"Home Page Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":9,"Name":"Mobile Menu Hotfix 2","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":10,"Name":"Mobile Menu Hotfix","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":11,"Name":"Mobile Menu Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":12,"Name":"0.0.6.8375a Patch","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":13,"Name":"Google Tracking Hotfix","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":14,"Name":"Privacy Policy Patch","Date":"2022-02-17T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":15,"Name":"Home Page Quick Hotfix","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":16,"Name":"Early Agile Patch","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":17,"Name":"Form Text Rendering Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":18,"Name":"Reducing Timing Interval Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":19,"Name":"Changelog Patch","Date":"2022-02-14T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":20,"Name":"SQL Patch","Date":"2022-03-26T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":21,"Name":"Stream Patch","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":22,"Name":"0.0.6.8900a Patch","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":23,"Name":"Database Links Patch","Date":"2022-04-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":24,"Name":"Open Source Patch","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":25,"Name":"Stream Patch","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":26,"Name":"Notes/Docs Patch","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":27,"Name":"Stream Patch","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":28,"Name":"Passive Patch","Date":"2022-04-12T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":29,"Name":"0.0.6.9121a Patch","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":30,"Name":"Stream Patch","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":31,"Name":"BuildCalc Hotfix","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":32,"Name":"Search Patch","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":33,"Name":"Search Hotfix","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":34,"Name":"Stream Patch","Date":"2022-04-17T00:00:00","GitChangeModels":[],"Important":"False"}]
[{"Id":1,"Name":"Database UX Patch","Date":"2022-03-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":2,"Name":"Thrum Stats Hotfix","Date":"2022-03-12T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":3,"Name":"Memory Tester Patch","Date":"2022-03-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":4,"Name":"Hide Pyre Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":5,"Name":"Stream Patch","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":6,"Name":"Agile UI Hotfix","Date":"2022-02-20T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":7,"Name":"Armor Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":8,"Name":"Home Page Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":9,"Name":"Mobile Menu Hotfix 2","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":10,"Name":"Mobile Menu Hotfix","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":11,"Name":"Mobile Menu Patch","Date":"2022-02-19T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":12,"Name":"0.0.6.8375a Patch","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":13,"Name":"Google Tracking Hotfix","Date":"2022-02-18T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":14,"Name":"Privacy Policy Patch","Date":"2022-02-17T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":15,"Name":"Home Page Quick Hotfix","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":16,"Name":"Early Agile Patch","Date":"2022-02-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":17,"Name":"Form Text Rendering Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":18,"Name":"Reducing Timing Interval Hotfix","Date":"2022-02-15T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":19,"Name":"Changelog Patch","Date":"2022-02-14T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":20,"Name":"SQL Patch","Date":"2022-03-26T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":21,"Name":"Stream Patch","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":22,"Name":"0.0.6.8900a Patch","Date":"2022-03-30T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":23,"Name":"Database Links Patch","Date":"2022-04-01T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":24,"Name":"Open Source Patch","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":25,"Name":"Stream Patch","Date":"2022-04-03T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":26,"Name":"Notes/Docs Patch","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":27,"Name":"Stream Patch","Date":"2022-04-10T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":28,"Name":"Passive Patch","Date":"2022-04-12T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":29,"Name":"0.0.6.9121a Patch","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"True"},{"Id":30,"Name":"Stream Patch","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":31,"Name":"BuildCalc Hotfix","Date":"2022-04-13T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":32,"Name":"Search Patch","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":33,"Name":"Search Hotfix","Date":"2022-04-16T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":34,"Name":"Stream Patch","Date":"2022-04-17T00:00:00","GitChangeModels":[],"Important":"False"},{"Id":35,"Name":"v0.0.6.9201a Patch","Date":"2022-04-18T00:00:00","GitChangeModels":[],"Important":"True"}]

1
IGP/wwwroot/generated/Variables.json

@ -0,0 +1 @@
[{"Key":"GamePatch","Value":"v0.0.6.9201a"}]

2
IGP_Convert/Program.cs

@ -27,4 +27,6 @@ using (var db = new DatabaseContext(options.Options))
File.WriteAllTextAsync($"{webPath}/NoteContentModels.json", JsonSerializer.Serialize(db.NoteContentModels));
File.WriteAllTextAsync($"{webPath}/NoteConnectionModels.json", JsonSerializer.Serialize(db.NoteConnectionModels));
File.WriteAllTextAsync($"{webPath}/NoteSectionModels.json", JsonSerializer.Serialize(db.NoteSectionModels));
File.WriteAllTextAsync($"{webPath}/Variables.json", JsonSerializer.Serialize(db.Variables));
}

2
Model/Entity/Data/DATA.cs

@ -2368,7 +2368,7 @@ public class DATA
.AddPart(new EntityProductionModel { DefensiveLayer = 30, Cooldown = 40 })
.AddPart(new EntityRequirementModel { Id = DataType.UPGRADE_RadiantWard })
.AddPart(new EntityVitalityModel
{ Health = 30, DefenseLayer = 30, Lasts = 30, Armor = ArmorType.Light, IsStructure = true })
{ Health = 30, DefenseLayer = 30, Lasts = 30, Armor = ArmorType.Light })
.AddPart(new EntityRequirementModel
{
Id = DataType.BUILDING_HouseOfFadingSaints,

2
Model/Entity/EntityModel.cs

@ -12,8 +12,6 @@ namespace Model.Entity;
public class EntityModel
{
public static readonly string GameVersion = "0.0.6.9121a";
private static Dictionary<string, EntityModel> _database = null!;
private static List<EntityModel> _entityModels = null!;

10
Model/Variable.cs

@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace Model;
public class Variable
{
[Key]
public string Key { get; set; } = "";
public string Value { get; set; } = "";
}

7
Services/IServices.cs

@ -45,6 +45,13 @@ public interface ISearchService
void Hide();
}
public interface IVariableService
{
public Dictionary<string, string> Variables { get; set; }
public Task Load();
public bool IsLoaded();
}
public interface IEconomyComparisonService
{
public List<BuildToCompareModel> BuildsToCompare { get; set; }

40
Services/Website/VariableService.cs

@ -0,0 +1,40 @@
using System.Net.Http.Json;
using Model;
namespace Services.Website;
public class VariableService : IVariableService
{
private readonly HttpClient httpClient;
private bool isLoaded;
public VariableService(HttpClient httpClient)
{
this.httpClient = httpClient;
}
public Dictionary<string, string> Variables { get; set; } = new();
public bool IsLoaded()
{
return isLoaded;
}
public async Task Load()
{
if (isLoaded) return;
var variables = (await httpClient.GetFromJsonAsync<Variable[]>("generated/Variables.json"))!
.ToList();
foreach (var variable in variables)
{
Variables.Add(variable.Key, variable.Value);
}
isLoaded = true;
}
}
Loading…
Cancel
Save