Skip to content

Commit

Permalink
Merge pull request #165 from Erol444/release/2.2.0
Browse files Browse the repository at this point in the history
Release 2.2.0

**Changelog**:
- Add auto-improve troops (works for both servers but TTWars is a better use case because of zero second upgrade). Read docs [here](https://tbs-docs.readthedocs.io/en/latest/improve.html)
- Redesign Village>Setting tab and add a checkbox to refresh setting to enable or disable
- Fix after first sleep, TBS wants to work 24/24
- Fix TBS use gold upgrade even with residence and similar building
- Fix TBS forgot to check the prerequisite building before build
- Fix TBS didn't know Travian forced to log out after a few inactive hours  

If you like my work, you can donate to me through [ko-fi.com/vinaghost](ko-fi.com/vinaghost)
  • Loading branch information
vinaghost authored Oct 24, 2022
2 parents 308231f + 4b41e3a commit 0dd664c
Show file tree
Hide file tree
Showing 69 changed files with 2,054 additions and 428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
${{needs.version.outputs.changelog}}
Discord:
runs-on: ubuntu-latest
needs: release
needs: [release, version]
steps:
- name: Ping @everyone
run: |
Expand Down
76 changes: 75 additions & 1 deletion MainCore/AppDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using MainCore.Models.Database;
using MainCore.Enums;
using MainCore.Helper;
using MainCore.Models.Database;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;

namespace MainCore
Expand Down Expand Up @@ -204,6 +207,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
});

#endregion Farm settings

#region Village troops

modelBuilder.Entity<VillageTroops>(entity =>
{
entity.ToTable("VillagesTroops");
entity.HasKey(e => new { e.VillageId, e.Id })
.HasName("PK_VILLAGESTROOPS");
});

#endregion Village troops
}

public void AddAccount(int accountId)
Expand Down Expand Up @@ -266,6 +280,22 @@ public void AddVillage(int villageId)
//VillagesBuildings
}

public void AddTroop(int villageId, TribeEnums tribe)
{
var troops = tribe.GetTroops();
for (int i = 0; i < troops.Count; i++)
{
var level = -1;
if (i == 0) level = 0;
VillagesTroops.Add(new VillageTroops
{
Id = (int)troops[i],
VillageId = villageId,
Level = level,
});
}
}

public void AddFarm(int farmId)
{
FarmsSettings.Add(new FarmSetting
Expand Down Expand Up @@ -377,6 +407,30 @@ public void UpdateDatabase()
});
}
}

if (!VillagesTroops.Any())
{
foreach (var account in Accounts)
{
var tribe = AccountsInfo.Find(account.Id).Tribe;
var troops = tribe.GetTroops();
var villages = Villages.Where(x => x.AccountId == account.Id).ToList();
foreach (var village in villages)
{
for (int i = 0; i < troops.Count; i++)
{
var level = -1;
if (i == 0) level = 0;
VillagesTroops.Add(new VillageTroops
{
Id = (int)troops[i],
VillageId = village.Id,
Level = level,
});
}
}
}
}
}

public void DeleteAccount(int accountId)
Expand Down Expand Up @@ -428,6 +482,8 @@ public void DeleteVillage(int villageId)
VillagesQueueBuildings.RemoveRange(queue);
var buildings = VillagesBuildings.Where(x => x.VillageId == villageId);
VillagesBuildings.RemoveRange(buildings);
var troops = VillagesTroops.Where(x => x.VillageId == villageId);
VillagesTroops.RemoveRange(troops);

var village = Villages.Find(villageId);
Villages.Remove(village);
Expand All @@ -441,6 +497,23 @@ public void DeleteFarm(int farmId)
Farms.Remove(farm);
}

public void AddVersionInfo()
{
Database.ExecuteSqlRaw("CREATE TABLE \"VersionInfo\" (\"Version\" INTEGER NOT NULL, \"AppliedOn\" DATETIME, \"Description\" TEXT)");

var migrations = new List<KeyValuePair<long, string>>()
{
KeyValuePair.Create(202209131759,"Farming"),
KeyValuePair.Create(202210061322,"NPCMigrations"),
KeyValuePair.Create(202210162304,"TroopsMigrations"),
KeyValuePair.Create(202210181120,"UpgradeTroopMigrations"),
};
foreach (var migration in migrations)
{
Database.ExecuteSqlRaw($"INSERT INTO VersionInfo (Version, Description) VALUES ('{migration.Key}','{migration.Value}')");
}
}

public DbSet<Account> Accounts { get; set; }
public DbSet<AccountInfo> AccountsInfo { get; set; }
public DbSet<Access> Accesses { get; set; }
Expand All @@ -458,5 +531,6 @@ public void DeleteFarm(int farmId)
public DbSet<VillageProduction> VillagesProduction { get; set; }
public DbSet<Farm> Farms { get; set; }
public DbSet<FarmSetting> FarmsSettings { get; set; }
public DbSet<VillageTroops> VillagesTroops { get; set; }
}
}
101 changes: 101 additions & 0 deletions MainCore/Enums/TroopEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
namespace MainCore.Enums
{
public enum TroopEnums
{
None,

//Romans//,
Legionnaire,

Praetorian,
Imperian,
EquitesLegati,
EquitesImperatoris,
EquitesCaesaris,
RomanRam,
RomanCatapult,
RomanChief,
RomanSettler,

//Teutons//,
Clubswinger,

Spearman,
Axeman,
Scout,
Paladin,
TeutonicKnight,
TeutonRam,
TeutonCatapult,
TeutonChief,
TeutonSettler,

//Gauls//,
Phalanx,

Swordsman,
Pathfinder,
TheutatesThunder,
Druidrider,
Haeduan,
GaulRam,
GaulCatapult,
GaulChief,
GaulSettler,

//Nature//,
Rat,

Spider,
Snake,
Bat,
WildBoar,
Wolf,
Bear,
Crocodile,
Tiger,
Elephant,

//Natars//,
Pikeman,

ThornedWarrior,
Guardsman,
BirdsOfPrey,
Axerider,
NatarianKnight,
Warelephant,
Ballista,
NatarianEmperor,
Settler,

//Egyptians//,
SlaveMilitia,

AshWarden,
KhopeshWarrior,
SopduExplorer,
AnhurGuard,
ReshephChariot,
EgyptianRam,
EgyptianCatapult,
EgyptianChief,
EgyptianSettler,

//Huns//,
Mercenary,

Bowman,
Spotter,
SteppeRider,
Marksman,
Marauder,
HunRam,
HunCatapult,
HunChief,
HunSettler,

//Hero
Hero
}
}
Loading

0 comments on commit 0dd664c

Please sign in to comment.