|
|
|
@ -3,7 +3,11 @@ use crate::{db, games::Game}; |
|
|
|
|
|
|
|
use super::{ |
|
|
|
client_id, |
|
|
|
grpc::game::{game_server, message_status::Piles, CardKind, Image, MessageStatus}, |
|
|
|
grpc::game::{ |
|
|
|
game_server, |
|
|
|
message_status::Piles, |
|
|
|
CardKind, Image, MessageStatus, |
|
|
|
}, |
|
|
|
}; |
|
|
|
pub use game_server::GameServer; |
|
|
|
use tonic::{Response, Status}; |
|
|
|
@ -144,7 +148,10 @@ impl game_server::Game for GameService { |
|
|
|
names.push((conn.get_name_for_uuid(uuid.clone()).await, *id)) |
|
|
|
} |
|
|
|
names.sort_by(|(_, a), (_, b)| a.cmp(b)); |
|
|
|
let names = names.into_iter().map(|(x, _)| super::grpc::common::Name {name: x}).collect(); |
|
|
|
let names = names |
|
|
|
.into_iter() |
|
|
|
.map(|(x, _)| super::grpc::common::Name { name: x }) |
|
|
|
.collect(); |
|
|
|
let status = MessageStatus { |
|
|
|
current_turn: game.get_current_player(), |
|
|
|
common_piles: Some(Piles { |
|
|
|
@ -169,7 +176,30 @@ impl game_server::Game for GameService { |
|
|
|
}) |
|
|
|
.collect(), |
|
|
|
}), |
|
|
|
player_piles: vec![], |
|
|
|
player_piles: game |
|
|
|
.player_piles.clone() |
|
|
|
.into_iter() |
|
|
|
.map(|piles| Piles { |
|
|
|
piles: piles |
|
|
|
.into_iter() |
|
|
|
.map(|(k, v)| { |
|
|
|
( |
|
|
|
k, |
|
|
|
super::grpc::game::message_status::Pile { |
|
|
|
cards: v |
|
|
|
.cards |
|
|
|
.into_iter() |
|
|
|
.map(|x| super::grpc::game::message_status::Card { |
|
|
|
kind: Some(CardKind {kind: x}), |
|
|
|
visible: true, |
|
|
|
}) |
|
|
|
.collect(), |
|
|
|
}, |
|
|
|
) |
|
|
|
}) |
|
|
|
.collect(), |
|
|
|
}) |
|
|
|
.collect(), |
|
|
|
names, |
|
|
|
}; |
|
|
|
Ok(Response::new(status)) |
|
|
|
|