Time in game

This commit is contained in:
Wiktor Mazur
2019-12-16 20:40:12 +01:00
parent 97e8a2635b
commit 7e6644ad9a
6 changed files with 60 additions and 36 deletions
+13 -4
View File
@@ -131,21 +131,30 @@ impl <'source> FromPyObject<'source> for StatType {
}
pub fn stats(py: Python, stat_type: StatType) -> PyResult<PyList> {
pub fn stats(py: Python, stat_type: StatType) -> PyResult<PyDict> {
let stats = PyDict::new(py);
if let Ok(ref mut py_meter) = METER.lock() {
if let Some(m) = py_meter.get() {
if let Ok(ref mut meter) = m.lock() {
return Ok(core::stats(&meter, stat_type)
let mut main : Option<core::PlayerStatistics> = None;
stats.set_item(py, "players", core::stats(&meter, stat_type)
.into_iter()
.inspect(|s| {
if s.main_player_stats {
main = Some(s.clone());
}
})
.filter(|s| !s.idle || s.fame != 0.0)
.collect::<Vec<meter::PlayerStatistics>>()
.into_py_object(py))
.into_py_object(py)).ok();
stats.set_item(py, "main", main.into_py_object(py)).ok();
return Ok(stats);
}
}
}
error!("Failed to acquire locks on meter");
Ok(PyList::new(py, Vec::<PyObject>::new().as_slice()))
Ok(stats)
}
pub fn reset(_py: Python, stat_type: StatType) -> PyResult<u32> {