track simple resource gain/loss stats

This commit is contained in:
Gered 2016-04-06 16:38:29 -04:00
parent 418d9c67e2
commit cc7da2b612
3 changed files with 69 additions and 23 deletions

View file

@ -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."

View file

@ -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

View file

@ -101,3 +101,6 @@
; TODO
(def HealProperties
{s/Any s/Any})
(def ResourceChangeProperties
{s/Any s/Any})