mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove unwrap
Former-commit-id: 68d26e366450010d1455c7662dc283cc0e0d9380
This commit is contained in:
parent
171ca86340
commit
07b9bfe3b7
@ -218,19 +218,21 @@ impl Server {
|
||||
.map(|(entity, dying)| {
|
||||
// Chat message
|
||||
if let Some(player) = ecs.read_storage::<comp::Player>().get(entity) {
|
||||
// While waiting for if-let-chains to be implemented...
|
||||
let msg = if let comp::HealthSource::Attack { by } = dying.cause {
|
||||
if let Some(attacker) = ecs
|
||||
.read_storage::<comp::Player>()
|
||||
.get(ecs.entity_from_uid(by.into()).unwrap())
|
||||
{
|
||||
format!("{} was killed by {}", &player.alias, &attacker.alias)
|
||||
} else {
|
||||
format!("{} died", &player.alias)
|
||||
}
|
||||
ecs.entity_from_uid(by.into()).and_then(|attacker| {
|
||||
ecs.read_storage::<comp::Player>()
|
||||
.get(attacker)
|
||||
.map(|attacker_alias| {
|
||||
format!(
|
||||
"{} was killed by {}",
|
||||
&player.alias, &attacker_alias.alias
|
||||
)
|
||||
})
|
||||
})
|
||||
} else {
|
||||
format!("{} died", &player.alias)
|
||||
};
|
||||
None
|
||||
}
|
||||
.unwrap_or(format!("{} died", &player.alias));
|
||||
|
||||
clients.notify_registered(ServerMsg::Chat(msg));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user