001  (ns cc.journeyman.the-great-game.holdings.holding
002    (:require [cc.journeyman.the-great-game.agent.agent :refer [ProtoAgent]]
003              [cc.journeyman.the-great-game.objects.container :refer [ProtoContainer]]
004              [cc.journeyman.the-great-game.objects.game-object :refer [ProtoObject]]
005  ;;            [cc.journeyman.the-great-game.location.location :refer [OrientedLocation]]
006              [cc.journeyman.the-great-game.world.routes :refer []]))
007  
008  ;;; A holding is a polygonal area of the map which does not
009  ;;; intersect with any other holding, or with any road or water feature. For 
010  ;;; the time being we'll make the 
011  ;;; simplifying assumption that every holding is a rectangular strip, and that
012  ;;; 'urban' holdings are of a reasonably standard width (see Viking-period 
013  ;;; York) and length. Rural holdings (farms, ?wood lots) may be much larger.
014  
015  (defprotocol ProtoHolding
016    (frontage
017      [holding]
018      "Returns a sequence of two locations representing the edge of the polygon
019      which defines this holding which is considered to be the front.")
020    (building-origin
021      [holding]
022      "Returns an oriented location - normally the right hand end of the 
023      frontage, for an urban holding - from which buildings on the holding
024      should be built."))
025  
026  (defrecord Holding [perimeter holder]
027    ;; Perimeter should be a list of locations in exactly the same sense as a
028    ;; route in `cc.journeyman.the-great-game.world.routes`. Some sanity checking
029    ;; is needed to ensure this!
030    ProtoContainer
031    ProtoHolding
032    (frontage 
033      [holding]
034     "TODO: this is WRONG, but will work for now. The frontage should
035      be the side of the perimeter nearest to the nearest existing 
036      route."
037      [(first (perimeter holding)) (nth (perimeter holding) 1)])
038    (building-origin 
039     [holding]
040     "TODO: again this is WRONG. The default building origin for rectangular 
041      buildings should be the right hand end of the frontage when viewed
042      from outside the holding. But that's not general; celtic-style circular
043      buildings should normally be in the centre of their holdings. So probably
044      building-origin becomes a method of building-family rather than of holding."
045     (first (frontage holding)))
046    ProtoObject)