228 lines
14 KiB
HTML
228 lines
14 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link rel="stylesheet" href="../../../../coverage.css"/> <title> cc/journeyman/the_great_game/gossip/gossip.clj </title>
|
|
</head>
|
|
<body>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
001 (ns cc.journeyman.the-great-game.gossip.gossip
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
002 "Interchange of news events between gossip agents.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
003
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
004 Note that habitual travellers are all gossip agents; specifically, at this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
005 stage, that means merchants. When merchants are moved we also need to
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
006 update the location of the gossip with the same key.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
007
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
008 Innkeepers are also gossip agents but do not typically move."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
009 (:require [cc.journeyman.the-great-game.utils :refer [deep-merge]]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
010 [cc.journeyman.the-great-game.gossip.news-items :refer [learn-news-item]]
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
011 ))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
012
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
013
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
014 (defn dialogue
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
015 "Dialogue between an `enquirer` and an `agent` in this `world`; returns a
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
016 map identical to `enquirer` except that its `:gossip` collection may have
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
017 additional entries."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
018 ;; TODO: not yet written, this is a stub.
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
019 [enquirer respondent world]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
020 enquirer)
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
021
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
022 (defn gather-news
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
023 "Gather news for the specified `gossip` in this `world`."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
024 [world gossip]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 7 forms covered">
|
|
025 (let [g (cond (keyword? gossip)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
026 (-> world :gossips gossip)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
027 (map? gossip)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
028 gossip)]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
029 (if g
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
030 {:gossips
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
031 {(:id g)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
032 (reduce
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
033 deep-merge
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
034 {}
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
035 (map
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
036 #(dialogue g % world)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
037 (remove
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
038 #(= g %)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
039 (filter
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 7 forms covered">
|
|
040 #(= (:location %) (:location g))
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
041 (vals (:gossips world))))))}}
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
042 {})))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
043
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
044 (defn move-gossip
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
045 "Return a world like this `world` but with this `gossip` moved to this
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
046 `new-location`. Many gossips are essentially shadow-records of agents of
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
047 other types, and the movement of the gossip should be controlled by the
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
048 run function of the type of the record they shadow. The [[#run]] function
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
049 below does NOT call this function."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
050 [gossip world new-location]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
051 (let [id (cond
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
052 (map? gossip)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 7 forms covered">
|
|
053 (-> world :gossips gossip :id)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
054 (keyword? gossip)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
055 gossip)]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
056 (deep-merge
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
057 world
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
058 {:gossips
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
059 {id
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
060 {:location new-location}}})))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
061
|
|
</span><br/>
|
|
<span class="covered" title="1 out of 1 forms covered">
|
|
062 (defn run
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
063 "Return a world like this `world`, with news items exchanged between gossip
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
064 agents."
|
|
</span><br/>
|
|
<span class="not-tracked" title="0 out of 0 forms covered">
|
|
065 [world]
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 2 forms covered">
|
|
066 (reduce
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
067 deep-merge
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 1 forms covered">
|
|
068 world
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 3 forms covered">
|
|
069 (map
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 4 forms covered">
|
|
070 #(gather-news world %)
|
|
</span><br/>
|
|
<span class="not-covered" title="0 out of 5 forms covered">
|
|
071 (keys (:gossips world)))))
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
072
|
|
</span><br/>
|
|
<span class="blank" title="0 out of 0 forms covered">
|
|
073
|
|
</span><br/>
|
|
</body>
|
|
</html>
|