From 42fd560f7e49ca1c437ec51fc5e7b2bf57248e71 Mon Sep 17 00:00:00 2001 From: Jorge Madrid Date: Thu, 16 Oct 2014 22:23:02 -0500 Subject: [PATCH] Class gretting created --- dungeon.rb | 87 +++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/dungeon.rb b/dungeon.rb index 0be59db..b1f9668 100644 --- a/dungeon.rb +++ b/dungeon.rb @@ -43,6 +43,44 @@ def go(direction) show_current_description end + class Gretting + + def game_init + gretting = puts "Elf: Wellcome strainger do you have any name ?\n" + puts "Yes my name is .. :" + @name = gets.chomp!.capitalize + + while @name.length <= 0 + puts "Elf: What is your name strainger:\n" + @name = gets.chomp!.capitalize + end + + + puts "\nElf: So your name is #{@name} uuhh!, dude! do have any idea of where on earth are you?, this isn't a place for racional people, best if you run away...\n " + + early_choise = false + while early_choise == false + puts "What you wanna do ?\n" + + puts "1. Leave" + puts "2. Keep on" + + option = gets.chomp.to_i + + if option == 1 + puts "You: OMG! i didn't notice, see ya! faggot" + puts "Game Over" + early_choise = true + exit + elsif option == 2 + puts "You: Shut up, and get out of my way!" + early_choise = true + end + end + puts "Elf: Well done strainger!, it's time to chose your class\n" + end + end + class Player attr_accessor :name, :location @@ -97,51 +135,20 @@ def full_description end end - -gretting = puts "Elf: Wellcome strainger do you have any name ?\n" -puts "Yes my name is .. :" -@name = gets.chomp!.capitalize - -while @name.length <= 0 - puts "Elf: What is your name strainger:\n" - @name = gets.chomp!.capitalize -end - - -puts "\nElf: So your name is #{@name} uuhh!, dude! do have any idea of where on earth are you?, this isn't a place for racional people, best if you run away...\n " - -early_choise = false -while early_choise == false - puts "What you wanna do ?\n" - - puts "1. Leave" - puts "2. Keep on" - - option = gets.chomp.to_i - - if option == 1 - puts "You: OMG! i didn't notice, see ya! faggot" - puts "Game Over" - early_choise = true - exit - elsif option == 2 - puts "You: Shut up, and get out of my way!" - early_choise = true - end -end +gretting = Dungeon::Gretting.new +gretting.game_init -puts "Elf: Well done strainger!, it's time to chose your class\n" new_player = Dungeon::Player.new("#{@name}") puts new_player.type_player - # Create the main dungeon object - my_dungeon = Dungeon.new("#{@name}") - # Add rooms to the dungeon - my_dungeon.add_room(:largecave, "Large Cave", "a large cavernous cave", { :west => :smallcave }) - my_dungeon.add_room(:smallcave, "Small Cave", "a small, claustrophobic cave", { :east => :largecave }) - # Start the dungeon by placing the player in the large cave - my_dungeon.start(:largecave) +# Create the main dungeon object +my_dungeon = Dungeon.new("#{@name}") +# Add rooms to the dungeon +my_dungeon.add_room(:largecave, "Large Cave", "a large cavernous cave", { :west => :smallcave }) +my_dungeon.add_room(:smallcave, "Small Cave", "a small, claustrophobic cave", { :east => :largecave }) +# Start the dungeon by placing the player in the large cave +my_dungeon.start(:largecave)