1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Terminology:
//! Attack = Single projectile or strike
//! Hit = Attack that connects with the target

use noisy_float::prelude::*;
use serde::{Deserialize, Serialize};

use super::attribute::Attribute;

/// Weapon target type
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub enum WeaponTargetType {
    /// To ground only
    Ground,
    /// To air only
    Air,
    /// To ground and air both
    Any,
}

/// Weapon bonus
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct WeaponBonus {
    /// Bonus affects attacks against units having this attribute
    against: Attribute,
    /// The amount of bonus damage per hit
    damage: R32,
}

/// Weapon
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct Weapon {
    target_type: WeaponTargetType,
    /// Damage per hit, no upgrades
    damage_per_hit: R32,
    /// Percentage
    damage_splash: R32,
    /// Attacks per one attack tick, e.g. 2 for Colossus
    attacks: u32,
    /// Range
    range: R32,
    /// Cooldown
    cooldown: R32,
    /// Bonuses
    bonuses: Vec<WeaponBonus>,
}