Browse Source

Merge pull request 'handle hospital visits' (#199) from hospital into master

pbs
jake 4 years ago
parent
commit
61a3f7bd30
  1. 18
      src/ship/packet/handler/message.rs
  2. 3
      src/ship/ship.rs

18
src/ship/packet/handler/message.rs

@ -309,3 +309,21 @@ where
Ok(Box::new(None.into_iter())) Ok(Box::new(None.into_iter()))
} }
pub async fn player_used_medical_center<EG>(id: ClientId,
_pumc: &PlayerUsedMedicalCenter, // not needed?
entity_gateway: &mut EG,
clients: &mut Clients)
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, ShipError>
where
EG: EntityGateway
{
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
if client.character.meseta >= 10 {
client.character.meseta -= 10;
entity_gateway.save_character(&client.character).await;
Ok(Box::new(None.into_iter()))
} else {
Err(ShipError::NotEnoughMeseta(id, client.character.meseta))
}
}

3
src/ship/ship.rs

@ -298,6 +298,9 @@ impl<EG: EntityGateway> ShipServerState<EG> {
GameMessage::PlayerUseItem(player_use_item) => { GameMessage::PlayerUseItem(player_use_item) => {
handler::message::use_item(id, player_use_item, &mut self.entity_gateway, &mut self.client_location, &mut self.clients, &mut self.item_manager).await handler::message::use_item(id, player_use_item, &mut self.entity_gateway, &mut self.client_location, &mut self.clients, &mut self.item_manager).await
}, },
GameMessage::PlayerUsedMedicalCenter(player_used_medical_center) => {
handler::message::player_used_medical_center(id, &player_used_medical_center, &mut self.entity_gateway, &mut self.clients).await
},
_ => { _ => {
let cmsg = msg.clone(); let cmsg = msg.clone();
Ok(Box::new(self.client_location.get_client_neighbors(id).unwrap().into_iter() Ok(Box::new(self.client_location.get_client_neighbors(id).unwrap().into_iter()

Loading…
Cancel
Save