some protection against adding "nil" entities
could occur in cases where a combat event has an optional source or target entity name and the handler code calls touch-entity for both (saves us from having to check for nil)
This commit is contained in:
parent
51ae63a262
commit
30b193b463
|
@ -2,6 +2,7 @@
|
||||||
(:import
|
(:import
|
||||||
(java.util Date))
|
(java.util Date))
|
||||||
(:require
|
(:require
|
||||||
|
[clojure.string :as string]
|
||||||
[clojure.tools.logging :refer [info warn error]]
|
[clojure.tools.logging :refer [info warn error]]
|
||||||
[schema.core :as s])
|
[schema.core :as s])
|
||||||
(:use
|
(:use
|
||||||
|
@ -19,24 +20,27 @@
|
||||||
provided, or adds a new entity under the given name to the active encounter if it does not already
|
provided, or adds a new entity under the given name to the active encounter if it does not already
|
||||||
exist. returns encounter with the updated entity information."
|
exist. returns encounter with the updated entity information."
|
||||||
[encounter :- Encounter
|
[encounter :- Encounter
|
||||||
entity-name :- s/Str
|
entity-name :- (s/maybe s/Str)
|
||||||
timestamp :- Date]
|
timestamp :- Date]
|
||||||
(if-not (get-in encounter [:entities entity-name])
|
(if-not (string/blank? entity-name)
|
||||||
(assoc-in encounter [:entities entity-name]
|
(if-not (get-in encounter [:entities entity-name])
|
||||||
{:name entity-name
|
(assoc-in encounter [:entities entity-name]
|
||||||
:added-at timestamp
|
{:name entity-name
|
||||||
:last-activity-at timestamp
|
:added-at timestamp
|
||||||
:damage {:in {:total 0}
|
:last-activity-at timestamp
|
||||||
:out {:total 0}}
|
:damage {:in {:total 0}
|
||||||
:healing {:in {:total 0}
|
:out {:total 0}}
|
||||||
:out {:total 0}}
|
:healing {:in {:total 0}
|
||||||
:skill-uses {}
|
:out {:total 0}}
|
||||||
:alive-dps 0
|
:skill-uses {}
|
||||||
:encounter-dps 0
|
:alive-dps 0
|
||||||
:deaths []
|
:encounter-dps 0
|
||||||
:resurrections []
|
:resources {}
|
||||||
:alive-duration 0})
|
:deaths []
|
||||||
(assoc-in encounter [:entities entity-name :last-activity-at] timestamp)))
|
:resurrections []
|
||||||
|
:alive-duration 0})
|
||||||
|
(assoc-in encounter [:entities entity-name :last-activity-at] timestamp))
|
||||||
|
entity-name))
|
||||||
|
|
||||||
(s/defn get-entity-last-activity :- (s/maybe Date)
|
(s/defn get-entity-last-activity :- (s/maybe Date)
|
||||||
[entity-name :- s/Str
|
[entity-name :- s/Str
|
||||||
|
|
Reference in a new issue