wolfrpg_map_parser/page/
condition.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::common::compare_operator::CompareOperator;
4
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(PartialEq, Clone)]
7pub struct Condition {
8 operator: CompareOperator,
9 variable: u32,
10 value: u32,
11}
12
13impl Condition {
14 pub fn new(operator: u8, variable: u32, value: u32) -> Self {
15 Self {
16 operator: CompareOperator::new(operator >> 4),
17 variable,
18 value
19 }
20 }
21
22 pub fn operator(&self) -> &CompareOperator {
23 &self.operator
24 }
25
26 pub fn operator_mut(&mut self) -> &mut CompareOperator {
27 &mut self.operator
28 }
29
30 pub fn variable(&self) -> u32 {
31 self.variable
32 }
33
34 pub fn variable_mut(&mut self) -> &mut u32 {
35 &mut self.variable
36 }
37
38 pub fn value(&self) -> u32 {
39 self.value
40 }
41
42 pub fn value_mut(&mut self) -> &mut u32 {
43 &mut self.value
44 }
45}