mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Account for no duration being possible
This commit is contained in:
parent
ffd0c01bbd
commit
a7c30b6721
@ -94,33 +94,63 @@ fn consumable_desc(maybe_effects: Option<&Vec<Effect>>, desc: &str) -> String {
|
|||||||
for effect in effects {
|
for effect in effects {
|
||||||
if let Effect::Buff(buff) = effect {
|
if let Effect::Buff(buff) = effect {
|
||||||
let strength = buff.data.strength * 0.1;
|
let strength = buff.data.strength * 0.1;
|
||||||
let dur_secs = buff.data.duration.unwrap().as_secs_f32();
|
let dur_secs = match buff.data.duration {
|
||||||
let str_total = strength * dur_secs;
|
Some(dur_secs) => dur_secs.as_secs_f32(),
|
||||||
|
None => 0.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
let str_total = {
|
||||||
|
if dur_secs > 0.0 {
|
||||||
|
strength * dur_secs
|
||||||
|
} else {
|
||||||
|
strength
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let buff_desc = match buff.kind {
|
let buff_desc = match buff.kind {
|
||||||
BuffKind::Saturation { .. } | BuffKind::Regeneration { .. } => {
|
BuffKind::Saturation { .. }
|
||||||
format!("Restores {} Health over {} seconds", str_total, dur_secs)
|
| BuffKind::Regeneration { .. }
|
||||||
},
|
| BuffKind::Potion { .. } => {
|
||||||
BuffKind::Potion { .. } => {
|
|
||||||
format!("Restores {} Health", str_total)
|
format!("Restores {} Health", str_total)
|
||||||
},
|
},
|
||||||
BuffKind::IncreaseMaxEnergy { .. } => {
|
BuffKind::IncreaseMaxEnergy { .. } => {
|
||||||
format!(
|
format!("Raises Maximum Stamina by {}", strength)
|
||||||
"Raises Maximum Stamina by {} for {} seconds",
|
|
||||||
strength, dur_secs
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
BuffKind::IncreaseMaxHealth { .. } => {
|
BuffKind::IncreaseMaxHealth { .. } => {
|
||||||
format!(
|
format!("Raises Maximum Health by {}", strength)
|
||||||
"Raises Maximum Health by {} for {} seconds",
|
|
||||||
strength, dur_secs
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
_ => String::new(),
|
_ => String::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if !buff_desc.is_empty() {
|
if buff_desc.is_empty() {
|
||||||
write!(&mut description, "\n\n{}", buff_desc).unwrap();
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
write!(&mut description, "\n\n{}", buff_desc).unwrap();
|
||||||
|
|
||||||
|
// The Potion buff has no real duration
|
||||||
|
if let BuffKind::Potion { .. } = buff.kind {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let dur_desc = {
|
||||||
|
if dur_secs > 0.0 {
|
||||||
|
match buff.kind {
|
||||||
|
BuffKind::Saturation { .. } | BuffKind::Regeneration { .. } => {
|
||||||
|
format!("over {} seconds", dur_secs)
|
||||||
|
},
|
||||||
|
BuffKind::IncreaseMaxEnergy | BuffKind::IncreaseMaxHealth { .. } => {
|
||||||
|
format!("for {} seconds", dur_secs)
|
||||||
|
},
|
||||||
|
_ => String::new(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
"every second".to_string()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if !dur_desc.is_empty() {
|
||||||
|
write!(&mut description, " {}", dur_desc).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user