nil-core 0.4.14

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

use derive_more::{Deref, Into};
use serde::{Deserialize, Serialize};
use std::ops::Mul;

#[derive(Clone, Copy, Debug, Deref, Into, Deserialize, Serialize, nil_num::F64Ops)]
pub struct RangedDebuff(f64);

impl RangedDebuff {
  pub const MIN: RangedDebuff = RangedDebuff(0.0);

  #[inline]
  pub const fn new(value: f64) -> Self {
    debug_assert!(value.is_finite());
    Self(value.max(Self::MIN.0))
  }
}

impl Mul<u32> for RangedDebuff {
  type Output = f64;

  fn mul(self, rhs: u32) -> Self::Output {
    self.0 * f64::from(rhs)
  }
}