1 use server::coretypes::{ServerVar, GameCfg, TeamInfo, HedgehogInfo}; |
1 use server::coretypes::{ |
|
2 ServerVar, GameCfg, TeamInfo, |
|
3 HedgehogInfo, VoteType |
|
4 }; |
2 use std::{ops, convert::From, iter::once}; |
5 use std::{ops, convert::From, iter::once}; |
3 |
6 |
4 #[derive(PartialEq, Eq, Clone, Debug)] |
7 #[derive(PartialEq, Eq, Clone, Debug)] |
5 pub enum HWProtocolMessage { |
8 pub enum HWProtocolMessage { |
6 // core |
9 // core |
88 TeamRemove(String), |
91 TeamRemove(String), |
89 TeamAccepted(String), |
92 TeamAccepted(String), |
90 TeamColor(String, u8), |
93 TeamColor(String, u8), |
91 HedgehogsNumber(String, u8), |
94 HedgehogsNumber(String, u8), |
92 ConfigEntry(String, Vec<String>), |
95 ConfigEntry(String, Vec<String>), |
|
96 Kicked, |
93 RunGame, |
97 RunGame, |
94 ForwardEngineMessage(Vec<String>), |
98 ForwardEngineMessage(Vec<String>), |
95 RoundFinished, |
99 RoundFinished, |
96 |
100 |
97 ServerMessage(String), |
101 ServerMessage(String), |
98 Warning(String), |
102 Warning(String), |
99 Error(String), |
103 Error(String), |
100 Connected(u32), |
104 Connected(u32), |
101 Unreachable, |
105 Unreachable, |
|
106 } |
|
107 |
|
108 pub fn server_chat(msg: &str) -> HWServerMessage { |
|
109 HWServerMessage::ChatMsg{ nick: "[server]".to_string(), msg: msg.to_string() } |
102 } |
110 } |
103 |
111 |
104 impl GameCfg { |
112 impl GameCfg { |
105 pub fn to_protocol(&self) -> (String, Vec<String>) { |
113 pub fn to_protocol(&self) -> (String, Vec<String>) { |
106 use server::coretypes::GameCfg::*; |
114 use server::coretypes::GameCfg::*; |
278 TeamAccepted(name) => msg!["TEAM_ACCEPTED", name], |
286 TeamAccepted(name) => msg!["TEAM_ACCEPTED", name], |
279 TeamColor(name, color) => msg!["TEAM_COLOR", name, color], |
287 TeamColor(name, color) => msg!["TEAM_COLOR", name, color], |
280 HedgehogsNumber(name, number) => msg!["HH_NUM", name, number], |
288 HedgehogsNumber(name, number) => msg!["HH_NUM", name, number], |
281 ConfigEntry(name, values) => |
289 ConfigEntry(name, values) => |
282 construct_message(&["CFG", name], &values), |
290 construct_message(&["CFG", name], &values), |
|
291 Kicked => msg!["KICKED"], |
283 RunGame => msg!["RUN_GAME"], |
292 RunGame => msg!["RUN_GAME"], |
284 ForwardEngineMessage(em) => |
293 ForwardEngineMessage(em) => |
285 construct_message(&["EM"], &em), |
294 construct_message(&["EM"], &em), |
286 RoundFinished => msg!["ROUND_FINISHED"], |
295 RoundFinished => msg!["ROUND_FINISHED"], |
287 ChatMsg {nick, msg} => msg!["CHAT", nick, msg], |
296 ChatMsg {nick, msg} => msg!["CHAT", nick, msg], |