track simple resource gain/loss stats
This commit is contained in:
parent
418d9c67e2
commit
cc7da2b612
|
@ -316,6 +316,21 @@
|
||||||
(update-in [:healing type skill] #(update-healing-statistics % heal-properties))
|
(update-in [:healing type skill] #(update-healing-statistics % heal-properties))
|
||||||
(update-in [:healing k] #(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)
|
;; other casts/abilities (non-damage/healing)
|
||||||
|
|
||||||
(s/defn check-for-resurrection :- Encounter
|
(s/defn check-for-resurrection :- Encounter
|
||||||
|
@ -405,6 +420,18 @@
|
||||||
(update-skill-use-count entity-name nil skill-name timestamp)
|
(update-skill-use-count entity-name nil skill-name timestamp)
|
||||||
(check-for-resurrection entity-name entity-name 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
|
(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
|
"sets up a new active encounter in the parsed data, returning the new parsed data set ready to use for
|
||||||
parsing a new encounter."
|
parsing a new encounter."
|
||||||
|
|
|
@ -135,33 +135,49 @@
|
||||||
(s/defmethod handle-event :resource-gained :- Encounter
|
(s/defmethod handle-event :resource-gained :- Encounter
|
||||||
[{:keys [target-name amount resource-type source-name skill timestamp]} :- CombatEvent
|
[{:keys [target-name amount resource-type source-name skill timestamp]} :- CombatEvent
|
||||||
encounter :- Encounter]
|
encounter :- Encounter]
|
||||||
(condp = resource-type
|
(if (= resource-type :health)
|
||||||
:health (analysis/process-source-to-target-healing
|
(analysis/process-source-to-target-healing
|
||||||
source-name
|
source-name
|
||||||
target-name
|
target-name
|
||||||
{:skill skill
|
{:skill skill
|
||||||
;:actual-skill? true ; TODO: this is not always true. e.g. if a potion is used (how to determine this?)
|
;:actual-skill? true ; TODO: this is not always true. e.g. if a potion is used (how to determine this?)
|
||||||
:amount amount
|
:amount amount
|
||||||
:crit? false}
|
:crit? false}
|
||||||
timestamp
|
timestamp
|
||||||
encounter)
|
encounter)
|
||||||
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
|
(s/defmethod handle-event :resource-lost :- Encounter
|
||||||
[{:keys [target-name amount resource-type source-name skill timestamp]} :- CombatEvent
|
[{:keys [target-name amount resource-type source-name skill timestamp]} :- CombatEvent
|
||||||
encounter :- Encounter]
|
encounter :- Encounter]
|
||||||
(condp = resource-type
|
(if (= resource-type :health)
|
||||||
:health (analysis/process-source-to-target-damage
|
(analysis/process-source-to-target-damage
|
||||||
source-name
|
source-name
|
||||||
target-name
|
target-name
|
||||||
{:skill skill
|
{:skill skill
|
||||||
:actual-skill? true
|
:actual-skill? true
|
||||||
:damage amount
|
:damage amount
|
||||||
:damage-type :physical
|
:damage-type :physical
|
||||||
:crit? false}
|
:crit? false}
|
||||||
timestamp
|
timestamp
|
||||||
encounter)
|
encounter)
|
||||||
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
|
(s/defmethod handle-event :special-gained :- Encounter
|
||||||
[{:keys [target-name special source timestamp]} :- CombatEvent
|
[{:keys [target-name special source timestamp]} :- CombatEvent
|
||||||
|
|
|
@ -101,3 +101,6 @@
|
||||||
; TODO
|
; TODO
|
||||||
(def HealProperties
|
(def HealProperties
|
||||||
{s/Any s/Any})
|
{s/Any s/Any})
|
||||||
|
|
||||||
|
(def ResourceChangeProperties
|
||||||
|
{s/Any s/Any})
|
||||||
|
|
Reference in a new issue