Skip to content

Commit

Permalink
Merge pull request #195 from Erol444/release/2.3.0
Browse files Browse the repository at this point in the history
Release 2.3.0
- Change to numeric input instead of text input
- Fix sleep problem 
- Fix wrong condition on auto NPC crop (thanks to @valenciaga1231)
- Add auto NPC for normal resource
- Add ignore Roman tribe's advantage (build 2 buildings instead of 3 for first village)

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 Nov 23, 2022
2 parents 9dc927e + 4fbbb62 commit 5ca74e0
Show file tree
Hide file tree
Showing 64 changed files with 288 additions and 147 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_BOT }}
title: New hotfix
title: New patch
nodetail: true
description: |
Version `TBS-${{needs.version.outputs.version}}`
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,6 @@ data/

Web/Client/
Web/Server/
Web/Shared/
Web/Shared/
/TBS.db-shm
/TBS.db-wal
2 changes: 2 additions & 0 deletions MainCore/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ public void AddVersionInfo()
KeyValuePair.Create(202210061322,"NPCMigrations"),
KeyValuePair.Create(202210162304,"TroopsMigrations"),
KeyValuePair.Create(202210181120,"UpgradeTroopMigrations"),
KeyValuePair.Create(202210271504,"NPCForWarhouse"),
KeyValuePair.Create(2022102716038,"IgnoreRomanAdvantage"),
};
foreach (var migration in migrations)
{
Expand Down
2 changes: 1 addition & 1 deletion MainCore/Helper/BuildingsHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MainCore.Enums;
using MainCore.Models.Runtime;
using MainCore.Services;
using MainCore.Services.Interface;
using System.Collections.Generic;
using System.Linq;

Expand Down
2 changes: 1 addition & 1 deletion MainCore/Helper/CheckHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HtmlAgilityPack;
using MainCore.Enums;
using MainCore.Services;
using System.Linq;
using MainCore.Services.Interface;

#if TRAVIAN_OFFICIAL

Expand Down
2 changes: 1 addition & 1 deletion MainCore/Helper/ClickHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HtmlAgilityPack;
using MainCore.Services;
using MainCore.Services.Interface;
using OpenQA.Selenium;
using System;

Expand Down
2 changes: 1 addition & 1 deletion MainCore/Helper/HeroHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using HtmlAgilityPack;
using MainCore.Enums;
using MainCore.Services;
using MainCore.Services.Interface;
using OpenQA.Selenium;
using System;

Expand Down
4 changes: 2 additions & 2 deletions MainCore/Helper/NavigateHelper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using MainCore.Services;
using System;
using System;
using OpenQA.Selenium;
using MainCore.Exceptions;
using System.Threading;
using System.Collections.ObjectModel;
using MainCore.Services.Interface;

#if TRAVIAN_OFFICIAL

Expand Down
2 changes: 1 addition & 1 deletion MainCore/Helper/UpdateHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MainCore.Enums;
using MainCore.Models.Database;
using MainCore.Services;
using MainCore.Services.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
7 changes: 4 additions & 3 deletions MainCore/Helper/UpgradeBuildingHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using MainCore.Enums;
using MainCore.Models.Database;
using MainCore.Models.Runtime;
using MainCore.Services;
using MainCore.Services.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -27,17 +27,18 @@ public static PlanTask NextBuildingTask(AppDbContext context, IPlanManager planM
var accountInfo = context.AccountsInfo.Find(accountId);
var tribe = accountInfo.Tribe;
var hasPlusAccount = accountInfo.HasPlusAccount;
var setting = context.VillagesSettings.Find(villageId);

var maxBuild = 1;
if (hasPlusAccount) maxBuild++;
if (tribe == TribeEnums.Romans) maxBuild++;
if (tribe == TribeEnums.Romans && !setting.IsIgnoreRomanAdvantage) maxBuild++;
if (totalBuild == maxBuild)
{
logManager.Information(accountId, "Amount of currently building is equal with maximum building can build in same time");
return null;
}

if (tribe == TribeEnums.Romans && maxBuild - totalBuild == 1)
if (tribe == TribeEnums.Romans && !setting.IsIgnoreRomanAdvantage && maxBuild - totalBuild == 1)
{
var numRes = currentList.Count(x => x.Type.IsResourceField());
var numInfra = totalBuild - numRes;
Expand Down
22 changes: 22 additions & 0 deletions MainCore/Migrations/202210271504_NPCForWarhouse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using FluentMigrator;

namespace MainCore.Migrations
{
[Migration(202210271504)]
public class NPCForWarhouse : Migration
{
public override void Down()
{
Delete
.Column("IsNPCOverflow")
.Column("AutoNPCWarehousePercent").FromTable("VillagesSettings");
}

public override void Up()
{
Alter.Table("VillagesSettings")
.AddColumn("IsNPCOverflow").AsBoolean().WithDefaultValue(false)
.AddColumn("AutoNPCWarehousePercent").AsInt32().WithDefaultValue(90);
}
}
}
20 changes: 20 additions & 0 deletions MainCore/Migrations/2022102716038_IgnoreRomanAdvantage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using FluentMigrator;

namespace MainCore.Migrations
{
[Migration(2022102716038)]
public class IgnoreRomanAdvantage : Migration
{
public override void Down()
{
Delete
.Column("IsIgnoreRomanAdvantage").FromTable("VillagesSettings");
}

public override void Up()
{
Alter.Table("VillagesSettings")
.AddColumn("IsIgnoreRomanAdvantage").AsBoolean().WithDefaultValue(false);
}
}
}
4 changes: 3 additions & 1 deletion MainCore/Models/Database/VillageSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class VillageSetting
{
public int VillageId { get; set; }
public bool IsUseHeroRes { get; set; }

public bool IsIgnoreRomanAdvantage { get; set; }
public bool IsInstantComplete { get; set; }
public int InstantCompleteTime { get; set; }

Expand All @@ -18,7 +18,9 @@ public class VillageSetting
public int AutoRefreshTimeMax { get; set; }

public bool IsAutoNPC { get; set; }
public bool IsNPCOverflow { get; set; }
public int AutoNPCPercent { get; set; }
public int AutoNPCWarehousePercent { get; set; }
public int AutoNPCWood { get; set; }
public int AutoNPCClay { get; set; }
public int AutoNPCIron { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using HtmlAgilityPack;
using MainCore.Models.Database;
using MainCore.Services.Interface;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Chrome.ChromeDriverExtensions;
using OpenQA.Selenium.Support.UI;
using System;
using System.IO;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class ChromeBrowser : IChromeBrowser
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Runtime.InteropServices;
using System.Threading.Tasks;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public static class ChromeDriverInstaller
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using MainCore.Services.Interface;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class ChromeManager : IChromeManager
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using MainCore.Models.Runtime;
using System;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class EventManager
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using MainCore.Enums;
using MainCore.Models.Runtime;
using MainCore.Services.Interface;
using Microsoft.EntityFrameworkCore;
using Serilog;
using System;
using System.Collections.Generic;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class LogManager : ILogManager
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using MainCore.Helper;
using MainCore.Models.Runtime;
using MainCore.Services.Interface;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class PlanManager : IPlanManager
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MainCore.Models.Runtime;
using MainCore.Services.Interface;
using Microsoft.EntityFrameworkCore;
using RestSharp;
using System;
Expand All @@ -7,7 +8,7 @@
using System.Security.Cryptography;
using System.Text;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class RestClientManager : IRestClientManager
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using MainCore.Exceptions;
using MainCore.Helper;
using MainCore.Models.Database;
using MainCore.Services.Interface;
using MainCore.Tasks;
using MainCore.Tasks.Misc;
using Microsoft.EntityFrameworkCore;
Expand All @@ -10,7 +11,7 @@
using System.Linq;
using System.Threading;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class TaskManager : ITaskManager
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Timers;
using MainCore.Services.Interface;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class TimerManager : ITimerManager
{
Expand All @@ -23,7 +24,7 @@ public void Start(int index)
if (!_dictTimer.ContainsKey(index))
{
var timer = new Timer(100) { AutoReset = false };
timer.Elapsed += (object sender, ElapsedEventArgs e) =>
timer.Elapsed += (sender, e) =>
{
try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using RestSharp;
using MainCore.Services.Interface;
using RestSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;

namespace MainCore.Services
namespace MainCore.Services.Implementations
{
public sealed class UseragentManager : IUseragentManager
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface IChromeBrowser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface IChromeManager : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface ILogManager : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using MainCore.Models.Runtime;
using System.Collections.Generic;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface IPlanManager
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using RestSharp;
using System;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface IRestClientManager : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using MainCore.Tasks;
using System.Collections.Generic;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface ITaskManager
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface ITimerManager : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;

namespace MainCore.Services
namespace MainCore.Services.Interface
{
public interface IUseragentManager
{
Expand Down
3 changes: 2 additions & 1 deletion MainCore/Tasks/Attack/StartFarmList.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MainCore.Helper;
using MainCore.Services;
using MainCore.Services.Implementations;
using MainCore.Services.Interface;
using MainCore.Tasks.Update;
using Microsoft.EntityFrameworkCore;
using OpenQA.Selenium;
Expand Down
3 changes: 2 additions & 1 deletion MainCore/Tasks/BotTask.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MainCore.Enums;
using MainCore.Services;
using MainCore.Services.Implementations;
using MainCore.Services.Interface;
using Microsoft.EntityFrameworkCore;
using System;
using System.Threading;
Expand Down
Loading

0 comments on commit 5ca74e0

Please sign in to comment.