diff --git a/vwowrla.core/src/vwowrla/core/encounters/analysis.clj b/vwowrla.core/src/vwowrla/core/encounters/analysis.clj index c859c9a..eff6ddb 100644 --- a/vwowrla.core/src/vwowrla/core/encounters/analysis.clj +++ b/vwowrla.core/src/vwowrla/core/encounters/analysis.clj @@ -316,6 +316,21 @@ (update-in [:healing type skill] #(update-healing-statistics % heal-properties)) (update-in [:healing k] #(update-healing-statistics % heal-properties))))) +;; resource gains/losses (not health... so no damage/healing in these) + +(s/defn update-resource-change-stats :- Encounter + [encounter :- Encounter + source-entity-name :- s/Str + target-entity-name :- s/Str + {:keys [skill amount resource-type gained?] + :as resource-change-properties} :- ResourceChangeProperties + timestamp :- Date] + (let [gained-or-lost (if gained? :gained :lost)] + (-> encounter + (update-entity-field target-entity-name [:resources resource-type gained-or-lost :total] #(if amount (+ (or % 0) amount) %)) + (update-entity-field target-entity-name [:resources resource-type gained-or-lost skill] #(if amount (+ (or % 0) amount) %)) + (update-entity-field target-entity-name [:resource-changes resource-type gained-or-lost skill] #(conj % {:timestamp timestamp :source source-entity-name :amount amount}))))) + ;; other casts/abilities (non-damage/healing) (s/defn check-for-resurrection :- Encounter @@ -405,6 +420,18 @@ (update-skill-use-count entity-name nil skill-name timestamp) (check-for-resurrection entity-name entity-name skill-name timestamp))) +(s/defn process-resource-change :- Encounter + [source-name :- s/Str + target-name :- s/Str + {:keys [skill] + :as resource-change-properties} :- ResourceChangeProperties + timestamp :- Date + encounter :- Encounter] + (-> encounter + (touch-entity source-name timestamp) + (touch-entity target-name timestamp) + (update-resource-change-stats source-name target-name resource-change-properties timestamp))) + (s/defn begin-encounter :- RaidAnalysis "sets up a new active encounter in the parsed data, returning the new parsed data set ready to use for parsing a new encounter." diff --git a/vwowrla.core/src/vwowrla/core/events/handlers.clj b/vwowrla.core/src/vwowrla/core/events/handlers.clj index cf30c7a..3c62962 100644 --- a/vwowrla.core/src/vwowrla/core/events/handlers.clj +++ b/vwowrla.core/src/vwowrla/core/events/handlers.clj @@ -135,33 +135,49 @@ (s/defmethod handle-event :resource-gained :- Encounter [{:keys [target-name amount resource-type source-name skill timestamp]} :- CombatEvent encounter :- Encounter] - (condp = resource-type - :health (analysis/process-source-to-target-healing - source-name - target-name - {:skill skill - ;:actual-skill? true ; TODO: this is not always true. e.g. if a potion is used (how to determine this?) - :amount amount - :crit? false} - timestamp - encounter) - encounter)) + (if (= resource-type :health) + (analysis/process-source-to-target-healing + source-name + target-name + {:skill skill + ;:actual-skill? true ; TODO: this is not always true. e.g. if a potion is used (how to determine this?) + :amount amount + :crit? false} + timestamp + encounter) + (analysis/process-resource-change + source-name + target-name + {:skill skill + :amount amount + :resource-type resource-type + :gained? true} + timestamp + encounter))) (s/defmethod handle-event :resource-lost :- Encounter [{:keys [target-name amount resource-type source-name skill timestamp]} :- CombatEvent encounter :- Encounter] - (condp = resource-type - :health (analysis/process-source-to-target-damage - source-name - target-name - {:skill skill - :actual-skill? true - :damage amount - :damage-type :physical - :crit? false} - timestamp - encounter) - encounter)) + (if (= resource-type :health) + (analysis/process-source-to-target-damage + source-name + target-name + {:skill skill + :actual-skill? true + :damage amount + :damage-type :physical + :crit? false} + timestamp + encounter) + (analysis/process-resource-change + source-name + target-name + {:skill skill + :amount amount + :resource-type resource-type + :gained? false} + timestamp + encounter))) (s/defmethod handle-event :special-gained :- Encounter [{:keys [target-name special source timestamp]} :- CombatEvent diff --git a/vwowrla.core/src/vwowrla/core/schemas.clj b/vwowrla.core/src/vwowrla/core/schemas.clj index ad533f3..38a77ac 100644 --- a/vwowrla.core/src/vwowrla/core/schemas.clj +++ b/vwowrla.core/src/vwowrla/core/schemas.clj @@ -101,3 +101,6 @@ ; TODO (def HealProperties {s/Any s/Any}) + +(def ResourceChangeProperties + {s/Any s/Any})