Skip to content

Commit 64549dd

Browse files
committed
Resolved conflicts with scout_villages branch
1 parent 8436577 commit 64549dd

File tree

18 files changed

+410
-231
lines changed

18 files changed

+410
-231
lines changed

TbsCore/Database/DbRepository.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,4 @@ private static DbAccount ConvertAcc(Account acc) =>
8484
JsonData = JsonConvert.SerializeObject(acc)
8585
};
8686
}
87-
88-
//public class RawAcc
89-
//{
90-
// public string Username { get; set; }
91-
// public string Server { get; set; }
92-
//}
93-
}
87+
}

TbsCore/Helpers/Classificator.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,5 +462,32 @@ public enum BuildingType
462462
General,
463463
AutoUpgradeResFields
464464
}
465+
466+
public enum ReportType
467+
{
468+
TruceReport, // iReport0
469+
AttackNoLosses, // iReport1 - Won as attacker without losses, Green sword
470+
AttackSomeLosses, // iReport2 - Won as attacker with losses
471+
AttackAllLosses, // iReport3 - Lost as attacker with losses
472+
DeffendNoLosses, // iReport4
473+
DeffendSomeLosses, // iReport5
474+
DeffendAllLosses, // iReport6
475+
DeffendNoDeff, // iReport7
476+
Reinforcement, // iReport8 - Reinforcement
477+
Unknown9, // 9
478+
Unknown10, // 9
479+
WoodDelivery, // iReport11 - Wood Delivery
480+
ClayDelivery, // iReport12 - Clay Delivery
481+
IronDelivery, // iReport13 - Iron Delivery
482+
CropDelivery, // iReport14 - Crop Delivery
483+
ScoutNoLosses, // iReport15 - Won scouting as attacker
484+
ScoutSomeLosses, // iReport16 - Won scouting as attacker but defender found out
485+
ScoutAllLosses, // iReport17 - Lost scouting as attacker
486+
ScoutingDeffended, // iReport18
487+
ScoutingPartlyDeffended, // iReport19
488+
AnimalsCaught, // iReport20
489+
AdventureReport, // iReport21
490+
NewVillage, // iReport22 - Settlers founded a new village
491+
}
465492
}
466493
}

TbsCore/Helpers/ObjectHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Reflection;
55
using System.Runtime.InteropServices;
66
using TbsCore.Models.AccModels;
7+
using TbsCore.Models.World;
78

89
namespace TbsCore.Helpers
910
{

TbsCore/Helpers/TroopsHelper.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal static int TroopIntFromInt(TribeEnum tribe, int num)
3636
internal static long TroopsToFill(Account acc, Village vill, TroopsEnum troop, bool great)
3737
{
3838
var troopCost = TroopCost.GetResourceCost(troop, great);
39-
var trainTime = TroopCost.GetTrainingTime(acc, vill, troop, great);
39+
var trainTime = TroopsData.GetTrainingTime(acc, vill, troop, great);
4040

4141
//how many troops we want to train
4242
// Take into account how many troop are already training
@@ -50,12 +50,20 @@ internal static long TroopsToFill(Account acc, Village vill, TroopsEnum troop, b
5050
return (long)Math.Ceiling(fillForHours / trainTime.TotalHours);
5151
}
5252

53-
public static DateTime TrainingDuration(HtmlAgilityPack.HtmlDocument html)
53+
public static DateTime TrainingDuration(HtmlDocument html)
5454
{
5555
var training = TroopsParser.GetTroopsCurrentlyTraining(html);
5656
return (training.Count == 0 ? DateTime.MinValue : training.Last().FinishTraining);
5757
}
5858

59+
public static List<TroopsEnum> AvailableTroops(TribeEnum tribe)
60+
{
61+
var ret = new List<TroopsEnum>();
62+
int troopsEnum = ((int)tribe - 1) * 10;
63+
for (var i = troopsEnum + 1; i < troopsEnum + 11; i++) ret.Add((TroopsEnum)i);
64+
return ret;
65+
}
66+
5967
/// <summary>
6068
/// Will (re)start troop training for all buildings (barracks,stable,gs...)
6169
/// </summary>

TbsCore/Helpers/VillageHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ public static int GetVillageIdFromName(string name, Account acc)
5151
public static string VillageType(Village vill)
5252
{
5353
string type = "";
54-
type += vill.Build.Buildings.Count(x => x.Type == Classificator.BuildingEnum.Woodcutter).ToString();
55-
type += vill.Build.Buildings.Count(x => x.Type == Classificator.BuildingEnum.ClayPit).ToString();
56-
type += vill.Build.Buildings.Count(x => x.Type == Classificator.BuildingEnum.IronMine).ToString();
57-
type += vill.Build.Buildings.Count(x => x.Type == Classificator.BuildingEnum.Cropland).ToString();
54+
type += vill.Build.Buildings.Count(x => x.Type == BuildingEnum.Woodcutter).ToString();
55+
type += vill.Build.Buildings.Count(x => x.Type == BuildingEnum.ClayPit).ToString();
56+
type += vill.Build.Buildings.Count(x => x.Type == BuildingEnum.IronMine).ToString();
57+
type += vill.Build.Buildings.Count(x => x.Type == BuildingEnum.Cropland).ToString();
5858
if (type == "11115") type = "15c";
5959
return type;
6060
}
6161

62-
public static string BuildingTypeToString(Classificator.BuildingEnum building) => EnumStrToString(building.ToString());
62+
public static string BuildingTypeToString(BuildingEnum building) => EnumStrToString(building.ToString());
6363

6464
public static string EnumStrToString(string str)
6565
{

TbsCore/Models/AccModels/Account.cs

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,65 @@
11
using Newtonsoft.Json;
22
using System.Collections.Generic;
3-
using Discord.Webhook;
3+
using Discord.Webhook;
44
using TbsCore.Models.Access;
55
using TbsCore.Models.Settings;
66
using TbsCore.Models.VillageModels;
7-
using TravBotSharp.Files.Models.AccModels;
8-
using TravBotSharp.Files.Tasks;
9-
10-
namespace TbsCore.Models.AccModels
11-
{
12-
public class Account
13-
{
14-
/// <summary>
15-
/// This method is called when new accounts is created
16-
/// </summary>
17-
public void Init()
18-
{
19-
Hero = new Hero();
20-
Hero.init();
21-
Tasks = new List<BotTask>();
22-
Villages = new List<Village>();
23-
Access = new AccessInfo();
24-
Access.Init();
25-
AccInfo = new AccInfo();
26-
AccInfo.Init();
27-
Quests = new QuestsSettings();
28-
Quests.Init();
29-
Settings = new GeneralSettings();
30-
Settings.Init();
31-
Farming = new Farming();
32-
NewVillages = new NewVillageSettings();
33-
NewVillages.Init();
34-
}
35-
36-
public AccInfo AccInfo { get; set; }
37-
public AccessInfo Access { get; set; }
38-
public List<Village> Villages { get; set; }
39-
public Farming Farming { get; set; }
40-
public Hero Hero { get; set; }
41-
public QuestsSettings Quests { get; set; }
42-
public NewVillageSettings NewVillages { get; set; }
7+
using TbsCore.Models.Logging;
8+
using TbsCore.Models.AccModels;
9+
using TbsCore.Tasks;
10+
11+
using Serilog;
12+
using TbsCore.Models.World;
13+
14+
namespace TbsCore.Models.AccModels
15+
{
16+
public class Account
17+
{
18+
/// <summary>
19+
/// This method is called when new accounts is created
20+
/// </summary>
21+
public void Init()
22+
{
23+
Hero = new Hero();
24+
Hero.init();
25+
Tasks = new List<BotTask>();
26+
Villages = new List<Village>();
27+
Access = new AccessInfo();
28+
Access.Init();
29+
AccInfo = new AccInfo();
30+
AccInfo.Init();
31+
Quests = new QuestsSettings();
32+
Quests.Init();
33+
Settings = new GeneralSettings();
34+
Settings.Init();
35+
Farming = new Farming();
36+
NewVillages = new NewVillageSettings();
37+
NewVillages.Init();
38+
39+
Server = new AccServerData();
40+
Server.Init();
41+
}
42+
43+
public AccInfo AccInfo { get; set; }
44+
public AccessInfo Access { get; set; }
45+
public List<Village> Villages { get; set; }
46+
public Farming Farming { get; set; }
47+
public Hero Hero { get; set; }
48+
public QuestsSettings Quests { get; set; }
49+
public NewVillageSettings NewVillages { get; set; }
4350
public GeneralSettings Settings { get; set; }
51+
public AccServerData Server { get; set; }
4452

45-
[JsonIgnore]
53+
[JsonIgnore]
4654
public WebBrowserInfo Wb { get; set; }
4755

48-
[JsonIgnore]
56+
[JsonIgnore]
4957
public List<BotTask> Tasks { get; set; }
5058

51-
[JsonIgnore]
59+
[JsonIgnore]
5260
public TaskTimer TaskTimer { get; set; }
5361

5462
[JsonIgnore]
5563
public DiscordWebhookClient WebhookClient { get; set; }
56-
}
64+
}
5765
}

TbsCore/Models/InactiveFarm.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

TbsCore/Models/MapModels/Coordinates.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.ComponentModel;
3+
using System.Globalization;
24

35
namespace TbsCore.Models.MapModels
46
{

TbsCore/Parsers/AdventureParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static List<Adventure> GetAdventures(HtmlAgilityPack.HtmlDocument htmlDoc
2323
{
2424
if (string.IsNullOrEmpty(adv.Id)) continue;
2525
var sec = (int)TimeParser.ParseDuration(adv.Descendants("td").FirstOrDefault(x => x.HasClass("moveTime")).InnerText).TotalSeconds;
26-
var coordinates = MapParser.GetCoordinates(adv.Descendants("td").FirstOrDefault(x => x.HasClass("coords")).InnerText);
26+
var coordinates = MapParser.GetCoordinates(adv);
2727

2828
DifficultyEnum difficulty = DifficultyEnum.Normal;
2929
switch (version)

TbsCore/Parsers/MapParser.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace TravBotSharp.Files.Parsers
77
{
88
public static class MapParser
99
{
10+
public static Coordinates GetCoordinates(HtmlNode node) =>
11+
GetCoordinates(node.Descendants("td").FirstOrDefault(x => x.HasClass("coords")).InnerText);
12+
1013
public static Coordinates GetCoordinates(string str)
1114
{
1215
var coords = str.Replace("(", "").Replace(")", "").Trim().Split('|');

0 commit comments

Comments
 (0)