@@ -43,6 +43,7 @@ pub fn get_db_dir() -> Option<&'static PathBuf> {
4343pub enum GoalMetric {
4444 Networth ,
4545 Kills ,
46+ Deaths ,
4647 LastHits ,
4748 Denies ,
4849 Level ,
@@ -55,6 +56,7 @@ impl GoalMetric {
5556 match self {
5657 GoalMetric :: Networth => "networth" ,
5758 GoalMetric :: Kills => "kills" ,
59+ GoalMetric :: Deaths => "deaths" ,
5860 GoalMetric :: LastHits => "last_hits" ,
5961 GoalMetric :: Denies => "denies" ,
6062 GoalMetric :: Level => "level" ,
@@ -67,6 +69,7 @@ impl GoalMetric {
6769 match s {
6870 "networth" => Some ( GoalMetric :: Networth ) ,
6971 "kills" => Some ( GoalMetric :: Kills ) ,
72+ "deaths" => Some ( GoalMetric :: Deaths ) ,
7073 "last_hits" => Some ( GoalMetric :: LastHits ) ,
7174 "denies" => Some ( GoalMetric :: Denies ) ,
7275 "level" => Some ( GoalMetric :: Level ) ,
@@ -1034,6 +1037,15 @@ pub fn evaluate_goal(conn: &Connection, goal: &Goal, match_data: &Match) -> Opti
10341037 ( ( match_data. kills as f32 / duration_minutes as f32 ) * target_minutes as f32 ) as i32
10351038 }
10361039 }
1040+ GoalMetric :: Deaths => {
1041+ // For deaths, assume linear progression (same as kills)
1042+ if duration_minutes <= target_minutes {
1043+ match_data. deaths
1044+ } else {
1045+ // Estimate deaths at target time
1046+ ( ( match_data. deaths as f32 / duration_minutes as f32 ) * target_minutes as f32 ) as i32
1047+ }
1048+ }
10371049 GoalMetric :: LastHits => {
10381050 // ONLY use exact per-minute CS data from OpenDota - never estimate
10391051 // Linear estimation (total_cs / game_time * target_time) is completely inaccurate
@@ -1101,10 +1113,8 @@ pub fn evaluate_goal(conn: &Connection, goal: &Goal, match_data: &Match) -> Opti
11011113 } ;
11021114
11031115 let achieved = match & goal. metric {
1104- GoalMetric :: ItemTiming => {
1105- // For item timing, actual_value is purchase time in seconds
1106- // target_value is target time in seconds
1107- // Achieved if purchased before or at target time
1116+ GoalMetric :: ItemTiming | GoalMetric :: Deaths => {
1117+ // Lower is better: achieved if actual <= target
11081118 actual_value <= goal. target_value
11091119 }
11101120 _ => {
@@ -1573,6 +1583,13 @@ pub fn get_goal_match_data(conn: &Connection, goal_id: i64) -> Result<Vec<MatchD
15731583 ( ( match_data. kills as f32 / duration_minutes as f32 ) * target_minutes as f32 ) as i32
15741584 }
15751585 }
1586+ GoalMetric :: Deaths => {
1587+ if duration_minutes <= target_minutes {
1588+ match_data. deaths
1589+ } else {
1590+ ( ( match_data. deaths as f32 / duration_minutes as f32 ) * target_minutes as f32 ) as i32
1591+ }
1592+ }
15761593 GoalMetric :: LastHits => {
15771594 match cs_map. get ( & match_data. match_id ) {
15781595 Some ( & ( lh, _) ) => lh,
@@ -1611,7 +1628,7 @@ pub fn get_goal_match_data(conn: &Connection, goal_id: i64) -> Result<Vec<MatchD
16111628 } ;
16121629
16131630 let achieved = match & goal. metric {
1614- GoalMetric :: ItemTiming => actual_value <= goal. target_value ,
1631+ GoalMetric :: ItemTiming | GoalMetric :: Deaths => actual_value <= goal. target_value ,
16151632 _ => actual_value >= goal. target_value ,
16161633 } ;
16171634
0 commit comments