Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. use pleco::{Board, PieceType, Player};
  2. use std::collections::HashMap;
  3.  
  4. struct ChessServer {
  5. boards: HashMap<String, Board>,
  6. }
  7.  
  8. impl Default for ChessServer {
  9. fn default() -> ChessServer {
  10. // default room
  11. let mut boards = HashMap::new();
  12. boards.insert("Main".to_owned(), Board::start_pos());
  13.  
  14. ChessServer { boards: boards }
  15. }
  16. }
  17.  
  18. impl ChessServer {
  19. fn board_move(&self, room: &str, message: &str, id: usize) {
  20. let mut msg = String::new();
  21. if let Some(board) = self.boards.get(room) {
  22. let moves = board.generate_moves();
  23. let m = moves[0];
  24. board.apply_move(m);
  25. msg = board.fen();
  26. }
  27. // "rnbqkbnr/1ppppppp/8/p7/4P3/8/PPPPBPPP/RNBQK1NR"
  28. }
  29. }
  30.  
  31. fn main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement