Skip to main content

nil_core/infrastructure/building/
silo.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 Silo {
18  level: BuildingLevel,
19  enabled: bool,
20}
21
22impl Silo {
23  pub const ID: BuildingId = BuildingId::Silo;
24  pub const STORAGE_ID: StorageId = StorageId::Silo;
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 MAINTENANCE_RATIO: MaintenanceRatio = MaintenanceRatio::new(0.0025);
33
34  pub const WOOD_RATIO: ResourceRatio = ResourceRatio::new(0.45);
35  pub const STONE_RATIO: ResourceRatio = ResourceRatio::new(0.25);
36  pub const IRON_RATIO: ResourceRatio = ResourceRatio::new(0.3);
37
38  pub const MIN_WORKFORCE: Workforce = Workforce::new(2);
39  pub const MAX_WORKFORCE: Workforce = Workforce::new(250);
40
41  pub const MIN_CAPACITY: StorageCapacity = StorageCapacity::new(1_000);
42  pub const MAX_CAPACITY: StorageCapacity = StorageCapacity::new(250_000);
43
44  pub const MIN_SCORE: Score = Score::new(6);
45  pub const MAX_SCORE: Score = Score::new(1187);
46
47  pub const INFRASTRUCTURE_REQUIREMENTS: InfrastructureRequirements =
48    InfrastructureRequirements::none();
49}
50
51impl Default for Silo {
52  fn default() -> Self {
53    Self {
54      level: BuildingLevel::new(1),
55      enabled: true,
56    }
57  }
58}
59
60check_total_resource_ratio!(Silo::WOOD_RATIO, Silo::STONE_RATIO, Silo::IRON_RATIO);