From 28426519e11e72576b1a3339f47c420f9c184e49 Mon Sep 17 00:00:00 2001 From: David Gay Date: Mon, 5 Jul 2021 20:30:15 -0400 Subject: Give characters a location, and replace the Locations view+controller with a Look view+controller --- app/controllers/game_controller.rb | 2 +- app/controllers/locations_controller.rb | 9 --------- app/controllers/look_controller.rb | 5 +++++ app/models/character.rb | 1 + app/models/location.rb | 1 + app/views/application/_navbar.html.erb | 2 +- app/views/locations/index.html.erb | 8 -------- app/views/locations/show.html.erb | 25 ------------------------- app/views/look/look.html.erb | 25 +++++++++++++++++++++++++ 9 files changed, 34 insertions(+), 44 deletions(-) delete mode 100644 app/controllers/locations_controller.rb create mode 100644 app/controllers/look_controller.rb delete mode 100644 app/views/locations/index.html.erb delete mode 100644 app/views/locations/show.html.erb create mode 100644 app/views/look/look.html.erb (limited to 'app') diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 39ea6c9..4bbbf53 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -18,7 +18,7 @@ class GameController < ApplicationController def stop_activity current_char.stop_activity - redirect_to locations_path + redirect_to look_path end def finish_activity diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb deleted file mode 100644 index 4616c3d..0000000 --- a/app/controllers/locations_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class LocationsController < ApplicationController - def index - @locations = Location.all - end - - def show - @location = Location.find(params[:id]) - end -end diff --git a/app/controllers/look_controller.rb b/app/controllers/look_controller.rb new file mode 100644 index 0000000..e604670 --- /dev/null +++ b/app/controllers/look_controller.rb @@ -0,0 +1,5 @@ +class LookController < ApplicationController + def look + @location = current_char.location + end +end diff --git a/app/models/character.rb b/app/models/character.rb index 2669626..96dafd0 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,6 +1,7 @@ class Character < ApplicationRecord belongs_to :user belongs_to :activity, optional: true + belongs_to :location has_many :title_awards has_many :titles, through: :title_awards belongs_to :active_title, class_name: "Title", optional: true diff --git a/app/models/location.rb b/app/models/location.rb index e008270..7bd1386 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -2,6 +2,7 @@ class Location < ApplicationRecord include HasWhatnot has_many :activities + has_many :characters has_many :monster_spawns validates :gid, :name, presence: true end diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index e315b42..d80e7b6 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -1,7 +1,7 @@