wolfrpg_map_parser/command/number_condition_command/
operator.rs

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
#[cfg(feature = "serde")]
use serde::Serialize;
use crate::common::compare_operator::CompareOperator;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Operator {
    operator: CompareOperator,
    not_variable: bool,
}

impl Operator {
    pub fn new(operator: u8) -> Self {
        Self {
            operator: CompareOperator::new(operator & 0x0f),
            not_variable: operator & 0b00010000 != 0,
        }
    }

    pub fn operator(&self) -> &CompareOperator {
        &self.operator
    }

    pub fn operator_mut(&mut self) -> &mut CompareOperator {
        &mut self.operator
    }

    pub fn not_variable(&self) -> bool {
        self.not_variable
    }

    pub fn not_variable_mut(&mut self) -> &mut bool {
        &mut self.not_variable
    }
}