This commit is contained in:
Robin Appelman 2021-08-08 15:49:13 +02:00
commit eba1c81126
4 changed files with 23 additions and 10 deletions

View file

@ -2,6 +2,7 @@ use crate::raw_event::RawSubject;
use enum_iterator::IntoEnumIterator;
use serde::ser::SerializeMap;
use serde::{Serialize, Serializer};
use std::cmp::Ordering;
use std::convert::TryFrom;
use std::fmt::{Display, Formatter};
use std::ops::{Index, IndexMut};
@ -249,6 +250,18 @@ impl TryFrom<&RawSubject<'_>> for SubjectData {
#[derive(Debug, Hash, Eq, PartialEq)]
pub struct SteamId3(pub SteamID);
impl PartialOrd<Self> for SteamId3 {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
(u64::from(self.0)).partial_cmp(&u64::from(other.0))
}
}
impl Ord for SteamId3 {
fn cmp(&self, other: &Self) -> Ordering {
(u64::from(self.0)).cmp(&u64::from(other.0))
}
}
impl From<SteamID> for SteamId3 {
fn from(id: SteamID) -> Self {
SteamId3(id)

View file

@ -4,7 +4,7 @@ use crate::module::EventHandler;
use crate::raw_event::{RawEventType, RawSubject};
use crate::SubjectMap;
use serde::Serialize;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::ops::{Add, AddAssign};
#[derive(Debug, Serialize, Default, PartialEq)]
@ -40,8 +40,8 @@ impl AddAssign for ClassStat {
#[derive(Default)]
pub struct ClassStatsHandler {
active: bool,
classes: HashMap<SubjectId, Class>,
stats: HashMap<SteamId3, ClassMap<ClassStat>>,
classes: BTreeMap<SubjectId, Class>,
stats: BTreeMap<SteamId3, ClassMap<ClassStat>>,
}
impl ClassStatsHandler {
@ -65,7 +65,7 @@ impl ClassStatsHandler {
}
impl EventHandler for ClassStatsHandler {
type Output = HashMap<SteamId3, ClassMap<ClassStat>>;
type Output = BTreeMap<SteamId3, ClassMap<ClassStat>>;
fn does_handle(&self, ty: RawEventType) -> bool {
matches!(

View file

@ -3,14 +3,14 @@ use crate::event::GameEvent;
use crate::module::EventHandler;
use crate::raw_event::RawEventType;
use crate::SubjectMap;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::convert::TryFrom;
#[derive(Default)]
pub struct HealSpreadHandler(HashMap<SteamId3, HashMap<SteamId3, u32>>);
pub struct HealSpreadHandler(BTreeMap<SteamId3, BTreeMap<SteamId3, u32>>);
impl EventHandler for HealSpreadHandler {
type Output = HashMap<SteamId3, HashMap<SteamId3, u32>>;
type Output = BTreeMap<SteamId3, BTreeMap<SteamId3, u32>>;
fn does_handle(&self, ty: RawEventType) -> bool {
matches!(ty, RawEventType::Healed)

View file

@ -4,7 +4,7 @@ use crate::module::EventHandler;
use crate::raw_event::RawEventType;
use crate::SubjectMap;
use serde::Serialize;
use std::collections::HashMap;
use std::collections::BTreeMap;
use thiserror::Error;
#[derive(Default)]
@ -62,10 +62,10 @@ impl From<MedicStatsBuilder> for MedicStats {
pub struct InvalidMedicEvent(String);
#[derive(Default)]
pub struct MedicStatsHandler(HashMap<SteamId3, MedicStatsBuilder>);
pub struct MedicStatsHandler(BTreeMap<SteamId3, MedicStatsBuilder>);
impl EventHandler for MedicStatsHandler {
type Output = HashMap<SteamId3, MedicStats>;
type Output = BTreeMap<SteamId3, MedicStats>;
fn does_handle(&self, ty: RawEventType) -> bool {
matches!(