firecore_battle/
message.rs1use core::fmt::Debug;
2use serde::{Deserialize, Serialize};
3
4use pokedex::{moves::MoveId, pokemon::owned::SavedPokemon};
5
6use crate::{
7 moves::{BattleMove, ClientMove},
8 player::ClientPlayerData,
9 pokemon::{remote::RemotePokemon, ActivePosition, Indexed, PartyPosition, PokemonIdentifier},
10};
11
12#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
13pub enum ClientMessage<ID> {
14 Move(ActivePosition, BattleMove<ID>),
15 ReplaceFaint(ActivePosition, PartyPosition),
16 Forfeit,
17 LearnMove(PartyPosition, MoveId, Option<usize>), }
19
20#[derive(Debug, Clone, Deserialize, Serialize)]
21pub enum ServerMessage<ID, T> {
22 Begin(ClientPlayerData<ID, T>),
23
24 Start(StartableAction<ID>),
25
26 Ping(TimedAction),
27 Fail(FailedAction),
28 Command(CommandAction<ID>),
29
30 AddRemote(Indexed<ID, RemotePokemon>),
31 Replace(Indexed<ID, usize>),
32
33 Catch(SavedPokemon),
34
35 PlayerEnd(ID, EndMessage),
36 GameEnd(
37 Option<ID>,
39 ),
40}
41
42#[derive(Debug, Clone, Deserialize, Serialize)]
43pub enum StartableAction<ID> {
44 Selecting,
45 Turns(Vec<Indexed<ID, ClientMove<ID>>>),
46}
47
48#[derive(Hash, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)]
49pub enum TimedAction {
50 Selecting,
51 Replace,
52}
53
54#[derive(Debug, Clone, Deserialize, Serialize)]
55pub enum CommandAction<ID> {
56 Faint(PokemonIdentifier<ID>),
58}
59
60#[derive(Debug, Clone, Deserialize, Serialize)]
61pub enum FailedAction {
62 Move(ActivePosition),
63 Switch(ActivePosition),
64 Replace(ActivePosition),
65}
66
67#[derive(Debug, Clone, Copy, Deserialize, Serialize)]
68pub enum EndMessage {
69 Lose, Run,
71 Other,
72}