Compare commits
5 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
a7cd03d64d | |
|
|
7e70ca87f6 | |
|
|
5428475717 | |
|
|
44405f092f | |
|
|
d75518d1ff |
|
|
@ -2,7 +2,7 @@
|
|||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
.idea
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\" />
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ VisualStudioVersion = 17.11.35327.3
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BHServer", "BHServer.csproj", "{84BDA934-6556-40C9-A550-EB1B894CFAC0}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AB5CF1F1-2CBD-4F37-BC7D-E8952804FC0C}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docker-compose.yaml = docker-compose.yaml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
|
|||
|
|
@ -1,60 +1,51 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using BHServer.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BHServer.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace BHServer.Controllers
|
||||
{
|
||||
public class AssaultTroopController : ControllerBase
|
||||
[Route("api/[controller]")]
|
||||
public class AssaultTroopController(ApplicationDbContext db) : DBController(db)
|
||||
{
|
||||
List<string> MockData = [
|
||||
"{\"id\": 1, \"name\": \"First Infantry Division\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 1}",
|
||||
"{\"id\": 2, \"name\": \"First Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||
"{\"id\": 3, \"name\": \"Second Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||
"{\"id\": 4, \"name\": \"Third Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||
"{\"id\": 5, \"name\": \"Cheeki Breeki Boys\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}",
|
||||
"{\"id\": 6, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||
"{\"id\": 7, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||
"{\"id\": 8, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||
"{\"id\": 9, \"name\": \"Cheeki Breeki Boys\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}",
|
||||
"{\"id\": 10, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||
"{\"id\": 11, \"name\": \"Fifth Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": -1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 5}",
|
||||
"{\"id\": 12, \"name\": \"Fifth Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": -1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 5}",
|
||||
"{\"id\": 13, \"name\": \"First Armor Division\", \"faction\": 1, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||
"{\"id\": 14, \"name\": \"Second Armor Division\", \"faction\": 1, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||
"{\"id\": 15, \"name\": \"Cheeki Breeki Tonks\", \"faction\": 2, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}"
|
||||
];
|
||||
|
||||
// GET: /<APIController>
|
||||
// GET: api/<APIController>
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
public string Get()
|
||||
{
|
||||
return MockData;
|
||||
List<AssaultTroop> assaultTroopList = DB.assault_troop.ToList();
|
||||
return JsonConvert.SerializeObject(assaultTroopList);
|
||||
}
|
||||
|
||||
// GET /<APIController>/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
var entry = MockData.ElementAt(id);
|
||||
return entry;
|
||||
AssaultTroop assaultTroop = DB.assault_troop.ElementAt(id);
|
||||
return JsonConvert.SerializeObject(assaultTroop);
|
||||
}
|
||||
|
||||
// POST /<APIController>
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
//TODO: Implement
|
||||
}
|
||||
|
||||
// PUT /<APIController>/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
//TODO: Implement
|
||||
}
|
||||
|
||||
// DELETE /<APIController>/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
//TODO: Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using BHServer.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BHServer.Controllers
|
||||
{
|
||||
public class DBController : ControllerBase
|
||||
{
|
||||
protected readonly ApplicationDbContext DB;
|
||||
|
||||
public DBController(ApplicationDbContext db)
|
||||
{
|
||||
DB = db;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +1,26 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
|
||||
using BHServer.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BHServer.Models;
|
||||
using Newtonsoft.Json;
|
||||
namespace BHServer.Controllers
|
||||
{
|
||||
public class ProvinceController : Controller
|
||||
[Route("api/[controller]")]
|
||||
public class ProvinceController(ApplicationDbContext db) : DBController(db)
|
||||
{
|
||||
List<string> MockData = [
|
||||
"{\"id\": 0, \"name\": \"Hessen\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [2, 3, 4], \"Axis\": [1, 5, 9, 10]}, \"state\": 1}",
|
||||
"{\"id\": 1, \"name\": \"Thuringen\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [6, 7, 8]}, \"state\": 0}",
|
||||
"{\"id\": 2, \"name\": \"Rheinland-Pfalz\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [13, 14], \"Axis\": [15]}, \"state\": 1}",
|
||||
"{\"id\": 3, \"name\": \"Saarland\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [16, 17, 18], \"Axis\": []}, \"state\": 0}",
|
||||
"{\"id\": 4, \"name\": \"Baden-Wurttemberg\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [17, 19], \"Axis\": []}, \"state\": 0}",
|
||||
"{\"id\": 5, \"name\": \"Bayern\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [20, 21], \"Axis\": []}, \"state\": 0}",
|
||||
"{\"id\": 6, \"name\": \"Sachsen\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [23], \"Axis\": []}, \"state\": 0}",
|
||||
"{\"id\": 7, \"name\": \"Brandenburg\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [25, 26, 27, 28]}, \"state\": 0}",
|
||||
"{\"id\": 8, \"name\": \"Berlin\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [29, 30, 31]}, \"state\": 0}",
|
||||
"{\"id\": 9, \"name\": \"Schleswig-Holstein\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [33]}, \"state\": 0}",
|
||||
"{\"id\": 10, \"name\": \"Hamburg\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [34]}, \"state\": 0}",
|
||||
"{\"id\": 11, \"name\": \"Niedersachsen\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [35]}, \"state\": 0}",
|
||||
"{\"id\": 12, \"name\": \"Nordreihn-Westfalen\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [36, 37], \"Axis\": []}, \"state\": 0}"
|
||||
];
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: api/<APIController>
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
public string Get()
|
||||
{
|
||||
return MockData;
|
||||
List<Province> provinceList = DB.province.ToList();
|
||||
return JsonConvert.SerializeObject(provinceList);
|
||||
}
|
||||
|
||||
// GET /<APIController>/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
var entry = MockData.ElementAt(id);
|
||||
return entry;
|
||||
var province = DB.province.ElementAt(id);
|
||||
return JsonConvert.SerializeObject(province);
|
||||
}
|
||||
|
||||
// POST /<APIController>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
using BHServer.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BHServer.Data
|
||||
{
|
||||
public class ApplicationDbContext : DbContext
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
||||
// this will pass along the options from the implementation to the definition
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<Province> province { get; set; } // specify the table and it's class
|
||||
// to run migrations, run `add-migration <name of the migration>` in the NuGet console
|
||||
// then make the migrations from the console by using `update-database`
|
||||
// to rollback migrations run the command `remove-migration <name>`
|
||||
|
||||
public DbSet<AssaultTroop> assault_troop { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
// <auto-generated />
|
||||
using BHServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BHServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20241124152636_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BHServer.Models.AssaultTroop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ATId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Faction")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Orders")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Owner")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Province")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("AssaultTroop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BHServer.Models.Province", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ATs")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Faction")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Multiplier")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ProvinceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("State")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Province");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BHServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AssaultTroop",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ATId = table.Column<int>(type: "integer", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Faction = table.Column<int>(type: "integer", nullable: false),
|
||||
Type = table.Column<int>(type: "integer", nullable: false),
|
||||
Province = table.Column<int>(type: "integer", nullable: false),
|
||||
Orders = table.Column<string>(type: "text", nullable: false),
|
||||
Owner = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AssaultTroop", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Province",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProvinceId = table.Column<int>(type: "integer", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Faction = table.Column<int>(type: "integer", nullable: false),
|
||||
Multiplier = table.Column<int>(type: "integer", nullable: false),
|
||||
ATs = table.Column<string>(type: "text", nullable: false),
|
||||
State = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Province", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AssaultTroop");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Province");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
// <auto-generated />
|
||||
using BHServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BHServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20241126211247_working state naming")]
|
||||
partial class workingstatenaming
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BHServer.Models.AssaultTroop", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||
|
||||
b.Property<int>("faction")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("orders")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("owner")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("province")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("assault_troop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BHServer.Models.Province", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||
|
||||
b.Property<string>("ats")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("faction")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("multiplier")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("state")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("province");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BHServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class workingstatenaming : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_Province",
|
||||
table: "Province");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_AssaultTroop",
|
||||
table: "AssaultTroop");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProvinceId",
|
||||
table: "Province");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ATId",
|
||||
table: "AssaultTroop");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "Province",
|
||||
newName: "province");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "AssaultTroop",
|
||||
newName: "assault_troop");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "State",
|
||||
table: "province",
|
||||
newName: "state");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Name",
|
||||
table: "province",
|
||||
newName: "name");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Multiplier",
|
||||
table: "province",
|
||||
newName: "multiplier");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Faction",
|
||||
table: "province",
|
||||
newName: "faction");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "ATs",
|
||||
table: "province",
|
||||
newName: "ats");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Id",
|
||||
table: "province",
|
||||
newName: "id");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Type",
|
||||
table: "assault_troop",
|
||||
newName: "type");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Province",
|
||||
table: "assault_troop",
|
||||
newName: "province");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Owner",
|
||||
table: "assault_troop",
|
||||
newName: "owner");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Orders",
|
||||
table: "assault_troop",
|
||||
newName: "orders");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Name",
|
||||
table: "assault_troop",
|
||||
newName: "name");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Faction",
|
||||
table: "assault_troop",
|
||||
newName: "faction");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Id",
|
||||
table: "assault_troop",
|
||||
newName: "id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_province",
|
||||
table: "province",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_assault_troop",
|
||||
table: "assault_troop",
|
||||
column: "id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_province",
|
||||
table: "province");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_assault_troop",
|
||||
table: "assault_troop");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "province",
|
||||
newName: "Province");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "assault_troop",
|
||||
newName: "AssaultTroop");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "state",
|
||||
table: "Province",
|
||||
newName: "State");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "name",
|
||||
table: "Province",
|
||||
newName: "Name");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "multiplier",
|
||||
table: "Province",
|
||||
newName: "Multiplier");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "faction",
|
||||
table: "Province",
|
||||
newName: "Faction");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "ats",
|
||||
table: "Province",
|
||||
newName: "ATs");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "id",
|
||||
table: "Province",
|
||||
newName: "Id");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "type",
|
||||
table: "AssaultTroop",
|
||||
newName: "Type");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "province",
|
||||
table: "AssaultTroop",
|
||||
newName: "Province");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "owner",
|
||||
table: "AssaultTroop",
|
||||
newName: "Owner");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "orders",
|
||||
table: "AssaultTroop",
|
||||
newName: "Orders");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "name",
|
||||
table: "AssaultTroop",
|
||||
newName: "Name");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "faction",
|
||||
table: "AssaultTroop",
|
||||
newName: "Faction");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "id",
|
||||
table: "AssaultTroop",
|
||||
newName: "Id");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ProvinceId",
|
||||
table: "Province",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ATId",
|
||||
table: "AssaultTroop",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_Province",
|
||||
table: "Province",
|
||||
column: "Id");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_AssaultTroop",
|
||||
table: "AssaultTroop",
|
||||
column: "Id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
// <auto-generated />
|
||||
using BHServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BHServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BHServer.Models.AssaultTroop", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||
|
||||
b.Property<int>("faction")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("orders")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("owner")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("province")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("assault_troop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BHServer.Models.Province", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
|
||||
|
||||
b.Property<string>("ats")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("faction")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("multiplier")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("state")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("province");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,19 +5,18 @@ namespace BHServer.Models
|
|||
public class AssaultTroop
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public int ATId { get; set; }
|
||||
public int id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public string name { get; set; }
|
||||
[Required]
|
||||
public int Faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis
|
||||
public int faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis
|
||||
[Required]
|
||||
public int Type { get; set; } // 1 - infantry, 4 - Armor
|
||||
public int type { get; set; } // 1 - infantry, 4 - Armor
|
||||
[Required]
|
||||
public int Province { get; set; } // -1 - not deployed, provinces id
|
||||
public int province { get; set; } // -1 - not deployed, provinces id
|
||||
[Required]
|
||||
public string Orders { get; set; } // Json String
|
||||
public string orders { get; set; } // Json String
|
||||
[Required]
|
||||
public int Owner { get; set; } // owner id
|
||||
public int owner { get; set; } // owner id
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,17 +5,16 @@ namespace BHServer.Models
|
|||
public class Province
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public int ProvinceId { get; set; }
|
||||
public int id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public string name { get; set; }
|
||||
[Required]
|
||||
public int Faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis
|
||||
public int faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis
|
||||
[Required]
|
||||
public int Multiplier { get; set; } // 0-1
|
||||
public int multiplier { get; set; } // 0-1
|
||||
[Required]
|
||||
public string ATs { get; set; } // Json String
|
||||
public string ats { get; set; } // Json String
|
||||
[Required]
|
||||
public int State { get; set; } // 0 - Peace, 1 - War
|
||||
public int state { get; set; } // 0 - Peace, 1 - War
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
# Use the official PostgreSQL image as the base image
|
||||
FROM postgres:latest
|
||||
|
||||
# Set environment variables for PostgreSQL
|
||||
ENV POSTGRES_DB=mydatabase
|
||||
ENV POSTGRES_USER=myuser
|
||||
ENV POSTGRES_PASSWORD=mypassword
|
||||
|
||||
# Copy initialization scripts into the Docker image
|
||||
COPY init.sql /docker-entrypoint-initdb.d/
|
||||
|
||||
# Expose the PostgreSQL port
|
||||
EXPOSE 5432
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
-- Create the AssaultTroop table
|
||||
CREATE TABLE assault_troop (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis
|
||||
type INT NOT NULL, -- 1 - Infantry, 4 - Armor
|
||||
province INT NOT NULL, -- -1 - Not deployed, Province IDs
|
||||
orders JSONB NOT NULL, -- JSON String
|
||||
owner INT NOT NULL -- Owner ID
|
||||
);
|
||||
|
||||
INSERT INTO assault_troop (id, name, faction, type, province, orders, owner) VALUES
|
||||
(0, 'First Armor Division', 2, 1, 0, '{"Dep": [], "Mov": []}', 1),
|
||||
(1, 'First Infantry Division', 2, 1, 0, '{"Dep": [], "Mov": []}', 1),
|
||||
(2, 'First Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
|
||||
(3, 'Second Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
|
||||
(4, 'Third Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2),
|
||||
(5, 'Cheeki Breeki Boys', 2, 1, 0, '{"Dep": [], "Mov": []}', 3),
|
||||
(6, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
|
||||
(7, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
|
||||
(8, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4),
|
||||
(9, 'Cheeki Breeki Boys', 2, 1, 1, '{"Dep": [], "Mov": []}', 3),
|
||||
(10, 'Hitlers Men', 2, 1, 0, '{"Dep": [], "Mov": []}', 4),
|
||||
(11, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5),
|
||||
(12, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5),
|
||||
(13, 'First Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2),
|
||||
(14, 'Second Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2),
|
||||
(15, 'Cheeki Breeki Tonks', 2, 4, 2, '{"Dep": [], "Mov": []}', 3);
|
||||
|
||||
|
||||
-- Create the Province table
|
||||
CREATE TABLE province (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis
|
||||
multiplier DECIMAL(3, 2) NOT NULL, -- 0-1
|
||||
ats JSONB NOT NULL, -- JSON String
|
||||
state INT NOT NULL -- 0 - Peace, 1 - War
|
||||
);
|
||||
|
||||
INSERT INTO province (id, name, faction, multiplier, ats, state) VALUES
|
||||
(0, 'Hessen', 2, 1.00, '{"Allies": [2, 3, 4], "Axis": [1, 5, 9, 10]}', 1),
|
||||
(1, 'Thuringen', 2, 1.00, '{"Allies": [], "Axis": [6, 7, 8]}', 0),
|
||||
(2, 'Rheinland-Pfalz', 1, 1.00, '{"Allies": [13, 14], "Axis": [15]}', 1),
|
||||
(4, 'Baden-Wurttemberg', 1, 1.00, '{"Allies": [17, 19], "Axis": []}', 0),
|
||||
(3, 'Saarland', 1, 1.00, '{"Allies": [16, 17, 18], "Axis": []}', 0),
|
||||
(5, 'Bayern', 1, 1.00, '{"Allies": [20, 21], "Axis": []}', 0),
|
||||
(6, 'Sachsen', 1, 1.00, '{"Allies": [23], "Axis": []}', 0),
|
||||
(7, 'Brandenburg', 2, 1.00, '{"Allies": [], "Axis": [25, 26, 27, 28]}', 0),
|
||||
(8, 'Berlin', 2, 1.00, '{"Allies": [], "Axis": [29, 30, 31]}', 0),
|
||||
(9, 'Schleswig-Holstein', 2, 1.00, '{"Allies": [], "Axis": [33]}', 0),
|
||||
(10, 'Hamburg', 2, 1.00, '{"Allies": [], "Axis": [34]}', 0),
|
||||
(11, 'Niedersachsen', 2, 1.00, '{"Allies": [], "Axis": [35]}', 0),
|
||||
(12, 'Nordreihn-Westfalen', 1, 1.00, '{"Allies": [36, 37], "Axis": []}', 0);
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using BHServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
|
@ -5,6 +6,12 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(
|
||||
options => options.UseNpgsql(connectionString)
|
||||
// `ConnectionString` is defined in the appsettings.json file
|
||||
);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
|
|
|||
|
|
@ -4,5 +4,8 @@
|
|||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=db;Username=APIUser;Password=APIUserPw;Database=BHDB;Port=5432;SearchPath=public"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=db;Username=APIUser;Password=APIUserPw;Database=BHDB;Port=5432;SearchPath=public"
|
||||
}
|
||||
// This also needs to be changed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
services:
|
||||
db:
|
||||
build: ./PostgressDB
|
||||
container_name: Beyond_Heroes_War_DB
|
||||
ports:
|
||||
- "6732:5432"
|
||||
environment:
|
||||
POSTGRES_DB: BHDB
|
||||
POSTGRES_USER: APIUser
|
||||
POSTGRES_PASSWORD: APIUserPw
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
POSTGRES_INITDB_ARGS: --auth-host=trust --auth-local=trust
|
||||
volumes:
|
||||
- ./PostgressDB/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
networks:
|
||||
- bhnetwork
|
||||
bhserver:
|
||||
container_name: Beyond_Heroes_War_Server
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "32770:8080"
|
||||
networks:
|
||||
- bhnetwork
|
||||
|
||||
networks:
|
||||
bhnetwork:
|
||||
driver: bridge
|
||||
Reference in New Issue