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
|
||||
(java.util Date))
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[clojure.tools.logging :refer [info warn error]]
|
||||
[schema.core :as s])
|
||||
(:use
|
||||
|
@ -19,8 +20,9 @@
|
|||
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."
|
||||
[encounter :- Encounter
|
||||
entity-name :- s/Str
|
||||
entity-name :- (s/maybe s/Str)
|
||||
timestamp :- Date]
|
||||
(if-not (string/blank? entity-name)
|
||||
(if-not (get-in encounter [:entities entity-name])
|
||||
(assoc-in encounter [:entities entity-name]
|
||||
{:name entity-name
|
||||
|
@ -33,10 +35,12 @@
|
|||
:skill-uses {}
|
||||
:alive-dps 0
|
||||
:encounter-dps 0
|
||||
:resources {}
|
||||
:deaths []
|
||||
:resurrections []
|
||||
:alive-duration 0})
|
||||
(assoc-in encounter [:entities entity-name :last-activity-at] timestamp)))
|
||||
(assoc-in encounter [:entities entity-name :last-activity-at] timestamp))
|
||||
entity-name))
|
||||
|
||||
(s/defn get-entity-last-activity :- (s/maybe Date)
|
||||
[entity-name :- s/Str
|
||||
|
|
Reference in a new issue