Many visual tweaks, suggested by Lan
[cs356-p2-videostore.git] / app / models / game.rb
index 6c6b59b..f2e627c 100644 (file)
@@ -1,7 +1,18 @@
 class Game < Rentable
+  has_many :game_genres, :through => Gamegenre
+  has_many :gameplatforms, :through => Gameplatform
+
   validates_presence_of :game_genre
   validates_presence_of :platform
 
+  def genre
+    return Gamegenre.find(game_genre).name
+  end
+
+  def game_platform
+    return Gameplatform.find(platform).name
+  end
+
   def calculated_price
     # FIXME: generate this based on day of week, newrelease
     day_of_week = Time.now.to_date.wday
@@ -24,4 +35,12 @@ class Game < Rentable
     return Time.now.advance(:days => period).to_date
   end
 
+  def genre_name
+    Gamegenre.find_by_id(game_genre).name
+  end
+
+  def platform_name
+    Gameplatform.find_by_id(platform).name
+  end
+
 end