wolfrpg_map_parser/command/string_condition_command/
operator.rs

1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::command::string_condition_command::compare_operator::CompareOperator;
4
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(PartialEq, Clone)]
7pub struct Operator {
8    value_is_variable: bool,
9    operator: CompareOperator
10}
11
12impl Operator {
13    pub fn new(operator: u8) -> Self {
14        Self {
15            value_is_variable: operator & 0b00000001 != 0,
16            operator: CompareOperator::new(operator >> 4)
17        }
18    }
19
20    pub fn value_is_variable(&self) -> bool {
21        self.value_is_variable
22    }
23
24    pub fn value_is_variable_mut(&mut self) -> &mut bool {
25        &mut self.value_is_variable
26    }
27
28    pub fn operator(&self) -> &CompareOperator {
29        &self.operator
30    }
31
32    pub fn operator_mut(&mut self) -> &mut CompareOperator {
33        &mut self.operator
34    }
35}
36