Deus Ex 5
Creating a simple text-based game titled "Deus Ex 5: Mankind on the Moon" in Ruby involves defining characters, story components, and choices. Below is a basic implementation of such a game. This code will prompt users to make choices as they navigate through the story.
```ruby
class Game
def initialize
@player_name = ""
@current_location = :moon_base
@inventory = []
@game_over = false
end
def start
puts "Welcome to Deus Ex 5: Mankind on the Moon"
print "Enter your name: "
@player_name = gets.chomp
puts "Hello, #{@player_name}. Your adventure begins now!"
main_game_loop
end
def main_game_loop
until @game_over
case @current_location
when :moon_base
moon_base
when :moon_surface
moon_surface
when :abandoned_mine
abandoned_mine
end
end
end
def moon_base
puts "\nYou are in a high-tech moon base. You see a control panel and a door leading to the moon's surface."
puts "Your inventory: #{@inventory.join(', ')}"
puts "What would you like to do?"
puts "1. Use the control panel"
puts "2. Go to the moon surface"
puts "3. Check inventory"
choice = gets.chomp.to_i
case choice
when 1
puts "You used the control panel and found information about an abandoned mine on the moon!"
@current_location = :abandoned_mine
when 2
puts "You step outside onto the moon's surface."
@current_location = :moon_surface
when 3
puts "Your inventory: #{@inventory.join(', ')}"
else
puts "Invalid choice, try again."
end
end
def moon_surface
puts "\nYou are now on the moon's surface. You see a mysterious object and a path leading to the abandoned mine."
puts "Your inventory: #{@inventory.join(', ')}"
puts "What would you like to do?"
puts "1. Inspect the mysterious object"
puts "2. Go to the abandoned mine"
puts "3. Check inventory"
choice = gets.chomp.to_i
case choice
when 1
puts "You found a powerful energy crystal! It's now in your inventory."
@inventory << "Energy Crystal"
when 2
puts "You approach the abandoned mine."
@current_location = :abandoned_mine
when 3
puts "Your inventory: #{@inventory.join(', ')}"
else
puts "Invalid choice, try again."
end
end
def abandoned_mine
puts "\nYou enter the abandoned mine. It's dark and eerie. Suddenly, you encounter a rogue AI!"
puts "Your inventory: #{@inventory.join(', ')}"
puts "What will you do?"
puts "1. Fight the rogue AI"
puts "2. Use the Energy Crystal to disable it"
puts "3. Run away"
choice = gets.chomp.to_i
case choice
when 1
puts "You bravely confront the rogue AI, but it overpowers you. Game Over!"
@game_over = true
when 2
if @inventory.include?("Energy Crystal")
puts "You successfully disable the rogue AI with the Energy Crystal! You've saved the moon base."
puts "Congratulations, #{@player_name}! You win!"
@game_over = true
else
puts "You don't have the Energy Crystal! You need to find it first."
end
when 3
puts "You run back to the moon base, escaping the rogue AI. However, you know you must return."
@current_location = :moon_base
else
puts "Invalid choice, try again."
end
end
end
game = Game.new
game.start
```
### Instructions to Run the Game:
1. Make sure you have Ruby installed on your computer. You can check if Ruby is installed by typing `ruby -v` in your command line or terminal.
2. Create a new file called `deus_ex_5.rb`.
3. Copy and paste the provided Ruby code into this file.
4. Save the file and run it in your terminal with the command `ruby deus_ex_5.rb`.
### Game Features:
- Players can navigate between locations (moon base, moon surface, and an abandoned mine).
- They can find items, like an "Energy Crystal."
- Players make choices that can lead to winning or losing outcomes.
Feel free to expand the game by adding more locations, items, and branching storylines!
Comments
Post a Comment