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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use warframe_macros::model;
/// Represents the difficulty of a [Nightwave Challenge](NightwaveChallenge)
#[model]
pub enum NightwaveChallengeType {
/// Easy
Easy,
/// Medium
Medium,
/// Hard
Hard,
/// Unknown
Unknown,
}
/// A Nightwave challenge
#[model(timed)]
pub struct NightwaveChallenge {
/// The ID of this challenge
pub id: String,
/// Whether it is a daily mission or not
pub is_daily: bool,
/// Whether it is an elite mission or not
pub is_elite: bool,
/// The Description of this challenge (what you need to do in order to complete it)
#[serde(rename = "desc")]
pub description: String,
/// The Title of this Challenge
pub title: String,
/// The amount of reputation (aka standing) you get by completing this mission
pub reputation: i32,
/// Whether it is permanent or not
pub is_permanent: bool,
}
impl NightwaveChallenge {
/// Gets the difficulty for this challenge
#[must_use]
pub fn challenge_type(&self) -> NightwaveChallengeType {
use NightwaveChallengeType::{
Easy,
Hard,
Medium,
Unknown,
};
if self.is_permanent {
return Unknown;
}
match (self.is_daily, self.is_elite) {
(true, false) => Easy,
(false, false) => Medium,
(false, true) => Hard,
_ => Unknown,
}
}
}
/// The Current cycle and challenges of Nightwave, a battle-pass-esque rotation and challenge system
#[model(endpoint = "/nightwave", return_style = Object, timed)]
pub struct Nightwave {
/// The ID of the Nightwave
pub id: String,
/// The Season of this Nightwave
pub season: i32,
/// The Tag of this Nightwave
pub tag: String,
/// The phase of the nightwave
pub phase: i32,
/// The active challenges (most likely the weekly rotation)
pub active_challenges: Vec<NightwaveChallenge>,
}
#[cfg(test)]
mod test_nightwave {
use rstest::rstest;
use serde_json::from_str;
use super::Nightwave;
use crate::worldstate::Queryable;
type R = <Nightwave as Queryable>::Return;
#[rstest]
fn test(
#[files("src/worldstate/models/fixtures/nightwave.json")]
#[mode = str]
nightwave_en: &str,
) {
from_str::<R>(nightwave_en).unwrap();
}
}