# the_great_game/world/run.clj

001 (ns the-great-game.world.run
002 "Run the whole simulation"
003 (:require [environ.core :refer [env]]
004 [taoensso.timbre :as timbre]
005 [taoensso.timbre.appenders.3rd-party.rotor :as rotor]
006 [the-great-game.gossip.gossip :as g]
007 [the-great-game.merchants.merchants :as m]
008 [the-great-game.merchants.markets :as k]
009 [the-great-game.world.world :as w]))
010
011 (defn init
012 ([]
013 (init {}))
014 ([config]
015 (timbre/merge-config!
016 {:appenders
017 {:rotor (rotor/rotor-appender
018 {:path "the-great-game.log"
019 :max-size (* 512 1024)
020 :backlog 10})}
021 :level (or
022 (:log-level config)
023 (if (env :dev) :debug)
024 :info)})))
025
026 (defn run
027 "The pipeline to run the simulation each game day. Returns a world like
028 this world, with all the various active elements updated. The optional
029 `date` argument, if supplied, is set as the `:date` of the returned world."
030 ([world]
031 (g/run
032 (m/run
033 (k/run
034 (w/run world)))))
035 ([world date]
036 (g/run
037 (m/run
038 (k/run
039 (w/run world date))))))