nil-core 0.5.1

Multiplayer strategy game
Documentation
// Copyright (C) Call of Nil contributors
// SPDX-License-Identifier: AGPL-3.0-only

use crate::check_total_resource_ratio;
use crate::infrastructure::building::{BuildingId, BuildingLevel, MineId};
use crate::infrastructure::mine::MineProduction;
use crate::infrastructure::requirements::InfrastructureRequirements;
use crate::ranking::score::Score;
use crate::resources::cost::{Cost, ResourceRatio};
use crate::resources::maintenance::MaintenanceRatio;
use crate::resources::workforce::Workforce;
use nil_core_macros::{Building, Mine};
use serde::{Deserialize, Serialize};

#[derive(Building, Mine, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
pub struct Quarry {
  level: BuildingLevel,
  enabled: bool,
}

impl Quarry {
  pub const ID: BuildingId = BuildingId::Quarry;
  pub const MINE_ID: MineId = MineId::Quarry;

  pub const MIN_LEVEL: BuildingLevel = BuildingLevel::ZERO;
  pub const MAX_LEVEL: BuildingLevel = BuildingLevel::new(30);

  pub const MIN_COST: Cost = Cost::new(100);
  pub const MAX_COST: Cost = Cost::new(72_000);

  pub const FOOD_RATIO: ResourceRatio = ResourceRatio::new(0.0);
  pub const IRON_RATIO: ResourceRatio = ResourceRatio::new(0.35);
  pub const STONE_RATIO: ResourceRatio = ResourceRatio::new(0.2);
  pub const WOOD_RATIO: ResourceRatio = ResourceRatio::new(0.45);

  pub const MAINTENANCE_RATIO: MaintenanceRatio = MaintenanceRatio::new(0.005);

  pub const MIN_WORKFORCE: Workforce = Workforce::new(1);
  pub const MAX_WORKFORCE: Workforce = Workforce::new(150);

  pub const MIN_PRODUCTION: MineProduction = MineProduction::new(250);
  pub const MAX_PRODUCTION: MineProduction = MineProduction::new(2_400);

  pub const MIN_SCORE: Score = Score::new(6);
  pub const MAX_SCORE: Score = Score::new(1_187);

  pub const INFRASTRUCTURE_REQUIREMENTS: InfrastructureRequirements =
    InfrastructureRequirements::none();
}

impl const Default for Quarry {
  fn default() -> Self {
    Self {
      level: BuildingLevel::new(1),
      enabled: true,
    }
  }
}

check_total_resource_ratio!(
  Quarry::FOOD_RATIO,
  Quarry::IRON_RATIO,
  Quarry::STONE_RATIO,
  Quarry::WOOD_RATIO
);