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

node_interchange_ctor = function (self)

   self.name = "Interchange"

   -- choose our interchanges
   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 = { [1] = 1, [2] = 3 + TerrainType } -- as we get into the mountains, more likely to find highways
      local Type = set_choose_weighted (TypeWeights)

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

node_interchange = class (node, node_interchange_ctor)

function node_interchange:action (Action)

   local T = ""
   if (not Action) then

      T = "You pull onta a complex interchange. Off-ramp signs present themselves to you in different ways://"
         .. "Some, they invite you.//"
         .. "Others, they seem to curse you.//"
         .. "All wring your heart as a sponge."

   else

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

   return T
end

function node_interchange:menu ()

   T = "All roads lead nowhere: that's where you are going."
   M = {}
   for ID, Change in pairs (self.changes) do

      table.insert (M, { ID, Change.name })
   end
   return T, M
end
