wolfrpg_map_parser/command/chip_management_command/
options.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
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
#[cfg(feature = "serde")]
use serde::Serialize;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Options {
    no_down: bool,
    no_left: bool,
    no_right: bool,
    no_up: bool,
    above_hero: bool,
    half_transparent: bool,
    counter: bool,
    match_lower_layer: bool,
}

impl Options {
    pub fn new(options: u32) -> Self {
        Self {
            no_down:            options & 0b00000001 != 0,
            no_left:            options & 0b00000010 != 0,
            no_right:           options & 0b00000100 != 0,
            no_up:              options & 0b00001000 != 0,
            above_hero:         options & 0b00010000 != 0,
            half_transparent:   options & 0b01000000 != 0,
            counter:            options & 0b10000000 != 0,

            match_lower_layer:  (options >> 8) & 0b00000010 != 0,
        }
    }

    pub fn no_down(&self) -> bool {
        self.no_down
    }
    
    pub fn no_down_mut(&mut self) -> &mut bool {
        &mut self.no_down
    }

    pub fn no_left(&self) -> bool {
        self.no_left
    }
    
    pub fn no_left_mut(&mut self) -> &mut bool {
        &mut self.no_left
    }

    pub fn no_right(&self) -> bool {
        self.no_right
    }
    
    pub fn no_right_mut(&mut self) -> &mut bool {
        &mut self.no_right
    }

    pub fn no_up(&self) -> bool {
        self.no_up
    }
    
    pub fn no_up_mut(&mut self) -> &mut bool {
        &mut self.no_up
    }

    pub fn above_hero(&self) -> bool {
        self.above_hero
    }
    
    pub fn above_hero_mut(&mut self) -> &mut bool {
        &mut self.above_hero
    }

    pub fn half_transparent(&self) -> bool {
        self.half_transparent
    }
    
    pub fn half_transparent_mut(&mut self) -> &mut bool {
        &mut self.half_transparent
    }

    pub fn counter(&self) -> bool {
        self.counter
    }
    
    pub fn counter_mut(&mut self) -> &mut bool {
        &mut self.counter
    }

    pub fn match_lower_layer(&self) -> bool {
        self.match_lower_layer
    }
    
    pub fn match_lower_layer_mut(&mut self) -> &mut bool {
        &mut self.match_lower_layer
    }
}