Skip to content

Commit

Permalink
Release 2.4.0 (#200)
Browse files Browse the repository at this point in the history
- Fix NPC not working
- Change how farmlist is sent
- Remove old hero UI version
- Optimize how bot execute task, it should pause lesser than before
- Optimize how to tab things work
- Optimize how things is loaded (it may delay in the first time you click it, but that it, everything later is faster)

If you like my work, you can donate to me through [ko-fi.com/vinaghost](https://ko-fi.com/vinaghost)
  • Loading branch information
vinaghost authored Jan 10, 2023
1 parent 5ca74e0 commit 4f516f9
Show file tree
Hide file tree
Showing 325 changed files with 8,563 additions and 77,997 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
strategy:
matrix:
server: [TRAVIAN_OFFICIAL, TRAVIAN_OFFICIAL_HEROUI, TTWARS]
server: [TRAVIAN_OFFICIAL, TTWARS]
runs-on: windows-2019
steps:
- name: Setup dotnet
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
needs: version
strategy:
matrix:
server: [TRAVIAN_OFFICIAL, TRAVIAN_OFFICIAL_HEROUI, TTWARS]
server: [TRAVIAN_OFFICIAL, TTWARS]
steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v2
Expand Down Expand Up @@ -83,8 +83,7 @@ jobs:

- name: Archive release
run: |
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TravianOfficial-OldHeroUI.zip" TBS-TRAVIAN_OFFICIAL; cp -R "TBS-${{needs.version.outputs.version}}-TravianOfficial-OldHeroUI.zip" ../; cd ..
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TravianOfficial-NewHeroUI.zip" TBS-TRAVIAN_OFFICIAL_HEROUI; cp -R "TBS-${{needs.version.outputs.version}}-TravianOfficial-NewHeroUI.zip" ../; cd ..
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TravianOfficial.zip" TBS-TRAVIAN_OFFICIAL; cp -R "TBS-${{needs.version.outputs.version}}-TravianOfficial.zip" ../; cd ..
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TTWars.zip" TBS-TTWARS; cp -R "TBS-${{needs.version.outputs.version}}-TTWars.zip" ../; cd ..
- name: Create release
Expand All @@ -93,7 +92,7 @@ jobs:
name: TBS-${{needs.version.outputs.version}}
tag: ${{needs.version.outputs.version}}
commit: master
artifacts: "TBS-${{needs.version.outputs.version}}-TravianOfficial-OldHeroUI.zip, TBS-${{needs.version.outputs.version}}-TravianOfficial-NewHeroUI.zip, TBS-${{needs.version.outputs.version}}-TTWars.zip"
artifacts: "TBS-${{needs.version.outputs.version}}-TravianOfficial.zip, TBS-${{needs.version.outputs.version}}-TTWars.zip"
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Please join our Discord server for more information: [https://discord.gg/mBa4f2K](https://discord.gg/mBa4f2K)
Expand Down Expand Up @@ -125,7 +124,7 @@ jobs:
needs: release
strategy:
matrix:
server: [TRAVIAN_OFFICIAL, TRAVIAN_OFFICIAL_HEROUI, TTWARS]
server: [TRAVIAN_OFFICIAL, TTWARS]
steps:
- name: Delete artifact
uses: geekyeggo/delete-artifact@v1
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
needs: version
strategy:
matrix:
server: [TRAVIAN_OFFICIAL, TRAVIAN_OFFICIAL_HEROUI, TTWARS]
server: [TRAVIAN_OFFICIAL, TTWARS]
steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v2
Expand Down Expand Up @@ -82,8 +82,7 @@ jobs:

- name: Archive release
run: |
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TravianOfficial-OldHeroUI.zip" TBS-TRAVIAN_OFFICIAL; cp -R "TBS-${{needs.version.outputs.version}}-TravianOfficial-OldHeroUI.zip" ../; cd ..
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TravianOfficial-NewHeroUI.zip" TBS-TRAVIAN_OFFICIAL_HEROUI; cp -R "TBS-${{needs.version.outputs.version}}-TravianOfficial-NewHeroUI.zip" ../; cd ..
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TravianOfficial.zip" TBS-TRAVIAN_OFFICIAL; cp -R "TBS-${{needs.version.outputs.version}}-TravianOfficial.zip" ../; cd ..
cd TBS; zip -r "TBS-${{needs.version.outputs.version}}-TTWars.zip" TBS-TTWARS; cp -R "TBS-${{needs.version.outputs.version}}-TTWars.zip" ../; cd ..
- name: Create release
Expand All @@ -92,7 +91,7 @@ jobs:
name: TBS-${{needs.version.outputs.version}}
tag: ${{needs.version.outputs.version}}
commit: master
artifacts: "TBS-${{needs.version.outputs.version}}-TravianOfficial-OldHeroUI.zip, TBS-${{needs.version.outputs.version}}-TravianOfficial-NewHeroUI.zip, TBS-${{needs.version.outputs.version}}-TTWars.zip"
artifacts: "TBS-${{needs.version.outputs.version}}-TravianOfficial.zip, TBS-${{needs.version.outputs.version}}-TTWars.zip"
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Please join our Discord server for more information: [https://discord.gg/mBa4f2K](https://discord.gg/mBa4f2K)
Expand Down Expand Up @@ -123,7 +122,7 @@ jobs:
needs: release
strategy:
matrix:
server: [TRAVIAN_OFFICIAL, TRAVIAN_OFFICIAL_HEROUI, TTWARS]
server: [TRAVIAN_OFFICIAL, TTWARS]
steps:
- name: Delete artifact
uses: geekyeggo/delete-artifact@v1
Expand Down
82 changes: 82 additions & 0 deletions MainCore/AppBosstrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using FluentMigrator.Runner;
using MainCore.Helper.Implementations;
using MainCore.Helper.Interface;
using MainCore.Migrations;
using MainCore.Services.Implementations;
using MainCore.Services.Interface;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using ModuleCore.Parser;

#if TRAVIAN_OFFICIAL

using TravianOfficialCore.Parsers;

#elif TTWARS

using TTWarsCore.Parsers;

#else

#error You forgot to define Travian version here

#endif

namespace MainCore
{
public static class DependencyInjectionCoreContainer
{
private const string _connectionString = "DataSource=TBS.db;Cache=Shared";

public static IServiceCollection ConfigureServices(this IServiceCollection services)
{
services.AddDbContextFactory<AppDbContext>(options => options.UseSqlite(_connectionString));
services.AddSingleton<IChromeManager, ChromeManager>();
services.AddSingleton<IRestClientManager, RestClientManager>();
services.AddSingleton<IUseragentManager, UseragentManager>();
services.AddSingleton<IEventManager, EventManager>();
services.AddSingleton<ITimerManager, TimerManager>();
services.AddSingleton<ITaskManager, TaskManager>();
services.AddSingleton<IPlanManager, PlanManager>();
services.AddSingleton<ILogManager, LogManager>();

services.AddFluentMigratorCore()
.ConfigureRunner(rb => rb
.AddSQLite()
.WithGlobalConnectionString(_connectionString)
.WithMigrationsIn(typeof(Farming).Assembly));
return services;
}

public static IServiceCollection ConfigureParser(this IServiceCollection services)
{
services.AddSingleton<IBuildingTabParser, BuildingTabParser>();
services.AddSingleton<IFarmListParser, FarmListParser>();
services.AddSingleton<IHeroSectionParser, HeroSectionParser>();
services.AddSingleton<INavigationBarParser, NavigationBarParser>();
services.AddSingleton<IRightBarParser, RightBarParser>();
services.AddSingleton<IStockBarParser, StockBarParser>();
services.AddSingleton<ISubTabParser, SubTabParser>();
services.AddSingleton<ISystemPageParser, SystemPageParser>();
services.AddSingleton<IVillageCurrentlyBuildingParser, VillageCurrentlyBuildingParser>();
services.AddSingleton<IVillageFieldParser, VillageFieldParser>();
services.AddSingleton<IVillageInfrastructureParser, VillageInfrastructureParser>();
services.AddSingleton<IVillagesTableParser, VillagesTableParser>();
return services;
}

public static IServiceCollection ConfigureHelper(this IServiceCollection services)
{
services.AddSingleton<IAccessHelper, AccessHelper>();
services.AddSingleton<IBuildingsHelper, BuildingsHelper>();
services.AddSingleton<ICheckHelper, CheckHelper>();
services.AddSingleton<IClickHelper, ClickHelper>();
services.AddSingleton<IGithubHelper, GithubHelper>();
services.AddSingleton<IHeroHelper, HeroHelper>();
services.AddSingleton<INavigateHelper, NavigateHelper>();
services.AddSingleton<IUpdateHelper, UpdateHelper>();
services.AddSingleton<IUpgradeBuildingHelper, UpgradeBuildingHelper>();
return services;
}
}
}
13 changes: 8 additions & 5 deletions MainCore/AppDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using MainCore.Enums;
using MainCore.Helper;
using MainCore.Models.Database;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
Expand Down Expand Up @@ -239,6 +238,8 @@ public void AddAccount(int accountId)
IsDontLoadImage = false,
IsMinimized = false,
IsAutoAdventure = false,
FarmIntervalMax = 610,
FarmIntervalMin = 590,
});
Heroes.Add(new Hero { AccountId = accountId });

Expand Down Expand Up @@ -268,7 +269,9 @@ public void AddVillage(int villageId)
AutoRefreshTimeMax = 35,

IsAutoNPC = false,
IsAutoNPCWarehouse = false,
AutoNPCPercent = 90,
AutoNPCWarehousePercent = 90,
AutoNPCWood = 1,
AutoNPCClay = 1,
AutoNPCIron = 1,
Expand Down Expand Up @@ -302,8 +305,6 @@ public void AddFarm(int farmId)
{
Id = farmId,
IsActive = false,
IntervalMin = 590,
IntervalMax = 610,
});
}

Expand Down Expand Up @@ -337,6 +338,8 @@ public void UpdateDatabase()
IsDontLoadImage = false,
IsMinimized = false,
IsAutoAdventure = false,
FarmIntervalMax = 610,
FarmIntervalMin = 590,
});
}
}
Expand Down Expand Up @@ -402,8 +405,6 @@ public void UpdateDatabase()
{
Id = farmId,
IsActive = false,
IntervalMin = 590,
IntervalMax = 610,
});
}
}
Expand Down Expand Up @@ -509,6 +510,8 @@ public void AddVersionInfo()
KeyValuePair.Create(202210181120,"UpgradeTroopMigrations"),
KeyValuePair.Create(202210271504,"NPCForWarhouse"),
KeyValuePair.Create(2022102716038,"IgnoreRomanAdvantage"),
KeyValuePair.Create(202212152155,"NPCWarehouse"),
KeyValuePair.Create(202212301138,"FarmSettings"),
};
foreach (var migration in migrations)
{
Expand Down
12 changes: 12 additions & 0 deletions MainCore/Errors/Cancel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using FluentResults;

namespace MainCore.Errors
{
public class Cancel : Error
{
public Cancel()
{

}
}
}
11 changes: 11 additions & 0 deletions MainCore/Errors/Login.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using FluentResults;

namespace MainCore.Errors
{
public class Login : Error
{
public Login() : base("Account is logged out.")
{
}
}
}
11 changes: 11 additions & 0 deletions MainCore/Errors/NetworkProblem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using FluentResults;

namespace MainCore.Errors
{
public class NetworkProblem : Error
{
public NetworkProblem(string message) : base($"{message}.")
{
}
}
}
11 changes: 11 additions & 0 deletions MainCore/Errors/Retry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using FluentResults;

namespace MainCore.Errors
{
public class Retry : Error
{
public Retry(string message) : base($"{message}. Bot must retry")
{
}
}
}
8 changes: 8 additions & 0 deletions MainCore/Errors/Skip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using FluentResults;

namespace MainCore.Errors
{
public class Skip : Error
{
}
}
11 changes: 11 additions & 0 deletions MainCore/Errors/Stop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using FluentResults;

namespace MainCore.Errors
{
public class Stop : Error
{
public Stop(string message) : base($"{message}. Bot must stop")
{
}
}
}
18 changes: 18 additions & 0 deletions MainCore/Errors/Trace.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using FluentResults;

namespace MainCore.Errors
{
public class Trace : Error
{
public Trace(string message) : base(message)
{
}

public static string TraceMessage(
[System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "",
[System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
{
return $"from file: {sourceFilePath} [{sourceLineNumber - 1}]";
}
}
}
8 changes: 0 additions & 8 deletions MainCore/Exceptions/ChromeMissingException.cs

This file was deleted.

8 changes: 0 additions & 8 deletions MainCore/Exceptions/LoginNeedException.cs

This file was deleted.

11 changes: 0 additions & 11 deletions MainCore/Exceptions/StopNowException.cs

This file was deleted.

Loading

0 comments on commit 4f516f9

Please sign in to comment.