luminol_data/rmxp/
troop.rs

1// Copyright (C) 2024 Melody Madeline Lyons
2//
3// This file is part of Luminol.
4//
5// Luminol is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Luminol is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Luminol.  If not, see <http://www.gnu.org/licenses/>.
17use crate::{id_alox, id_serde, optional_id_alox, optional_id_serde, rpg::EventCommand};
18
19#[derive(Default, Debug, serde::Deserialize, serde::Serialize)]
20#[derive(alox_48::Deserialize, alox_48::Serialize)]
21#[marshal(class = "RPG::Troop")]
22pub struct Troop {
23    #[serde(with = "id_serde")]
24    #[marshal(with = "id_alox")]
25    pub id: usize,
26    pub name: String,
27    pub members: Vec<Member>,
28    pub pages: Vec<Page>,
29}
30
31#[derive(Default, Debug, serde::Deserialize, serde::Serialize)]
32#[derive(alox_48::Deserialize, alox_48::Serialize)]
33#[marshal(class = "RPG::Troop::Member")]
34pub struct Member {
35    #[serde(with = "id_serde")]
36    #[marshal(with = "id_alox")]
37    pub enemy_id: usize,
38    pub x: i32,
39    pub y: i32,
40    pub hidden: bool,
41    pub immortal: bool,
42}
43
44#[derive(Default, Debug, serde::Deserialize, serde::Serialize)]
45#[derive(alox_48::Deserialize, alox_48::Serialize)]
46#[marshal(class = "RPG::Troop::Page")]
47pub struct Page {
48    pub condition: Condition,
49    pub span: i32,
50    pub list: Vec<EventCommand>,
51}
52
53#[derive(Default, Debug, serde::Deserialize, serde::Serialize)]
54#[derive(alox_48::Deserialize, alox_48::Serialize)]
55#[marshal(class = "RPG::Troop::Page::Condition")]
56pub struct Condition {
57    pub turn_valid: bool,
58    pub enemy_valid: bool,
59    pub actor_valid: bool,
60    pub switch_valid: bool,
61    pub turn_a: i32,
62    pub turn_b: i32,
63    pub enemy_index: usize,
64    pub enemy_hp: i32,
65    #[serde(with = "optional_id_serde")]
66    #[marshal(with = "optional_id_alox")]
67    pub actor_id: Option<usize>,
68    pub actor_hp: i32,
69    #[serde(with = "optional_id_serde")]
70    #[marshal(with = "optional_id_alox")]
71    pub switch_id: Option<usize>,
72}