rust/hedgewars-engine-messages/src/messages.rs
author unC0Rr
Wed, 14 Nov 2018 11:09:01 +0100
changeset 14230 ab1ef7074e07
child 14231 1c55c54013c4
permissions -rw-r--r--
Rearrange code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14230
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     1
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     2
pub enum KeystrokeAction {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     3
    Press,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     4
    Release,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     5
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     6
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     7
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     8
pub enum SyncedEngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
     9
    Left(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    10
    Right(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    11
    Up(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    12
    Down(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    13
    Precise(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    14
    Attack(KeystrokeAction),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    15
    NextTurn,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    16
    Switch,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    17
    Timer(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    18
    Slot(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    19
    SetWeapon(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    20
    Put(i32, i32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    21
    HighJump,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    22
    LowJump,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    23
    Skip,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    24
    TeamControlGained(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    25
    TeamControlLost(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    26
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    27
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    28
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    29
pub enum UnsyncedEngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    30
    Ping,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    31
    Pong,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    32
    Say(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    33
    Taunt(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    34
    GameType(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    35
    Warning(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    36
    StopSyncing,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    37
    GameOver,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    38
    GameInterrupted,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    39
    GameSetupChecksum(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    40
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    41
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    42
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    43
pub enum ConfigEngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    44
    ConfigRequest,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    45
    SetAmmo(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    46
    SetScript(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    47
    SetScriptParam(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    48
    Spectate,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    49
    TeamLocality(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    50
    SetMap(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    51
    SetTheme(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    52
    SetSeed(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    53
    SetTemplateFilter(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    54
    SetMapGenerator(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    55
    SetFeatureSize(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    56
    SetDelay(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    57
    SetReadyDelay(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    58
    SetCratesFrequency(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    59
    SetHealthCrateProbability(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    60
    SetHealthCratesNumber(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    61
    SetRoundsTilSuddenDeath(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    62
    SetSuddenDeathWaterRiseSpeed(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    63
    SetSuddenDeathHealthDecreaseRate(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    64
    SetDamageMultiplier(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    65
    SetRopeLength(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    66
    SetGetawayTime(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    67
    SetDudMinesPercent(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    68
    SetMinesNumber(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    69
    SetAirMinesNumber(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    70
    SetBarrelsNumber(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    71
    SetTurnTime(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    72
    SetMinesTime(u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    73
    SetWorldEdge(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    74
    Draw,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    75
    // TODO
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    76
    SetVoicePack(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    77
    AddHedgehog(String, u8, u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    78
    AddTeam(String, u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    79
    SetHedgehogCoordinates(i32, i32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    80
    SetFort(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    81
    SetGrave(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    82
    SetHat(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    83
    SetFlag(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    84
    SetOwner(String),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    85
    SetOneClanMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    86
    SetMultishootMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    87
    SetSolidLand(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    88
    SetBorders(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    89
    SetDivideTeams(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    90
    SetLowGravity(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    91
    SetLaserSight(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    92
    SetInvulnerability(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    93
    SetHealthReset(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    94
    SetVampiric(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    95
    SetKarma(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    96
    SetArtilleryMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    97
    SetHedgehogSwitch(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    98
    SetRandomOrder(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
    99
    SetKingMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   100
    SetPlaceHedgehog(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   101
    SetSharedAmmo(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   102
    SetGirdersEnabled(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   103
    SetLandObjectsEnabled(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   104
    SetAISurvivalMode(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   105
    SetInfiniteAttack(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   106
    SetResetWeapons(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   107
    SetAmmoPerHedgehog(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   108
    SetWindMode(u8),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   109
    SetTagTeam(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   110
    SetBottomBorder(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   111
    SetShoppaBorder(bool),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   112
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   113
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   114
#[derive(Debug, PartialEq)]
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   115
pub enum EngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   116
    Synced(SyncedEngineMessage, u32),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   117
    Unsynced(UnsyncedEngineMessage),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   118
    Config(ConfigEngineMessage),
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   119
    Unknown,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   120
    Empty,
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   121
}
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   122
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   123
impl EngineMessage {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   124
    fn from_bytes(buf: &[u8]) -> Self {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   125
        unimplemented!()
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   126
    }
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   127
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   128
    fn to_bytes(&self) -> Vec<u8> {
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   129
        unimplemented!()
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   130
    }
ab1ef7074e07 Rearrange code
unC0Rr
parents:
diff changeset
   131
}