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
47
48
49
50
51
52
53
54
55
56
57
58
use chrono::{DateTime, Utc};
use serde::{Serialize, Deserialize};

/// Log of damage 
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct DamageLog {
    timestamp: DateTime::<Utc>,
    damage: isize,
    other_player: String,
    other_ship: String,
    weapon: String,
    destination: Destination,
}

impl DamageLog {
    /// Builds a new DamageLog
    pub fn new(timestamp: DateTime::<Utc>, damage: isize, other_player: String, other_ship: String, weapon: String, destination: Destination) -> Self {
        DamageLog { timestamp, damage, other_player, other_ship, weapon, destination }
    } 
}


/// Log of logi reps
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct LogiLog {
    timestamp: DateTime::<Utc>,
    amount: isize,
    other_player: String,
    other_ship: String,
    rep_type: String,
    destination: Destination,
}

impl LogiLog {
    /// Builds a new [LogiLog]
    pub fn new(timestamp: DateTime::<Utc>, amount: isize, other_player: String, other_ship: String, rep_type: String, destination: Destination) -> Self {
        LogiLog { timestamp, amount, other_player, other_ship, rep_type, destination }
    }
}

/// Represents if the log is created by the player or not
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Destination {
    /// The log is received by the player
    /// (being shot at, being repped, ...)
    Receiving,
    /// The log is initiated by the player
    /// (shooting someone, repping someone, ...)
    Dealing,
}

/// General struct embedding any kind of log
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum Log {
    Damage(DamageLog), 
    Logi(LogiLog),
}