Skip to main content

nil_core/infrastructure/building/
warehouse.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use crate::check_total_resource_ratio;
5use crate::infrastructure::building::{BuildingId, BuildingLevel, StorageId};
6use crate::infrastructure::requirements::InfrastructureRequirements;
7use crate::infrastructure::storage::StorageCapacity;
8use crate::ranking::score::Score;
9use crate::resources::cost::{Cost, ResourceRatio};
10use crate::resources::maintenance::MaintenanceRatio;
11use crate::resources::workforce::Workforce;
12use nil_core_macros::{Building, Storage};
13use serde::{Deserialize, Serialize};
14
15#[derive(Building, Storage, Clone, Debug, Deserialize, Serialize)]
16#[serde(rename_all = "camelCase")]
17pub struct Warehouse {
18  level: BuildingLevel,
19  enabled: bool,
20}
21
22impl Warehouse {
23  pub const ID: BuildingId = BuildingId::Warehouse;
24  pub const STORAGE_ID: StorageId = StorageId::Warehouse;
25
26  pub const MIN_LEVEL: BuildingLevel = BuildingLevel::ZERO;
27  pub const MAX_LEVEL: BuildingLevel = BuildingLevel::new(30);
28
29  pub const MIN_COST: Cost = Cost::new(500);
30  pub const MAX_COST: Cost = Cost::new(100_000);
31
32  pub const WOOD_RATIO: ResourceRatio = ResourceRatio::new(0.4);
33  pub const STONE_RATIO: ResourceRatio = ResourceRatio::new(0.4);
34  pub const IRON_RATIO: ResourceRatio = ResourceRatio::new(0.2);
35  pub const MAINTENANCE_RATIO: MaintenanceRatio = MaintenanceRatio::new(0.005);
36
37  pub const MIN_WORKFORCE: Workforce = Workforce::new(2);
38  pub const MAX_WORKFORCE: Workforce = Workforce::new(250);
39
40  pub const MIN_CAPACITY: StorageCapacity = StorageCapacity::new(1_000);
41  pub const MAX_CAPACITY: StorageCapacity = StorageCapacity::new(400_000);
42
43  pub const MIN_SCORE: Score = Score::new(6);
44  pub const MAX_SCORE: Score = Score::new(1187);
45
46  pub const INFRASTRUCTURE_REQUIREMENTS: InfrastructureRequirements =
47    InfrastructureRequirements::none();
48}
49
50impl Default for Warehouse {
51  fn default() -> Self {
52    Self {
53      level: BuildingLevel::new(1),
54      enabled: true,
55    }
56  }
57}
58
59check_total_resource_ratio!(
60  Warehouse::WOOD_RATIO,
61  Warehouse::STONE_RATIO,
62  Warehouse::IRON_RATIO,
63);