--
-- intersection lets us get on other freeways or highways
--

node_intersection_ctor = function (self)

   self.name = "Intersection"

   -- choose our intersections
   self.changes = {}
   for i = 1, 3, 1 do

      -- terrain type can go up or down; more likely to go up depending on player's mood
      local TerrainType = cur_play:get_next_terrain ()

      -- compute the roadstream type
      local TypeWeights = { [2] = 1, [3] = 3 + TerrainType } -- as we get into the mountains, more likely to find back roads
      local Type = set_choose_weighted (TypeWeights)

      -- the intersection
      local Change = roadstream ()
      Change:init (Type, TerrainType, RN_get_seed ())
      table.insert (self.changes, Change)
   end
end

node_intersection = class (node, node_intersection_ctor)

function node_intersection:action (Action)

   local T = ""
   if (not Action) then

      T = "You pull up to a highway intersection. Mountains loom in the distance; morning is beckoning you."

   else

      local Change = self.changes[Action]
      T = "You pull onto " .. Change.name .. "."
      cur_adventure:leave (Change)
   end

   return T
end

function node_intersection:menu ()

   local TerrainDescs = {

      "back to the desert.",
      "to the prairies.",
      "into the mountains."
   }

   T = "This place feels more like home."
   M = {}
   for ID, Change in pairs (self.changes) do

      table.insert (M, { ID, Change.name .. ", " .. tostring (TerrainDescs[Change.terrain_type]) })
   end
   return T, M
end
