--
-- a city
--

function node_city_ctor (self)

   self.name = "Major City"

   self.state = "freeway"
end

node_city = class (node, node_city_ctor)

function node_city:action (Action)

   local T = ""

   if (not Action) then

      T = "You enter the freeway system of a large city."

   elseif ("cruise" == Action) then

      T = self[self.state] (self)
      if ("freeways" == self.state) then cur_play:advance (1000)
      else cur_play:advance (100)
      end

   else

      cur_play:advance (500)
      T = self[Action] (self)

   end

   return T
end

function node_city:menu ()

   local StatePrompts = {

      freeway = "The lights of the city seem unreal as they pass by, your car tracking it's way from freeway to freeway, no goal in mind. ",
      suburbs = "Large, cold houses line themselves endlessly up against one another.",--//Blue flickerings emit from time to time, testimony to insomniac infomercial-watchers or chatroom-addicts.",
      ghetto = "This rundown neighbourhood seems alive, unsatiated, hot.",--//Bands of teenagers still roam, and you can hear a dog barking in the distance.",
      downtown = "The streets of downtown are abandoned this late at night.",--//A bum sleeps utterly in a bus stop; the last bus left hours ago."
   }

   local T = StatePrompts[self.state]

   local M = {}

   if (self.state == "freeway") then

      table.insert (M, { "cruise", "Keep to the freeways" })
      table.insert (M, { "offramp", "Take the next off-ramp" })
      table.insert (M, { "leave", "Leave town" })
   else

      table.insert (M, { "cruise", "Cruise" })
      table.insert (M, { "onramp", "Back to the freeways" })
   end

   return T, M
end

function node_city:offramp ()

   local States = { "suburbs", "ghetto", "downtown" }
   self.state = table_choose (States)

   local StateTexts = {

      suburbs = "A rustic-sounding community name beckons you from it's flambouyant off-ramp sign; you answer by turning off at it.",
      ghetto = "An off-ramps sign has been vandalized. You take this exit, hoping for the worst.",
      downtown = "You follow the freeway signs as they lead you into the stillborn heart of the city.",
   }
   return StateTexts[self.state]
end

function node_city:onramp ()

   self.state = "freeway"
   return "You find the nearest on-ramp, and soon find yourself on the freeway once again."
end

function node_city:leave ()

   local FreewayStream = roadstream ()
   FreewayStream:init (1, cur_play:get_next_terrain (), RN_get_seed ())
   cur_adventure:leave (FreewayStream)
   return "You aren't sure at this point where you are. But intuitively, exit-by-exit, you feel your way out of the urban leviathan and onto another highway."
end

function node_city:freeway ()

   cur_play:soothe (2)
   return "You keep to the freeways; the rhythm of the lights as they draw their angular, overlapping shadows mezmerises you."
end

function node_city:suburbs ()

   cur_play:soothe (2)
   return "Keeping to the suburbs, you turn down side street after side street. "
end

function node_city:ghetto ()

   cur_play:agitate (2)
   return "You continue to cruise the 'hood. Taking your chances, or not, you aren't sure. "
end

function node_city:downtown ()

   local T = "Downtown is an endless, right-angled maze.//You track it methodically, seeing always the same buildings but now from a different angle, now partly obscured by another."
   cur_play:soothe (1)

   if (RN () < 0.25) then

      T = T .. "//As you are parked at a red, a hooker comes up to your car, and you for money. She is in a bad way.//"
         .. "You fish into your pocket, and give her what you have left."

      cur_play.money = 0
      cur_play:experience ("hooker")
   end

   return T
end
