Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use pleco::{Board, PieceType, Player};
- use std::collections::HashMap;
- struct ChessServer {
- boards: HashMap<String, Board>,
- }
- impl Default for ChessServer {
- fn default() -> ChessServer {
- // default room
- let mut boards = HashMap::new();
- boards.insert("Main".to_owned(), Board::start_pos());
- ChessServer { boards: boards }
- }
- }
- impl ChessServer {
- fn board_move(&self, room: &str, message: &str, id: usize) {
- let mut msg = String::new();
- if let Some(board) = self.boards.get(room) {
- let moves = board.generate_moves();
- let m = moves[0];
- board.apply_move(m);
- msg = board.fen();
- }
- // "rnbqkbnr/1ppppppp/8/p7/4P3/8/PPPPBPPP/RNBQK1NR"
- }
- }
- fn main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement