Add backend projects with core models and tests, setup Godot frontend
This commit is contained in:
11
backend/MyBiz.slnx
Normal file
11
backend/MyBiz.slnx
Normal file
@@ -0,0 +1,11 @@
|
||||
<Solution>
|
||||
<Folder Name="/src/">
|
||||
<Project Path="src/MyBiz.Core/MyBiz.Core.csproj" />
|
||||
<Project Path="src/MyBiz.Economy/MyBiz.Economy.csproj" />
|
||||
<Project Path="src/MyBiz.Production/MyBiz.Production.csproj" />
|
||||
<Project Path="src/MyBiz.Trade/MyBiz.Trade.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/tests/">
|
||||
<Project Path="tests/MyBiz.Tests/MyBiz.Tests.csproj" />
|
||||
</Folder>
|
||||
</Solution>
|
||||
74
backend/src/MyBiz.Core/Building.cs
Normal file
74
backend/src/MyBiz.Core/Building.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
namespace MyBiz.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Тип здания
|
||||
/// </summary>
|
||||
public enum BuildingType
|
||||
{
|
||||
// Добыча сырья
|
||||
Farm, // Ферма
|
||||
CottonField, // Хлопковое поле
|
||||
Mine, // Шахта
|
||||
|
||||
// Производство
|
||||
FoodFactory, // Пищекомбинат
|
||||
TextileFactory, // Текстильная фабрика
|
||||
SteelMill, // Сталелитейный завод
|
||||
PlasticPlant, // Завод пластика
|
||||
ElectronicsFactory, // Завод электроники
|
||||
AutoFactory, // Автозавод
|
||||
|
||||
// Торговля
|
||||
GroceryStore, // Продуктовый магазин
|
||||
ClothingStore, // Магазин одежды
|
||||
ElectronicsStore, // Магазин электроники
|
||||
AutoDealer, // Автосалон
|
||||
Mall, // Торговый центр
|
||||
|
||||
// Исследования
|
||||
Laboratory, // Лаборатория
|
||||
|
||||
// Склад
|
||||
Warehouse // Склад
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Здание
|
||||
/// </summary>
|
||||
public class Building
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
public BuildingType Type { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string CityId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Уровень здания (влияет на эффективность)
|
||||
/// </summary>
|
||||
public int Level { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Стоимость постройки
|
||||
/// </summary>
|
||||
public decimal BuildCost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Стоимость содержания в тик
|
||||
/// </summary>
|
||||
public decimal UpkeepCost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вместимость склада
|
||||
/// </summary>
|
||||
public int StorageCapacity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Количество рабочих мест
|
||||
/// </summary>
|
||||
public int WorkerSlots { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Заполненность рабочими
|
||||
/// </summary>
|
||||
public int Workers { get; set; }
|
||||
}
|
||||
47
backend/src/MyBiz.Core/City.cs
Normal file
47
backend/src/MyBiz.Core/City.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace MyBiz.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Размер города
|
||||
/// </summary>
|
||||
public enum CitySize
|
||||
{
|
||||
Small, // Малый
|
||||
Medium, // Средний
|
||||
Large // Крупный
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Город
|
||||
/// </summary>
|
||||
public class City
|
||||
{
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Country { get; set; } = string.Empty;
|
||||
public CitySize Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Население
|
||||
/// </summary>
|
||||
public int Population { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Доступные здания
|
||||
/// </summary>
|
||||
public List<Building> Buildings { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Рынок города (спрос на продукты)
|
||||
/// </summary>
|
||||
public Dictionary<ProductType, int> MarketDemand { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Предложение на рынке
|
||||
/// </summary>
|
||||
public Dictionary<ProductType, int> MarketSupply { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Текущие цены
|
||||
/// </summary>
|
||||
public Dictionary<ProductType, decimal> Prices { get; set; } = new();
|
||||
}
|
||||
50
backend/src/MyBiz.Core/Company.cs
Normal file
50
backend/src/MyBiz.Core/Company.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace MyBiz.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Компания игрока
|
||||
/// </summary>
|
||||
public class Company
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Доступные деньги
|
||||
/// </summary>
|
||||
public decimal Cash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Активы компании
|
||||
/// </summary>
|
||||
public decimal Assets { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Пассивы (долги)
|
||||
/// </summary>
|
||||
public decimal Liabilities { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Прибыль за последний период
|
||||
/// </summary>
|
||||
public decimal LastPeriodProfit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Список зданий компании
|
||||
/// </summary>
|
||||
public List<Building> Buildings { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Складские запасы
|
||||
/// </summary>
|
||||
public Dictionary<ProductType, int> Inventory { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Открытые технологии
|
||||
/// </summary>
|
||||
public HashSet<string> UnlockedTechnologies { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Рассчитать чистую стоимость
|
||||
/// </summary>
|
||||
public decimal NetWorth => Assets - Liabilities + Cash;
|
||||
}
|
||||
65
backend/src/MyBiz.Core/Product.cs
Normal file
65
backend/src/MyBiz.Core/Product.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace MyBiz.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Категория продукта
|
||||
/// </summary>
|
||||
public enum ProductCategory
|
||||
{
|
||||
RawMaterial, // Сырьё
|
||||
Component, // Компоненты
|
||||
ConsumerGoods // Товары народного потребления
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Тип продукта
|
||||
/// </summary>
|
||||
public enum ProductType
|
||||
{
|
||||
// Сырьё
|
||||
Cotton, // Хлопок
|
||||
Steel, // Сталь
|
||||
Plastic, // Пластик
|
||||
FoodRaw, // Сырьё для еды
|
||||
|
||||
// Компоненты
|
||||
Fabric, // Ткань
|
||||
MetalParts, // Металлические детали
|
||||
PlasticParts, // Пластиковые детали
|
||||
ElectronicsComponents, // Электронные компоненты
|
||||
|
||||
// Товары
|
||||
Food, // Еда
|
||||
Clothing, // Одежда
|
||||
Electronics, // Электроника
|
||||
Automobile // Автомобили
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Продукт
|
||||
/// </summary>
|
||||
public class Product
|
||||
{
|
||||
public ProductType Type { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public ProductCategory Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Базовая цена продукта
|
||||
/// </summary>
|
||||
public decimal BasePrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Текущая цена (с учётом спроса/предложения)
|
||||
/// </summary>
|
||||
public decimal CurrentPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Доступное количество на рынке
|
||||
/// </summary>
|
||||
public int AvailableQuantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Спрос на продукт
|
||||
/// </summary>
|
||||
public int Demand { get; set; }
|
||||
}
|
||||
37
backend/src/MyBiz.Core/ProductionChain.cs
Normal file
37
backend/src/MyBiz.Core/ProductionChain.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace MyBiz.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Шаг производственной цепочки
|
||||
/// </summary>
|
||||
public class ProductionStep
|
||||
{
|
||||
/// <summary>
|
||||
/// Требуемый продукт
|
||||
/// </summary>
|
||||
public ProductType InputProduct { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Количество требуемого продукта
|
||||
/// </summary>
|
||||
public int InputQuantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Время производства (в тиках)
|
||||
/// </summary>
|
||||
public int ProductionTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Производственная цепочка
|
||||
/// </summary>
|
||||
public class ProductionChain
|
||||
{
|
||||
public ProductType OutputProduct { get; set; }
|
||||
public BuildingType RequiredBuilding { get; set; }
|
||||
public List<ProductionStep> Steps { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Количество выходного продукта за цикл
|
||||
/// </summary>
|
||||
public int OutputQuantity { get; set; }
|
||||
}
|
||||
41
backend/tests/MyBiz.Tests/ProductTests.cs
Normal file
41
backend/tests/MyBiz.Tests/ProductTests.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using MyBiz.Core;
|
||||
|
||||
namespace MyBiz.Tests;
|
||||
|
||||
public class ProductTests
|
||||
{
|
||||
[Fact]
|
||||
public void Product_Creation_ShouldInitializeProperties()
|
||||
{
|
||||
// Arrange & Act
|
||||
var product = new Product
|
||||
{
|
||||
Type = ProductType.Food,
|
||||
Name = "Bread",
|
||||
Category = ProductCategory.ConsumerGoods,
|
||||
BasePrice = 10m
|
||||
};
|
||||
|
||||
// Assert
|
||||
Assert.Equal(ProductType.Food, product.Type);
|
||||
Assert.Equal("Bread", product.Name);
|
||||
Assert.Equal(ProductCategory.ConsumerGoods, product.Category);
|
||||
Assert.Equal(10m, product.BasePrice);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Product_CurrentPrice_ShouldDefaultToBasePrice()
|
||||
{
|
||||
// Arrange
|
||||
var product = new Product
|
||||
{
|
||||
BasePrice = 25m
|
||||
};
|
||||
|
||||
// Act
|
||||
product.CurrentPrice = product.BasePrice;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(25m, product.CurrentPrice);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user