Share your repls and programming experiences

← Back to all posts
This won't let me do 'end'

For some reason this won't let me use 'end' and says '(repl):106: warning: string literal in condition'

KobeFF (349)

I think it works now, @pureAWESOMESO.

class String
def black;          "\e[30m#{self}\e[0m" end
def red;            "\e[31m#{self}\e[0m" end
def green;          "\e[32m#{self}\e[0m" end
def brown;          "\e[33m#{self}\e[0m" end
def blue;           "\e[34m#{self}\e[0m" end
def magenta;        "\e[35m#{self}\e[0m" end
def cyan;           "\e[36m#{self}\e[0m" end
def gray;           "\e[37m#{self}\e[0m" end

def bg_black;       "\e[40m#{self}\e[0m" end
def bg_red;         "\e[41m#{self}\e[0m" end
def bg_green;       "\e[42m#{self}\e[0m" end
def bg_brown;       "\e[43m#{self}\e[0m" end
def bg_blue;        "\e[44m#{self}\e[0m" end
def bg_magenta;     "\e[45m#{self}\e[0m" end
def bg_cyan;        "\e[46m#{self}\e[0m" end
def bg_gray;        "\e[47m#{self}\e[0m" end

def bold;           "\e[1m#{self}\e[22m" end
def italic;         "\e[3m#{self}\e[23m" end
def underline;      "\e[4m#{self}\e[24m" end
def blink;          "\e[5m#{self}\e[25m" end
def reverse_color;  "\e[7m#{self}\e[27m" end
player_hp = 10
def zombie_attack
  player_hp -= 1
  puts "Ouchies! The zombies slammed into you!"
puts ""
puts "Welcome To..."
puts ""
puts "                       ****************"
puts "                       *DUNGEON QUEST!*"
puts "                       ***************"
puts ""
print "Loading"
sleep 4
print ".".blink
sleep 4
print ".".blink
sleep 4
puts ".".blink
def a
  puts ""
puts a*50
puts "What is your name warrior,"
name = gets.chomp
puts "Hello, #{name} "
puts "You can be either a fighter or a spellcaster"
user_class = gets.chomp.capitalize!

if user_class == "Fighter"
  f_weapon =
  ["Longsword", "2 hand axes", "morningstar", "maul"].sample
  puts "That's cool you get a #{f_weapon}"
puts "You are at the mouth of a cave."
puts ""
puts "Do you want to enter the cave?"

bloop_1 =gets.chomp.capitalize!

if bloop_1 == "Yes"
  puts "Ok, you walk in the cave"

elsif bloop_1 == 'No'
  puts "Well, you just go into the cave."
  until bloop_1 == "Yes"
puts "Invalid command, try again"

puts "Once in the cave you look around and see 8 standing sarcophagi."
puts "You can open sarchophogai or you can go into the door."
bloop_2 = gets.chomp

if bloop_2 == "Sarchophagai" or "Open sarcophagai"
  puts "Oh, No!"
  puts "A zombie popped out and attacked you!"
  player_hp -= 1
elsif bloop_2 == "Door" or "Open door" 
  puts "You walk into a dark musty room."
  puts "The dark musty room reeks of moldy water."
  until bloop_2 == "Sarchophagai" or "Open sarchophagai" or "Door" or "Open door"
    puts "What did you say?"
puts "Once in the room you notice a small little heap of ash in the far right corner."
puts "There is an exit to the left."
puts "There is a curious little stone altar-thingy with carvings."

bloop_3 = gets.chomp

if bloop_3 == "Examine altar" or "Altar" 
  puts "Oh No!".red
  puts "It was a trap and you fell into a lava pit and burned up.".bg_red
  puts "|       AAH!  |"
  puts "|      O        |"
  puts "|     /|\       |"
  puts "|^^^^^^/\^^^^^^^|"
  puts "_________________"

elsif bloop_3 == "Ash heap" or "Examine ash heap"
  puts "Out of the ash heap springs a monster!".red.bold
  puts "OH NO!!!".red.bold.blink
  if bloop_3 == 'Door' or 'Open door' or 'Left door'
    puts "You enter a room with a large stone column"

    puts "What?"