 ;; character sprite functions
 ;;
 
-(defn- displaycharactersprite [renderstate character]
-  ;; create sprite if needed
-  (let [spritemap (:spritemap renderstate)
+(defn- displaycharactermapsprite [renderstate character]
+  (let [spritemap (:mapsprites renderstate)
         charactersprite (get spritemap (:uniqueid character))
         newx (* tilespacing (:x character))
         newy (* tilespacing (:y character))
         characterstage (:stage-characters renderstate)]
+    ;;(js/console.log (clj->js spritemap))
+    ;;(js/console.log (clj->js character))
     (positionsprite charactersprite newx newy)
     (makestandardsizeandorigin charactersprite)
     (.addChild characterstage charactersprite)))

  (let [stage (:stage @displayed-renderstate)
        tilemap (createeaseljscontainer "tilemap" 100 100)
        characters (createeaseljscontainer "characters" 100 100)
        leftRoster (createcharacterroster "leftRoster" 0 100)
        rightRoster (createcharacterroster "rightRoster" 500 100)]
    (.removeAllChildren stage)
    (.addChild stage tilemap)
    (.addChild stage characters)

;; left/right GUI functions
;;

(defn- displaycharacterrostersprite [roster character x y]
  )

(defn rebuildrosterdisplaylist [gamestate rosterteam]
  (let [roster (get (:rostermap @displayed-renderstate) rosterteam)
        allcharacters (vals (:characters gamestate))
        teamcharacters (filter #(= (:team %1) rosterteam) allcharacters)
        orderedteamcharacters (sort-by :uniqueid teamcharacters)
        rostersize (count teamcharacters)]
    (.removeAllChildren roster)
    (syncsprites! :team1rostersprites allcharacters)
    (let [renderstate @displayed-renderstate
          rostersprites (:team1rostersprites renderstate)]
      (doseq [characterindex (range rostersize)
              character (get orderedteamcharacters characterindex)
              drawx 0
              drawy (* tilespacing characterindex)]
        (displaycharacterrostersprite roster character drawx drawy)))))


;;
;; initialization functions
