nil_core/report/
battle.rs1use crate::battle::BattleResult;
5use crate::continent::Coord;
6use crate::report::ReportId;
7use crate::resources::Resources;
8use crate::round::RoundId;
9use crate::ruler::Ruler;
10use bon::Builder;
11use jiff::Zoned;
12use nil_core_macros::Report;
13use serde::{Deserialize, Serialize};
14
15#[derive(Report, Builder, Clone, Debug, Deserialize, Serialize)]
16#[serde(rename_all = "camelCase")]
17#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
18pub struct BattleReport {
19 #[builder(skip = ReportId::new())]
20 id: ReportId,
21 attacker: Ruler,
22 defender: Ruler,
23 origin: Coord,
24 destination: Coord,
25 result: BattleResult,
26 hauled_resources: Resources,
27 round: RoundId,
28 #[builder(skip = Zoned::now())]
29 time: Zoned,
30}
31
32impl BattleReport {
33 #[inline]
34 pub fn attacker(&self) -> &Ruler {
35 &self.attacker
36 }
37
38 #[inline]
39 pub fn defender(&self) -> &Ruler {
40 &self.defender
41 }
42
43 #[inline]
44 pub fn result(&self) -> &BattleResult {
45 &self.result
46 }
47
48 #[inline]
49 pub fn origin(&self) -> Coord {
50 self.origin
51 }
52
53 #[inline]
54 pub fn destination(&self) -> Coord {
55 self.destination
56 }
57
58 #[inline]
59 pub fn hauled_resources(&self) -> &Resources {
60 &self.hauled_resources
61 }
62}